ndp.h File Reference

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

Go to the source code of this file.

Defines

#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

Functions

int ndp_resolve (struct net_device *netdev, struct in6_addr *src, struct in6_addr *dest, void *dest_ll_addr)
 Resolve the link-layer address.
int ndp_process_advert (struct io_buffer *iobuf, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest)


Define Documentation

#define NDP_STATE_INVALID   0

Definition at line 11 of file ndp.h.

Referenced by ndp_find_entry().

#define NDP_STATE_INCOMPLETE   1

Definition at line 12 of file ndp.h.

Referenced by ndp_resolve().

#define NDP_STATE_REACHABLE   2

Definition at line 13 of file ndp.h.

Referenced by ndp_process_advert(), and ndp_resolve().

#define NDP_STATE_DELAY   3

Definition at line 14 of file ndp.h.

#define NDP_STATE_PROBE   4

Definition at line 15 of file ndp.h.

#define NDP_STATE_STALE   5

Definition at line 16 of file ndp.h.


Function Documentation

int ndp_resolve ( struct net_device netdev,
struct in6_addr dest,
struct in6_addr src,
void *  dest_ll_addr 
)

Resolve the link-layer address.

Parameters:
netdev Network device
dest Destination address
src Source address
Return values:
dest_ll_addr Destination link-layer address or NULL
rc Status
This function looks up the neighbour cache for an entry corresponding to the destination address. If it finds a valid entry, it fills up dest_ll_addr and returns 0. Otherwise it sends a neighbour solicitation to the solicited multicast address.

Definition at line 102 of file ndp.c.

References add_ndp_entry(), DBG, ENOENT, icmp6_send_solicit(), inet6_ntoa(), ndp_entry::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy, ll_protocol::name, ndp_find_entry(), NDP_STATE_INCOMPLETE, NDP_STATE_REACHABLE, ll_protocol::ntoa, NULL, and ndp_entry::state.

Referenced by ipv6_tx().

00103                                                              {
00104         struct ll_protocol *ll_protocol = netdev->ll_protocol;
00105         struct ndp_entry *ndp;
00106         int rc;
00107 
00108         ndp = ndp_find_entry ( dest );
00109         /* Check if the entry is valid */
00110         if ( ndp && ndp->state == NDP_STATE_REACHABLE ) {
00111                 DBG ( "Neighbour cache hit: IP6 %s => %s %s\n",
00112                       inet6_ntoa ( *dest ), ll_protocol->name,
00113                       ll_protocol->ntoa ( ndp->ll_addr ) );
00114                 memcpy ( dest_ll_addr, ndp->ll_addr, ll_protocol->ll_addr_len );
00115                 return 0;
00116         }
00117 
00118         /* Check if the entry was already created */
00119         if ( ndp ) {
00120                 DBG ( "Awaiting neighbour advertisement\n" );
00121                 /* For test */
00122 //              ndp->state = NDP_STATE_REACHABLE;
00123 //              memcpy ( ndp->ll_addr, netdev->ll_addr, 6 );
00124 //              assert ( ndp->ll_protocol->ll_addr_len == 6 );
00125 //              icmp6_test_nadvert ( netdev, dest, ndp->ll_addr );
00126 //              assert ( ndp->state == NDP_STATE_REACHABLE );
00127                 /* Take it out till here */
00128                 return -ENOENT;
00129         }
00130         DBG ( "Neighbour cache miss: IP6 %s\n", inet6_ntoa ( *dest ) );
00131 
00132         /* Add entry in the neighbour cache */
00133         add_ndp_entry ( netdev, dest, NULL, NDP_STATE_INCOMPLETE );
00134 
00135         /* Send neighbour solicitation */
00136         if ( ( rc = icmp6_send_solicit ( netdev, src, dest ) ) != 0 ) {
00137                 return rc;
00138         }
00139         return -ENOENT;
00140 }

int ndp_process_advert ( struct io_buffer iobuf,
struct sockaddr_tcpip st_src,
struct sockaddr_tcpip st_dest 
)


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