ip: Protocol Independent IP Neighbors
[vpp.git] / src / vnet / arp / arp.h
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef __ARP_H__
17 #define __ARP_H__
18
19 #include <vnet/ethernet/ethernet.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/ethernet/arp_packet.h>
22
23 #define foreach_ethernet_arp_error                                      \
24   _ (replies_sent, "ARP replies sent")                                  \
25   _ (l2_type_not_ethernet, "L2 type not ethernet")                      \
26   _ (l3_type_not_ip4, "L3 type not IP4")                                \
27   _ (l3_src_address_not_local, "IP4 source address not local to subnet") \
28   _ (l3_dst_address_not_local, "IP4 destination address not local to subnet") \
29   _ (l3_dst_address_unset, "IP4 destination address is unset")          \
30   _ (l3_src_address_is_local, "IP4 source address matches local interface") \
31   _ (l3_src_address_learned, "ARP request IP4 source address learned")  \
32   _ (replies_received, "ARP replies received")                          \
33   _ (opcode_not_request, "ARP opcode not request")                      \
34   _ (proxy_arp_replies_sent, "Proxy ARP replies sent")                  \
35   _ (l2_address_mismatch, "ARP hw addr does not match L2 frame src addr") \
36   _ (gratuitous_arp, "ARP probe or announcement dropped") \
37   _ (interface_no_table, "Interface is not mapped to an IP table") \
38   _ (interface_not_ip_enabled, "Interface is not IP enabled") \
39   _ (unnumbered_mismatch, "RX interface is unnumbered to different subnet") \
40
41 typedef enum
42 {
43 #define _(sym,string) ETHERNET_ARP_ERROR_##sym,
44   foreach_ethernet_arp_error
45 #undef _
46     ETHERNET_ARP_N_ERROR,
47 } ethernet_arp_reply_error_t;
48
49 extern int arp_proxy_add (u32 fib_index,
50                           const ip4_address_t * lo_addr,
51                           const ip4_address_t * hi_addr);
52 extern int arp_proxy_del (u32 fib_index,
53                           const ip4_address_t * lo_addr,
54                           const ip4_address_t * hi_addr);
55
56 extern int arp_proxy_enable (u32 sw_if_index);
57 extern int arp_proxy_disable (u32 sw_if_index);
58
59 /**
60  * call back function when walking the DB of proxy ARPs
61  * @return 0 to stop the walk !0 to continue
62  */
63 typedef walk_rc_t (proxy_arp_walk_t) (const ip4_address_t * lo_addr,
64                                       const ip4_address_t * hi_addr,
65                                       u32 fib_index, void *dat);
66
67 extern void proxy_arp_walk (proxy_arp_walk_t cb, void *data);
68
69 /**
70  * call back function when walking the DB of proxy ARP interface
71  * @return 0 to stop the walk !0 to continue
72  */
73 typedef walk_rc_t (proxy_arp_intf_walk_t) (u32 sw_if_index, void *data);
74
75 extern void proxy_arp_intfc_walk (proxy_arp_intf_walk_t cb, void *data);
76
77 #endif
78
79 /*
80  * fd.io coding-style-patch-verification: ON
81  *
82  * Local Variables:
83  * eval: (c-set-style "gnu")
84  * End:
85  */