Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 1 | /* |
| 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 Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 25 | |
| 26 | /***** |
| 27 | * APIs external modules can invoke on the neighbor subsystem |
| 28 | */ |
| 29 | |
| 30 | extern ip_neighbor_t *ip_neighbor_get (index_t ipni); |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 31 | extern int ip_neighbor_add (const ip_address_t * ip, |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 32 | const mac_address_t * mac, |
| 33 | u32 sw_if_index, |
| 34 | ip_neighbor_flags_t flags, u32 * stats_index); |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 35 | extern int ip_neighbor_del (const ip_address_t * ip, u32 sw_if_index); |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 36 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 37 | extern int ip_neighbor_config (ip_address_family_t af, |
| 38 | u32 limit, u32 age, bool recycle); |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 39 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 40 | extern void ip_neighbor_del_all (ip_address_family_t af, u32 sw_if_index); |
Neale Ranns | 240dcb2 | 2020-04-23 09:04:59 +0000 | [diff] [blame] | 41 | |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 42 | typedef walk_rc_t (*ip_neighbor_walk_cb_t) (index_t ipni, void *ctx); |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 43 | extern void ip_neighbor_walk (ip_address_family_t af, |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 44 | u32 sw_if_index, |
| 45 | ip_neighbor_walk_cb_t fn, void *ctx); |
| 46 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 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); |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 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); |
| 51 | |
| 52 | extern void ip_neighbor_learn (const ip_neighbor_learn_t * l); |
| 53 | |
| 54 | extern void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai); |
| 55 | |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 56 | extern void ip_neighbor_probe (const ip_adjacency_t * adj); |
| 57 | extern void ip_neighbor_probe_dst (const ip_adjacency_t * adj, |
| 58 | const ip46_address_t * ip); |
| 59 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 60 | extern void ip_neighbor_mark (ip_address_family_t af); |
| 61 | extern void ip_neighbor_sweep (ip_address_family_t af); |
Neale Ranns | c87fbb4 | 2020-04-02 17:08:28 +0000 | [diff] [blame] | 62 | |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 63 | /** |
| 64 | * From the watcher to the API to publish a new neighbor |
| 65 | */ |
Neale Ranns | 4ac36bc | 2020-11-20 13:05:59 +0000 | [diff] [blame^] | 66 | extern void ip_neighbor_handle_event (ip_neighbor_event_t * ipne); |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * The set of function that vnet requires from the IP neighbour module. |
| 70 | * Note that an implementation of these functions will not exist |
| 71 | * if the ip-neighbour plugin is not loaded. so check the error codes! |
| 72 | */ |
| 73 | extern int ip4_neighbor_proxy_add (u32 fib_index, |
| 74 | const ip4_address_t * start, |
| 75 | const ip4_address_t * end); |
| 76 | extern int ip4_neighbor_proxy_delete (u32 fib_index, |
| 77 | const ip4_address_t * start, |
| 78 | const ip4_address_t * end); |
| 79 | extern int ip4_neighbor_proxy_enable (u32 sw_if_index); |
| 80 | extern int ip4_neighbor_proxy_disable (u32 sw_if_index); |
| 81 | extern int ip6_neighbor_proxy_add (u32 sw_if_index, |
| 82 | const ip6_address_t * addr); |
| 83 | extern int ip6_neighbor_proxy_del (u32 sw_if_index, |
| 84 | const ip6_address_t * addr); |
| 85 | |
| 86 | /** |
| 87 | * neighbor protocol implementation registration functions |
| 88 | * this are provided by ARP and IP-ND |
| 89 | */ |
| 90 | typedef int (*ip4_neighbor_proxy_addr_t) (u32 fib_index, |
| 91 | const ip4_address_t * start, |
| 92 | const ip4_address_t * end); |
| 93 | typedef int (*ip4_neighbor_proxy_cfg_t) (u32 sw_if_index); |
| 94 | typedef int (*ip6_neighbor_proxy_cfg_t) (u32 sw_if_index, |
| 95 | const ip6_address_t * addr); |
| 96 | |
| 97 | /** |
| 98 | * Virtual function Table for neighbor protocol implementations to register |
| 99 | */ |
| 100 | typedef struct ip_neighbor_vft_t_ |
| 101 | { |
| 102 | ip4_neighbor_proxy_cfg_t inv_proxy4_enable; |
| 103 | ip4_neighbor_proxy_cfg_t inv_proxy4_disable; |
| 104 | ip4_neighbor_proxy_addr_t inv_proxy4_add; |
| 105 | ip4_neighbor_proxy_addr_t inv_proxy4_del; |
| 106 | ip6_neighbor_proxy_cfg_t inv_proxy6_add; |
| 107 | ip6_neighbor_proxy_cfg_t inv_proxy6_del; |
| 108 | } ip_neighbor_vft_t; |
| 109 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 110 | extern void ip_neighbor_register (ip_address_family_t af, |
Neale Ranns | cbe25aa | 2019-09-30 10:53:31 +0000 | [diff] [blame] | 111 | const ip_neighbor_vft_t * vft); |
| 112 | |
| 113 | |
| 114 | #endif /* __INCLUDE_IP_NEIGHBOR_H__ */ |
| 115 | |
| 116 | /* |
| 117 | * fd.io coding-style-patch-verification: ON |
| 118 | * |
| 119 | * Local Variables: |
| 120 | * eval: (c-set-style "gnu") |
| 121 | * End: |
| 122 | */ |