Choco OS  V.0.16.9.0
Join to the chocolate world
NetifMan - Network interface manager

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...
 

Detailed Description

========================================================================================================================================

        The section with functions

Typedef Documentation

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.

Parameters
ReceivedPacketPacket received in the ring
ParameterOptional parameter
NetifNetif that has received the packet
Returns
true if this is the expected packet

Definition at line 78 of file oc_netifman.h.

Function Documentation

oC_List ( oC_Netif_t  )

The function returns list with network interfaces.

Warning
It returns original network list pointer. You cannot change it!
Returns
real network interface list

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.

Parameters
NetifNetif object from the oC_Netif_New function
Returns
code of error or oC_ErrorCode_None when success

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_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.

Parameters
DestinationNetwork destination address (some address that we want to achieve, for example 192.168.0.0)
NetmaskSubnetwork mask
CostCost of usage the network interface for the address
NetifNetwork interface to use for this routing table entry
Returns
code of error or oC_ErrorCode_None when success

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_WrongAddress The Destination or Netmask does not contain correct address
oC_ErrorCode_ObjectNotCorrect The Netif object is not correct
See also
oC_NetifMan_RemoveRoutingTableEntry

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.

Parameters
FriendlyNameFriendly name of the Netif interface
Returns
Netif object or NULL if not found
Note
When the function fails, the error code is saved to the errors stack.

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.

Parameters
AddressFilterFiltering 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
Parameters
outPacketDestination for the packet
TimeoutMaximum time for receive operation
outNetifDestination for the network interface, that has received the packet. It is optional - can be set to NULL if not used.
FilterFunctionPointer 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
ParameterParameter for FilterFunction or NULL if not used
Returns
code of error or oC_ErrorCode_None when success

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_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).

Parameters
NetifThe Netif object from the oC_Netif_New function
Returns
code of error or oC_ErrorCode_None when success

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_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.

Parameters
DestinationNetwork destination address (some address that we want to remove, for example 192.168.0.0) or NULL if not used
NetmaskSubnetwork mask or NULL if not used
NetifNetwork interface to use for this routing table entry
Returns
code of error or oC_ErrorCode_None when success

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_WrongAddress The Destination or Netmask does not contain correct address
oC_ErrorCode_ObjectNotCorrect The Netif object is not correct
See also
oC_NetifMan_AddRoutingTableEntry

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.

Parameters
AddressDestination address
PacketPacket to send
TimeoutMaximum time for packet transmission
outNetifDestination for the Netif used for the transmission or NULL if not used
Returns
code of error or oC_ErrorCode_None when success

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_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.

Returns
code of error or oC_ErrorCode_None when success

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_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.

Returns
code of error or 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.

Note
Errors from this function are saved in the errors stack.

Definition at line 834 of file oc_netifman.c.