blob: cc888ba2054653d6bcb6df368587b81345d95ad8 [file] [log] [blame]
Neale Rannscbe25aa2019-09-30 10:53:31 +00001/*
2 * ip_neighboor.h: ip neighbor generic services
3 *
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:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17
18#ifndef __INCLUDE_IP_NEIGHBOR_H__
19#define __INCLUDE_IP_NEIGHBOR_H__
20
21#include <vnet/ip-neighbor/ip_neighbor_types.h>
22
23#include <vnet/adj/adj.h>
24
Neale Rannscbe25aa2019-09-30 10:53:31 +000025
26/*****
27 * APIs external modules can invoke on the neighbor subsystem
28 */
29
30extern ip_neighbor_t *ip_neighbor_get (index_t ipni);
Neale Rannsdc617b82020-08-20 08:22:56 +000031extern int ip_neighbor_add (const ip_address_t * ip,
Neale Rannscbe25aa2019-09-30 10:53:31 +000032 const mac_address_t * mac,
33 u32 sw_if_index,
34 ip_neighbor_flags_t flags, u32 * stats_index);
Neale Rannsdc617b82020-08-20 08:22:56 +000035extern int ip_neighbor_del (const ip_address_t * ip, u32 sw_if_index);
Neale Rannscbe25aa2019-09-30 10:53:31 +000036
Neale Rannsdc617b82020-08-20 08:22:56 +000037extern int ip_neighbor_config (ip_address_family_t af,
38 u32 limit, u32 age, bool recycle);
Alexander Chernavine1cc8752023-06-26 15:57:57 +000039extern int ip_neighbor_get_config (ip_address_family_t af, u32 *limit,
40 u32 *age, bool *recycle);
Neale Rannscbe25aa2019-09-30 10:53:31 +000041
Neale Rannsdc617b82020-08-20 08:22:56 +000042extern void ip_neighbor_del_all (ip_address_family_t af, u32 sw_if_index);
Neale Ranns240dcb22020-04-23 09:04:59 +000043
Neale Rannscbe25aa2019-09-30 10:53:31 +000044typedef walk_rc_t (*ip_neighbor_walk_cb_t) (index_t ipni, void *ctx);
Neale Rannsdc617b82020-08-20 08:22:56 +000045extern void ip_neighbor_walk (ip_address_family_t af,
Neale Rannscbe25aa2019-09-30 10:53:31 +000046 u32 sw_if_index,
47 ip_neighbor_walk_cb_t fn, void *ctx);
48
Neale Rannsdc617b82020-08-20 08:22:56 +000049extern const ip_address_t *ip_neighbor_get_ip (const ip_neighbor_t * ipn);
50extern ip_address_family_t ip_neighbor_get_af (const ip_neighbor_t * ipn);
Neale Rannscbe25aa2019-09-30 10:53:31 +000051extern const mac_address_t *ip_neighbor_get_mac (const ip_neighbor_t * ipn);
52extern const u32 ip_neighbor_get_sw_if_index (const ip_neighbor_t * ipn);
53
54extern void ip_neighbor_learn (const ip_neighbor_learn_t * l);
55
56extern void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai);
57
Neale Rannscbe25aa2019-09-30 10:53:31 +000058extern void ip_neighbor_probe (const ip_adjacency_t * adj);
Neale Rannsfd2417b2021-07-16 14:00:16 +000059extern void ip_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
Neale Rannse2fe0972020-11-26 08:37:27 +000060 ip_address_family_t af,
Neale Rannsfd2417b2021-07-16 14:00:16 +000061 const ip46_address_t *ip);
Neale Rannscbe25aa2019-09-30 10:53:31 +000062
Neale Rannsdc617b82020-08-20 08:22:56 +000063extern void ip_neighbor_mark (ip_address_family_t af);
64extern void ip_neighbor_sweep (ip_address_family_t af);
Stanislav Zaikin3bad8b62022-04-25 19:11:36 +020065extern walk_rc_t ip_neighbor_mark_one (index_t ipni, void *ctx);
Neale Rannsc87fbb42020-04-02 17:08:28 +000066
Neale Rannscbe25aa2019-09-30 10:53:31 +000067/**
68 * From the watcher to the API to publish a new neighbor
69 */
Neale Ranns4ac36bc2020-11-20 13:05:59 +000070extern void ip_neighbor_handle_event (ip_neighbor_event_t * ipne);
Neale Rannscbe25aa2019-09-30 10:53:31 +000071
72/**
73 * The set of function that vnet requires from the IP neighbour module.
74 * Note that an implementation of these functions will not exist
75 * if the ip-neighbour plugin is not loaded. so check the error codes!
76 */
77extern int ip4_neighbor_proxy_add (u32 fib_index,
78 const ip4_address_t * start,
79 const ip4_address_t * end);
80extern int ip4_neighbor_proxy_delete (u32 fib_index,
81 const ip4_address_t * start,
82 const ip4_address_t * end);
83extern int ip4_neighbor_proxy_enable (u32 sw_if_index);
84extern int ip4_neighbor_proxy_disable (u32 sw_if_index);
85extern int ip6_neighbor_proxy_add (u32 sw_if_index,
86 const ip6_address_t * addr);
87extern int ip6_neighbor_proxy_del (u32 sw_if_index,
88 const ip6_address_t * addr);
89
90/**
91 * neighbor protocol implementation registration functions
92 * this are provided by ARP and IP-ND
93 */
94typedef int (*ip4_neighbor_proxy_addr_t) (u32 fib_index,
95 const ip4_address_t * start,
96 const ip4_address_t * end);
97typedef int (*ip4_neighbor_proxy_cfg_t) (u32 sw_if_index);
98typedef int (*ip6_neighbor_proxy_cfg_t) (u32 sw_if_index,
99 const ip6_address_t * addr);
100
101/**
102 * Virtual function Table for neighbor protocol implementations to register
103 */
104typedef struct ip_neighbor_vft_t_
105{
106 ip4_neighbor_proxy_cfg_t inv_proxy4_enable;
107 ip4_neighbor_proxy_cfg_t inv_proxy4_disable;
108 ip4_neighbor_proxy_addr_t inv_proxy4_add;
109 ip4_neighbor_proxy_addr_t inv_proxy4_del;
110 ip6_neighbor_proxy_cfg_t inv_proxy6_add;
111 ip6_neighbor_proxy_cfg_t inv_proxy6_del;
112} ip_neighbor_vft_t;
113
Neale Rannsdc617b82020-08-20 08:22:56 +0000114extern void ip_neighbor_register (ip_address_family_t af,
Neale Rannscbe25aa2019-09-30 10:53:31 +0000115 const ip_neighbor_vft_t * vft);
116
Neale Rannscbe25aa2019-09-30 10:53:31 +0000117#endif /* __INCLUDE_IP_NEIGHBOR_H__ */
118
119/*
120 * fd.io coding-style-patch-verification: ON
121 *
122 * Local Variables:
123 * eval: (c-set-style "gnu")
124 * End:
125 */