Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef __MPLS_TUNNEL_H__ |
| 17 | #define __MPLS_TUNNEL_H__ |
| 18 | |
| 19 | #include <vnet/mpls/mpls.h> |
| 20 | |
| 21 | /** |
| 22 | * @brief A uni-directional MPLS tunnel |
| 23 | */ |
| 24 | typedef struct mpls_tunnel_t_ |
| 25 | { |
| 26 | /** |
| 27 | * @brief The tunnel hooks into the FIB control plane graph. |
| 28 | */ |
| 29 | fib_node_t mt_node; |
| 30 | |
| 31 | /** |
| 32 | * @brief If the tunnel is an L2 tunnel, this is the link type ETHERNET |
| 33 | * adjacency |
| 34 | */ |
| 35 | adj_index_t mt_l2_adj; |
| 36 | |
| 37 | /** |
| 38 | * @brief on a L2 tunnel this is the VLIB arc from the L2-tx to the l2-midchain |
| 39 | */ |
| 40 | u32 mt_l2_tx_arc; |
| 41 | |
| 42 | /** |
| 43 | * @brief The path-list over which the tunnel's destination is reachable |
| 44 | */ |
| 45 | fib_node_index_t mt_path_list; |
| 46 | |
| 47 | /** |
| 48 | * @brief sibling index on the path-list so notifications are received. |
| 49 | */ |
| 50 | u32 mt_sibling_index; |
| 51 | |
| 52 | /** |
| 53 | * @brief The Label stack to apply to egress packets |
| 54 | */ |
| 55 | mpls_label_t *mt_label_stack; |
| 56 | |
| 57 | /** |
| 58 | * @brief Flag to indicate the tunnel is only for L2 traffic, that is |
| 59 | * this tunnel belongs in a bridge domain. |
| 60 | */ |
| 61 | u8 mt_l2_only; |
| 62 | |
| 63 | /** |
| 64 | * @brief The HW interface index of the tunnel interfaces |
| 65 | */ |
| 66 | u32 mt_hw_if_index; |
| 67 | |
| 68 | /** |
| 69 | * @brief The SW interface index of the tunnel interfaces |
| 70 | */ |
| 71 | u32 mt_sw_if_index; |
| 72 | |
| 73 | } mpls_tunnel_t; |
| 74 | |
| 75 | /** |
| 76 | * @brief Create a new MPLS tunnel |
| 77 | */ |
| 78 | extern void vnet_mpls_tunnel_add (fib_route_path_t *rpath, |
| 79 | mpls_label_t *label_stack, |
| 80 | u8 l2_only, |
| 81 | u32 *sw_if_index); |
| 82 | |
| 83 | extern void vnet_mpls_tunnel_del (u32 sw_if_index); |
| 84 | |
| 85 | extern const mpls_tunnel_t *mpls_tunnel_get(u32 index); |
| 86 | |
| 87 | /** |
| 88 | * @brief Callback function invoked while walking MPLS tunnels |
| 89 | */ |
| 90 | typedef void (*mpls_tunnel_walk_cb_t)(u32 index, void *ctx); |
| 91 | |
| 92 | /** |
| 93 | * @brief Walk all the MPLS tunnels |
| 94 | */ |
| 95 | extern void mpls_tunnel_walk(mpls_tunnel_walk_cb_t cb, |
| 96 | void *ctx); |
| 97 | |
| 98 | #endif |