Choco OS
V.0.16.9.0
Join to the chocolate world
|
Handles network interface objects. More...
Data Structures | |
struct | oC_NetifMan_RoutingTableEntry_t |
stores entry of the routing table More... | |
Typedefs | |
typedef bool(* | oC_NetifMan_PacketFilterFunction_t) (oC_Net_Packet_t *ReceivedPacket, const void *Parameter, oC_Netif_t Netif) |
stores pointer to the function to filter packets More... | |
Functions | |
oC_ErrorCode_t | oC_NetifMan_TurnOff (void) |
releases module resources More... | |
void | oC_NetifMan_ConfigureAll (void) |
configures all network interface More... | |
void | oC_NetifMan_UnconfigureAll (void) |
unconfigures all network interface More... | |
oC_Netif_t | oC_NetifMan_GetNetif (oC_Netif_FriendlyName_t FriendlyName) |
returns #Netif with the given name More... | |
oC_Netif_t | oC_NetifMan_GetNetifForAddress (const oC_Net_Address_t *Destination) |
returns network interface according to destination address More... | |
oC_ErrorCode_t | oC_NetifMan_AddNetifToList (oC_Netif_t Netif) |
adds new netif to the list More... | |
oC_ErrorCode_t | oC_NetifMan_RemoveNetifFromList (oC_Netif_t Netif) |
removes a Netif object from the list More... | |
oC_ErrorCode_t | oC_NetifMan_AddRoutingTableEntry (const oC_Net_Address_t *Destination, const oC_Net_Address_t *Netmask, oC_Net_Cost_t Cost, oC_Netif_t Netif) |
adds an entry to the routing table More... | |
oC_ErrorCode_t | oC_NetifMan_RemoveRoutingTableEntry (const oC_Net_Address_t *Destination, const oC_Net_Address_t *Netmask, oC_Netif_t Netif) |
removes entry from the Routing Table More... | |
oC_List (oC_Netif_t) | |
returns list of network interfaces More... | |
oC_ErrorCode_t | oC_NetifMan_SendPacket (const oC_Net_Address_t *Address, oC_Net_Packet_t *Packet, oC_Time_t Timeout, oC_Netif_t *outNetif) |
sends packet via active network interface More... | |
oC_ErrorCode_t | oC_NetifMan_ReceivePacket (const oC_Net_Address_t *AddressFilter, oC_Net_Packet_t *outPacket, oC_Time_t Timeout, oC_Netif_t *outNetif, oC_NetifMan_PacketFilterFunction_t FilterFunction, const void *Parameter) |
receives packet from the network More... | |
void | oC_NetifMan_UpdateRoutingTable (void) |
updates active routing table More... | |
oC_ErrorCode_t | oC_NetifMan_StartDaemon (void) |
starts the NetifMan daemon More... | |
========================================================================================================================================
The section with functions
typedef bool(* oC_NetifMan_PacketFilterFunction_t) (oC_Net_Packet_t *ReceivedPacket, const void *Parameter, oC_Netif_t Netif) |
The function is used for filtering packets during receiving it from the Netif.
ReceivedPacket | Packet received in the ring |
Parameter | Optional parameter |
Netif | Netif that has received the packet |
Definition at line 78 of file oc_netifman.h.
oC_List | ( | oC_Netif_t | ) |
The function returns list with network interfaces.
Definition at line 660 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_AddNetifToList | ( | oC_Netif_t | Netif | ) |
The function is for adding the Netif
object to the network interface list. The object has to be valid, and it cannot already exist on the list.
Netif | Netif object from the oC_Netif_New function |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_ObjectNotCorrect | The Netif object is not correct or not valid anymore |
oC_ErrorCode_FoundOnList | The Netif has already been found on the list |
oC_ErrorCode_CannotAddObjectToList | Some error occurred during adding the Netif object to the list |
Definition at line 454 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_AddRoutingTableEntry | ( | const oC_Net_Address_t * | Destination, |
const oC_Net_Address_t * | Netmask, | ||
oC_Net_Cost_t | Cost, | ||
oC_Netif_t | Netif | ||
) |
The Routing Table is a data table stored in a router or a networked computer that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with those routes. The routing table contains information about the topology of the network immediately around it.
The function adds an entry to the routing table array.
Destination | Network destination address (some address that we want to achieve, for example 192.168.0.0) |
Netmask | Subnetwork mask |
Cost | Cost of usage the network interface for the address |
Netif | Network interface to use for this routing table entry |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_WrongAddress | The Destination or Netmask does not contain correct address |
oC_ErrorCode_ObjectNotCorrect | The Netif object is not correct |
Definition at line 547 of file oc_netifman.c.
void oC_NetifMan_ConfigureAll | ( | void | ) |
The function configures all network drivers related with the netifs. The error can be read from the error stack. The function also updates active Netif.
Definition at line 335 of file oc_netifman.c.
oC_Netif_t oC_NetifMan_GetNetif | ( | oC_Netif_FriendlyName_t | FriendlyName | ) |
The function searches for the #Netif object that matches the given FriendlyName
.
FriendlyName | Friendly name of the Netif interface |
Definition at line 386 of file oc_netifman.c.
oC_Netif_t oC_NetifMan_GetNetifForAddress | ( | const oC_Net_Address_t * | Destination | ) |
The function returns network interface that can be used to send data to the given destination address.
Definition at line 415 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_ReceivePacket | ( | const oC_Net_Address_t * | AddressFilter, |
oC_Net_Packet_t * | outPacket, | ||
oC_Time_t | Timeout, | ||
oC_Netif_t * | outNetif, | ||
oC_NetifMan_PacketFilterFunction_t | FilterFunction, | ||
const void * | Parameter | ||
) |
The function is for receiving packets from the network. At least one network interface (netif) has to be configured. Also the routing table has to contain at least one entry. The function allows to receive packet from the selected source address (with or without port specified), from any address in the given protocol (address is set to 0, only protocol is specified) or just receive packet without address filtering.
AddressFilter | Filtering address - allows to choose source address of the received packets. Set it to NULL if packets should not be filtering |
Otherwise it can be set to:
IP | Protocol | Description |
---|---|---|
0.0.0.0 | 0 | Receives all packets (similar to NULL pointer) |
0.0.0.0 | 17 | Receives only packets at the given protocol (17) |
10.10.10.10 | 41 | Receives only packets from the given IP (10.10.10.10) at the given protocol (41) |
10.50.30.10 | 0 | Receives only packets from the given IP (10.50.30.10) at all protocols |
outPacket | Destination for the packet |
Timeout | Maximum time for receive operation |
outNetif | Destination for the network interface, that has received the packet. It is optional - can be set to NULL if not used. |
FilterFunction | Pointer to the function to call when packet is received. It should compare the given packets and returns true if the packet is the one that we expect. Can be NULL if not used |
Parameter | Parameter for FilterFunction or NULL if not used |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_OutputAddressNotInRAM | outNetif is not NULL but the address does not point to the RAM section or outPacket is not in RAM |
oC_ErrorCode_WrongAddress | Address or FilterFunction is not NULL but the pointer is not correct |
oC_ErrorCode_Timeout | Maximum time for operation has been achieved. |
Definition at line 763 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_RemoveNetifFromList | ( | oC_Netif_t | Netif | ) |
The function removes Netif
from the list. It removes it also if the object is not correct (it should exist on the list if it is not correct).
Netif | The Netif object from the oC_Netif_New function |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_ObjectNotFoundOnList | The Netif object has not been found on the list |
Definition at line 500 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_RemoveRoutingTableEntry | ( | const oC_Net_Address_t * | Destination, |
const oC_Net_Address_t * | Netmask, | ||
oC_Netif_t | Netif | ||
) |
The Routing Table is a data table stored in a router or a networked computer that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with those routes. The routing table contains information about the topology of the network immediately around it.
The function removes an entry from the routing table array.
Destination | Network destination address (some address that we want to remove, for example 192.168.0.0) or NULL if not used |
Netmask | Subnetwork mask or NULL if not used |
Netif | Network interface to use for this routing table entry |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_WrongAddress | The Destination or Netmask does not contain correct address |
oC_ErrorCode_ObjectNotCorrect | The Netif object is not correct |
Definition at line 610 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_SendPacket | ( | const oC_Net_Address_t * | Address, |
oC_Net_Packet_t * | Packet, | ||
oC_Time_t | Timeout, | ||
oC_Netif_t * | outNetif | ||
) |
The function sends packet via active network interface.
Address | Destination address |
Packet | Packet to send |
Timeout | Maximum time for packet transmission |
outNetif | Destination for the Netif used for the transmission or NULL if not used |
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_WrongAddress | Packet address is not correct |
oC_ErrorCode_OutputAddressNotInRAM | outNetif is not NULL but the address does not point to the RAM section |
oC_ErrorCode_RoutingTableEntryNotFound | The given address does not match any entry in the routing table |
Definition at line 689 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_StartDaemon | ( | void | ) |
The NetifMan daemon is designed to manage the network interfaces during work of the system. It removes invalid entries from the routing table and swaps the network interfaces if there are duplicated.
oC_ErrorCode_None
when successHere is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_ProcessAlreadyStarted | Process has been started already |
oC_ErrorCode_CannotCreateProcess | The process cannot be created |
oC_ErrorCode_CannotCreateThread | The thread cannot be created |
oC_ErrorCode_CannotRunThread | Some error occurred during starting of the thread |
Definition at line 905 of file oc_netifman.c.
oC_ErrorCode_t oC_NetifMan_TurnOff | ( | void | ) |
The function is for turning off the module. It release all module resources and variables.
oC_ErrorCode_None
Here is the list of standard error codes, that can be returned by the function. Note, that it is not full list of them, some of errors can be returned also by the other system functions, that this one calls.
Code of error | Description |
---|---|
oC_ErrorCode_ModuleNotStartedYet | The module is not turned on |
oC_ErrorCode_AllocationError | Cannot release memory of the module |
oC_ErrorCode_CannotDeleteObject | Cannot delete some of Netif objects |
oC_ErrorCode_CannotDeleteProcess | Cannot delete process |
oC_ErrorCode_CannotDeleteThread | Cannot delete thread |
Definition at line 279 of file oc_netifman.c.
void oC_NetifMan_UnconfigureAll | ( | void | ) |
The function unconfigures all network drivers related with the netifs. The error can be read from the error stack.
Definition at line 358 of file oc_netifman.c.
void oC_NetifMan_UpdateRoutingTable | ( | void | ) |
The function is for updating the routing table. It searches for interfaces in the routing table, updates its link statuses and creates a list of active routing table entries.
Definition at line 834 of file oc_netifman.c.