Rewrite from scratch a TCP/IP stack for mbed. So far the following parts are usable: Drivers: - EMAC driver (from CMSIS 2.0) Protocols: - Ethernet protocol - ARP over ethernet for IPv4 - IPv4 over Ethernet - ICMPv4 over IPv4 - UDPv4 over IPv4 APIs: - Sockets for UDPv4 The structure of this stack is designed to be very modular. Each protocol can register one or more protocol to handle its payload, and in each protocol, an API can be hooked (like Sockets for example). This is an early release.

Files at this revision

API Documentation at this revision

Comitter:
Benoit
Date:
Sun Jun 12 19:51:22 2011 +0000
Parent:
1:f4040665bc61
Child:
3:e8677c542c5d
Commit message:
Removed NetIF_ProcessFrames now that an interrupt handler is doing the job

Changed in this revision

NetIF.cpp Show annotated file Show diff for this revision Revisions of this file
NetIF.h Show annotated file Show diff for this revision Revisions of this file
--- a/NetIF.cpp	Sun Jun 12 19:17:11 2011 +0000
+++ b/NetIF.cpp	Sun Jun 12 19:51:22 2011 +0000
@@ -148,6 +148,7 @@
 }
 
 
+/*
 int32_t NetIF_ProcessFrames(void)
 {
     NetIF_Index_t        netIFIndex;
@@ -172,6 +173,7 @@
     DEBUG_SOURCE(DEBUG_LEVEL_VERBOSE2, ("leave"));
     return result;
 }
+*/
 
 
 int32_t NetIF_RegisterPeriodicFunction(char *name, PeriodicFunction_t function, FunctionPeriod_t period)
@@ -238,7 +240,7 @@
 }
 
 
-int32_t    NetIF_SendIPv4Packet(IPv4_Header_t *ipv4Header)
+int32_t NetIF_SendIPv4Packet(IPv4_Header_t *ipv4Header)
 {
     int32_t                result = -1, 
                         mtu,
@@ -262,18 +264,21 @@
     if ((netIF == NULL) && (gatewayNetIFIndex >= 0))
     {
         netIF = netIF_Table + gatewayNetIFIndex;
-        DEBUG_MODULE(DEBUG_LEVEL_INFO, ("using gateway %d.%d.%d.%d to talk to %d.%d.%d.%d",
-            netIF->ipv4Gateway.IP0,    
-            netIF->ipv4Gateway.IP1,    
-            netIF->ipv4Gateway.IP2,    
-            netIF->ipv4Gateway.IP3,    
+        if (netIF->up)
+        {
+            DEBUG_MODULE(DEBUG_LEVEL_INFO, ("using gateway %d.%d.%d.%d to talk to %d.%d.%d.%d",
+                netIF->ipv4Gateway.IP0,    
+                netIF->ipv4Gateway.IP1,    
+                netIF->ipv4Gateway.IP2,    
+                netIF->ipv4Gateway.IP3,    
 
-            ipv4Header->dest.IP0,
-            ipv4Header->dest.IP1,
-            ipv4Header->dest.IP2,
-            ipv4Header->dest.IP3
-        ));
-        useGateway = True;
+                ipv4Header->dest.IP0,
+                ipv4Header->dest.IP1,
+                ipv4Header->dest.IP2,
+                ipv4Header->dest.IP3
+            ));
+            useGateway = True;
+        }
     }
     
     /* Still no interface able to send, then return error */
@@ -318,12 +323,11 @@
                 netIF->ipv4Gateway.IP2,
                 netIF->ipv4Gateway.IP3
             ));
-            NetIF_ProcessFrames();
         }
     }
     else
     {
-        while (ARP_ResolveIPv4Address(netIF, ipv4Header->dest, &ethernetHeader->destination))
+        while (ARP_ResolveIPv4Address(netIF, ipv4Header->dest, &ethernetHeader->destination) == -1)
         {
             DEBUG_MODULE(DEBUG_LEVEL_VERBOSE0, ("%d.%d.%d.%d not in ARP cache",
                 ipv4Header->dest.IP0,
@@ -331,7 +335,6 @@
                 ipv4Header->dest.IP2,
                 ipv4Header->dest.IP3
             ));
-            NetIF_ProcessFrames();
         }
     }
     
@@ -350,7 +353,6 @@
         
         netIF->name,
         netIF->index
-
     ));
 
     /* Copy source MAC address */
--- a/NetIF.h	Sun Jun 12 19:17:11 2011 +0000
+++ b/NetIF.h	Sun Jun 12 19:51:22 2011 +0000
@@ -136,7 +136,6 @@
 
 
 NetIF_t    *NetIF_RegisterInterface(IPv4_Addr_t *address, IPv4_Addr_t *netmask, IPv4_Addr_t *gateway, NetIF_Driver_t *driver, void *driverParameter);
-int32_t    NetIF_ProcessFrames(void);
 int32_t    NetIF_RegisterPeriodicFunction(char *name, PeriodicFunction_t function, FunctionPeriod_t period);
 int32_t    NetIF_ProcessTimers(int32_t elapsedTime);
 int32_t    NetIF_SendIPv4Packet(IPv4_Header_t *ipv4Header);