Skip to content

Commit

Permalink
[ipv6] Replace IPv6 stack
Browse files Browse the repository at this point in the history
Replace the existing partially-implemented IPv6 stack with a fresh
implementation.

This implementation is not yet complete.  The IPv6 transmit and
receive datapaths are functional (including fragment reassembly and
parsing of arbitrary extension headers).  NDP neighbour solicitations
and advertisements are supported.  ICMPv6 echo is supported.

At present, only link-local addresses may be used, and there is no way
to specify an IPv6 address as part of a URI (either directly or via
a DNS lookup).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Sep 3, 2013
1 parent 43307b4 commit f7f3087
Show file tree
Hide file tree
Showing 16 changed files with 1,669 additions and 652 deletions.
3 changes: 3 additions & 0 deletions src/config/config.c
Expand Up @@ -101,6 +101,9 @@ REQUIRE_OBJECT ( debugcon );
#ifdef NET_PROTO_IPV4
REQUIRE_OBJECT ( ipv4 );
#endif
#ifdef NET_PROTO_IPV6
REQUIRE_OBJECT ( ipv6 );
#endif

/*
* Drag in all requested PXE support
Expand Down
3 changes: 3 additions & 0 deletions src/config/config_route.c
Expand Up @@ -22,3 +22,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#ifdef NET_PROTO_IPV4
REQUIRE_OBJECT ( route_ipv4 );
#endif
#ifdef NET_PROTO_IPV6
REQUIRE_OBJECT ( route_ipv6 );
#endif
1 change: 1 addition & 0 deletions src/config/general.h
Expand Up @@ -40,6 +40,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/

#define NET_PROTO_IPV4 /* IPv4 protocol */
#undef NET_PROTO_IPV6 /* IPv6 protocol */
#undef NET_PROTO_FCOE /* Fibre Channel over Ethernet protocol */

/*
Expand Down
59 changes: 0 additions & 59 deletions src/include/ipxe/icmp6.h

This file was deleted.

78 changes: 78 additions & 0 deletions src/include/ipxe/icmpv6.h
@@ -0,0 +1,78 @@
#ifndef _IPXE_ICMP6_H
#define _IPXE_ICMP6_H

/** @file
*
* ICMPv6 protocol
*
*/

FILE_LICENCE ( GPL2_OR_LATER );

#include <stdint.h>
#include <ipxe/tables.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>

/** An ICMPv6 header */
struct icmpv6_header {
/** Type */
uint8_t type;
/** Code */
uint8_t code;
/** Checksum */
uint16_t chksum;
} __attribute__ (( packed ));

/** An ICMPv6 echo request/reply */
struct icmpv6_echo {
/** ICMPv6 header */
struct icmpv6_header icmp;
/** Identifier */
uint16_t ident;
/** Sequence number */
uint16_t sequence;
/** Data */
uint8_t data[0];
} __attribute__ (( packed ));

/** An ICMPv6 handler */
struct icmpv6_handler {
/** Type */
unsigned int type;
/** Process received packet
*
* @v iobuf I/O buffer
* @v netdev Network device
* @v sin6_src Source socket address
* @v sin6_dest Destination socket address
* @ret rc Return status code
*
* This function takes ownership of the I/O buffer.
*/
int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
struct sockaddr_in6 *sin6_src,
struct sockaddr_in6 *sin6_dest );
};

/** ICMPv6 handler table */
#define ICMPV6_HANDLERS __table ( struct icmpv6_handler, "icmpv6_handlers" )

/** Declare an ICMPv6 handler */
#define __icmpv6_handler __table_entry ( ICMPV6_HANDLERS, 01 )

/** ICMPv6 echo request */
#define ICMPV6_ECHO_REQUEST 128

/** ICMPv6 echo reply */
#define ICMPV6_ECHO_REPLY 129

/** ICMPv6 neighbour solicitation */
#define ICMPV6_NDP_NEIGHBOUR_SOLICITATION 135

/** ICMPv6 neighbour advertisement */
#define ICMPV6_NDP_NEIGHBOUR_ADVERTISEMENT 136

extern struct tcpip_protocol icmpv6_protocol __tcpip_protocol;

#endif /* _IPXE_ICMP6_H */
31 changes: 17 additions & 14 deletions src/include/ipxe/in.h
Expand Up @@ -50,6 +50,13 @@ struct in6_addr {
#define s6_addr32 in6_u.u6_addr32
};

#define IN6_IS_ADDR_MULTICAST( addr ) \
( *( ( const uint8_t * ) (addr) ) == 0xff )

#define IN6_IS_ADDR_LINKLOCAL( addr ) \
( ( *( ( const uint16_t * ) (addr) ) & htons ( 0xffc0 ) ) == \
htonl ( 0xfe80 ) )

/**
* IPv4 socket address
*/
Expand Down Expand Up @@ -90,9 +97,13 @@ struct sockaddr_in6 {
uint16_t sin6_flags;
/** TCP/IP port (part of struct @c sockaddr_tcpip) */
uint16_t sin6_port;
uint32_t sin6_flowinfo; /* Flow number */
struct in6_addr sin6_addr; /* 128-bit destination address */
uint32_t sin6_scope_id; /* Scope ID */
/** Scope ID
*
* For link-local addresses, this is the network device index.
*/
uint16_t sin6_scope_id;
/** IPv6 address */
struct in6_addr sin6_addr;
/** Padding
*
* This ensures that a struct @c sockaddr_in6 is large
Expand All @@ -103,20 +114,12 @@ struct sockaddr_in6 {
( sizeof ( sa_family_t ) /* sin6_family */ +
sizeof ( uint16_t ) /* sin6_flags */ +
sizeof ( uint16_t ) /* sin6_port */ +
sizeof ( uint32_t ) /* sin6_flowinfo */ +
sizeof ( struct in6_addr ) /* sin6_addr */ +
sizeof ( uint32_t ) /* sin6_scope_id */ ) ];
sizeof ( uint16_t ) /* sin6_scope_id */ +
sizeof ( struct in6_addr ) /* sin6_addr */ ) ];
} __attribute__ (( may_alias ));

extern int inet_aton ( const char *cp, struct in_addr *inp );
extern char * inet_ntoa ( struct in_addr in );

/* Adding the following for IP6 support
*
extern int inet6_aton ( const char *cp, struct in6_addr *inp );
extern char * inet6_ntoa ( struct in_addr in );
*/
extern char * inet6_ntoa ( const struct in6_addr *in6 );

#endif /* _IPXE_IN_H */
80 changes: 0 additions & 80 deletions src/include/ipxe/ip6.h

This file was deleted.

0 comments on commit f7f3087

Please sign in to comment.