2 * Copyright (c) 2016 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @brief LISP sub-interfaces.
21 #ifndef __LISP_GPE_SUB_INTERFACE_H__
22 #define __LISP_GPE_SUB_INTERFACE_H__
24 #include <vnet/lisp-gpe/lisp_gpe.h>
27 * A Key for lookup in the L£ sub-interface DB
29 typedef struct lisp_gpe_sub_interface_key_t_
32 * The local-RLOC. This is the interface's 'source' address.
34 ip_address_t local_rloc;
37 * The VNI. In network byte order!
40 } lisp_gpe_sub_interface_key_t;
43 * @brief A LISP L3 sub-interface
45 * A LISP sub-interface is a multi-access interface, whose local address is a
46 * single local-RLOC. Adjacencies that form on this sub-interface, represent
48 * This is analogous to an ethernet interface.
49 * As with all interface types it can only be present in one VRF, hence a
50 * LISP sub-interface is per-local-rloc and per-VNI.
52 typedef struct lisp_gpe_sub_interface_t_
55 * The interface's key inthe DB; rloc & vni;
56 * The key is allocated from the heap so it can be used in the hash-table.
57 * if it's part of the object, then it is subjet to realloc, which no-worky.
59 lisp_gpe_sub_interface_key_t *key;
62 * The Table-ID in the overlay that this interface is bound to.
67 * A reference counting lock on the number of users of this interface.
68 * When this count drops to 0 the interface is deleted.
73 * The SW if index assigned to this sub-interface
78 * The SW IF index assigned to the main interface of which this is a sub.
81 } lisp_gpe_sub_interface_t;
83 extern index_t lisp_gpe_sub_interface_find_or_create_and_lock (const
90 extern u8 *format_lisp_gpe_sub_interface (u8 * s, va_list * ap);
92 extern void lisp_gpe_sub_interface_unlock (index_t itf);
94 extern const lisp_gpe_sub_interface_t *lisp_gpe_sub_interface_get (index_t
98 * A DB of all L3 sub-interfaces. The key is:{VNI,l-RLOC}
100 extern uword *lisp_gpe_sub_interfaces_sw_if_index;
104 * Get a VNET L3 interface matching the local-RLOC and VNI
105 * Called from the data-plane
108 lisp_gpe_sub_interface_find_ip6 (const ip6_address_t * addr, u32 vni)
110 lisp_gpe_sub_interface_key_t key;
113 ip_addr_v6 (&key.local_rloc).as_u64[0] = addr->as_u64[0];
114 ip_addr_v6 (&key.local_rloc).as_u64[1] = addr->as_u64[1];
115 ip_addr_version (&key.local_rloc) = AF_IP6;
118 p = hash_get_mem (&lisp_gpe_sub_interfaces_sw_if_index, &key);
123 return (INDEX_INVALID);
128 * Get a VNET L3 interface matching the local-RLOC and VNI
129 * Called from the data-plane
131 always_inline index_t
132 lisp_gpe_sub_interface_find_ip4 (const ip4_address_t * addr, u32 vni)
134 lisp_gpe_sub_interface_key_t key;
137 ip_addr_v4 (&key.local_rloc).as_u32 = addr->as_u32;
138 key.local_rloc.version = AF_IP4;
141 p = hash_get_mem (&lisp_gpe_sub_interfaces_sw_if_index, &key);
146 return (INDEX_INVALID);
150 * fd.io coding-style-patch-verification: ON
153 * eval: (c-set-style "gnu")