Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
mcb30 committed Sep 3, 2013
1 parent 6bf36f5 commit c6a0408
Show file tree
Hide file tree
Showing 5 changed files with 579 additions and 357 deletions.
24 changes: 21 additions & 3 deletions src/include/ipxe/arp.h
Expand Up @@ -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 {
Expand All @@ -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 */
1 change: 1 addition & 0 deletions src/include/ipxe/errfile.h
Expand Up @@ -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 )
Expand Down
44 changes: 44 additions & 0 deletions 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 */

0 comments on commit c6a0408

Please sign in to comment.