mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 17:42:47 +03:00
[ipv6] Add ndp_tx_router_solicitation() to send router solicitations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -46,6 +46,9 @@ struct icmpv6_handler {
|
||||
/** ICMPv6 echo reply */
|
||||
#define ICMPV6_ECHO_REPLY 129
|
||||
|
||||
/** ICMPv6 router solicitation */
|
||||
#define ICMPV6_ROUTER_SOLICITATION 133
|
||||
|
||||
/** ICMPv6 router advertisement */
|
||||
#define ICMPV6_ROUTER_ADVERTISEMENT 134
|
||||
|
||||
|
||||
@@ -194,14 +194,13 @@ static inline int ipv6_eui64 ( struct in6_addr *addr,
|
||||
/**
|
||||
* Construct link-local address via EUI-64
|
||||
*
|
||||
* @v addr Address to construct
|
||||
* @v addr Zeroed address to construct
|
||||
* @v netdev Network device
|
||||
* @ret prefix_len Prefix length, or negative error
|
||||
*/
|
||||
static inline int ipv6_link_local ( struct in6_addr *addr,
|
||||
struct net_device *netdev ) {
|
||||
|
||||
memset ( addr, 0, sizeof ( *addr ) );
|
||||
addr->s6_addr16[0] = htons ( 0xfe80 );
|
||||
return ipv6_eui64 ( addr, netdev );
|
||||
}
|
||||
@@ -209,19 +208,28 @@ static inline int ipv6_link_local ( struct in6_addr *addr,
|
||||
/**
|
||||
* Construct solicited-node multicast address
|
||||
*
|
||||
* @v addr Address to construct
|
||||
* @v addr Zeroed address to construct
|
||||
* @v unicast Unicast address
|
||||
*/
|
||||
static inline void ipv6_solicited_node ( struct in6_addr *addr,
|
||||
const struct in6_addr *unicast ) {
|
||||
|
||||
memset ( addr, 0, sizeof ( *addr ) );
|
||||
addr->s6_addr16[0] = htons ( 0xff02 );
|
||||
addr->s6_addr[11] = 1;
|
||||
addr->s6_addr[12] = 0xff;
|
||||
memcpy ( &addr->s6_addr[13], &unicast->s6_addr[13], 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct all-routers multicast address
|
||||
*
|
||||
* @v addr Zeroed address to construct
|
||||
*/
|
||||
static inline void ipv6_all_routers ( struct in6_addr *addr ) {
|
||||
addr->s6_addr16[0] = htons ( 0xff02 );
|
||||
addr->s6_addr[15] = 2;
|
||||
}
|
||||
|
||||
extern struct list_head ipv6_miniroutes;
|
||||
|
||||
extern struct net_protocol ipv6_protocol __net_protocol;
|
||||
|
||||
@@ -124,12 +124,24 @@ struct ndp_router_advertisement_header {
|
||||
/** NDP other configuration */
|
||||
#define NDP_ROUTER_OTHER 0x40
|
||||
|
||||
/** An NDP router solicitation header */
|
||||
struct ndp_router_solicitation_header {
|
||||
/** ICMPv6 header */
|
||||
struct icmp_header icmp;
|
||||
/** Reserved */
|
||||
uint32_t reserved;
|
||||
/** Options */
|
||||
union ndp_option option[0];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** An NDP header */
|
||||
union ndp_header {
|
||||
/** ICMPv6 header */
|
||||
struct icmp_header icmp;
|
||||
/** Neighbour solicitation or advertisement header */
|
||||
struct ndp_neighbour_header neigh;
|
||||
/** Router solicitation header */
|
||||
struct ndp_router_solicitation_header rsol;
|
||||
/** Router advertisement header */
|
||||
struct ndp_router_advertisement_header radv;
|
||||
} __attribute__ (( packed ));
|
||||
@@ -154,4 +166,6 @@ static inline int ndp_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||
&ndp_discovery, net_source, ll_source );
|
||||
}
|
||||
|
||||
extern int ndp_tx_router_solicitation ( struct net_device *netdev );
|
||||
|
||||
#endif /* _IPXE_NDP_H */
|
||||
|
||||
Reference in New Issue
Block a user