blob: c976da9327aca54c5fc66133755b3fe505a544f6 [file] [log] [blame]
Neale Ranns0bfe5d82016-08-25 15:29:12 +01001/*
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:
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#include "fib_entry.h"
17#include "fib_entry_src.h"
18
19/**
20 * Source initialisation Function
21 */
22static void
23fib_entry_src_special_init (fib_entry_src_t *src)
24{
Neale Ranns450cd302016-11-09 17:49:42 +000025 src->fes_flags = FIB_ENTRY_SRC_FLAG_NONE;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010026}
27
28/**
29 * Source deinitialisation Function
30 */
31static void
32fib_entry_src_special_deinit (fib_entry_src_t *src)
33{
34}
35
36static void
37fib_entry_src_special_remove (fib_entry_src_t *src)
38{
39 src->fes_pl = FIB_NODE_INDEX_INVALID;
40}
41
42static void
43fib_entry_src_special_add (fib_entry_src_t *src,
44 const fib_entry_t *entry,
45 fib_entry_flag_t flags,
Neale Rannsda78f952017-05-24 09:15:43 -070046 dpo_proto_t proto,
Neale Ranns0bfe5d82016-08-25 15:29:12 +010047 const dpo_id_t *dpo)
48{
49 src->fes_pl =
50 fib_path_list_create_special(proto,
51 fib_entry_src_flags_2_path_list_flags(flags),
52 dpo);
53}
54
Neale Ranns53da2212018-02-24 02:11:19 -080055static void
56fib_entry_src_special_path_swap (fib_entry_src_t *src,
57 const fib_entry_t *entry,
58 fib_path_list_flags_t pl_flags,
59 const fib_route_path_t *rpaths)
60{
61 src->fes_pl = fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED | pl_flags),
62 rpaths);
63}
64
Neale Ranns0bfe5d82016-08-25 15:29:12 +010065const static fib_entry_src_vft_t special_src_vft = {
66 .fesv_init = fib_entry_src_special_init,
67 .fesv_deinit = fib_entry_src_special_deinit,
68 .fesv_add = fib_entry_src_special_add,
69 .fesv_remove = fib_entry_src_special_remove,
Neale Ranns53da2212018-02-24 02:11:19 -080070 .fesv_path_swap = fib_entry_src_special_path_swap,
Neale Ranns0bfe5d82016-08-25 15:29:12 +010071};
72
73void
74fib_entry_src_special_register (void)
75{
76 fib_entry_src_register(FIB_SOURCE_SPECIAL, &special_src_vft);
77 fib_entry_src_register(FIB_SOURCE_MAP, &special_src_vft);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010078 fib_entry_src_register(FIB_SOURCE_CLASSIFY, &special_src_vft);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010079 fib_entry_src_register(FIB_SOURCE_AE, &special_src_vft);
Andrew Yourtchenko5f3fcb92017-10-25 05:50:37 -070080 fib_entry_src_register(FIB_SOURCE_PROXY, &special_src_vft);
Neale Rannsd792d9c2017-10-21 10:53:20 -070081 fib_entry_src_register(FIB_SOURCE_BIER, &special_src_vft);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010082}