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.

ARP.h

Committer:
Benoit
Date:
2011-06-12
Revision:
0:19f5f51584de
Child:
1:f4040665bc61

File content as of revision 0:19f5f51584de:

/*
 * $Id: ARP.h 29 2011-06-11 14:53:08Z benoit $
 * $Author: benoit $
 * $Date: 2011-06-11 16:53:08 +0200 (sam., 11 juin 2011) $
 * $Rev: 29 $
 * 
 * 
 * 
 * 
 * 
 */
 
#ifndef __ARP_H__
#define    __ARP_H__


#include "IPv4.h"
#include "Ethernet.h"


#define    ARP_HW_TYPE_ENET        0x0001

#define    ARP_OPERATION_REQUEST    0x0001
#define    ARP_OPERATION_REPLY        0x0002


typedef uint16_t                ARP_Type_t;
typedef uint16_t                ARP_Protocol_t;
typedef uint16_t                ARP_Operation_t;


#pragma push
#pragma pack(1)
struct ARP_Header
{
    ARP_Type_t            type;
    ARP_Protocol_t        protocol;
    uint8_t                hardAddrLen;
    uint8_t                protoAddrLen;
    ARP_Operation_t        operation;
};
#pragma pop
typedef struct ARP_Header ARP_Header_t;


#pragma push
#pragma pack(1)
struct ARP_IPv4Data
{
    Ethernet_Addr_t        hwSource;
    IPv4_Addr_t            ipSource;
    Ethernet_Addr_t        hwDest;
    IPv4_Addr_t            ipDest;
};
#pragma pop
typedef struct ARP_IPv4Data ARP_IPv4Data_t;


extern Protocol_Handler_t arp;


CAPI int32_t    ARP_ResolveIPv4Address(NetIF_t *netIF, IPv4_Addr_t address, Ethernet_Addr_t *ethernetAddr);
CAPI int32_t    ARP_AddStaticEntry(NetIF_t *netIF, IPv4_Addr_t address, const Ethernet_Addr_t *ethernetAddr);
CAPI int32_t    ARP_RemoveEntry(const NetIF_t *netIF, IPv4_Addr_t address);
CAPI void        ARP_InvalidateCache(Bool_t flushStaticEntries);
CAPI void        ARP_Timer(void);
CAPI void        ARP_DisplayCache(void);
CAPI void         ARP_DumpHeader(const char *prefix, ARP_Header_t *arpHeader);

#endif /* __ARP_H__ */