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