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.
Revision 7:8e12f7357b9f, committed 2011-06-26
- Comitter:
- Benoit
- Date:
- Sun Jun 26 09:56:31 2011 +0000
- Parent:
- 6:7f7f29fde21c
- Commit message:
- Added IPv4 global broadcast address to processed frames inside IPv4 layer.
Changed in this revision
IPv4.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7f7f29fde21c -r 8e12f7357b9f IPv4.cpp --- a/IPv4.cpp Mon Jun 13 15:40:56 2011 +0000 +++ b/IPv4.cpp Sun Jun 26 09:56:31 2011 +0000 @@ -20,7 +20,7 @@ #define DEBUG_CURRENT_MODULE_ID DEBUG_MODULE_IPV4 -static void Init(void); +static void Init(void); static int32_t RegisterProtocol(Protocol_Handler_t *protocolHandler); static void Handler(NetIF_t *netIF, NetPacket_t *packet); @@ -83,30 +83,32 @@ static void Handler(NetIF_t *netIF, NetPacket_t *packet) { - int32_t protocolIndex, - payloadOffset; - Protocol_Number_t protocolNumber; - Protocol_Handler_t *protocolHandler; - IPv4_Header_t *ipv4Packet; - - - ipv4Packet = (IPv4_Header_t *)packet->data; + int32_t protocolIndex, + payloadOffset; + Protocol_Number_t protocolNumber; + Protocol_Handler_t *protocolHandler; + IPv4_Header_t *ipv4Packet; + + + ipv4Packet = (IPv4_Header_t *)packet->data; protocolNumber = ipv4Packet->protocol; payloadOffset = ipv4Packet->ihl << 2; - if ((ipv4Packet->dest.addr == netIF->ipv4Address.addr) || (ipv4Packet->dest.addr == netIF->ipv4Broadcast.addr)) + if ( (ipv4Packet->dest.addr == netIF->ipv4Address.addr) || + (ipv4Packet->dest.addr == netIF->ipv4Broadcast.addr) || + (ipv4Packet->dest.addr == ipv4_Addr_Broadcast.addr) ) { - for (protocolIndex = 0; protocolIndex < protocolHandlerCount; protocolIndex++) - { - protocolHandler = protocolHandlerTable[protocolIndex]; - if (protocolHandler->protocolNumber == protocolNumber) - { - NetIF_ProtoPush(packet, payloadOffset, Protocol_ID_IPv4); - protocolHandler->HandlePacket(netIF, packet); - break; - } - } + for (protocolIndex = 0; protocolIndex < protocolHandlerCount; protocolIndex++) + { + protocolHandler = protocolHandlerTable[protocolIndex]; + if (protocolHandler->protocolNumber == protocolNumber) + { + NetIF_ProtoPush(packet, payloadOffset, Protocol_ID_IPv4); + protocolHandler->HandlePacket(netIF, packet); + break; + } + } } return;