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.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ICMPv4.h Source File

ICMPv4.h

00001 /*
00002  * $Id: ICMPv4.h 23 2011-06-06 06:03:23Z benoit $
00003  * $Author: benoit $
00004  * $Date: 2011-06-06 08:03:23 +0200 (lun., 06 juin 2011) $
00005  * $Rev: 23 $
00006  * 
00007  * 
00008  * 
00009  * 
00010  * 
00011  */
00012  
00013 #ifndef __ICMPV4_H__
00014 #define    __ICMPV4_H__
00015 
00016 
00017 #include "NetIF.h"
00018 #include "IPv4.h"
00019 
00020 
00021 #define    ICMPV4_TYPE_ECHO_REPLY        0
00022 #define    ICMPV4_TYPE_ECHO_REQUEST    8
00023 
00024 
00025 typedef uint8_t        ICMPv4_Type_t;
00026 typedef uint8_t        ICMPv4_Code_t;
00027 
00028 
00029 #pragma push
00030 #pragma pack(1)
00031 struct ICMPv4_Header
00032 {
00033     uint8_t        type;
00034     uint8_t        code;
00035     uint16_t    crc;
00036     union 
00037     {
00038         uint32_t    restOfHeader;
00039         struct
00040         {
00041             uint16_t    id,
00042                         sequence;
00043         } ping;
00044     } rest;
00045 };
00046 #pragma pop
00047 typedef struct ICMPv4_Header ICMPv4_Header_t;
00048 
00049 
00050 extern Protocol_Handler_t    icmpv4;
00051 
00052 
00053 uint16_t    ICMPv4_ComputeCRC(ICMPv4_Header_t *packet, int32_t length);
00054 Bool_t      ICMPv4_CheckCRC(ICMPv4_Header_t *packet, int32_t length);
00055 void        ICMPv4_DumpHeader(const char *prefix, IPv4_Header_t *ipv4Header);
00056 
00057 #endif /* __ICMPV4_H__ */