blob: ca5c788a5460470367d2f2cba196aea5e71d0391 [file] [log] [blame]
Neale Ranns9e829a82018-12-17 05:50:32 -08001/*
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
19static mfib_entry_src_vft mfib_entry_src_vfts[MFIB_N_SOURCES];
20
21static void
22mfib_entry_src_default_deactiviate (mfib_entry_t *mfib_entry,
23 mfib_entry_src_t *msrc)
24{
25}
26
27static void
28mfib_entry_src_default_activiate (mfib_entry_t *mfib_entry,
29 mfib_entry_src_t *msrc)
30{
31}
32
33static mfib_src_res_t
34mfib_entry_src_default_cover_change (mfib_entry_t *mfib_entry,
35 mfib_entry_src_t *msrc)
36{
37 return (MFIB_SRC_OK);
38}
39
40static mfib_src_res_t
41mfib_entry_src_default_cover_update (mfib_entry_t *mfib_entry,
42 mfib_entry_src_t *msrc)
43{
44 return (MFIB_SRC_OK);
45}
46
47void
48mfib_entry_src_register (mfib_source_t source,
49 const mfib_entry_src_vft *mvft)
50{
51 mfib_entry_src_vfts[source] = *mvft;
52}
53
54void
55mfib_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
62void
63mfib_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
70mfib_src_res_t
71mfib_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
77mfib_src_res_t
78mfib_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
84void
85mfib_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}