TRIP Routing Daemon
TRIP (RFC 3219) Location Server Implementation
Loading...
Searching...
No Matches
pib.h
Go to the documentation of this file.
1/*
2
3 trip: Modern TRIP LS implementation
4 Copyright (C) 2025 arf20 (Ángel Ruiz Fernandez)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19*/
20
24
25#ifndef _PIB_H
26#define _PIB_H
27
28#include <stddef.h>
29#include <stdint.h>
30
31
33typedef struct {
34 int deny;
35 char *expression;
37
39typedef struct {
40 char *name;
41 acl_entry_t *entries;
42 size_t entries_size, entries_capacity;
43} acl_t;
44
45
53
55typedef struct {
56 int af;
57 acl_t **acls;
58 size_t size, capacity;
60
62typedef struct {
63 routemap_set_attr_t attribute;
64 int value;
65 char *valstr1, *valstr2;
67
69typedef struct {
70 uint32_t seq;
71 int deny;
72 routemap_matcher_t *matchers;
73 size_t matchers_size, matchers_capacity;
74 routemap_action_t *actions;
75 size_t actions_size, actions_capacity;
77
79typedef struct {
80 char *name;
81 routemap_statement_t *statements;
82 size_t size, capacity;
84
85
87typedef struct {
88 acl_t *acls;
89 size_t acls_size, acls_capacity;
90 routemap_t *routemaps;
91 size_t routemaps_size, routemaps_capacity;
92} pib_t;
93
94
96pib_t *pib_new();
98void pib_destroy(pib_t *pib);
100acl_t *pib_acl_new(pib_t *pib, const char *name);
102routemap_t *pib_routemap_new(pib_t *pib, const char *name, int deny);
104acl_t *pib_acl_find(const pib_t *pib, const char *name);
106routemap_t *pib_routemap_find(const pib_t *pib, const char *name);
107
109void acl_insert(acl_t *acl, int deny, const char *expression);
111acl_entry_t *acl_find(const acl_t *acl, const char *expression);
112
113
116 routemap_statement_t *statement, int af);
119 const routemap_action_t *action);
122
124void routemap_matcher_insert(routemap_matcher_t *matcher, const acl_t *acl);
127
130 const routemap_statement_t *statement, routemap_set_attr_t attribute);
131
134 int deny);
137 uint32_t seq);
138
139
143const routemap_statement_t *routemap_match(const routemap_t *routemap,
144 const char *route);
145
146#endif /* _PIB_H */
147
pib_t * pib_new()
Initialize PIB.
Definition pib.c:50
routemap_set_attr_t
Attributes that can be set.
Definition pib.h:47
@ ROUTEMAP_SET_METRIC
Definition pib.h:49
@ ROUTEMAP_SET_ITADPATH_PREPEND
Definition pib.h:51
@ ROUTEMAP_SET_NEXTHOP
Definition pib.h:50
@ ROUTEMAP_SET_LOCALPREF
Definition pib.h:48
routemap_t * pib_routemap_find(const pib_t *pib, const char *name)
Find a route map by name.
Definition pib.c:138
routemap_t * pib_routemap_new(pib_t *pib, const char *name, int deny)
Create and insert route map into PIB.
Definition pib.c:112
void routemap_statement_insert_action(routemap_statement_t *statement, const routemap_action_t *action)
Insert action (copy) into route map.
Definition pib.c:284
void routemap_statement_action_deinit(routemap_action_t *action)
Deinit route map action.
Definition pib.c:295
acl_entry_t * acl_find(const acl_t *acl, const char *expression)
Find entry in ACL.
Definition pib.c:160
acl_t * pib_acl_new(pib_t *pib, const char *name)
Create and insert ACL into PIB.
Definition pib.c:96
void pib_destroy(pib_t *pib)
Deinitialize PIB.
Definition pib.c:68
routemap_statement_t * routemap_statement_new(routemap_t *routemap, uint32_t seq, int deny)
Allocate statement in route map.
Definition pib.c:331
const routemap_statement_t * routemap_match(const routemap_t *routemap, const char *route)
Match route against route map matchers.
Definition pib.c:367
routemap_statement_t * routemap_statement_find(routemap_t *routemap, uint32_t seq)
Find statement in route map by sequence number.
Definition pib.c:358
routemap_action_t * routemap_statement_action_find(const routemap_statement_t *statement, routemap_set_attr_t attribute)
Find action by attribute.
Definition pib.c:320
void routemap_matcher_insert(routemap_matcher_t *matcher, const acl_t *acl)
Insert ACL into route map matcher.
Definition pib.c:304
routemap_matcher_t * routemap_statement_matcher_new(routemap_statement_t *statement, int af)
Allocate a matcher in a route map statement.
Definition pib.c:268
void acl_insert(acl_t *acl, int deny, const char *expression)
Create and insert entry into ACL.
Definition pib.c:148
void routemap_matcher_deinit(routemap_matcher_t *matcher)
Deinitialize a route map matcher.
Definition pib.c:313
acl_t * pib_acl_find(const pib_t *pib, const char *name)
Find an ACL by name.
Definition pib.c:129
af
Address families.
Definition protocol.h:206
Access Control List entry.
Definition pib.h:33
int deny
Definition pib.h:34
Access Control List.
Definition pib.h:39
Policy Information Base.
Definition pib.h:87
Route map Action.
Definition pib.h:62
Route map ACL matcher.
Definition pib.h:55
size_t capacity
Definition pib.h:58
Route map statement.
Definition pib.h:69
Route map.
Definition pib.h:79
size_t capacity
Definition pib.h:82