diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-09-01 16:13:58 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-09-03 02:02:58 +0100 |
commit | c6a04085d25721a29af75beeb7c9c2e08a610cf2 (patch) | |
tree | 754695775f7c670fa395ea1a0782c06ccb8bd719 /src/include/ipxe | |
parent | 6bf36f57a0f7a22ffa85ae4995933077df62e309 (diff) | |
download | ipxe-c6a04085d25721a29af75beeb7c9c2e08a610cf2.tar.gz |
[neighbour] Generalise concept of neighbour discovery
Split the protocol-independent portions of arp.c into a separate file
neighbour.c, to allow for sharing of functionality between IPv4+ARP
and IPv6+NDP.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r-- | src/include/ipxe/arp.h | 24 | ||||
-rw-r--r-- | src/include/ipxe/errfile.h | 1 | ||||
-rw-r--r-- | src/include/ipxe/neighbour.h | 44 |
3 files changed, 66 insertions, 3 deletions
diff --git a/src/include/ipxe/arp.h b/src/include/ipxe/arp.h index 00396d821..e30ae6b76 100644 --- a/src/include/ipxe/arp.h +++ b/src/include/ipxe/arp.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/tables.h> #include <ipxe/netdevice.h> +#include <ipxe/neighbour.h> /** A network-layer protocol that relies upon ARP */ struct arp_net_protocol { @@ -34,9 +35,26 @@ struct arp_net_protocol { #define __arp_net_protocol __table_entry ( ARP_NET_PROTOCOLS, 01 ) extern struct net_protocol arp_protocol __net_protocol; +extern struct neighbour_discovery arp_discovery; -extern int arp_tx ( struct io_buffer *iobuf, struct net_device *netdev, - struct net_protocol *net_protocol, const void *net_dest, - const void *net_source, const void *ll_source ); +/** + * Transmit packet, determining link-layer address via ARP + * + * @v iobuf I/O buffer + * @v netdev Network device + * @v net_protocol Network-layer protocol + * @v net_dest Destination network-layer address + * @v net_source Source network-layer address + * @v ll_source Source link-layer address + * @ret rc Return status code + */ +static inline int arp_tx ( struct io_buffer *iobuf, struct net_device *netdev, + struct net_protocol *net_protocol, + const void *net_dest, const void *net_source, + const void *ll_source ) { + + return neighbour_tx ( iobuf, netdev, net_protocol, net_dest, + &arp_discovery, net_source, ll_source ); +} #endif /* _IPXE_ARP_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 801d579b6..83675796c 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -214,6 +214,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_nfs_open ( ERRFILE_NET | 0x00340000 ) #define ERRFILE_mount ( ERRFILE_NET | 0x00350000 ) #define ERRFILE_oncrpc_iob ( ERRFILE_NET | 0x00360000 ) +#define ERRFILE_neighbour ( ERRFILE_NET | 0x00370000 ) #define ERRFILE_image ( ERRFILE_IMAGE | 0x00000000 ) #define ERRFILE_elf ( ERRFILE_IMAGE | 0x00010000 ) diff --git a/src/include/ipxe/neighbour.h b/src/include/ipxe/neighbour.h new file mode 100644 index 000000000..5720e8b0f --- /dev/null +++ b/src/include/ipxe/neighbour.h @@ -0,0 +1,44 @@ +#ifndef _IPXE_NEIGHBOUR_H +#define _IPXE_NEIGHBOUR_H + +/** @file + * + * Neighbour discovery + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <ipxe/netdevice.h> + +/** A neighbour discovery protocol */ +struct neighbour_discovery { + /** Name */ + const char *name; + /** + * Transmit neighbour discovery request + * + * @v netdev Network device + * @v net_protocol Network-layer protocol + * @v net_dest Destination network-layer address + * @v net_source Source network-layer address + * @ret rc Return status code + */ + int ( * tx_request ) ( struct net_device *netdev, + struct net_protocol *net_protocol, + const void *net_dest, const void *net_source ); +}; + +extern 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 ); +extern int neighbour_update ( struct net_device *netdev, + struct net_protocol *net_protocol, + const void *net_dest, const void *ll_dest ); +extern int neighbour_define ( struct net_device *netdev, + struct net_protocol *net_protocol, + const void *net_dest, const void *ll_dest ); + +#endif /* _IPXE_NEIGHBOUR_H */ |