Choco OS
V.0.16.9.0
Join to the chocolate world
|
Helps to managing network ports in different protocols. More...
Data Structures | |
struct | oC_PortMan_Config_t |
stores configuration of the module More... | |
Typedefs | |
typedef uint32_t | oC_PortMan_Port_t |
stores the port number | |
Functions | |
oC_ErrorCode_t | oC_PortMan_TurnOn (void) |
turns on the module More... | |
oC_ErrorCode_t | oC_PortMan_TurnOff (void) |
turns off the module More... | |
oC_ErrorCode_t | oC_PortMan_RegisterModule (oC_Module_t Module, const oC_PortMan_Config_t *Config, oC_Time_t Timeout) |
registers module in the port manager More... | |
oC_ErrorCode_t | oC_PortMan_UnregisterModule (oC_Module_t Module, oC_Time_t Timeout) |
unregisters module in the port manager More... | |
oC_ErrorCode_t | oC_PortMan_ReservePort (oC_Module_t Module, oC_PortMan_Port_t *Port, oC_Time_t Timeout) |
reserves a port of the given module More... | |
oC_ErrorCode_t | oC_PortMan_ReleasePort (oC_Module_t Module, oC_PortMan_Port_t Port, oC_Time_t Timeout) |
releases port More... | |
oC_ErrorCode_t | oC_PortMan_ReleaseAllPortsOf (oC_Module_t Module, oC_Process_t Process, oC_Time_t Timeout) |
releases all ports reserved by a given process More... | |
bool | oC_PortMan_IsPortReserved (oC_Module_t Module, oC_PortMan_Port_t Port) |
returns true if port is reserved More... | |
bool | oC_PortMan_IsPortReservedBy (oC_Module_t Module, oC_PortMan_Port_t Port, oC_Process_t Process) |
checks if the given port is reserved by the given process More... | |
bool oC_PortMan_IsPortReserved | ( | oC_Module_t | Module, |
oC_PortMan_Port_t | Port | ||
) |
The function checks if the given port is reserved at the given module. '
Module | Module registered earlier |
Port | Port to check |
Definition at line 567 of file oc_portman.c.
bool oC_PortMan_IsPortReservedBy | ( | oC_Module_t | Module, |
oC_PortMan_Port_t | Port, | ||
oC_Process_t | Process | ||
) |
The function is for checking if the given port is reserved by the given process.
Module | Registered module |
Port | Port of the module to check |
Process | Process object to check |
Definition at line 602 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_RegisterModule | ( | oC_Module_t | Module, |
const oC_PortMan_Config_t * | Config, | ||
oC_Time_t | Timeout | ||
) |
Each module, that uses the Port Manager
for ports reservations has to register itself by using this function. It allocates memory required for handling reservations, creates required objects and puts the registration into the registrations list.
Module | ID of the module to register |
Config | Pointer to the structure with configuration of the module to register. |
Timeout | Maximum time to wait for the registration |
Here is an example of usage:
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_PermissionDenied | Only root user can register modules |
oC_ErrorCode_ModuleNotCorrect | The given Module is not correct (please check if it is defined in the oc_module.h file |
oC_ErrorCode_WrongAddress | Address of the Config parameter is not correct |
oC_ErrorCode_MaximumValueNotCorrect | Config->MaximumPortNumber cannot be 0! |
oC_ErrorCode_PortNotCorrect | Config->FirstDynamicPortNumber or Config->LastDynamicPortNumber is incorrect |
oC_ErrorCode_TimeNotCorrect | Timeout is below 0 |
oC_ErrorCode_ModuleAlreadyRegistered | The given module has been registered before |
oC_ErrorCode_ModuleIsBusy | Maximum time for the operation has expired and the module is still busy |
oC_ErrorCode_AllocationError | There is a problem with memory allocation |
Definition at line 257 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_ReleaseAllPortsOf | ( | oC_Module_t | Module, |
oC_Process_t | Process, | ||
oC_Time_t | Timeout | ||
) |
The function releases all ports that has been reserved by the given process. It is designed to provide a possibility to quickly and easy close a process by the kernel.
Module | Index of the module registered earlier |
Process | Process to release |
Timeout | Maximum time for the operation |
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_ModuleNotCorrect | The given Module is not correct (please check if it is defined in the oc_module.h file |
oC_ErrorCode_TimeNotCorrect | Timeout is below 0 |
oC_ErrorCode_ModuleNotRegistered | The given module has not been registered before |
oC_ErrorCode_ModuleIsBusy | Maximum time for the operation has expired and the module is still busy |
oC_ErrorCode_ReleaseError | There is a problem with memory releasing |
oC_ErrorCode_CannotRemoveObjectFromList | Internal error related with removing port reservation from list |
The function can also return an error code from the function oC_PortMan_ReleasePort
Definition at line 522 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_ReleasePort | ( | oC_Module_t | Module, |
oC_PortMan_Port_t | Port, | ||
oC_Time_t | Timeout | ||
) |
The function is for releasing a port that has been reserved by the function oC_PortMan_ReservePort.
Module | Module of the port to release |
Port | Port to release |
Timeout | Maximum time to wait for the port manager |
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_ModuleNotCorrect | The given Module is not correct (please check if it is defined in the oc_module.h file |
oC_ErrorCode_TimeNotCorrect | Timeout is below 0 |
oC_ErrorCode_ModuleNotRegistered | The given module has not been registered before |
oC_ErrorCode_ModuleIsBusy | Maximum time for the operation has expired and the module is still busy |
oC_ErrorCode_ReleaseError | There is a problem with memory releasing |
oC_ErrorCode_CannotRemoveObjectFromList | Internal error related with removing port reservation from list |
oC_ErrorCode_PortNotCorrect | The given port is too big for the given module |
oC_ErrorCode_PortNotReserved | The specified port has not been reserved |
Definition at line 457 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_ReservePort | ( | oC_Module_t | Module, |
oC_PortMan_Port_t * | Port, | ||
oC_Time_t | Timeout | ||
) |
The function reserves a port of the given module. The module has to be registered before by the function oC_PortMan_RegisterModule. If the Port
argument will point to 0, then the port manager will try to find a first available dynamic port of the given module, that matches ID from the configuration of module registration (value between FirstDynamicPortNumber
and LastDynamicPortNumber
)
Module | Registered module ID |
Port | Address to the port on input or address to zero if you want to find a first free port |
Timeout | Maximum time for operation |
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_ModuleNotCorrect | The given Module is not correct (please check if it is defined in the oc_module.h file |
oC_ErrorCode_TimeNotCorrect | Timeout is below 0 |
oC_ErrorCode_ModuleNotRegistered | The given module has not been registered before |
oC_ErrorCode_ModuleIsBusy | Maximum time for the operation has expired and the module is still busy |
oC_ErrorCode_AllocationError | There is a problem with memory allocation |
oC_ErrorCode_PortNotCorrect | The given port is too big for the given module |
oC_ErrorCode_PortBusy | The specified port or all ports (if the Port points to 0) are reserved |
Definition at line 389 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_TurnOff | ( | void | ) |
The function is for turning off the module.
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_PermissionDenied | Only root user can turn off the module |
oC_ErrorCode_ReleaseError | There was a problem with releasing the memory |
Definition at line 180 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_TurnOn | ( | void | ) |
The function turns on the module and initialize it to work.
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleIsTurnedOn | The module is already turned on |
oC_ErrorCode_PermissionDenied | Only root user can enable the module |
oC_ErrorCode_AllocationError | There was a problem with memory allocation |
Definition at line 126 of file oc_portman.c.
oC_ErrorCode_t oC_PortMan_UnregisterModule | ( | oC_Module_t | Module, |
oC_Time_t | Timeout | ||
) |
Each module, that uses the Port Manager
for ports reservations has to register itself by using oC_PortMan_RegisterModule function. When the module is not needed anymore, it should unregister itself in the Port Manager by using this function.
Module | ID of the module to unregister |
Timeout | Maximum time to wait for the unregistration |
oC_ErrorCode_None
if successList of standard error codes, that can be returned by the function:
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module has not been turned on earlier |
oC_ErrorCode_PermissionDenied | Only root user can unregister modules |
oC_ErrorCode_ModuleNotCorrect | The given Module is not correct (please check if it is defined in the oc_module.h file |
oC_ErrorCode_TimeNotCorrect | Timeout is below 0 |
oC_ErrorCode_ModuleNotRegistered | The given module has not been registered before |
oC_ErrorCode_ModuleIsBusy | Maximum time for the operation has expired and the module is still busy |
oC_ErrorCode_ReleaseError | There is a problem with memory releasing |
Definition at line 328 of file oc_portman.c.