icmpv6.c File Reference

#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <gpxe/in.h>
#include <gpxe/ip6.h>
#include <gpxe/if_ether.h>
#include <gpxe/iobuf.h>
#include <gpxe/ndp.h>
#include <gpxe/icmp6.h>
#include <gpxe/tcpip.h>
#include <gpxe/netdevice.h>

Go to the source code of this file.

Functions

int icmp6_send_solicit (struct net_device *netdev, struct in6_addr *src __unused, struct in6_addr *dest)
 Send neighbour solicitation packet.
static int icmp6_rx (struct io_buffer *iobuf, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, __unused uint16_t pshdr_csum)
 Process ICMP6 headers.

Variables

struct tcpip_protocol icmp6_protocol
struct tcpip_protocol
icmp6_protocol 
__tcpip_protocol
 ICMP6 protocol.


Function Documentation

int icmp6_send_solicit ( struct net_device netdev,
struct in6_addr *src  __unused,
struct in6_addr dest 
)

Send neighbour solicitation packet.

Parameters:
netdev Network device
src Source address
dest Destination address
This function prepares a neighbour solicitation packet and sends it to the network layer.

Definition at line 26 of file icmpv6.c.

References AF_INET6, alloc_iob(), neighbour_solicit::code, neighbour_solicit::csum, ICMP6_NSOLICIT, icmp6_protocol, in6_addr::in6_u, iob_put, iob_reserve, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, MAX_HDR_LEN, memcpy, memset(), MIN_IOB_LEN, NULL, neighbour_solicit::opt_len, neighbour_solicit::opt_ll_addr, neighbour_solicit::opt_type, neighbour_solicit::target, tcpip_chksum(), tcpip_tx(), neighbour_solicit::type, and in6_addr::u6_addr32.

Referenced by ndp_resolve().

00027                                                  {
00028         union {
00029                 struct sockaddr_in6 sin6;
00030                 struct sockaddr_tcpip st;
00031         } st_dest;
00032         struct ll_protocol *ll_protocol = netdev->ll_protocol;
00033         struct neighbour_solicit *nsolicit;
00034         struct io_buffer *iobuf = alloc_iob ( sizeof ( *nsolicit ) + MIN_IOB_LEN );
00035         iob_reserve ( iobuf, MAX_HDR_LEN );
00036         nsolicit = iob_put ( iobuf, sizeof ( *nsolicit ) );
00037 
00038         /* Fill up the headers */
00039         memset ( nsolicit, 0, sizeof ( *nsolicit ) );
00040         nsolicit->type = ICMP6_NSOLICIT;
00041         nsolicit->code = 0;
00042         nsolicit->target = *dest;
00043         nsolicit->opt_type = 1;
00044         nsolicit->opt_len = ( 2 + ll_protocol->ll_addr_len ) / 8;
00045         memcpy ( nsolicit->opt_ll_addr, netdev->ll_addr,
00046                                 netdev->ll_protocol->ll_addr_len );
00047         /* Partial checksum */
00048         nsolicit->csum = 0;
00049         nsolicit->csum = tcpip_chksum ( nsolicit, sizeof ( *nsolicit ) );
00050 
00051         /* Solicited multicast address */
00052         st_dest.sin6.sin_family = AF_INET6;
00053         st_dest.sin6.sin6_addr.in6_u.u6_addr8[0] = 0xff;
00054         st_dest.sin6.sin6_addr.in6_u.u6_addr8[2] = 0x02;
00055         st_dest.sin6.sin6_addr.in6_u.u6_addr16[1] = 0x0000;
00056         st_dest.sin6.sin6_addr.in6_u.u6_addr32[1] = 0x00000000;
00057         st_dest.sin6.sin6_addr.in6_u.u6_addr16[4] = 0x0000;
00058         st_dest.sin6.sin6_addr.in6_u.u6_addr16[5] = 0x0001;
00059         st_dest.sin6.sin6_addr.in6_u.u6_addr32[3] = dest->in6_u.u6_addr32[3];
00060         st_dest.sin6.sin6_addr.in6_u.u6_addr8[13] = 0xff;
00061         
00062         /* Send packet over IP6 */
00063         return tcpip_tx ( iobuf, &icmp6_protocol, NULL, &st_dest.st,
00064                           NULL, &nsolicit->csum );
00065 }

static int icmp6_rx ( struct io_buffer iobuf,
struct sockaddr_tcpip st_src,
struct sockaddr_tcpip st_dest,
__unused uint16_t  pshdr_csum 
) [static]

Process ICMP6 headers.

Parameters:
iobuf I/O buffer
st_src Source address
st_dest Destination address

Definition at line 74 of file icmpv6.c.

References io_buffer::data, DBG, EINVAL, ENOSYS, free_iob(), ICMP6_NADVERT, iob_len(), ndp_process_advert(), and icmp6_header::type.

00075                                                                                      {
00076         struct icmp6_header *icmp6hdr = iobuf->data;
00077 
00078         /* Sanity check */
00079         if ( iob_len ( iobuf ) < sizeof ( *icmp6hdr ) ) {
00080                 DBG ( "Packet too short (%zd bytes)\n", iob_len ( iobuf ) );
00081                 free_iob ( iobuf );
00082                 return -EINVAL;
00083         }
00084 
00085         /* TODO: Verify checksum */
00086 
00087         /* Process the ICMP header */
00088         switch ( icmp6hdr->type ) {
00089         case ICMP6_NADVERT:
00090                 return ndp_process_advert ( iobuf, st_src, st_dest );
00091         }
00092         return -ENOSYS;
00093 }


Variable Documentation

Definition at line 14 of file icmpv6.c.

Referenced by icmp6_send_solicit().

Initial value:

 {
        .name = "ICMP6",
        .rx = icmp6_rx,
        .tcpip_proto = IP_ICMP6, 
}
ICMP6 protocol.

Definition at line 124 of file icmpv6.c.


Generated on Tue Apr 6 20:01:55 2010 for gPXE by  doxygen 1.5.7.1