Neale Ranns | 9e829a8 | 2018-12-17 05:50:32 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 | |
| 17 | #include <vnet/mfib/mfib_entry_src.h> |
| 18 | |
| 19 | static mfib_entry_src_vft mfib_entry_src_vfts[MFIB_N_SOURCES]; |
| 20 | |
| 21 | static void |
| 22 | mfib_entry_src_default_deactiviate (mfib_entry_t *mfib_entry, |
| 23 | mfib_entry_src_t *msrc) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | static void |
| 28 | mfib_entry_src_default_activiate (mfib_entry_t *mfib_entry, |
| 29 | mfib_entry_src_t *msrc) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | static mfib_src_res_t |
| 34 | mfib_entry_src_default_cover_change (mfib_entry_t *mfib_entry, |
| 35 | mfib_entry_src_t *msrc) |
| 36 | { |
| 37 | return (MFIB_SRC_OK); |
| 38 | } |
| 39 | |
| 40 | static mfib_src_res_t |
| 41 | mfib_entry_src_default_cover_update (mfib_entry_t *mfib_entry, |
| 42 | mfib_entry_src_t *msrc) |
| 43 | { |
| 44 | return (MFIB_SRC_OK); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | mfib_entry_src_register (mfib_source_t source, |
| 49 | const mfib_entry_src_vft *mvft) |
| 50 | { |
| 51 | mfib_entry_src_vfts[source] = *mvft; |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | mfib_entry_src_deactivate (mfib_entry_t *mfib_entry, |
| 56 | mfib_entry_src_t *msrc) |
| 57 | { |
| 58 | if (NULL != msrc) |
| 59 | mfib_entry_src_vfts[msrc->mfes_src].mev_deactivate(mfib_entry, msrc); |
| 60 | } |
| 61 | |
| 62 | void |
| 63 | mfib_entry_src_activate (mfib_entry_t *mfib_entry, |
| 64 | mfib_entry_src_t *msrc) |
| 65 | { |
| 66 | if (NULL != msrc) |
| 67 | mfib_entry_src_vfts[msrc->mfes_src].mev_activate(mfib_entry, msrc); |
| 68 | } |
| 69 | |
| 70 | mfib_src_res_t |
| 71 | mfib_entry_src_cover_change (mfib_entry_t *mfib_entry, |
| 72 | mfib_entry_src_t *msrc) |
| 73 | { |
| 74 | return (mfib_entry_src_vfts[msrc->mfes_src].mev_cover_change(mfib_entry, msrc)); |
| 75 | } |
| 76 | |
| 77 | mfib_src_res_t |
| 78 | mfib_entry_src_cover_update (mfib_entry_t *mfib_entry, |
| 79 | mfib_entry_src_t *msrc) |
| 80 | { |
| 81 | return (mfib_entry_src_vfts[msrc->mfes_src].mev_cover_update(mfib_entry, msrc)); |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | mfib_entry_src_module_init (void) |
| 86 | { |
| 87 | mfib_entry_src_vft mvft = { |
| 88 | .mev_activate = mfib_entry_src_default_activiate, |
| 89 | .mev_deactivate = mfib_entry_src_default_deactiviate, |
| 90 | .mev_cover_change = mfib_entry_src_default_cover_change, |
| 91 | .mev_cover_update = mfib_entry_src_default_cover_update, |
| 92 | }; |
| 93 | mfib_source_t source; |
| 94 | |
| 95 | FOREACH_MFIB_SOURCE(source) |
| 96 | { |
| 97 | mfib_entry_src_register(source, &mvft); |
| 98 | } |
| 99 | |
| 100 | mfib_entry_src_rr_module_init(); |
| 101 | } |