mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 13:00:39 +03:00
IP6 support
This commit is contained in:
58
src/include/gpxe/icmp6.h
Normal file
58
src/include/gpxe/icmp6.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _GPXE_ICMP6_H
|
||||
#define _GPXE_ICMP6_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* ICMP6 protocol
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ip.h>
|
||||
#include <gpxe/ip6.h>
|
||||
#include <gpxe/ndp.h>
|
||||
|
||||
#define ICMP6_NSOLICIT 135
|
||||
#define ICMP6_NADVERT 136
|
||||
|
||||
extern struct tcpip_protocol icmp6_protocol;
|
||||
|
||||
struct icmp6_header {
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t csum;
|
||||
/* Message body */
|
||||
};
|
||||
|
||||
struct neighbour_solicit {
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t csum;
|
||||
uint32_t reserved;
|
||||
struct in6_addr target;
|
||||
/* "Compulsory" options */
|
||||
uint8_t opt_type;
|
||||
uint8_t opt_len;
|
||||
#warning hack alert
|
||||
uint8_t opt_ll_addr[6];
|
||||
};
|
||||
|
||||
struct neighbour_advert {
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t csum;
|
||||
uint8_t flags;
|
||||
uint8_t reserved;
|
||||
struct in6_addr target;
|
||||
uint8_t opt_type;
|
||||
uint8_t opt_len;
|
||||
#warning hack alert
|
||||
uint8_t opt_ll_addr[6];
|
||||
};
|
||||
|
||||
#define ICMP6_FLAGS_ROUTER 0x80
|
||||
#define ICMP6_FLAGS_SOLICITED 0x40
|
||||
#define ICMP6_FLAGS_OVERRIDE 0x20
|
||||
|
||||
int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src, struct in6_addr *dest );
|
||||
|
||||
#endif /* _GPXE_ICMP6_H */
|
||||
@@ -10,6 +10,7 @@
|
||||
#define IP_IGMP 2
|
||||
#define IP_TCP 6
|
||||
#define IP_UDP 17
|
||||
#define IP_ICMP6 58
|
||||
|
||||
/* IP address constants */
|
||||
|
||||
@@ -36,7 +37,7 @@ struct in6_addr {
|
||||
uint8_t u6_addr8[16];
|
||||
uint16_t u6_addr16[8];
|
||||
uint32_t u6_addr32[4];
|
||||
} in16_u;
|
||||
} in6_u;
|
||||
#define s6_addr in6_u.u6_addr8
|
||||
#define s6_addr16 in6_u.u6_addr16
|
||||
#define s6_addr32 in6_u.u6_addr32
|
||||
@@ -67,7 +68,7 @@ struct sockaddr_in6 {
|
||||
*/
|
||||
sa_family_t sin_family;
|
||||
/** TCP/IP port (part of struct @c sockaddr_tcpip) */
|
||||
uint16_t sin_port;
|
||||
uint16_t sin_port;
|
||||
uint32_t sin6_flowinfo; /* Flow number */
|
||||
struct in6_addr sin6_addr; /* 128-bit destination address */
|
||||
uint32_t sin6_scope_id; /* Scope ID */
|
||||
|
||||
@@ -8,18 +8,33 @@
|
||||
*/
|
||||
|
||||
#include <ip.h>
|
||||
#include <gpxe/in.h>
|
||||
|
||||
/* IP6 constants */
|
||||
|
||||
#define IP6_VERSION 0x6
|
||||
#define IP6_HOP_LIMIT 64
|
||||
#define IP6_HOP_LIMIT 255
|
||||
|
||||
/**
|
||||
* Packet buffer contents
|
||||
* This is duplicated in tcp.h and here. Ideally it should go into pkbuff.h
|
||||
*/
|
||||
#define MAX_HDR_LEN 100
|
||||
#define MAX_PKB_LEN 1500
|
||||
#define MIN_PKB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */
|
||||
|
||||
#define IP6_EQUAL( in6_addr1, in6_addr2 ) \
|
||||
( strncmp ( ( char* ) &( in6_addr1 ), ( char* ) &( in6_addr2 ),\
|
||||
sizeof ( struct in6_addr ) ) == 0 )
|
||||
|
||||
#define IS_UNSPECIFIED( addr ) \
|
||||
( ( (addr).in6_u.u6_addr32[0] == 0x00000000 ) && \
|
||||
( (addr).in6_u.u6_addr32[1] == 0x00000000 ) && \
|
||||
( (addr).in6_u.u6_addr32[2] == 0x00000000 ) && \
|
||||
( (addr).in6_u.u6_addr32[3] == 0x00000000 ) )
|
||||
/* IP6 header */
|
||||
|
||||
struct ip6_header {
|
||||
uint32_t vers:4,
|
||||
traffic_class:8,
|
||||
flow_label:20;
|
||||
uint32_t ver_traffic_class_flow_label;
|
||||
uint16_t payload_len;
|
||||
uint8_t nxt_hdr;
|
||||
uint8_t hop_limit;
|
||||
@@ -27,12 +42,32 @@ struct ip6_header {
|
||||
struct in6_addr dest;
|
||||
};
|
||||
|
||||
/* IP6 pseudo header */
|
||||
struct ipv6_pseudo_header {
|
||||
struct in6_addr src;
|
||||
struct in6_addr dest;
|
||||
uint8_t zero_padding;
|
||||
uint8_t nxt_hdr;
|
||||
uint16_t len;
|
||||
};
|
||||
|
||||
/* Next header numbers */
|
||||
#define IP6_HOPBYHOP 0x00
|
||||
#define IP6_ROUTING 0x43
|
||||
#define IP6_FRAGMENT 0x44
|
||||
#define IP6_AUTHENTICATION 0x51
|
||||
#define IP6_DEST_OPTS 0x60
|
||||
#define IP6_ESP 0x50
|
||||
#define IP6_ICMP6 0x58
|
||||
#define IP6_NO_HEADER 0x59
|
||||
|
||||
struct pk_buff;
|
||||
struct net_device;
|
||||
struct net_protocol;
|
||||
|
||||
extern struct net_protocol ipv6_protocol;
|
||||
extern struct tcpip_net_protocol ipv6_tcpip_protocol;
|
||||
extern char * inet6_ntoa ( struct in6_addr in6 );
|
||||
|
||||
extern int ipv6_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in6_addr *dest );
|
||||
|
||||
#endif /* _GPXE_IP6_H */
|
||||
|
||||
23
src/include/gpxe/ndp.h
Normal file
23
src/include/gpxe/ndp.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <gpxe/icmp6.h>
|
||||
#include <gpxe/ip6.h>
|
||||
#include <gpxe/in.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
#include <gpxe/pkbuff.h>
|
||||
#include <gpxe/tcpip.h>
|
||||
|
||||
#define NDP_STATE_INVALID 0
|
||||
#define NDP_STATE_INCOMPLETE 1
|
||||
#define NDP_STATE_REACHABLE 2
|
||||
#define NDP_STATE_DELAY 3
|
||||
#define NDP_STATE_PROBE 4
|
||||
#define NDP_STATE_STALE 5
|
||||
|
||||
static struct ndp_entry * ndp_find_entry ( struct in6_addr *in6 );
|
||||
int ndp_resolve ( struct net_device *netdev, struct in6_addr *src,
|
||||
struct in6_addr *dest, void *dest_ll_addr );
|
||||
int ndp_process_advert ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
|
||||
struct sockaddr_tcpip *st_dest );
|
||||
Reference in New Issue
Block a user