Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * nhrp.h: next-hop resolution |
| 3 | * |
| 4 | * Copyright (c) 2016 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 __NHRP_H__ |
| 19 | #define __NHRP_H__ |
| 20 | |
| 21 | #include <vnet/ip/ip.h> |
| 22 | |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 23 | /** |
| 24 | * An NHRP entry represents the mapping between a peer on an interface in the overlay |
| 25 | * and a next-hop address in the underlay. |
| 26 | * i.e. there's a multipoint tunnel providing the overlay (henace a peer on |
| 27 | * that tunnel) which is reachable via 'tunnel destination' address in the |
| 28 | * underlay. |
| 29 | */ |
| 30 | typedef struct nhrp_entry_t_ nhrp_entry_t; |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 31 | |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 32 | /** accessors for the opaque struct */ |
| 33 | extern u32 nhrp_entry_get_sw_if_index (const nhrp_entry_t * ne); |
| 34 | extern u32 nhrp_entry_get_fib_index (const nhrp_entry_t * ne); |
| 35 | extern const ip46_address_t *nhrp_entry_get_peer (const nhrp_entry_t * ne); |
| 36 | extern const fib_prefix_t *nhrp_entry_get_nh (const nhrp_entry_t * ne); |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 37 | extern u8 *format_nhrp_entry (u8 * s, va_list * args); |
| 38 | |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 39 | /** |
| 40 | * Create a new NHRP entry |
| 41 | */ |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 42 | extern int nhrp_entry_add (u32 sw_if_index, |
| 43 | const ip46_address_t * peer, |
| 44 | u32 nh_table_id, const ip46_address_t * nh); |
| 45 | |
| 46 | extern int nhrp_entry_del (u32 sw_if_index, const ip46_address_t * peer); |
| 47 | |
| 48 | extern nhrp_entry_t *nhrp_entry_find (u32 sw_if_index, |
| 49 | const ip46_address_t * peer); |
| 50 | extern nhrp_entry_t *nhrp_entry_get (index_t nei); |
| 51 | |
| 52 | extern void nhrp_entry_adj_stack (const nhrp_entry_t * ne, adj_index_t ai); |
| 53 | |
| 54 | typedef walk_rc_t (*nhrp_walk_cb_t) (index_t nei, void *ctx); |
| 55 | |
| 56 | extern void nhrp_walk (nhrp_walk_cb_t fn, void *ctx); |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 57 | extern void nhrp_walk_itf (u32 sw_if_index, nhrp_walk_cb_t fn, void *ctx); |
| 58 | |
| 59 | /** |
| 60 | * Notifications for the creation and deletion of NHRP entries |
| 61 | */ |
| 62 | typedef void (*nhrp_entry_added_t) (const nhrp_entry_t * ne); |
| 63 | typedef void (*nhrp_entry_deleted_t) (const nhrp_entry_t * ne); |
| 64 | |
| 65 | typedef struct nhrp_vft_t_ |
| 66 | { |
| 67 | nhrp_entry_added_t nv_added; |
| 68 | nhrp_entry_deleted_t nv_deleted; |
| 69 | } nhrp_vft_t; |
| 70 | |
| 71 | extern void nhrp_register (const nhrp_vft_t * vft); |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 72 | |
| 73 | #endif |
| 74 | |
| 75 | /* |
| 76 | * fd.io coding-style-patch-verification: ON |
| 77 | * |
| 78 | * Local Variables: |
| 79 | * eval: (c-set-style "gnu") |
| 80 | * End: |
| 81 | */ |