1 #ifndef _IPXE_NEIGHBOUR_H
2 #define _IPXE_NEIGHBOUR_H
10 FILE_LICENCE ( GPL2_OR_LATER );
13 #include <ipxe/refcnt.h>
14 #include <ipxe/list.h>
15 #include <ipxe/netdevice.h>
16 #include <ipxe/retry.h>
18 /** A neighbour discovery protocol */
19 struct neighbour_discovery {
23 * Transmit neighbour discovery request
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
31 int ( * tx_request ) ( struct net_device *netdev,
32 struct net_protocol *net_protocol,
33 const void *net_dest, const void *net_source );
36 /** A neighbour cache entry */
38 /** Reference count */
40 /** List of neighbour cache entries */
41 struct list_head list;
44 struct net_device *netdev;
45 /** Network-layer protocol */
46 struct net_protocol *net_protocol;
47 /** Network-layer destination address */
48 uint8_t net_dest[MAX_NET_ADDR_LEN];
49 /** Link-layer destination address */
50 uint8_t ll_dest[MAX_LL_ADDR_LEN];
52 /** Neighbour discovery protocol (if any) */
53 struct neighbour_discovery *discovery;
54 /** Network-layer source address (if any) */
55 uint8_t net_source[MAX_NET_ADDR_LEN];
56 /** Retransmission timer */
57 struct retry_timer timer;
59 /** Pending I/O buffers */
60 struct list_head tx_queue;
64 * Test if neighbour cache entry has a valid link-layer address
66 * @v neighbour Neighbour cache entry
67 * @ret has_ll_dest Neighbour cache entry has a valid link-layer address
69 static inline __attribute__ (( always_inline )) int
70 neighbour_has_ll_dest ( struct neighbour *neighbour ) {
71 return ( ! timer_running ( &neighbour->timer ) );
74 extern struct list_head neighbours;
76 extern int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
77 struct net_protocol *net_protocol,
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 );
88 #endif /* _IPXE_NEIGHBOUR_H */