Choco OS  V.0.16.9.0
Join to the chocolate world
oc_netifman.c
Go to the documentation of this file.
1 
27 #include <oc_netifman.h>
28 #include <oc_netif_cfg.c>
29 #include <oc_intman.h>
30 #include <oc_driverman.h>
31 #include <oc_processman.h>
32 #include <oc_debug.h>
33 #include <oc_semaphore.h>
34 #include <oc_module.h>
35 #include <oc_userman.h>
36 #include <oc_event.h>
37 #include <oc_streamman.h>
38 #include <oc_icmp.h>
39 
45 #define _________________________________________DEFINITIONS_SECTION________________________________________________________________________
46 
47 #define SOFTWARE_RING_SIZE 10
48 #define STACK_SIZE kB(2)
49 #define DAEMON_SLEEP_TIME s(1)
50 
51 #undef _________________________________________DEFINITIONS_SECTION________________________________________________________________________
52 
53 
59 #define _________________________________________TYPES_SECTION______________________________________________________________________________
60 
61 typedef struct
62 {
63  bool Used;
64  oC_Timestamp_t Timestamp;
65  oC_Net_Packet_t Packet;
66  oC_Netif_t Netif;
67 } Packet_t;
68 
69 typedef struct
70 {
71  Packet_t Packets[SOFTWARE_RING_SIZE];
72  uint32_t Count;
73  oC_Event_t DataAvailable;
75 
77 
78 typedef struct
79 {
80  oC_List(RoutingTableEntry_t*) RoutingActiveEntryList;
81  oC_List(RoutingTableEntry_t*) RoutingTable;
83 
84 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
85 
91 #define _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
92 
93 static void PutToSoftwareRing ( SoftwareRing_t * SoftwareRing , oC_Netif_t Netif , oC_Net_Packet_t * Packet );
94 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);
95 static inline bool IsSoftwareRingFull ( SoftwareRing_t * SoftwareRing );
97 static void DaemonThread ( void * Argument );
98 
99 #undef _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
100 
101 
107 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
108 
109 //==========================================================================================================================================
113 //==========================================================================================================================================
114 static const oC_Allocator_t Allocator = {
115  .Name = "NetifMan" ,
116 };
117 static oC_List(oC_Netif_t) NetifList = NULL;
118 static oC_Process_t Process = NULL;
119 static oC_Thread_t Thread = NULL;
120 static uint32_t NumberOfIgnoredPackets = 0;
121 static uint32_t NumberOfReceivedPackets = 0;
122 static SoftwareRing_t ReceivedPackets;
123 static RoutingTableData_t RoutingTableData;
124 
125 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
126 
132 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
133 
138 //==========================================================================================================================================
158 //==========================================================================================================================================
159 oC_ErrorCode_t oC_NetifMan_TurnOn( void )
160 {
161  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
162 
163  oC_IntMan_EnterCriticalSection();
164 
165  if(oC_Module_TurnOffVerification(&errorCode , oC_Module_NetifMan))
166  {
167  //--------------------------------------------------------//
168  // VARIABLES INITIALIZATION //
169  //--------------------------------------------------------//
170  memset(&ReceivedPackets,0,sizeof(ReceivedPackets));
171  memset(&RoutingTableData,0,sizeof(RoutingTableData));
172 
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);
178  Process = NULL;
179  Thread = NULL;
180  NumberOfIgnoredPackets = 0;
181  NumberOfReceivedPackets = 0;
182 
183  if(
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 )
188  )
189  {
190  bool pushed = false;
191  errorCode = oC_ErrorCode_None;
192 
193  /* The module is now enabled... */
194  oC_Module_TurnOn(oC_Module_NetifMan);
195 
196  (void)pushed;
197 
198  //--------------------------------------------------------//
199  // ADDING DEFAULT INTERFACES //
200  //--------------------------------------------------------//
201 #define NETIF_NAME(CONFIG_NAME) oC_1WORD_FROM_2(CONFIG_NAME,_Netif)
202 #define AUTO NULL
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);
208 
209  CFG_NETIF_LIST(ADD_NET,UNIVERSAL_DONT_ADD);
210 
211 #undef NETIF_NAME
212 #undef ADD_NET
213 #undef AUTO
214 
215  //--------------------------------------------------------//
216  // CREATING DEFAULT ROUTING TABLE //
217  //--------------------------------------------------------//
218 #define ADD_ENTRY(DESTINATION,NETMASK,COST,FRIENDLY_NAME) \
219  { \
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 ) );\
229  }
230  CFG_ROUTING_TABLE(ADD_ENTRY,UNIVERSAL_DONT_ADD);
231 #undef ADD_ENTRY
232 
233  }
234  else
235  {
236  //--------------------------------------------------------//
237  // RELEASING RESOURCES WHEN FAILED //
238  //--------------------------------------------------------//
239  bool deleted = oC_List_Delete(NetifList,AllocationFlags_CanWait1Second);
240  oC_SaveIfFalse("NetifMan::TurnOn - NetifList - ", deleted , oC_ErrorCode_ReleaseError);
241 
242  deleted = oC_List_Delete(RoutingTableData.RoutingActiveEntryList,AllocationFlags_CanWait1Second);
243  oC_SaveIfFalse("NetifMan::TurnOn - RoutingEntryList - ", deleted , oC_ErrorCode_ReleaseError);
244 
245  deleted = oC_List_Delete(RoutingTableData.RoutingTable,AllocationFlags_CanWait1Second);
246  oC_SaveIfFalse("NetifMan::TurnOn - RoutingTable - ", deleted , oC_ErrorCode_ReleaseError);
247 
248  oC_SaveIfFalse("NetifMan::TurnOn - DataAvailable semaphore - ",
249  oC_Event_Delete(&ReceivedPackets.DataAvailable,AllocationFlags_CanWait1Second),
250  oC_ErrorCode_ReleaseError);
251  }
252  }
253 
254  oC_IntMan_ExitCriticalSection();
255 
256  return errorCode;
257 }
258 
259 //==========================================================================================================================================
278 //==========================================================================================================================================
279 oC_ErrorCode_t oC_NetifMan_TurnOff( void )
280 {
281  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
282  bool deleted = false;
283 
284  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
285  {
287 
288  oC_Module_TurnOff(oC_Module_NetifMan);
289 
290  errorCode = oC_ErrorCode_None;
291 
292  if(Process != NULL)
293  {
294  ErrorCondition( oC_Process_Delete(&Process) , oC_ErrorCode_CannotDeleteProcess );
295  }
296 
297  if(Thread != NULL)
298  {
299  ErrorCondition( oC_Thread_Delete(&Thread) , oC_ErrorCode_CannotDeleteThread );
300  }
301 
302  oC_List_Foreach(NetifList,netif)
303  {
304  ErrorCondition(oC_Netif_Delete(&netif),oC_ErrorCode_CannotDeleteObject);
305  }
306 
307  ErrorCondition(oC_Event_Delete(&ReceivedPackets.DataAvailable,AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
308 
309  deleted = oC_List_Delete(NetifList,AllocationFlags_CanWait1Second);
310  ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
311 
312  foreach(RoutingTableData.RoutingTable,entry)
313  {
314  ErrorCondition(kfree(entry,AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
315  }
316 
317  deleted = oC_List_Delete(RoutingTableData.RoutingTable,AllocationFlags_CanWait1Second);
318  ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
319 
320  deleted = oC_List_Delete(RoutingTableData.RoutingActiveEntryList,AllocationFlags_CanWait1Second);
321  ErrorCondition(deleted,oC_ErrorCode_CannotDeleteObject);
322  }
323 
324  return errorCode;
325 }
326 
327 //==========================================================================================================================================
334 //==========================================================================================================================================
336 {
337  if(oC_SaveIfFalse("NetifMan::ConfigureAll - " , oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
338  {
339  oC_List_Foreach(NetifList,netif)
340  {
341  if(oC_Driver_IsTurnedOn(oC_Netif_GetDriver(netif)) && oC_Netif_IsConfigured(netif) == false)
342  {
343  oC_SaveIfErrorOccur(oC_Netif_GetFriendlyName(netif),oC_Netif_Configure(netif));
344  }
345  }
346 
348  }
349 }
350 
351 //==========================================================================================================================================
357 //==========================================================================================================================================
359 {
360  if(oC_SaveIfFalse("NetifMan::UnconfigureAll - " , oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
361  {
362  oC_List_Foreach(NetifList,netif)
363  {
364  if(oC_Driver_IsTurnedOn(oC_Netif_GetDriver(netif)) && oC_Netif_IsConfigured(netif) == true)
365  {
366  oC_SaveIfErrorOccur(oC_Netif_GetFriendlyName(netif),oC_Netif_Unconfigure(netif));
367  }
368  }
369  }
370 }
371 
372 //==========================================================================================================================================
385 //==========================================================================================================================================
387 {
388  oC_Netif_t netifToReturn = NULL;
389 
390  if(
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 )
394  )
395  {
396  oC_List_Foreach(NetifList,netif)
397  {
398  if(strcmp(FriendlyName , oC_Netif_GetFriendlyName(netif)) == 0)
399  {
400  netifToReturn = netif;
401  }
402  }
403  }
404 
405  return netifToReturn;
406 }
407 
408 //==========================================================================================================================================
414 //==========================================================================================================================================
416 {
417  oC_Netif_t netif = NULL;
418 
419  if(isaddresscorrect(Destination))
420  {
421  RoutingTableEntry_t * entry = GetActiveRoutingTableEntry(Destination);
422 
423  if(isaddresscorrect(entry))
424  {
425  netif = entry->Netif;
426  }
427  }
428 
429  return netif;
430 }
431 
432 //==========================================================================================================================================
453 //==========================================================================================================================================
454 oC_ErrorCode_t oC_NetifMan_AddNetifToList( oC_Netif_t Netif )
455 {
456  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
457 
458  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
459  {
460  bool existOnTheList = oC_List_Contains(NetifList,Netif);
461 
462  if(
463  ErrorCondition( oC_Netif_IsCorrect(Netif) , oC_ErrorCode_ObjectNotCorrect )
464  && ErrorCondition( existOnTheList == false , oC_ErrorCode_FoundOnList )
465  )
466  {
467  bool pushed = oC_List_PushBack( NetifList, Netif, &Allocator);
468 
469  if(ErrorCondition(pushed , oC_ErrorCode_CannotAddObjectToList))
470  {
472  errorCode = oC_ErrorCode_None;
473  }
474  }
475  }
476 
477  return errorCode;
478 }
479 
480 //==========================================================================================================================================
499 //==========================================================================================================================================
501 {
502  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
503 
504  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
505  {
506  bool deleted = oC_List_RemoveAll(NetifList,Netif);
507 
508  if(ErrorCondition(deleted,oC_ErrorCode_ObjectNotFoundOnList))
509  {
511  errorCode = oC_ErrorCode_None;
512  }
513  }
514 
515  return errorCode;
516 }
517 
518 //==========================================================================================================================================
546 //==========================================================================================================================================
547 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 )
548 {
549  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
550 
551  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
552  {
553  if(
554  ErrorCondition( oC_Net_IsAddressCorrect(Destination) , oC_ErrorCode_WrongAddress )
555  && ErrorCondition( oC_Net_IsAddressCorrect(Netmask) , oC_ErrorCode_WrongAddress )
556  && ErrorCondition( oC_Netif_IsCorrect(Netif) , oC_ErrorCode_ObjectNotCorrect )
557  )
558  {
559  RoutingTableEntry_t * entry = kmalloc( sizeof(RoutingTableEntry_t),&Allocator,AllocationFlags_CanWait1Second | AllocationFlags_ZeroFill );
560 
561  if(
562  ErrorCondition( entry != NULL , oC_ErrorCode_AllocationError )
563  )
564  {
565  entry->Cost = Cost;
566  entry->Netif = Netif;
567 
568  bool pushed = oC_List_PushBack( RoutingTableData.RoutingActiveEntryList, entry, &Allocator );
569 
570  if(ErrorCondition(pushed, oC_ErrorCode_CannotAddObjectToList))
571  {
572  errorCode = oC_ErrorCode_None;
573  }
574  }
576  }
577  }
578 
579  return errorCode;
580 }
581 
582 //==========================================================================================================================================
609 //==========================================================================================================================================
610 oC_ErrorCode_t oC_NetifMan_RemoveRoutingTableEntry( const oC_Net_Address_t * Destination, const oC_Net_Address_t * Netmask, oC_Netif_t Netif )
611 {
612  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
613 
614  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
615  {
616  if(
617  ErrorCondition( oC_Netif_IsCorrect(Netif) , oC_ErrorCode_ObjectNotCorrect )
618  && ( Destination == NULL || ErrorCondition( isaddresscorrect(Destination) , oC_ErrorCode_WrongAddress ) )
619  && ( Netmask == NULL || ErrorCondition( isaddresscorrect(Netmask) , oC_ErrorCode_WrongAddress ) )
620  )
621  {
622  errorCode = oC_ErrorCode_ObjectNotFoundOnList;
623 
624  foreach(RoutingTableData.RoutingActiveEntryList,entry)
625  {
626  if(entry->Netif == Netif)
627  {
628  if( Destination == NULL || oC_Net_AreAddressesTheSame( Destination, &entry->DestinationAddress ) )
629  {
630  if(Netmask == NULL || oC_Net_AreAddressesTheSame( Netmask, &entry->Netmask ))
631  {
632  errorCode = oC_ErrorCode_None;
633 
634  ErrorCondition( kfree(entry,AllocationFlags_CanWait1Second) , oC_ErrorCode_ReleaseError );
635  oC_List_RemoveCurrentElement(RoutingTableData.RoutingActiveEntryList, entry );
636  }
637  }
638  }
639  }
641  }
642 
643  }
644 
645  return errorCode;
646 }
647 
648 //==========================================================================================================================================
659 //==========================================================================================================================================
660 oC_List(oC_Netif_t) oC_NetifMan_GetList( void )
661 {
662  return NetifList;
663 }
664 
665 //==========================================================================================================================================
688 //==========================================================================================================================================
689 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 )
690 {
691  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
692 
693  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
694  {
696 
697  if(
698  ErrorCondition( isaddresscorrect(Packet), oC_ErrorCode_WrongAddress )
699  && ErrorCondition( entry != NULL , oC_ErrorCode_RoutingTableEntryNotFound )
700  )
701  {
702  oC_IntMan_EnterCriticalSection();
703  oC_Netif_t netif = entry->Netif;
704  oC_IntMan_ExitCriticalSection();
705 
706  if(
707  ErrorCondition( oC_Netif_IsCorrect(netif) , oC_ErrorCode_NetifNotCorrect )
708  && ErrorCode( oC_Netif_SendPacket(netif,Packet,Timeout) )
709  )
710  {
711  errorCode = oC_ErrorCode_None;
712 
713  if(
714  outNetif != NULL
715  && ErrorCondition( isram(outNetif), oC_ErrorCode_OutputAddressNotInRAM ) )
716  {
717  *outNetif = netif;
718  }
719  }
720  }
721  }
722 
723  return errorCode;
724 }
725 
726 //==========================================================================================================================================
762 //==========================================================================================================================================
763 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 )
764 {
765  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
766 
767  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
768  {
769  if(
770  ErrorCondition( isram(outPacket) , oC_ErrorCode_OutputAddressNotInRAM )
771  && ErrorCondition( FilterFunction == NULL || isaddresscorrect(FilterFunction) , oC_ErrorCode_WrongAddress )
772  )
773  {
774  if(
775  ( outNetif == NULL || ErrorCondition( isram(outNetif) , oC_ErrorCode_OutputAddressNotInRAM ) )
776  && ( AddressFilter == NULL || ErrorCondition( isaddresscorrect(AddressFilter) , oC_ErrorCode_WrongAddress ) )
777  )
778  {
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;
783 
784  while(received == false && Timeout > 0)
785  {
786  if(ErrorCondition(oC_Event_WaitForState(ReceivedPackets.DataAvailable,NumberOfReceivedPackets,oC_Event_StateMask_DifferentThan,Timeout) , oC_ErrorCode_Timeout))
787  {
788  currentTime = oC_KTime_GetTimestamp();
789  received = GetFromSoftwareRing(&ReceivedPackets,AddressFilter,outPacket,outNetif,FilterFunction,Parameter);
790 
791  if(received)
792  {
793  errorCode = oC_ErrorCode_None;
794  break;
795  }
796  }
797 
798  if(currentTime < endTime)
799  {
800  Timeout = endTime - oC_KTime_GetTimestamp();
801  }
802  else
803  {
804  Timeout = 0;
805  }
806  }
807 
808  if(received == false)
809  {
810  errorCode = oC_ErrorCode_Timeout;
811  }
812  else
813  {
814  errorCode = oC_ErrorCode_None;
815  }
816  }
817  }
818  }
819 
820  return errorCode;
821 }
822 
823 //==========================================================================================================================================
833 //==========================================================================================================================================
835 {
836  if(oC_SaveIfFalse("NetifMan::UpdateRoutingTable - module is not turned on - " , oC_Module_IsTurnedOn(oC_Module_NetifMan) , oC_ErrorCode_ModuleNotStartedYet))
837  {
838  foreach(RoutingTableData.RoutingTable,entry)
839  {
840  RoutingTableEntry_t * foundEntry = NULL;
841 
842  oC_SaveIfErrorOccur("NetifMan::UpdateRoutingTable - cannot update link status - " , oC_Netif_UpdateLinkStatus(entry->Netif));
843 
844  foreach(RoutingTableData.RoutingActiveEntryList,activeEntry)
845  {
846  oC_ASSERT(activeEntry != NULL);
847 
848  if(
849  activeEntry->DestinationAddress.Type == oC_Net_AddressType_IPv4
850  && activeEntry->Netmask.Type == oC_Net_AddressType_IPv4
851  )
852  {
853  if(
854  activeEntry->DestinationAddress.IPv4 == entry->DestinationAddress.IPv4
855  && activeEntry->Netmask.IPv4 == entry->Netmask.IPv4
856  )
857  {
858  foundEntry = entry;
859  break;
860  }
861  }
862  else
863  {
864  oC_SaveError("NetifMan::UpdateRoutingTable - not implemented for IPv6 - " , oC_ErrorCode_NotImplemented);
865  }
866  }
867 
868  if(foundEntry == NULL)
869  {
870  oC_List_PushBack(RoutingTableData.RoutingActiveEntryList,foundEntry,&Allocator);
871  }
872  else if(foundEntry != entry)
873  {
874 
876  {
877  oC_List_Swap(RoutingTableData.RoutingActiveEntryList,foundEntry,entry);
878  }
879  }
880  }
881  }
882 }
883 
884 //==========================================================================================================================================
904 //==========================================================================================================================================
905 oC_ErrorCode_t oC_NetifMan_StartDaemon( void )
906 {
907  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
908 
909  if(oC_Module_TurnOnVerification(&errorCode, oC_Module_NetifMan))
910  {
911  if(ErrorCondition( Process == NULL , oC_ErrorCode_ProcessAlreadyStarted ))
912  {
913  Process = oC_Process_New( oC_Process_Priority_NetworkHandlerProcess , "NetifMan-Process", oC_UserMan_GetRootUser() , 0 , NULL, oC_StreamMan_GetStdErrorStream(), oC_StreamMan_GetStdErrorStream());
914 
915  if(
916  ErrorCondition( Process != NULL, oC_ErrorCode_CannotCreateProcess )
917  && ErrorCode ( oC_ProcessMan_AddProcess(Process) )
918  )
919  {
920  Thread = oC_Thread_New(0,STACK_SIZE,Process,"netifman::daemon",DaemonThread,NULL);
921 
922  if(
923  ErrorCondition( Thread != NULL , oC_ErrorCode_CannotCreateThread )
924  && ErrorCondition( oC_Thread_Run(Thread) , oC_ErrorCode_CannotRunThread )
925  )
926  {
927  errorCode = oC_ErrorCode_None;
928  }
929  }
930  }
931  }
932 
933  return errorCode;
934 }
935 
937 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
938 
944 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
945 
946 //==========================================================================================================================================
950 //==========================================================================================================================================
951 static void PutToSoftwareRing( SoftwareRing_t * SoftwareRing , oC_Netif_t Netif , oC_Net_Packet_t * Packet )
952 {
953  oC_IntMan_EnterCriticalSection();
954  if(IsSoftwareRingFull(SoftwareRing))
955  {
956  GetFromSoftwareRing(SoftwareRing,NULL,NULL,NULL,NULL,NULL);
957  NumberOfIgnoredPackets++;
958  }
959 
961  {
962  for(uint32_t i = 0; i < SOFTWARE_RING_SIZE; i++ )
963  {
964  if(SoftwareRing->Packets[i].Used == false)
965  {
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++;
972  break;
973  }
974  }
975  }
976 
977  oC_IntMan_ExitCriticalSection();
978 
979  oC_Event_SetState(SoftwareRing->DataAvailable,NumberOfReceivedPackets);
980 }
981 
982 //==========================================================================================================================================
986 //==========================================================================================================================================
987 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 )
988 {
989  bool packetFound = false;
990  uint32_t takenIndex = 0;
991 
992  oC_IntMan_EnterCriticalSection();
993 
994  if(Address == NULL || Address->Type == oC_Net_AddressType_IPv4 || Address->Type == 0)
995  {
996  oC_Net_Ipv4_t ip = (Address == NULL || Address->Type == 0) ? 0 : Address->IPv4;
997  oC_Net_Protocol_t protocol = (Address == NULL) ? 0 : Address->Protocol;
998 
999  for(uint32_t i = 0; i < SOFTWARE_RING_SIZE; i++)
1000  {
1001  if(
1002  (SoftwareRing->Packets[i].Used == true)
1003  && (ip == 0 || ip == SoftwareRing->Packets[i].Packet.IPv4.Header.SourceIp )
1004  && (protocol == 0 || protocol == SoftwareRing->Packets[i].Packet.IPv4.Header.Protocol )
1005  )
1006  {
1007  if( FilterFunction == NULL || FilterFunction(&SoftwareRing->Packets[i].Packet,Parameter,SoftwareRing->Packets[i].Netif) )
1008  {
1009  if(!packetFound || SoftwareRing->Packets[takenIndex].Timestamp < SoftwareRing->Packets[i].Timestamp)
1010  {
1011  takenIndex = i;
1012  packetFound = true;
1013  }
1014  }
1015  }
1016  }
1017 
1018  if(packetFound)
1019  {
1020  SoftwareRing->Count--;
1021  SoftwareRing->Packets[takenIndex].Used = false;
1022 
1023  if(outPacket != NULL)
1024  {
1025  memcpy(outPacket,&SoftwareRing->Packets[takenIndex].Packet,sizeof(oC_Net_Packet_t));
1026  }
1027  if(outNetif != NULL)
1028  {
1029  *outNetif = SoftwareRing->Packets[takenIndex].Netif;
1030  }
1031  }
1032  }
1033  else
1034  {
1035  oC_SaveError("NetifMan::GetFromSoftwareRing - IPv6 is not implemented - " , oC_ErrorCode_NotImplemented);
1036  }
1037 
1038 
1039  oC_IntMan_ExitCriticalSection();
1040 
1041  return packetFound;
1042 }
1043 
1044 //==========================================================================================================================================
1048 //==========================================================================================================================================
1049 static inline bool IsSoftwareRingFull( SoftwareRing_t * SoftwareRing )
1050 {
1051  return SoftwareRing->Count == SOFTWARE_RING_SIZE;
1052 }
1053 
1054 //==========================================================================================================================================
1058 //==========================================================================================================================================
1060 {
1061  RoutingTableEntry_t * entry = NULL;
1062 
1063  foreach(RoutingTableData.RoutingActiveEntryList,tempEntry)
1064  {
1065  if(oC_Net_IsAddressInSubnet(Address,&tempEntry->DestinationAddress,&tempEntry->Netmask)
1066  || (tempEntry->Netmask.IPv4 == 0 && tempEntry->DestinationAddress.IPv4 == 0)
1067  )
1068  {
1069  entry = tempEntry;
1070  break;
1071  }
1072  }
1073 
1074  return entry;
1075 }
1076 
1077 //==========================================================================================================================================
1081 //==========================================================================================================================================
1082 static void ReceivePacketsThread( oC_Netif_t Netif )
1083 {
1084  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1085  oC_Net_Packet_t* packet = kmalloc( sizeof(oC_Net_Packet_t), &Allocator, AllocationFlags_CanWait1Second | AllocationFlags_ZeroFill );
1086 
1087  while(oC_Netif_IsConfigured(Netif) && packet != NULL)
1088  {
1089  if(ErrorCode(oC_Netif_UpdateLinkStatus(Netif)) && oC_Netif_GetLinkStatus(Netif) == oC_Net_LinkStatus_Up && oC_Netif_GetListenMode(Netif) == false)
1090  {
1091  errorCode = oC_Netif_ReceivePacket(Netif, packet, sizeof(oC_Net_Packet_t) , min(1));
1092 
1093  if(!oC_ErrorOccur(errorCode))
1094  {
1095  PutToSoftwareRing(&ReceivedPackets,Netif,packet);
1096  memset(packet,0,sizeof(oC_Net_Packet_t));
1097  }
1098  else if (errorCode != oC_ErrorCode_Timeout)
1099  {
1100  oC_SaveError("NetifMan::ReceivePacketsThread - cannot receive packet - ", errorCode );
1101  }
1102  }
1103  else
1104  {
1105  sleep(s(1));
1106  }
1107  }
1108 
1109  if(packet != NULL)
1110  {
1111  oC_SaveIfFalse("packet", kfree(packet,0), oC_ErrorCode_ReleaseError);
1112  }
1113 }
1114 
1115 //==========================================================================================================================================
1119 //==========================================================================================================================================
1120 static void EchoThread( void * Thread )
1121 {
1122  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1123 
1124  sleep(s(2));
1125 
1126  while(1)
1127  {
1129  {
1130  oC_Icmp_Packet_t * packet = malloc( sizeof(oC_Icmp_Packet_t), AllocationFlags_ZeroFill );
1131  oC_Net_Address_t destination;
1132 
1133  destination.Type = oC_Net_AddressType_IPv4;
1134  destination.Protocol = oC_Net_Protocol_ICMP;
1135  destination.IPv4 = 0;
1136 
1137  while(oC_SaveIfFalse("packet" , packet != NULL, oC_ErrorCode_AllocationError))
1138  {
1139  if(
1140  ErrorCode ( oC_Icmp_Receive( NULL, packet, oC_Icmp_Type_EchoRequest, min(10) ) )
1141  && ErrorCondition( isram(packet) , oC_ErrorCode_InternalDataAreDamaged )
1142  )
1143  {
1145  {
1147  destination.IPv4 = packet->IPv4.Header.SourceIp;
1148 
1149  oC_SaveIfErrorOccur("icmp-echo - cannot send packet - ", ErrorCode( oC_Icmp_Send(NULL, &destination, packet, min(2)) ));
1150 
1151  }
1152  }
1153  }
1155  oC_SaveIfFalse("packet", kfree(packet, AllocationFlags_Default), oC_ErrorCode_ReleaseError);
1156  }
1157  else
1158  {
1159  oC_SaveError("icmp-echo: Cannot reserve type - ", errorCode);
1160  sleep(s(5));
1161  }
1162  }
1163 }
1164 
1165 //==========================================================================================================================================
1169 //==========================================================================================================================================
1170 static void DaemonThread( void * Argument )
1171 {
1172  oC_Timestamp_t nextIpUpdateTimestamp = oC_KTime_GetTimestamp();
1173 
1174  oC_Thread_t echoThread = oC_Thread_New( 0, kB(1), NULL, "icmp-echo", EchoThread, NULL );
1175 
1176  if(oC_SaveIfFalse("NetifMan::DaemonThread - icmp echo - ", echoThread , oC_ErrorCode_CannotCreateThread))
1177  {
1178  if(false == oC_SaveIfFalse("NetifMan::Daemon - icmp echo - " , oC_Thread_Run(echoThread) , oC_ErrorCode_CannotRunThread))
1179  {
1180  oC_SaveIfFalse("NetifMan::Daemon - icmp echo - " , oC_Thread_Delete(&echoThread) , oC_ErrorCode_CannotDeleteThread);
1181  }
1182  }
1183 
1184  while(1)
1185  {
1187 
1188  foreach(NetifList,netif)
1189  {
1190  if(oC_Netif_IsConfigured(netif))
1191  {
1192  oC_Thread_t relatedThread = NULL;
1193 
1194  if(oC_Netif_ReadReceiveThread(netif,&relatedThread) == oC_ErrorCode_ThreadNotSet)
1195  {
1196  relatedThread = oC_Thread_New( 0, STACK_SIZE , NULL, oC_Netif_GetFriendlyName(netif), (oC_Thread_Function_t)ReceivePacketsThread, netif );
1197 
1198  if(oC_SaveIfFalse("NetifMan::DeamonThread - Cannot create thread - " , relatedThread != NULL, oC_ErrorCode_CannotCreateThread))
1199  {
1200  if(
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) )
1203  )
1204  {
1205  kdebuglog(oC_LogType_Info, "NetifMan::Daemon - thread created for %s", oC_Netif_GetFriendlyName(netif));
1206  }
1207  else
1208  {
1209  oC_SaveIfFalse("NetifMan::Daemon - cannot delete thread ", oC_Thread_Delete(&relatedThread), oC_ErrorCode_CannotDeleteThread);
1210  }
1211  }
1212  }
1213 
1214  if(oC_Netif_IsIpAssigned(netif) == false && oC_KTime_GetTimestamp() >= nextIpUpdateTimestamp && oC_Netif_GetLinkStatus(netif) == oC_Net_LinkStatus_Up)
1215  {
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);
1219  }
1220  }
1221  }
1222 
1223  sleep(DAEMON_SLEEP_TIME);
1224  }
1225 }
1226 
1227 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1228 
oC_Net_Ipv4_t SourceIp
Source IP address.
Definition: oc_net.h:231
#define min(time)
Number of min.
Definition: oc_cfg.h:138
oC_ErrorCode_t oC_NetifMan_RemoveNetifFromList(oC_Netif_t Netif)
removes a Netif object from the list
Definition: oc_netifman.c:500
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
Definition: oc_icmp.c:642
Packet in type IPv4.
Definition: oc_net.h:177
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
Definition: oc_net.h:1033
bool oC_Event_WaitForState(oC_Event_t Event, oC_Event_State_t State, oC_Event_StateMask_t StateMask, oC_Time_t Timeout)
Definition: oc_event.c:245
FILE__DESCRIPTION
#define s(time)
Number of s.
Definition: oc_cfg.h:133
oC_Netif_t oC_NetifMan_GetNetif(oC_Netif_FriendlyName_t FriendlyName)
returns #Netif with the given name
Definition: oc_netifman.c:386
oC_Net_Protocol_t Protocol
IP Protocol.
Definition: oc_net.h:449
oC_ErrorCode_t oC_NetifMan_StartDaemon(void)
starts the NetifMan daemon
Definition: oc_netifman.c:905
const char * Name
Definition: oc_stdlib.h:161
bool oC_Netif_GetListenMode(oC_Netif_t Netif)
returns true if listen mode is enabled
Definition: oc_netif.c:1696
oC_Driver_t oC_Netif_GetDriver(oC_Netif_t Netif)
returns driver related with the Netif
Definition: oc_netif.c:407
const char * oC_Netif_GetFriendlyName(oC_Netif_t Netif)
returns friendly name of the network interface
Definition: oc_netif.c:383
oC_Net_Ipv4PacketHeader_t Header
Header of the IPv4 packet.
Definition: oc_net.h:276
identifier for allocations
Definition: oc_stdlib.h:159
oC_ErrorCode_t oC_Netif_ReadReceiveThread(oC_Netif_t Netif, oC_Thread_t *outThread)
sets thread for receiving packets
Definition: oc_netif.c:1723
void oC_NetifMan_ConfigureAll(void)
configures all network interface
Definition: oc_netifman.c:335
static void DaemonThread(void *Argument)
main thread for handling network interfaces
Definition: oc_netifman.c:1170
The file with interface for process manager.
Echo Request.
Definition: oc_icmp.h:61
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.
Definition: oc_net.h:155
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
Definition: oc_netifman.c:763
File with interface for user system manager.
oC_Net_Packet_t Packet
IP packet.
Definition: oc_icmp.h:165
stores ICMP packet (datagram + IP header)
Definition: oc_icmp.h:163
Stores interface of netif manager module.
oC_ErrorCode_t oC_Netif_Unconfigure(oC_Netif_t Netif)
unconfigures network driver related with the Netif
Definition: oc_netif.c:477
stores network address
Definition: oc_net.h:441
static void EchoThread(void *Thread)
thread for echo messages
Definition: oc_netifman.c:1120
oC_Icmp_Datagram_t IcmpDatagram
ICMP data in the IPv4 packet.
Definition: oc_icmp.h:170
uint32_t oC_Net_Ipv4_t
stores IPv4 address
Definition: oc_net.h:132
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
Definition: oc_net.h:1001
bool oC_Netif_IsCorrect(oC_Netif_t Netif)
checks if the Netif object is correct
Definition: oc_netif.c:351
static oC_Net_PacketType_t oC_Net_Packet_GetType(const oC_Net_Packet_t *Packet)
returns type of the packet
Definition: oc_net.h:1370
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
Definition: oc_netifman.c:610
Echo reply.
Definition: oc_icmp.h:57
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
Definition: oc_icmp.c:742
static void ReceivePacketsThread(oC_Netif_t Netif)
thread for receiving packets via network interface
Definition: oc_netifman.c:1082
uint32_t oC_Net_Cost_t
stores cost of the network connection
Definition: oc_net.h:459
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
Definition: oc_netif.c:1477
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
Definition: oc_module.h:121
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
Definition: oc_netif.c:438
uint8_t Type
Type of the ICMP message.
Definition: oc_icmp.h:84
stores network packet
Definition: oc_net.h:302
oC_ErrorCode_t oC_Netif_SetReceiveThread(oC_Netif_t Netif, oC_Thread_t Thread)
sets thread for receiving packets
Definition: oc_netif.c:1634
oC_Net_Ipv4_t IPv4
Address in IPv4 version.
Definition: oc_net.h:446
static bool IsSoftwareRingFull(SoftwareRing_t *SoftwareRing)
checks if the software ring is full
Definition: oc_netifman.c:1049
oC_ErrorCode_t oC_Icmp_ReserveType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
reserves a ICMP type
Definition: oc_icmp.c:252
oC_List(oC_Netif_t)
returns list of network interfaces
Definition: oc_netifman.c:660
oC_Netif_t Netif
Netif interface to use.
Definition: oc_netifman.h:61
static const oC_Allocator_t Allocator
Definition: oc_netifman.c:114
stores entry of the routing table
Definition: oc_netifman.h:56
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
Definition: oc_netifman.h:78
oC_ErrorCode_t oC_NetifMan_TurnOff(void)
releases module resources
Definition: oc_netifman.c:279
bool oC_Netif_Delete(oC_Netif_t *outNetif)
deletes netif object
Definition: oc_netif.c:284
Internet Control Message Protocol.
Definition: oc_net.h:157
static bool oC_Net_IsAddressCorrect(const oC_Net_Address_t *Address)
returns true if the given address is correct
Definition: oc_net.h:918
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Definition: oc_module.h:170
The file with drivers manager interface.
oC_Icmp_Header_t Header
Header of the ICMP packet.
Definition: oc_icmp.h:147
IP address in version 4.
Definition: oc_net.h:429
oC_Net_Ipv4Packet_t IPv4
Packet in format IPv4.
Definition: oc_net.h:304
void oC_NetifMan_UnconfigureAll(void)
unconfigures all network interface
Definition: oc_netifman.c:358
oC_Netif_t oC_NetifMan_GetNetifForAddress(const oC_Net_Address_t *Destination)
returns network interface according to destination address
Definition: oc_netifman.c:415
bool oC_Netif_IsIpAssigned(oC_Netif_t Netif)
returns true if IP is assigned
Definition: oc_netif.c:1491
bool oC_Netif_IsConfigured(oC_Netif_t Netif)
checks if the driver is configured
Definition: oc_netif.c:367
oC_ErrorCode_t oC_NetifMan_AddNetifToList(oC_Netif_t Netif)
adds new netif to the list
Definition: oc_netifman.c:454
static void PutToSoftwareRing(SoftwareRing_t *SoftwareRing, oC_Netif_t Netif, oC_Net_Packet_t *Packet)
puts packet to the software ring
Definition: oc_netifman.c:951
Network interface is DOWN (cable is not connected)
Definition: oc_net.h:363
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
Definition: oc_netifman.c:547
uint32_t Version
4 bits, that contain the version, that specified if it&#39;s an IPv4 or IPv6 packet
Definition: oc_net.h:219
uint32_t Protocol
Contains selected protocol (TCP/UDP/ICMP,etc).
Definition: oc_net.h:229
void oC_NetifMan_UpdateRoutingTable(void)
updates active routing table
Definition: oc_netifman.c:834
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
Definition: oc_netif.c:697
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
Definition: oc_module.h:155
oC_Net_FriendlyInterfaceName_t oC_Netif_FriendlyName_t
type for storing friendly name string
Definition: oc_netif.h:68
File with interface for ICMP.
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
Definition: oc_module.h:138
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
Definition: oc_netif.c:572
The file with interface for semaphores.
oC_Net_Ipv4PacketHeader_t Header
IPv4 header.
Definition: oc_icmp.h:169
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
Definition: oc_netifman.c:689
#define kB(kBytes)
Number of kB.
Definition: oc_cfg.h:78
oC_Net_LinkStatus_t oC_Netif_GetLinkStatus(oC_Netif_t Netif)
returns last known link status of the network interface
Definition: oc_netif.c:1026
static RoutingTableEntry_t * GetActiveRoutingTableEntry(const oC_Net_Address_t *Address)
returns active table entry for the given address
Definition: oc_netifman.c:1059
oC_Net_Cost_t Cost
Cost of interface usage (it is to allow choosing one interface more frequently than another) ...
Definition: oc_netifman.h:60
oC_ErrorCode_t oC_Netif_UpdateIp(oC_Netif_t Netif, oC_Time_t Timeout)
updates IP in the given network interface
Definition: oc_netif.c:1583
oC_Net_AddressType_t Type
Type of the address stored inside.
Definition: oc_net.h:443
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
Definition: oc_netifman.c:987
oC_ErrorCode_t oC_Icmp_ReleaseType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
releases a type
Definition: oc_icmp.c:347
#define NULL
pointer to a zero
Definition: oc_null.h:37
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
Definition: oc_module.h:185