iPXE
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...
struct  neighbour_delay
 A neighbour transmission delay pseudo-header. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
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)
 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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ neighbour_tx()

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 )
extern

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
Return values
rcReturn status code

Definition at line 377 of file neighbour.c.

380 {
381 struct neighbour *neighbour;
382 struct neighbour_delay *delay;
383 int rc;
384
385 /* Find or create neighbour cache entry */
387 if ( ! neighbour ) {
389 if ( ! neighbour )
390 return -ENOMEM;
391 neighbour_discover ( neighbour, discovery, net_source );
392 }
393
394 /* If discovery is still in progress or if delay injection is
395 * in use, then queue for later transmission.
396 */
398
399 /* Add to deferred packet queue */
400 DBGC2 ( neighbour, "NEIGHBOUR %s %s %s deferring packet\n",
401 netdev->name, net_protocol->name,
402 net_protocol->ntoa ( net_dest ) );
403 list_add_tail ( &iobuf->list, &neighbour->tx_queue );
404
405 /* Handle delay injection, if applicable */
406 if ( NEIGHBOUR_DELAY_MS ) {
407
408 /* Record original transmission time */
409 delay = iob_push ( iobuf, sizeof ( *delay ) );
410 delay->start = currticks();
411
412 /* Add pending operation */
414
415 /* Process deferred packet queue, if possible */
416 if ( ! neighbour->discovery )
418 }
419
420 return 0;
421 }
422
423 /* Otherwise, transmit immediately */
424 if ( ( rc = net_tx ( iobuf, netdev, net_protocol, neighbour->ll_dest,
425 netdev->ll_addr ) ) != 0 ) {
426 return rc;
427 }
428
429 return 0;
430}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define NEIGHBOUR_DELAY_MS
Definition fault.h:19
#define delay(nanosec)
Definition epic100.c:49
static struct net_device * netdev
Definition gdbudp.c:53
#define DBGC2(...)
Definition compiler.h:522
#define ENOMEM
Not enough space.
Definition errno.h:535
#define iob_push(iobuf, len)
Definition iobuf.h:89
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
static struct neighbour * neighbour_create(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest)
Create neighbour cache entry.
Definition neighbour.c:101
static struct neighbour * neighbour_find(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest)
Find neighbour cache entry.
Definition neighbour.c:136
static struct pending_operation neighbour_delayed
Pending operation for delayed transmissions.
Definition neighbour.c:70
static void neighbour_tx_queue(struct neighbour *neighbour)
Transmit deferred packets.
Definition neighbour.c:189
static void neighbour_discover(struct neighbour *neighbour, struct neighbour_discovery *discovery, const void *net_source)
Start neighbour discovery.
Definition neighbour.c:164
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition netdevice.c:1074
void pending_get(struct pending_operation *pending)
Mark an operation as pending.
Definition pending.c:46
struct list_head list
List of which this buffer is a member.
Definition iobuf.h:45
A neighbour transmission delay pseudo-header.
Definition neighbour.h:65
A neighbour cache entry.
Definition neighbour.h:38
struct neighbour_discovery * discovery
Neighbour discovery protocol (if discovery is ongoing)
Definition neighbour.h:54
struct list_head tx_queue
Pending I/O buffers.
Definition neighbour.h:61
uint8_t ll_dest[MAX_LL_ADDR_LEN]
Link-layer destination address.
Definition neighbour.h:51
A network-layer protocol.
Definition netdevice.h:65
const char * name
Protocol name.
Definition netdevice.h:67
const char *(* ntoa)(const void *net_addr)
Transcribe network-layer address.
Definition netdevice.h:95
unsigned long currticks(void)
Get current system time in ticks.
Definition timer.c:43

References currticks(), DBGC2, delay, neighbour::discovery, ENOMEM, iob_push, io_buffer::list, list_add_tail, neighbour::ll_dest, net_protocol::name, neighbour_create(), NEIGHBOUR_DELAY_MS, neighbour_delayed, neighbour_discover(), neighbour_find(), neighbour_tx_queue(), net_tx(), netdev, net_protocol::ntoa, pending_get(), rc, and neighbour::tx_queue.

Referenced by arp_tx(), and ndp_tx().

◆ neighbour_update()

int neighbour_update ( struct net_device * netdev,
struct net_protocol * net_protocol,
const void * net_dest,
const void * ll_dest )
extern

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 441 of file neighbour.c.

443 {
444 struct neighbour *neighbour;
445
446 /* Find neighbour cache entry */
448 if ( ! neighbour )
449 return -ENOENT;
450
451 /* Set destination address */
453
454 return 0;
455}
#define ENOENT
No such file or directory.
Definition errno.h:515
static void neighbour_discovered(struct neighbour *neighbour, const void *ll_dest)
Complete neighbour discovery.
Definition neighbour.c:263
uint8_t net_dest[MAX_NET_ADDR_LEN]
Network-layer destination address.
Definition neighbour.h:49

References ENOENT, neighbour::ll_dest, neighbour_discovered(), neighbour_find(), neighbour::net_dest, and netdev.

Referenced by arp_rx(), and ndp_rx_neighbour_advertisement_ll_target().

◆ neighbour_define()

int neighbour_define ( struct net_device * netdev,
struct net_protocol * net_protocol,
const void * net_dest,
const void * ll_dest )
extern

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 466 of file neighbour.c.

468 {
469 struct neighbour *neighbour;
470
471 /* Find or create neighbour cache entry */
473 if ( ! neighbour ) {
475 if ( ! neighbour )
476 return -ENOMEM;
477 }
478
479 /* Set destination address */
481
482 return 0;
483}

References ENOMEM, neighbour::ll_dest, neighbour_create(), neighbour_discovered(), neighbour_find(), neighbour::net_dest, and netdev.

Referenced by ndp_rx_neighbour_solicitation_ll_source(), and ndp_rx_router_advertisement_ll_source().

Variable Documentation

◆ neighbours

struct list_head neighbours
extern

The neighbour cache.

Definition at line 67 of file neighbour.c.

Referenced by neighbour_create(), neighbour_discard(), neighbour_find(), neighbour_flush(), and nstat().