Networking: Update ICMPv6 logic to RFCs

This commit is contained in:
Gregory Nutt
2015-01-20 11:06:51 -06:00
parent 92f440c20c
commit d68cd0d8de
11 changed files with 181 additions and 78 deletions
+47 -13
View File
@@ -94,14 +94,25 @@
#define ICMPv6_FLAG_S (1 << 6)
#define ICMPv6_OPTION_SOURCE_LINK_ADDRESS 1
#define ICMPv6_OPTION_TARGET_LINK_ADDRESS 2
/* Header sizes */
#define ICMPv6_HDRLEN 4 /* Size of ICMPv6 header */
#define IPICMPv6_HDRLEN (ICMPv6_HDRLEN + IPv6_HDRLEN) /* Size of IPv6 + ICMPv6 header */
/* Option types */
#define ICMPv6_OPT_SRCLLADDR 1 /* Source Link-Layer Address */
#define ICMPv6_OPT_TGTLLADDR 2 /* Target Link-Layer Address */
#define ICMPv6_OPT_PREFIX 3 /* Prefix Information */
#define ICMPv6_OPT_REDIRECT 4 /* Redirected Header */
#define ICMPv6_OPT_MTU 5 /* MTU */
/* ICMPv6 Neighbor Advertisement message flags */
#define ICMPv6_FLAG_R (1 << 7) /* Router flag */
#define ICMPv6_FLAG_S (1 << 6) /* Solicited flag */
#define ICMPv6_FLAG_O (1 << 5) /* Override flag */
/****************************************************************************
* Public Type Definitions
****************************************************************************/
@@ -113,7 +124,7 @@ struct icmpv6_iphdr_s
/* IPv6 Ip header */
uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
uint16_t flow; /* 16-bit flow label (LS) */
uint8_t len[2]; /* 16-bit Payload length */
uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
@@ -124,21 +135,44 @@ struct icmpv6_iphdr_s
/* ICMPv6 header */
uint8_t type; /* Defines the format of the ICMP message */
uint8_t icode; /* Further qualifies the ICMP messages */
uint16_t icmpv6chksum; /* Checksum of ICMP header and data */
uint8_t code; /* Further qualifies the ICMP messages */
uint16_t chksum; /* Checksum of ICMP header and data */
/* Data following the ICMP header contains the data specific to the
* message type indicated by the Type and Code fields.
*/
};
/* ICMPv6_ECHO_REQUEST and ICMPv6_ECHO_REPLY data */
/* This the message format for the ICMPv6 Neighbor Solicitation message */
uint8_t flags;
uint8_t reserved1;
uint8_t reserved2;
uint8_t reserved3;
uint8_t icmpv6data[16];
uint8_t options[1];
struct icmpv6_neighbor_solicit_s
{
uint8_t type; /* Message Type: ICMPv6_NEIGHBOR_SOLICIT */
uint8_t code; /* Further qualifies the ICMP messages */
uint16_t chksum; /* Checksum of ICMP header and data */
uint8_t flags[4]; /* See ICMPv6_FLAG_ definitions */
net_ipv6addr_t tgtaddr; /* 128-bit Target IPv6 address */
uint8_t opttype; /* Option Type: ICMPv6_OPT_SRCLLADDR */
uint8_t optlen; /* Option length: 8 octets */
#ifdef CONFIG_NET_ETHERNET
uint8_t srclladdr[6]; /* Options: Source link layer address */
#endif
};
/* This the message format for the ICMPv6 Neighbor Advertisement message */
struct icmpv6_neighbor_advertise_s
{
uint8_t type; /* Message Type: ICMPv6_NEIGHBOR_ADVERTISE */
uint8_t code; /* Further qualifies the ICMP messages */
uint16_t chksum; /* Checksum of ICMP header and data */
uint8_t flags[4]; /* See ICMPv6_FLAG_ definitions */
net_ipv6addr_t tgtaddr; /* Target IPv6 address */
uint8_t opttype; /* Option Type: ICMPv6_OPT_TGTLLADDR */
uint8_t optlen; /* Option length: 8 octets */
#ifdef CONFIG_NET_ETHERNET
uint8_t tgtlladdr[6]; /* Options: Target link layer address */
#endif
};
/* The structure holding the ICMP statistics that are gathered if