#include <gpxe/ip6.h>
#include <gpxe/ndp.h>
+#include <gpxe/tables.h>
+
+struct net_device;
+struct net_protocol;
+
+/** A network-layer protocol that relies upon ICMPv6 */
+struct icmp6_net_protocol {
+ /** Network-layer protocol */
+ struct net_protocol *net_protocol;
+ /** Check existence of address
+ *
+ * @v netdev Network device
+ * @v net_addr Network-layer address
+ * @ret rc Return status code
+ */
+ int ( * check ) ( struct net_device *netdev,
+ const void *net_addr );
+};
+
+/** ICMPv6 protocol table */
+#define ICMP6_NET_PROTOCOLS \
+ __table ( struct icmp6_net_protocol, "icmp6_net_protocols" )
+
+/** Declare an ICMPv6 protocol */
+#define __icmp6_net_protocol __table_entry ( ICMP6_NET_PROTOCOLS, 01 )
+
#define ICMP6_NSOLICIT 135
#define ICMP6_NADVERT 136
struct in6_addr gateway ) {
struct ipv6_miniroute *miniroute;
- DBG("ipv6 add: %s/%d ", inet6_ntoa(address), prefix_len);
- DBG("gw %s\n", inet6_ntoa(gateway));
+ DBG( "ipv6 add: %s/%d ", inet6_ntoa ( address ), prefix_len );
+ DBG( "gw %s\n", inet6_ntoa( gateway ) );
miniroute = malloc ( sizeof ( *miniroute ) );
if ( miniroute ) {
return inet6_ntoa ( * ( ( struct in6_addr * ) net_addr ) );
}
+static int ipv6_check ( struct net_device *netdev, const void *net_addr ) {
+ const struct in6_addr *address = net_addr;
+ struct ipv6_miniroute *miniroute;
+
+ list_for_each_entry ( miniroute, &miniroutes, list ) {
+ if ( ( miniroute->netdev == netdev ) &&
+ ( ! memcmp ( &miniroute->address, address, 16 ) ) ) {
+ /* Found matching address */
+ return 0;
+ }
+ }
+ return -ENOENT;
+}
+
/** IPv6 protocol */
struct net_protocol ipv6_protocol __net_protocol = {
.name = "IPV6",
.sa_family = AF_INET6,
.tx = ipv6_tx,
};
+
+/** IPv6 ICMPv6 protocol, for NDP */
+struct icmp6_net_protocol ipv6_icmp6_protocol __icmp6_net_protocol = {
+ .net_protocol = &ipv6_protocol,
+ .check = ipv6_check,
+};
+