diff options
author | Neale Ranns <nranns@cisco.com> | 2018-12-17 05:50:32 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-12-18 12:52:56 +0000 |
commit | 9e829a856fdf88b3ea5770048ea20dcd50d1b4eb (patch) | |
tree | 48506b15a4550b5f766248378d5aea03510ce0f8 /src/vnet/mfib/mfib_entry_delegate.h | |
parent | 05b5d1b3a6663c0366e863adc845d7ee4facc1e3 (diff) |
MFIB: recurse resolution through an MFIB entry
Change-Id: I8dc261e40b8398c5c8ab6bb69ecebbd0176055d9
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/mfib/mfib_entry_delegate.h')
-rw-r--r-- | src/vnet/mfib/mfib_entry_delegate.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/vnet/mfib/mfib_entry_delegate.h b/src/vnet/mfib/mfib_entry_delegate.h new file mode 100644 index 00000000000..0454a0f157a --- /dev/null +++ b/src/vnet/mfib/mfib_entry_delegate.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MFIB_ENTRY_DELEGATE_T__ +#define __MFIB_ENTRY_DELEGATE_T__ + +#include <vnet/fib/fib_node.h> + +/** + * Delegate types + */ +typedef enum mfib_entry_delegate_type_t_ { + /** + * Dependency list of covered entries. + * these are more specific entries that are interested in changes + * to their respective cover + */ + MFIB_ENTRY_DELEGATE_COVERED, +} mfib_entry_delegate_type_t; + +#define FOR_EACH_MFIB_DELEGATE(_entry, _fdt, _fed, _body) \ +{ \ + for (_fdt = MFIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP4; \ + _fdt <= MFIB_ENTRY_DELEGATE_ATTACHED_EXPORT; \ + _fdt++) \ + { \ + _fed = mfib_entry_delegate_get(_entry, _fdt); \ + if (NULL != _fed) { \ + _body; \ + } \ + } \ +} + +/** + * A Delagate is a means to implmenet the Delagation design pattern; the extension of an + * objects functionality through the composition of, and delgation to, other objects. + * These 'other' objects are delegates. Delagates are thus attached to other MFIB objects + * to extend their functionality. + */ +typedef struct mfib_entry_delegate_t_ +{ + /** + * The MFIB entry object to which the delagate is attached + */ + fib_node_index_t mfd_entry_index; + + /** + * The delagate type + */ + mfib_entry_delegate_type_t mfd_type; + + /** + * A union of data for the different delegate types + * These delegates are stored in a sparse vector on the entry, so they + * must all be of the same size. + */ + union + { + /** + * For the cover tracking. The node list; + */ + fib_node_list_t mfd_list; + }; +} mfib_entry_delegate_t; + +struct mfib_entry_t_; + +extern void mfib_entry_delegate_remove(struct mfib_entry_t_ *mfib_entry, + mfib_entry_delegate_type_t type); + +extern mfib_entry_delegate_t *mfib_entry_delegate_find_or_add(struct mfib_entry_t_ *mfib_entry, + mfib_entry_delegate_type_t fdt); +extern mfib_entry_delegate_t *mfib_entry_delegate_get(const struct mfib_entry_t_ *mfib_entry, + mfib_entry_delegate_type_t type); + +extern u8 *format_mfib_entry_deletegate(u8 * s, va_list * args); + +#endif |