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

399 {
400 struct neighbour *neighbour;
401 struct neighbour_delay *delay;
402 int rc;
403
404 /* Find or create neighbour cache entry */
406 if ( ! neighbour ) {
408 if ( ! neighbour )
409 return -ENOMEM;
410 neighbour_discover ( neighbour, discovery, net_source );
411 }
412
413 /* If discovery is still in progress or if delay injection is
414 * in use, then queue for later transmission.
415 */
417
418 /* Add to deferred packet queue */
419 DBGC2 ( neighbour, "NEIGHBOUR %s %s %s deferring packet\n",
420 netdev->name, net_protocol->name,
421 net_protocol->ntoa ( net_dest ) );
422 list_add_tail ( &iobuf->list, &neighbour->tx_queue );
423
424 /* Handle delay injection, if applicable */
425 if ( NEIGHBOUR_DELAY_MS ) {
426
427 /* Record original transmission time */
428 delay = iob_push ( iobuf, sizeof ( *delay ) );
429 delay->start = currticks();
430
431 /* Add pending operation */
433
434 /* Process deferred packet queue, if possible */
435 if ( ! neighbour->discovery )
437 }
438
439 return 0;
440 }
441
442 /* Otherwise, transmit immediately */
443 if ( ( rc = net_tx ( iobuf, netdev, net_protocol, neighbour->ll_dest,
444 netdev->ll_addr ) ) != 0 ) {
445 return rc;
446 }
447
448 return 0;
449}
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:547
#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:1078
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 460 of file neighbour.c.

462 {
463 struct neighbour *neighbour;
464
465 /* Find neighbour cache entry */
467 if ( ! neighbour )
468 return -ENOENT;
469
470 /* Set destination address */
472
473 return 0;
474}
#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:293
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 485 of file neighbour.c.

487 {
488 struct neighbour *neighbour;
489
490 /* Find or create neighbour cache entry */
492 if ( ! neighbour ) {
494 if ( ! neighbour )
495 return -ENOMEM;
496 }
497
498 /* Set destination address */
500
501 return 0;
502}

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(), neighbour_queue_discard(), and nstat().