28 #include <oc_netif_cfg.c> 45 #define _________________________________________DEFINITIONS_SECTION________________________________________________________________________ 47 #define SOFTWARE_RING_SIZE 10 48 #define STACK_SIZE kB(2) 49 #define DAEMON_SLEEP_TIME s(1) 51 #undef _________________________________________DEFINITIONS_SECTION________________________________________________________________________ 59 #define _________________________________________TYPES_SECTION______________________________________________________________________________ 64 oC_Timestamp_t Timestamp;
71 Packet_t Packets[SOFTWARE_RING_SIZE];
84 #undef _________________________________________TYPES_SECTION______________________________________________________________________________ 91 #define _________________________________________PROTOTYPES_SECTION_________________________________________________________________________ 99 #undef _________________________________________PROTOTYPES_SECTION_________________________________________________________________________ 107 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________ 120 static uint32_t NumberOfIgnoredPackets = 0;
121 static uint32_t NumberOfReceivedPackets = 0;
125 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________ 132 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________ 159 oC_ErrorCode_t oC_NetifMan_TurnOn(
void )
161 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
163 oC_IntMan_EnterCriticalSection();
170 memset(&ReceivedPackets,0,
sizeof(ReceivedPackets));
171 memset(&RoutingTableData,0,
sizeof(RoutingTableData));
173 NetifList = oC_List_New(&Allocator,AllocationFlags_CanWait1Second);
174 RoutingTableData.RoutingActiveEntryList = oC_List_New(&Allocator,AllocationFlags_CanWait1Second);
175 RoutingTableData.RoutingTable = oC_List_New(&Allocator,AllocationFlags_CanWait1Second);
176 ReceivedPackets.Count = 0;
177 ReceivedPackets.DataAvailable = oC_Event_New(0,&Allocator,AllocationFlags_CanWait1Second);
180 NumberOfIgnoredPackets = 0;
181 NumberOfReceivedPackets = 0;
184 ErrorCondition(NetifList !=
NULL , oC_ErrorCode_AllocationError )
185 && ErrorCondition(ReceivedPackets.DataAvailable !=
NULL , oC_ErrorCode_AllocationError )
186 && ErrorCondition(RoutingTableData.RoutingActiveEntryList !=
NULL , oC_ErrorCode_AllocationError )
187 && ErrorCondition(RoutingTableData.RoutingTable !=
NULL , oC_ErrorCode_AllocationError )
191 errorCode = oC_ErrorCode_None;
201 #define NETIF_NAME(CONFIG_NAME) oC_1WORD_FROM_2(CONFIG_NAME,_Netif) 203 #define ADD_NET(FRIENDLY_NAME,IP,NETMASK,DRIVER_NAME,CONFIG_NAME) \ 204 oC_Netif_t NETIF_NAME(CONFIG_NAME) = oC_Netif_New( FRIENDLY_NAME, IP, NETMASK , &DRIVER_NAME, &CONFIG_NAME); \ 205 oC_SaveIfFalse("NetifMan::TurnOn - cannot create interface " FRIENDLY_NAME " - " , NETIF_NAME(CONFIG_NAME) != NULL , oC_ErrorCode_AllocationError ); \ 206 pushed = oC_List_PushBack(NetifList,NETIF_NAME(CONFIG_NAME),&Allocator);\ 207 oC_SaveIfFalse("NetifMan::TurnOn - cannot add to list interface " FRIENDLY_NAME " - " , pushed , oC_ErrorCode_CannotAddObjectToList); 209 CFG_NETIF_LIST(ADD_NET,UNIVERSAL_DONT_ADD);
218 #define ADD_ENTRY(DESTINATION,NETMASK,COST,FRIENDLY_NAME) \ 220 oC_Netif_t netif = oC_NetifMan_GetNetif(FRIENDLY_NAME);\ 221 oC_Net_Address_t destination;\ 222 memset(&destination,0,sizeof(destination));\ 223 oC_Net_Address_t netmask;\ 224 memset(&destination,0,sizeof(netmask));\ 225 oC_SaveIfFalse ("NetifMan::TurnOn - cannot get network interface named '" FRIENDLY_NAME "' - " , netif != NULL , oC_ErrorCode_ObjectNotFoundOnList )\ 226 && oC_SaveIfErrorOccur("NetifMan::TurnOn - cannot read destination address '" DESTINATION "'" , oC_Net_AddressFromString( DESTINATION, &destination ) )\ 227 && oC_SaveIfErrorOccur("NetifMan::TurnOn - cannot read netmask address '" NETMASK "'" , oC_Net_AddressFromString( NETMASK, &netmask ) )\ 228 && oC_SaveIfErrorOccur("NetifMan::TurnOn - cannot add routing table entry '[" DESTINATION "]/[" NETMASK "]/[" FRIENDLY_NAME "]' - ", oC_NetifMan_AddRoutingTableEntry( &destination, &netmask, COST, netif ) );\ 230 CFG_ROUTING_TABLE(ADD_ENTRY,UNIVERSAL_DONT_ADD);
239 bool deleted = oC_List_Delete(NetifList,AllocationFlags_CanWait1Second);
240 oC_SaveIfFalse(
"NetifMan::TurnOn - NetifList - ", deleted , oC_ErrorCode_ReleaseError);
242 deleted = oC_List_Delete(RoutingTableData.RoutingActiveEntryList,AllocationFlags_CanWait1Second);
243 oC_SaveIfFalse(
"NetifMan::TurnOn - RoutingEntryList - ", deleted , oC_ErrorCode_ReleaseError);
245 deleted = oC_List_Delete(RoutingTableData.RoutingTable,AllocationFlags_CanWait1Second);
246 oC_SaveIfFalse(
"NetifMan::TurnOn - RoutingTable - ", deleted , oC_ErrorCode_ReleaseError);
248 oC_SaveIfFalse(
"NetifMan::TurnOn - DataAvailable semaphore - ",
249 oC_Event_Delete(&ReceivedPackets.DataAvailable,AllocationFlags_CanWait1Second),
250 oC_ErrorCode_ReleaseError);
254 oC_IntMan_ExitCriticalSection();
281 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
282 bool deleted =
false;
290 errorCode = oC_ErrorCode_None;
294 ErrorCondition( oC_Process_Delete(&Process) , oC_ErrorCode_CannotDeleteProcess );
299 ErrorCondition( oC_Thread_Delete(&Thread) , oC_ErrorCode_CannotDeleteThread );
302 oC_List_Foreach(NetifList,netif)
304 ErrorCondition(
oC_Netif_Delete(&netif),oC_ErrorCode_CannotDeleteObject);
307 ErrorCondition(oC_Event_Delete(&ReceivedPackets.DataAvailable,AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
309 deleted = oC_List_Delete(NetifList,AllocationFlags_CanWait1Second);
310 ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
312 foreach(RoutingTableData.RoutingTable,entry)
314 ErrorCondition(kfree(entry,AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
317 deleted = oC_List_Delete(RoutingTableData.RoutingTable,AllocationFlags_CanWait1Second);
318 ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
320 deleted = oC_List_Delete(RoutingTableData.RoutingActiveEntryList,AllocationFlags_CanWait1Second);
321 ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
337 if(oC_SaveIfFalse(
"NetifMan::ConfigureAll - " ,
oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
339 oC_List_Foreach(NetifList,netif)
360 if(oC_SaveIfFalse(
"NetifMan::UnconfigureAll - " ,
oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
362 oC_List_Foreach(NetifList,netif)
391 oC_SaveIfFalse(
"NetifMan::GetNetif - " ,
oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet )
392 && oC_SaveIfFalse(
"NetifMan::GetNetif - " , isaddresscorrect(FriendlyName) , oC_ErrorCode_WrongAddress )
393 && oC_SaveIfFalse(
"NetifMan::GetNetif - " , strlen(FriendlyName) > 0 , oC_ErrorCode_StringIsEmpty )
396 oC_List_Foreach(NetifList,netif)
400 netifToReturn = netif;
405 return netifToReturn;
419 if(isaddresscorrect(Destination))
423 if(isaddresscorrect(entry))
425 netif = entry->
Netif;
456 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
460 bool existOnTheList = oC_List_Contains(NetifList,Netif);
464 && ErrorCondition( existOnTheList ==
false , oC_ErrorCode_FoundOnList )
467 bool pushed = oC_List_PushBack( NetifList, Netif, &Allocator);
469 if(ErrorCondition(pushed , oC_ErrorCode_CannotAddObjectToList))
472 errorCode = oC_ErrorCode_None;
502 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
506 bool deleted = oC_List_RemoveAll(NetifList,Netif);
508 if(ErrorCondition(deleted,oC_ErrorCode_ObjectNotFoundOnList))
511 errorCode = oC_ErrorCode_None;
549 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
562 ErrorCondition( entry !=
NULL , oC_ErrorCode_AllocationError )
566 entry->
Netif = Netif;
568 bool pushed = oC_List_PushBack( RoutingTableData.RoutingActiveEntryList, entry, &Allocator );
570 if(ErrorCondition(pushed, oC_ErrorCode_CannotAddObjectToList))
572 errorCode = oC_ErrorCode_None;
612 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
618 && ( Destination ==
NULL || ErrorCondition( isaddresscorrect(Destination) , oC_ErrorCode_WrongAddress ) )
619 && ( Netmask ==
NULL || ErrorCondition( isaddresscorrect(Netmask) , oC_ErrorCode_WrongAddress ) )
622 errorCode = oC_ErrorCode_ObjectNotFoundOnList;
624 foreach(RoutingTableData.RoutingActiveEntryList,entry)
626 if(entry->Netif == Netif)
632 errorCode = oC_ErrorCode_None;
634 ErrorCondition( kfree(entry,AllocationFlags_CanWait1Second) , oC_ErrorCode_ReleaseError );
635 oC_List_RemoveCurrentElement(RoutingTableData.RoutingActiveEntryList, entry );
691 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
698 ErrorCondition( isaddresscorrect(Packet), oC_ErrorCode_WrongAddress )
699 && ErrorCondition( entry !=
NULL , oC_ErrorCode_RoutingTableEntryNotFound )
702 oC_IntMan_EnterCriticalSection();
704 oC_IntMan_ExitCriticalSection();
711 errorCode = oC_ErrorCode_None;
715 && ErrorCondition( isram(outNetif), oC_ErrorCode_OutputAddressNotInRAM ) )
765 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
770 ErrorCondition( isram(outPacket) , oC_ErrorCode_OutputAddressNotInRAM )
771 && ErrorCondition( FilterFunction ==
NULL || isaddresscorrect(FilterFunction) , oC_ErrorCode_WrongAddress )
775 ( outNetif ==
NULL || ErrorCondition( isram(outNetif) , oC_ErrorCode_OutputAddressNotInRAM ) )
776 && ( AddressFilter ==
NULL || ErrorCondition( isaddresscorrect(AddressFilter) , oC_ErrorCode_WrongAddress ) )
779 bool received =
GetFromSoftwareRing(&ReceivedPackets,AddressFilter,outPacket,outNetif,FilterFunction,Parameter);
780 oC_Time_t currentTime = oC_KTime_GetTimestamp();
781 oC_Time_t time = currentTime;
782 oC_Time_t endTime = time + Timeout;
784 while(received ==
false && Timeout > 0)
786 if(ErrorCondition(
oC_Event_WaitForState(ReceivedPackets.DataAvailable,NumberOfReceivedPackets,oC_Event_StateMask_DifferentThan,Timeout) , oC_ErrorCode_Timeout))
788 currentTime = oC_KTime_GetTimestamp();
789 received =
GetFromSoftwareRing(&ReceivedPackets,AddressFilter,outPacket,outNetif,FilterFunction,Parameter);
793 errorCode = oC_ErrorCode_None;
798 if(currentTime < endTime)
800 Timeout = endTime - oC_KTime_GetTimestamp();
808 if(received ==
false)
810 errorCode = oC_ErrorCode_Timeout;
814 errorCode = oC_ErrorCode_None;
836 if(oC_SaveIfFalse(
"NetifMan::UpdateRoutingTable - module is not turned on - " ,
oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
838 foreach(RoutingTableData.RoutingTable,entry)
842 oC_SaveIfErrorOccur(
"NetifMan::UpdateRoutingTable - cannot update link status - " ,
oC_Netif_UpdateLinkStatus(entry->Netif));
844 foreach(RoutingTableData.RoutingActiveEntryList,activeEntry)
846 oC_ASSERT(activeEntry !=
NULL);
854 activeEntry->DestinationAddress.IPv4 == entry->DestinationAddress.IPv4
855 && activeEntry->Netmask.IPv4 == entry->Netmask.IPv4
864 oC_SaveError(
"NetifMan::UpdateRoutingTable - not implemented for IPv6 - " , oC_ErrorCode_NotImplemented);
868 if(foundEntry ==
NULL)
870 oC_List_PushBack(RoutingTableData.RoutingActiveEntryList,foundEntry,&Allocator);
872 else if(foundEntry != entry)
877 oC_List_Swap(RoutingTableData.RoutingActiveEntryList,foundEntry,entry);
907 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
911 if(ErrorCondition( Process ==
NULL , oC_ErrorCode_ProcessAlreadyStarted ))
913 Process = oC_Process_New( oC_Process_Priority_NetworkHandlerProcess ,
"NetifMan-Process", oC_UserMan_GetRootUser() , 0 ,
NULL, oC_StreamMan_GetStdErrorStream(), oC_StreamMan_GetStdErrorStream());
916 ErrorCondition( Process !=
NULL, oC_ErrorCode_CannotCreateProcess )
917 && ErrorCode ( oC_ProcessMan_AddProcess(Process) )
920 Thread = oC_Thread_New(0,STACK_SIZE,Process,
"netifman::daemon",
DaemonThread,
NULL);
923 ErrorCondition( Thread !=
NULL , oC_ErrorCode_CannotCreateThread )
924 && ErrorCondition( oC_Thread_Run(Thread) , oC_ErrorCode_CannotRunThread )
927 errorCode = oC_ErrorCode_None;
937 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________ 944 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 953 oC_IntMan_EnterCriticalSection();
957 NumberOfIgnoredPackets++;
962 for(uint32_t i = 0; i < SOFTWARE_RING_SIZE; i++ )
964 if(SoftwareRing->Packets[i].Used ==
false)
966 SoftwareRing->Packets[i].Netif = Netif;
967 SoftwareRing->Packets[i].Timestamp = oC_KTime_GetTimestamp();
968 SoftwareRing->Packets[i].Used =
true;
969 memcpy(&SoftwareRing->Packets[i].Packet,Packet,
sizeof(
oC_Net_Packet_t));
970 SoftwareRing->Count++;
971 NumberOfReceivedPackets++;
977 oC_IntMan_ExitCriticalSection();
979 oC_Event_SetState(SoftwareRing->DataAvailable,NumberOfReceivedPackets);
989 bool packetFound =
false;
990 uint32_t takenIndex = 0;
992 oC_IntMan_EnterCriticalSection();
999 for(uint32_t i = 0; i < SOFTWARE_RING_SIZE; i++)
1002 (SoftwareRing->Packets[i].Used ==
true)
1004 && (protocol == 0 || protocol == SoftwareRing->Packets[i].Packet.
IPv4.
Header.
Protocol )
1007 if( FilterFunction ==
NULL || FilterFunction(&SoftwareRing->Packets[i].Packet,Parameter,SoftwareRing->Packets[i].Netif) )
1009 if(!packetFound || SoftwareRing->Packets[takenIndex].Timestamp < SoftwareRing->Packets[i].Timestamp)
1020 SoftwareRing->Count--;
1021 SoftwareRing->Packets[takenIndex].Used =
false;
1023 if(outPacket !=
NULL)
1025 memcpy(outPacket,&SoftwareRing->Packets[takenIndex].Packet,
sizeof(
oC_Net_Packet_t));
1027 if(outNetif !=
NULL)
1029 *outNetif = SoftwareRing->Packets[takenIndex].Netif;
1035 oC_SaveError(
"NetifMan::GetFromSoftwareRing - IPv6 is not implemented - " , oC_ErrorCode_NotImplemented);
1039 oC_IntMan_ExitCriticalSection();
1051 return SoftwareRing->Count == SOFTWARE_RING_SIZE;
1063 foreach(RoutingTableData.RoutingActiveEntryList,tempEntry)
1066 || (tempEntry->Netmask.IPv4 == 0 && tempEntry->DestinationAddress.IPv4 == 0)
1084 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1093 if(!oC_ErrorOccur(errorCode))
1098 else if (errorCode != oC_ErrorCode_Timeout)
1100 oC_SaveError(
"NetifMan::ReceivePacketsThread - cannot receive packet - ", errorCode );
1111 oC_SaveIfFalse(
"packet", kfree(packet,0), oC_ErrorCode_ReleaseError);
1122 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1135 destination.
IPv4 = 0;
1137 while(oC_SaveIfFalse(
"packet" , packet !=
NULL, oC_ErrorCode_AllocationError))
1141 && ErrorCondition( isram(packet) , oC_ErrorCode_InternalDataAreDamaged )
1149 oC_SaveIfErrorOccur(
"icmp-echo - cannot send packet - ", ErrorCode(
oC_Icmp_Send(
NULL, &destination, packet,
min(2)) ));
1155 oC_SaveIfFalse(
"packet", kfree(packet, AllocationFlags_Default), oC_ErrorCode_ReleaseError);
1159 oC_SaveError(
"icmp-echo: Cannot reserve type - ", errorCode);
1172 oC_Timestamp_t nextIpUpdateTimestamp = oC_KTime_GetTimestamp();
1176 if(oC_SaveIfFalse(
"NetifMan::DaemonThread - icmp echo - ", echoThread , oC_ErrorCode_CannotCreateThread))
1178 if(
false == oC_SaveIfFalse(
"NetifMan::Daemon - icmp echo - " , oC_Thread_Run(echoThread) , oC_ErrorCode_CannotRunThread))
1180 oC_SaveIfFalse(
"NetifMan::Daemon - icmp echo - " , oC_Thread_Delete(&echoThread) , oC_ErrorCode_CannotDeleteThread);
1188 foreach(NetifList,netif)
1198 if(oC_SaveIfFalse(
"NetifMan::DeamonThread - Cannot create thread - " , relatedThread !=
NULL, oC_ErrorCode_CannotCreateThread))
1201 oC_SaveIfFalse(
"NetifMan::DaemonThread - Cannot run thread" , oC_Thread_Run(relatedThread), oC_ErrorCode_CannotRunThread)
1202 && oC_SaveIfErrorOccur(
"NetifMan::DaemonThread - Cannot set thread for netif - " ,
oC_Netif_SetReceiveThread(netif,relatedThread) )
1209 oC_SaveIfFalse(
"NetifMan::Daemon - cannot delete thread ", oC_Thread_Delete(&relatedThread), oC_ErrorCode_CannotDeleteThread);
1216 oC_SaveIfErrorOccur(
"NetifMan::ReceivePacketsThead - cannot update link status - " ,
oC_Netif_UpdateLinkStatus(netif) );
1217 oC_SaveIfErrorOccur(
"NetifMan::ReceivePacketsThead - cannot update IP - " ,
oC_Netif_UpdateIp(netif,
s(30)) );
1218 nextIpUpdateTimestamp = oC_KTime_GetTimestamp() +
s(5);
1223 sleep(DAEMON_SLEEP_TIME);
1227 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ oC_Net_Ipv4_t SourceIp
Source IP address.
#define min(time)
Number of min.
oC_ErrorCode_t oC_NetifMan_RemoveNetifFromList(oC_Netif_t Netif)
removes a Netif object from the list
oC_ErrorCode_t oC_Icmp_Send(oC_Netif_t Netif, const oC_Net_Address_t *Destination, oC_Icmp_Packet_t *Packet, oC_Time_t Timeout)
sends ICMP packet
static bool oC_Net_AreAddressesTheSame(const oC_Net_Address_t *Address1, const oC_Net_Address_t *Address2)
returns true if both pointers stores the same address
bool oC_Event_WaitForState(oC_Event_t Event, oC_Event_State_t State, oC_Event_StateMask_t StateMask, oC_Time_t Timeout)
#define s(time)
Number of s.
oC_Netif_t oC_NetifMan_GetNetif(oC_Netif_FriendlyName_t FriendlyName)
returns #Netif with the given name
oC_Net_Protocol_t Protocol
IP Protocol.
oC_ErrorCode_t oC_NetifMan_StartDaemon(void)
starts the NetifMan daemon
bool oC_Netif_GetListenMode(oC_Netif_t Netif)
returns true if listen mode is enabled
oC_Driver_t oC_Netif_GetDriver(oC_Netif_t Netif)
returns driver related with the Netif
const char * oC_Netif_GetFriendlyName(oC_Netif_t Netif)
returns friendly name of the network interface
oC_Net_Ipv4PacketHeader_t Header
Header of the IPv4 packet.
identifier for allocations
oC_ErrorCode_t oC_Netif_ReadReceiveThread(oC_Netif_t Netif, oC_Thread_t *outThread)
sets thread for receiving packets
void oC_NetifMan_ConfigureAll(void)
configures all network interface
static void DaemonThread(void *Argument)
main thread for handling network interfaces
The file with interface for process manager.
oC_Net_Protocol_t
stores the protocol number for the IP headers The type is for storing protocol number. The values can be written indirectly to the IP headers.
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
File with interface for user system manager.
oC_Net_Packet_t Packet
IP packet.
stores ICMP packet (datagram + IP header)
Stores interface of netif manager module.
oC_ErrorCode_t oC_Netif_Unconfigure(oC_Netif_t Netif)
unconfigures network driver related with the Netif
static void EchoThread(void *Thread)
thread for echo messages
oC_Icmp_Datagram_t IcmpDatagram
ICMP data in the IPv4 packet.
uint32_t oC_Net_Ipv4_t
stores IPv4 address
static bool oC_Net_IsAddressInSubnet(const oC_Net_Address_t *Address, const oC_Net_Address_t *Subnet, const oC_Net_Address_t *Mask)
checks if the address is in subnet
bool oC_Netif_IsCorrect(oC_Netif_t Netif)
checks if the Netif object is correct
static oC_Net_PacketType_t oC_Net_Packet_GetType(const oC_Net_Packet_t *Packet)
returns type of the packet
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
oC_ErrorCode_t oC_Icmp_Receive(oC_Netif_t Netif, oC_Icmp_Packet_t *outPacket, oC_Icmp_Type_t Type, oC_Time_t Timeout)
receives ICMP packet
static void ReceivePacketsThread(oC_Netif_t Netif)
thread for receiving packets via network interface
uint32_t oC_Net_Cost_t
stores cost of the network connection
The file with interface for the module library.
oC_ErrorCode_t oC_Netif_UpdateLinkStatus(oC_Netif_t Netif)
updates link status in the network interface object
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
The file with interface for stream manager.
The file with interface for event module.
oC_ErrorCode_t oC_Netif_Configure(oC_Netif_t Netif)
configures network driver to work with netif
oC_ErrorCode_t oC_Netif_SetReceiveThread(oC_Netif_t Netif, oC_Thread_t Thread)
sets thread for receiving packets
oC_Net_Ipv4_t IPv4
Address in IPv4 version.
static bool IsSoftwareRingFull(SoftwareRing_t *SoftwareRing)
checks if the software ring is full
oC_ErrorCode_t oC_Icmp_ReserveType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
reserves a ICMP type
oC_List(oC_Netif_t)
returns list of network interfaces
oC_Netif_t Netif
Netif interface to use.
static const oC_Allocator_t Allocator
stores entry of the routing table
The file with interface for interrupt manager.
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
oC_ErrorCode_t oC_NetifMan_TurnOff(void)
releases module resources
bool oC_Netif_Delete(oC_Netif_t *outNetif)
deletes netif object
Internet Control Message Protocol.
static bool oC_Net_IsAddressCorrect(const oC_Net_Address_t *Address)
returns true if the given address is correct
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
The file with drivers manager interface.
oC_Icmp_Header_t Header
Header of the ICMP packet.
oC_Net_Ipv4Packet_t IPv4
Packet in format IPv4.
void oC_NetifMan_UnconfigureAll(void)
unconfigures all network interface
oC_Netif_t oC_NetifMan_GetNetifForAddress(const oC_Net_Address_t *Destination)
returns network interface according to destination address
bool oC_Netif_IsIpAssigned(oC_Netif_t Netif)
returns true if IP is assigned
bool oC_Netif_IsConfigured(oC_Netif_t Netif)
checks if the driver is configured
oC_ErrorCode_t oC_NetifMan_AddNetifToList(oC_Netif_t Netif)
adds new netif to the list
static void PutToSoftwareRing(SoftwareRing_t *SoftwareRing, oC_Netif_t Netif, oC_Net_Packet_t *Packet)
puts packet to the software ring
Network interface is DOWN (cable is not connected)
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
uint32_t Version
4 bits, that contain the version, that specified if it's an IPv4 or IPv6 packet
uint32_t Protocol
Contains selected protocol (TCP/UDP/ICMP,etc).
void oC_NetifMan_UpdateRoutingTable(void)
updates active routing table
oC_ErrorCode_t oC_Netif_ReceivePacket(oC_Netif_t Netif, oC_Net_Packet_t *Packet, oC_MemorySize_t PacketSize, oC_Time_t Timeout)
receives packet by using the interface
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
oC_Net_FriendlyInterfaceName_t oC_Netif_FriendlyName_t
type for storing friendly name string
File with interface for ICMP.
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
oC_ErrorCode_t oC_Netif_SendPacket(oC_Netif_t Netif, oC_Net_Packet_t *Packet, oC_Time_t Timeout)
sends packet by using the network interface
The file with interface for semaphores.
oC_Net_Ipv4PacketHeader_t Header
IPv4 header.
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
#define kB(kBytes)
Number of kB.
oC_Net_LinkStatus_t oC_Netif_GetLinkStatus(oC_Netif_t Netif)
returns last known link status of the network interface
static RoutingTableEntry_t * GetActiveRoutingTableEntry(const oC_Net_Address_t *Address)
returns active table entry for the given address
oC_Net_Cost_t Cost
Cost of interface usage (it is to allow choosing one interface more frequently than another) ...
oC_ErrorCode_t oC_Netif_UpdateIp(oC_Netif_t Netif, oC_Time_t Timeout)
updates IP in the given network interface
oC_Net_AddressType_t Type
Type of the address stored inside.
static bool GetFromSoftwareRing(SoftwareRing_t *SoftwareRing, const oC_Net_Address_t *Address, oC_Net_Packet_t *outPacket, oC_Netif_t *outNetif, oC_NetifMan_PacketFilterFunction_t FilterFunction, const void *Parameter)
reads packet from the software ring
oC_ErrorCode_t oC_Icmp_ReleaseType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
releases a type
#define NULL
pointer to a zero
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off