blob: cf78bdae4eba80495dbb6fe94923776674cefd43 [file] [log] [blame]
Neale Rannsd792d9c2017-10-21 10:53:20 -07001/*
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 * @brief bier_fmask_db : The BIER fmask Database
17 */
18
19#ifndef __BIER_FMASK_DB_H__
20#define __BIER_FMASK_DB_H__
21
22#include <vnet/ip/ip.h>
23
Neale Ranns91286372017-12-05 13:24:04 -080024#include <vnet/fib/fib_types.h>
Neale Rannsd792d9c2017-10-21 10:53:20 -070025
26/**
Neale Ranns91286372017-12-05 13:24:04 -080027 * BIER header encapulsation types
Neale Rannsd792d9c2017-10-21 10:53:20 -070028 */
Neale Rannsd792d9c2017-10-21 10:53:20 -070029typedef enum bier_hdr_type_t_ {
Neale Ranns91286372017-12-05 13:24:04 -080030 /**
31 * BIER Header in MPLS networks
32 */
Neale Rannsd792d9c2017-10-21 10:53:20 -070033 BIER_HDR_O_MPLS,
Neale Ranns91286372017-12-05 13:24:04 -080034
35 /**
36 * BIER header in non-MPLS networks
37 */
38 BIER_HDR_O_OTHER,
Neale Ranns586479a2018-06-07 02:08:07 -070039} __attribute__((packed)) bier_hdr_type_t;
40
41/**
42 * BIER next-hop type
43 */
44typedef enum bier_nh_type_t_ {
45 /**
46 * BIER Header in MPLS networks
47 */
48 BIER_NH_IP,
49
50 /**
51 * BIER header in non-MPLS networks
52 */
53 BIER_NH_UDP,
54} __attribute__((packed)) bier_nh_type_t;
Neale Rannsd792d9c2017-10-21 10:53:20 -070055
Neale Ranns91286372017-12-05 13:24:04 -080056/**
57 * A key/ID for a BIER forwarding Mas (FMask).
58 * This is a simplified version of a fib_route_path_t.
59 */
Neale Rannsd792d9c2017-10-21 10:53:20 -070060typedef struct bier_fmask_id_t_ {
Neale Ranns91286372017-12-05 13:24:04 -080061 union {
62 /**
63 * next-hop of the peer
64 */
65 ip46_address_t bfmi_nh;
66
67 /**
68 * ID of the next-hop object, e.g. a UDP-encap
69 */
70 u32 bfmi_id;
71 };
Neale Ranns586479a2018-06-07 02:08:07 -070072 /**
73 * The BIER table this fmask is in
74 */
75 index_t bfmi_bti;
Neale Ranns91286372017-12-05 13:24:04 -080076
77 /**
Neale Ranns586479a2018-06-07 02:08:07 -070078 * Type of BIER header this fmask supports
Neale Ranns91286372017-12-05 13:24:04 -080079 */
Neale Ranns586479a2018-06-07 02:08:07 -070080 bier_hdr_type_t bfmi_hdr_type;
81
82 /**
Neale Ranns9c0a3c42018-09-07 08:57:41 -070083 * Union discriminator
Neale Ranns586479a2018-06-07 02:08:07 -070084 */
85 bier_nh_type_t bfmi_nh_type;
Neale Ranns91286372017-12-05 13:24:04 -080086} __attribute__((packed)) bier_fmask_id_t;
87
88extern index_t
Neale Rannsd792d9c2017-10-21 10:53:20 -070089bier_fmask_db_find_or_create_and_lock(index_t bti,
Neale Rannsd792d9c2017-10-21 10:53:20 -070090 const fib_route_path_t *rpath);
Neale Ranns91286372017-12-05 13:24:04 -080091extern index_t bier_fmask_db_find (index_t bti,
92 const fib_route_path_t *rpath);
Neale Rannsd792d9c2017-10-21 10:53:20 -070093
Neale Ranns91286372017-12-05 13:24:04 -080094extern void bier_fmask_db_remove (const bier_fmask_id_t *fmid);
Neale Rannsd792d9c2017-10-21 10:53:20 -070095
Neale Ranns586479a2018-06-07 02:08:07 -070096/**
97 * Walk all the BIER fmasks
98 */
99typedef walk_rc_t (*bier_fmask_walk_fn_t) (index_t bfmi, void *ctx);
100
101extern void bier_fmask_db_walk(bier_fmask_walk_fn_t fn, void *ctx);
Neale Rannsd792d9c2017-10-21 10:53:20 -0700102
103#endif