aboutsummaryrefslogtreecommitdiffstats
path: root/metis/ccnx/forwarder/metis/processor/metis_FIB.h
blob: 97e20fd66ebcfe8b539193553a35ae18d6b0ee1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright (c) 2017 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.
 */

/**
 * The Forwarding Information Base (FIB) table is a map from a name to a MetisFibEntry.
 *
 * Each MetisFibEntry has a set of nexthops and a MetisStrategy to pick a nexthop.
 *
 * The strategy may be changed.  It will wipe out all the previous state for the last
 * strategy and the new strategy will need to start from scratch.  changing the strategy does
 * not change the nexthops, but it does wipe any stragegy-specific state in each nexthop.
 *
 * So, the FIB table is make up of rows like this:
 *   name -> { strategy, { {nexthop_1, strategyState_1}, {nexthop_2, strategyState_2}, ... } }
 *
 * The "strategy" is a MetisStrategyImpl function structure (see strategies/metis_Strategy.h).
 * Some strategies might allocate an implementation per row, others might use one implementation
 * for the whole table.  Its up to the strategy implementation.
 *
 *
 */

#ifndef Metis_metis_FIB_h
#define Metis_metis_FIB_h

#include <ccnx/common/ccnx_Name.h>
#include <ccnx/api/control/cpi_RouteEntry.h>

#include <ccnx/forwarder/metis/core/metis_NumberSet.h>
#include <ccnx/forwarder/metis/core/metis_Message.h>
#include <ccnx/forwarder/metis/processor/metis_FibEntryList.h>
#include <ccnx/forwarder/metis/processor/metis_FibEntry.h>
#include <ccnx/forwarder/metis/core/metis_Logger.h>

struct metis_fib;
typedef struct metis_fib MetisFIB;

/**
 * <#One Line Description#>
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [<#in out in,out#>] <#name#> <#description#>
 *
 * @return <#value#> <#explanation#>
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
MetisFIB *metisFIB_Create(MetisLogger *logger);

/**
 * <#One Line Description#>
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [<#in out in,out#>] <#name#> <#description#>
 *
 * @return <#value#> <#explanation#>
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void metisFIB_Destroy(MetisFIB **fibPtr);

/**
 * @function metisFib_AddOrUpdate
 * @abstract Adds or updates a route
 * @discussion
 *   <#Discussion#>
 *
 * @param <#param1#>
 * @return true if added/updated, false if a problem.
 */
bool metisFIB_AddOrUpdate(MetisFIB *fib, CPIRouteEntry *route, const char * fwdStrategy);

/**
 * Removes a route
 *
 * Removes a specific nexthop for a route.  If there are no nexthops left after the
 * removal, the entire route is deleted from the FIB.
 *
 * @param [in] fib The FIB to modify
 * @param [in] route The route to remove
 *
 * @retval true Route completely removed
 * @retval false There are still other nexthops for the route
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisFIB_Remove(MetisFIB *fib, CPIRouteEntry *route);

/**
 * Removes the given connection ID from all routes
 *
 * Removes the given connection ID from all routes.  If that leaves a route
 * with no nexthops, the route remains in the table with an empty nexthop set.
 *
 * @param [in] fib The forwarding table
 * @param [in] connectionId The connection to remove.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void metisFIB_RemoveConnectionIdFromRoutes(MetisFIB *fib, unsigned connectionId);

/**
 * @function metisFib_Match
 * @abstract Lookup the interest in the FIB, returns set of connection ids to forward over
 * @discussion
 *   This is the internal state of the FIB entry.  If you will store a copy you must acquire a reference.
 *
 * @param <#param1#>
 * @return May be empty, should not be null
 */
MetisFibEntry *metisFIB_Match(MetisFIB *fib, const MetisMessage *interestMessage);
/**
 * @function metisFib_Length
 * @abstract The number of entries in the forwarding table
 * @discussion
 *   <#Discussion#>
 *
 * @param <#param1#>
 * @return <#return#>
 */
size_t metisFIB_Length(const MetisFIB *fib);

/**
 * @function metisFib_GetEntries
 * @abstract Returns a list of the current FIB entries.
 * @discussion
 *   Caller must destroy the list
 *
 * @param <#param1#>
 * @return <#return#>
 */
MetisFibEntryList *metisFIB_GetEntries(const MetisFIB *fib);
#endif // Metis_metis_FIB_h