iPXE
neighbour.h
Go to the documentation of this file.
1 #ifndef _IPXE_NEIGHBOUR_H
2 #define _IPXE_NEIGHBOUR_H
3 
4 /** @file
5  *
6  * Neighbour discovery
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/refcnt.h>
14 #include <ipxe/list.h>
15 #include <ipxe/netdevice.h>
16 #include <ipxe/retry.h>
17 
18 /** A neighbour discovery protocol */
20  /** Name */
21  const char *name;
22  /**
23  * Transmit neighbour discovery request
24  *
25  * @v netdev Network device
26  * @v net_protocol Network-layer protocol
27  * @v net_dest Destination network-layer address
28  * @v net_source Source network-layer address
29  * @ret rc Return status code
30  */
31  int ( * tx_request ) ( struct net_device *netdev,
32  struct net_protocol *net_protocol,
33  const void *net_dest, const void *net_source );
34 };
35 
36 /** A neighbour cache entry */
37 struct neighbour {
38  /** Reference count */
39  struct refcnt refcnt;
40  /** List of neighbour cache entries */
41  struct list_head list;
42 
43  /** Network device */
44  struct net_device *netdev;
45  /** Network-layer protocol */
47  /** Network-layer destination address */
49  /** Link-layer destination address */
51 
52  /** Neighbour discovery protocol (if any) */
54  /** Network-layer source address (if any) */
56  /** Retransmission timer */
58 
59  /** Pending I/O buffers */
61 };
62 
63 /**
64  * Test if neighbour cache entry has a valid link-layer address
65  *
66  * @v neighbour Neighbour cache entry
67  * @ret has_ll_dest Neighbour cache entry has a valid link-layer address
68  */
69 static inline __attribute__ (( always_inline )) int
71  return ( ! timer_running ( &neighbour->timer ) );
72 }
73 
74 extern struct list_head neighbours;
75 
76 extern int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
77  struct net_protocol *net_protocol,
78  const void *net_dest,
79  struct neighbour_discovery *discovery,
80  const void *net_source, const void *ll_source );
81 extern int neighbour_update ( struct net_device *netdev,
82  struct net_protocol *net_protocol,
83  const void *net_dest, const void *ll_dest );
84 extern int neighbour_define ( struct net_device *netdev,
85  struct net_protocol *net_protocol,
86  const void *net_dest, const void *ll_dest );
87 
88 #endif /* _IPXE_NEIGHBOUR_H */
#define __attribute__(x)
Definition: compiler.h:10
const char * name
Name.
Definition: neighbour.h:21
uint8_t net_dest[MAX_NET_ADDR_LEN]
Network-layer destination address.
Definition: neighbour.h:48
struct net_protocol * net_protocol
Network-layer protocol.
Definition: neighbour.h:46
Retry timers.
struct retry_timer timer
Retransmission timer.
Definition: neighbour.h:57
A retry timer.
Definition: retry.h:21
A neighbour discovery protocol.
Definition: neighbour.h:19
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
A timer.
Definition: timer.h:28
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.
Definition: neighbour.c:338
struct list_head neighbours
The neighbour cache.
Definition: neighbour.c:52
struct list_head list
List of neighbour cache entries.
Definition: neighbour.h:41
int(* tx_request)(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
Transmit neighbour discovery request.
Definition: neighbour.h:31
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
Definition: netdevice.h:36
struct neighbour_discovery * discovery
Neighbour discovery protocol (if any)
Definition: neighbour.h:53
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct net_device * netdev
Definition: gdbudp.c:52
struct list_head tx_queue
Pending I/O buffers.
Definition: neighbour.h:60
uint8_t ll_dest[MAX_LL_ADDR_LEN]
Link-layer destination address.
Definition: neighbour.h:50
Linked lists.
int neighbour_define(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *ll_dest)
Define neighbour cache entry.
Definition: neighbour.c:363
A network device.
Definition: netdevice.h:352
unsigned char uint8_t
Definition: stdint.h:10
A neighbour cache entry.
Definition: neighbour.h:37
A network-layer protocol.
Definition: netdevice.h:64
Network device management.
Reference counting.
struct net_device * netdev
Network device.
Definition: neighbour.h:44
#define MAX_NET_ADDR_LEN
Maximum length of a network-layer address.
Definition: netdevice.h:48
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.
Definition: neighbour.c:299
uint8_t net_source[MAX_NET_ADDR_LEN]
Network-layer source address (if any)
Definition: neighbour.h:55
static int neighbour_has_ll_dest(struct neighbour *neighbour)
Test if neighbour cache entry has a valid link-layer address.
Definition: neighbour.h:70
A persistent I/O buffer.
Definition: iobuf.h:33