iPXE
Data Structures | Functions | Variables
neighbour.h File Reference

Neighbour discovery. More...

#include <stdint.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/netdevice.h>
#include <ipxe/retry.h>

Go to the source code of this file.

Data Structures

struct  neighbour_discovery
 A neighbour discovery protocol. More...
struct  neighbour
 A neighbour cache entry. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int neighbour_has_ll_dest (struct neighbour *neighbour)
 Test if neighbour cache entry has a valid link-layer address.
int neighbour_tx (struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, struct neighbour_discovery *discovery, const void *net_source, const void *ll_source)
 Transmit packet, determining link-layer address via neighbour discovery.
int neighbour_update (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *ll_dest)
 Update existing neighbour cache entry.
int neighbour_define (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *ll_dest)
 Define neighbour cache entry.

Variables

struct list_head neighbours
 The neighbour cache.

Detailed Description

Neighbour discovery.

Definition in file neighbour.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int neighbour_has_ll_dest ( struct neighbour neighbour) [inline, static]

Test if neighbour cache entry has a valid link-layer address.

Parameters:
neighbourNeighbour cache entry
Return values:
has_ll_destNeighbour cache entry has a valid link-layer address

Definition at line 70 of file neighbour.h.

Referenced by neighbour_tx(), and nstat().

                                                      {
        return ( ! timer_running ( &neighbour->timer ) );
}
int neighbour_tx ( struct io_buffer iobuf,
struct net_device netdev,
struct net_protocol net_protocol,
const void *  net_dest,
struct neighbour_discovery discovery,
const void *  net_source,
const void *  ll_source 
)

Transmit packet, determining link-layer address via neighbour discovery.

Parameters:
iobufI/O buffer
netdevNetwork device
discoveryNeighbour discovery protocol
net_protocolNetwork-layer protocol
net_destDestination network-layer address
net_sourceSource network-layer address
ll_sourceSource link-layer address
Return values:
rcReturn status code

Definition at line 299 of file neighbour.c.

References DBGC2, ENOMEM, io_buffer::list, list_add_tail, neighbour::ll_dest, net_protocol::name, net_device::name, neighbour_create(), neighbour_discover(), neighbour_find(), neighbour_has_ll_dest(), net_tx(), net_protocol::ntoa, and neighbour::tx_queue.

Referenced by arp_tx(), and ndp_tx().

                                                                   {
        struct neighbour *neighbour;

        /* Find or create neighbour cache entry */
        neighbour = neighbour_find ( netdev, net_protocol, net_dest );
        if ( ! neighbour ) {
                neighbour = neighbour_create ( netdev, net_protocol, net_dest );
                if ( ! neighbour )
                        return -ENOMEM;
                neighbour_discover ( neighbour, discovery, net_source );
        }

        /* If a link-layer address is available then transmit
         * immediately, otherwise queue for later transmission.
         */
        if ( neighbour_has_ll_dest ( neighbour ) ) {
                return net_tx ( iobuf, netdev, net_protocol, neighbour->ll_dest,
                                ll_source );
        } else {
                DBGC2 ( neighbour, "NEIGHBOUR %s %s %s deferring packet\n",
                        netdev->name, net_protocol->name,
                        net_protocol->ntoa ( net_dest ) );
                list_add_tail ( &iobuf->list, &neighbour->tx_queue );
                return 0;
        }
}
int neighbour_update ( struct net_device netdev,
struct net_protocol net_protocol,
const void *  net_dest,
const void *  ll_dest 
)

Update existing neighbour cache entry.

Parameters:
netdevNetwork device
net_protocolNetwork-layer protocol
net_destDestination network-layer address
ll_destDestination link-layer address
Return values:
rcReturn status code

Definition at line 338 of file neighbour.c.

References ENOENT, neighbour_discovered(), and neighbour_find().

Referenced by arp_rx(), and ndp_rx_neighbour_advertisement_ll_target().

                                                                   {
        struct neighbour *neighbour;

        /* Find neighbour cache entry */
        neighbour = neighbour_find ( netdev, net_protocol, net_dest );
        if ( ! neighbour )
                return -ENOENT;

        /* Set destination address */
        neighbour_discovered ( neighbour, ll_dest );

        return 0;
}
int neighbour_define ( struct net_device netdev,
struct net_protocol net_protocol,
const void *  net_dest,
const void *  ll_dest 
)

Define neighbour cache entry.

Parameters:
netdevNetwork device
net_protocolNetwork-layer protocol
net_destDestination network-layer address
ll_destDestination link-layer address, if known
Return values:
rcReturn status code

Definition at line 363 of file neighbour.c.

References ENOMEM, neighbour_create(), neighbour_discovered(), and neighbour_find().

Referenced by ndp_rx_neighbour_solicitation_ll_source(), and ndp_rx_router_advertisement_ll_source().

                                                                   {
        struct neighbour *neighbour;

        /* Find or create neighbour cache entry */
        neighbour = neighbour_find ( netdev, net_protocol, net_dest );
        if ( ! neighbour ) {
                neighbour = neighbour_create ( netdev, net_protocol, net_dest );
                if ( ! neighbour )
                        return -ENOMEM;
        }

        /* Set destination address */
        neighbour_discovered ( neighbour, ll_dest );

        return 0;
}

Variable Documentation

The neighbour cache.

Definition at line 52 of file neighbour.c.

Referenced by nstat().