2 * ip_neighboor.h: ip neighbor generic services
4 * Copyright (c) 2018 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __INCLUDE_IP_NEIGHBOR_H__
19 #define __INCLUDE_IP_NEIGHBOR_H__
21 #include <vnet/ip-neighbor/ip_neighbor_types.h>
23 #include <vnet/adj/adj.h>
27 * APIs external modules can invoke on the neighbor subsystem
30 extern ip_neighbor_t *ip_neighbor_get (index_t ipni);
31 extern int ip_neighbor_add (const ip_address_t * ip,
32 const mac_address_t * mac,
34 ip_neighbor_flags_t flags, u32 * stats_index);
35 extern int ip_neighbor_del (const ip_address_t * ip, u32 sw_if_index);
37 extern int ip_neighbor_config (ip_address_family_t af,
38 u32 limit, u32 age, bool recycle);
40 extern void ip_neighbor_del_all (ip_address_family_t af, u32 sw_if_index);
42 typedef walk_rc_t (*ip_neighbor_walk_cb_t) (index_t ipni, void *ctx);
43 extern void ip_neighbor_walk (ip_address_family_t af,
45 ip_neighbor_walk_cb_t fn, void *ctx);
47 extern const ip_address_t *ip_neighbor_get_ip (const ip_neighbor_t * ipn);
48 extern ip_address_family_t ip_neighbor_get_af (const ip_neighbor_t * ipn);
49 extern const mac_address_t *ip_neighbor_get_mac (const ip_neighbor_t * ipn);
50 extern const u32 ip_neighbor_get_sw_if_index (const ip_neighbor_t * ipn);
52 extern void ip_neighbor_learn (const ip_neighbor_learn_t * l);
54 extern void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai);
56 extern void ip_neighbor_probe (const ip_adjacency_t * adj);
57 extern void ip_neighbor_probe_dst (u32 sw_if_index,
58 ip_address_family_t af,
59 const ip46_address_t * ip);
61 extern void ip_neighbor_mark (ip_address_family_t af);
62 extern void ip_neighbor_sweep (ip_address_family_t af);
65 * From the watcher to the API to publish a new neighbor
67 extern void ip_neighbor_handle_event (ip_neighbor_event_t * ipne);
70 * The set of function that vnet requires from the IP neighbour module.
71 * Note that an implementation of these functions will not exist
72 * if the ip-neighbour plugin is not loaded. so check the error codes!
74 extern int ip4_neighbor_proxy_add (u32 fib_index,
75 const ip4_address_t * start,
76 const ip4_address_t * end);
77 extern int ip4_neighbor_proxy_delete (u32 fib_index,
78 const ip4_address_t * start,
79 const ip4_address_t * end);
80 extern int ip4_neighbor_proxy_enable (u32 sw_if_index);
81 extern int ip4_neighbor_proxy_disable (u32 sw_if_index);
82 extern int ip6_neighbor_proxy_add (u32 sw_if_index,
83 const ip6_address_t * addr);
84 extern int ip6_neighbor_proxy_del (u32 sw_if_index,
85 const ip6_address_t * addr);
88 * neighbor protocol implementation registration functions
89 * this are provided by ARP and IP-ND
91 typedef int (*ip4_neighbor_proxy_addr_t) (u32 fib_index,
92 const ip4_address_t * start,
93 const ip4_address_t * end);
94 typedef int (*ip4_neighbor_proxy_cfg_t) (u32 sw_if_index);
95 typedef int (*ip6_neighbor_proxy_cfg_t) (u32 sw_if_index,
96 const ip6_address_t * addr);
99 * Virtual function Table for neighbor protocol implementations to register
101 typedef struct ip_neighbor_vft_t_
103 ip4_neighbor_proxy_cfg_t inv_proxy4_enable;
104 ip4_neighbor_proxy_cfg_t inv_proxy4_disable;
105 ip4_neighbor_proxy_addr_t inv_proxy4_add;
106 ip4_neighbor_proxy_addr_t inv_proxy4_del;
107 ip6_neighbor_proxy_cfg_t inv_proxy6_add;
108 ip6_neighbor_proxy_cfg_t inv_proxy6_del;
111 extern void ip_neighbor_register (ip_address_family_t af,
112 const ip_neighbor_vft_t * vft);
115 #endif /* __INCLUDE_IP_NEIGHBOR_H__ */
118 * fd.io coding-style-patch-verification: ON
121 * eval: (c-set-style "gnu")