2 // Copyright (c) 2020 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef _PROX_IP_V6_H_
18 #define _PROX_IP_V6_H_
22 #define ALL_NODES_IPV6_MCAST_ADDR "ff02:0000:0000:0000:0000:0000:0000:0001" // FF02::1
23 #define ALL_ROUTERS_IPV6_MCAST_ADDR "ff02:0000:0000:0000:0000:0000:0000:0002" // FF02::2
25 #define RANDOM_IPV6 "1234:1234:1234:1234:1234:1234:1234:1234" // Used by PROX as a flag forrandom IP
27 #define ALL_DHCP_RELAY_AGENTS_AND_SERVERS "ff02:0000:0000:0000:0000:0000:0001:0002" // FF02::1:2
28 #define ALL_DHCP_SERVERS "ff05:0000:0000:0000:0000:0000:0001:0003" // FF02::1:2
30 #define DHCP_CLIENT_UDP_PORT 546
31 #define DHCP_SERVER_UDP_PORT 547
33 #define PROX_UNSOLLICITED 0
34 #define PROX_SOLLICITED 1
38 #define ICMPv6_DU 0x01
39 #define ICMPv6_PTB 0x02
40 #define ICMPv6_TE 0x03
41 #define ICMPv6_PaPr 0x04
42 #define ICMPv6_RS 0x85
43 #define ICMPv6_RA 0x86
44 #define ICMPv6_NS 0x87
45 #define ICMPv6_NA 0x88
46 #define ICMPv6_RE 0x89
48 #define ICMPv6_source_link_layer_address 1
49 #define ICMPv6_target_link_layer_address 2
50 #define ICMPv6_prefix_information 3
51 #define ICMPv6_redirect_header 4
54 extern struct ipv6_addr null_addr;
56 struct icmpv6_prefix_option {
59 uint8_t prefix_length;
61 uint32_t valid_lifetime;
62 uint32_t preferred_lifetime;
64 struct ipv6_addr prefix;
67 struct icmpv6_option {
71 } __attribute__((__packed__));
85 uint16_t router_lifespan;
86 uint32_t reachable_timeout;
87 uint32_t retrans_timeout;
88 struct icmpv6_option options;
89 } __attribute__((__packed__));
96 struct icmpv6_option options;
97 } __attribute__((__packed__));
104 struct ipv6_addr target_address;
105 struct icmpv6_option options;
106 } __attribute__((__packed__));
114 struct ipv6_addr destination_address;
115 struct icmpv6_option options;
116 } __attribute__((__packed__));
123 struct ipv6_addr destination_address_hop;
124 struct ipv6_addr destination_address;
126 } __attribute__((__packed__));
128 void set_mcast_mac_from_ipv6(prox_rte_ether_addr *mac, struct ipv6_addr *ipv6_addr);
129 char *IP6_Canonical(struct ipv6_addr *addr);
130 void set_link_local(struct ipv6_addr *ipv6_addr);
131 void set_EUI(struct ipv6_addr *ipv6_addr, prox_rte_ether_addr *mac);
132 void create_mac_from_EUI(struct ipv6_addr *ipv6_addr, prox_rte_ether_addr *mac);
135 void build_router_sollicitation(struct rte_mbuf *mbuf, prox_rte_ether_addr *s_addr, struct ipv6_addr *ipv6_s_addr);
136 void build_router_advertisement(struct rte_mbuf *mbuf, prox_rte_ether_addr *s_addr, struct ipv6_addr *ipv6_s_addr, struct ipv6_addr *router_prefix);
137 void build_neighbour_sollicitation(struct rte_mbuf *mbuf, prox_rte_ether_addr *s_addr, struct ipv6_addr *dst, struct ipv6_addr *src);
138 void build_neighbour_advertisement(struct task_base *tbase, struct rte_mbuf *mbuf, prox_rte_ether_addr *target_mac, struct ipv6_addr *ipv6_addr, int sollicited);
140 #endif /* _PROX_IP_V6_H_ */