Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
7c053fe7
Commit
7c053fe7
authored
Mar 29, 2022
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Export add_filters and simplify interface.
parent
91c44f82
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
configuration.c
configuration.c
+25
-7
configuration.h
configuration.h
+6
-0
No files found.
configuration.c
View file @
7c053fe7
...
@@ -853,9 +853,26 @@ parse_key(int c, gnc_t gnc, void *closure, struct key **key_return)
...
@@ -853,9 +853,26 @@ parse_key(int c, gnc_t gnc, void *closure, struct key **key_return)
return
-
2
;
return
-
2
;
}
}
static
void
int
add_filter
(
struct
filter
*
filter
,
struct
filter
**
filters
)
add_filter
(
struct
filter
*
filter
,
int
type
)
{
{
struct
filter
**
filters
;
switch
(
type
)
{
case
FILTER_TYPE_INPUT
:
filters
=
&
input_filters
;
break
;
case
FILTER_TYPE_OUTPUT
:
filters
=
&
output_filters
;
break
;
case
FILTER_TYPE_REDISTRIBUTE
:
filters
=
&
redistribute_filters
;
break
;
case
FILTER_TYPE_INSTALL
:
filters
=
&
install_filters
;
break
;
default:
return
-
1
;
}
if
(
*
filters
==
NULL
)
{
if
(
*
filters
==
NULL
)
{
filter
->
next
=
NULL
;
filter
->
next
=
NULL
;
*
filters
=
filter
;
*
filters
=
filter
;
...
@@ -867,6 +884,7 @@ add_filter(struct filter *filter, struct filter **filters)
...
@@ -867,6 +884,7 @@ add_filter(struct filter *filter, struct filter **filters)
filter
->
next
=
NULL
;
filter
->
next
=
NULL
;
f
->
next
=
filter
;
f
->
next
=
filter
;
}
}
return
1
;
}
}
static
void
static
void
...
@@ -1174,7 +1192,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
...
@@ -1174,7 +1192,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
c
<
-
1
)
if
(
c
<
-
1
)
goto
fail
;
goto
fail
;
add_filter
(
filter
,
&
input_filters
);
add_filter
(
filter
,
FILTER_TYPE_INPUT
);
}
else
if
(
strcmp
(
token
,
"out"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"out"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
if
(
config_finalised
)
if
(
config_finalised
)
...
@@ -1182,7 +1200,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
...
@@ -1182,7 +1200,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
c
<
-
1
)
if
(
c
<
-
1
)
goto
fail
;
goto
fail
;
add_filter
(
filter
,
&
output_filters
);
add_filter
(
filter
,
FILTER_TYPE_OUTPUT
);
}
else
if
(
strcmp
(
token
,
"redistribute"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"redistribute"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
if
(
config_finalised
)
if
(
config_finalised
)
...
@@ -1190,7 +1208,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
...
@@ -1190,7 +1208,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
c
<
-
1
)
if
(
c
<
-
1
)
goto
fail
;
goto
fail
;
add_filter
(
filter
,
&
redistribute_filters
);
add_filter
(
filter
,
FILTER_TYPE_REDISTRIBUTE
);
}
else
if
(
strcmp
(
token
,
"install"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"install"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
if
(
config_finalised
)
if
(
config_finalised
)
...
@@ -1198,7 +1216,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
...
@@ -1198,7 +1216,7 @@ parse_config_line(int c, gnc_t gnc, void *closure,
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
c
<
-
1
)
if
(
c
<
-
1
)
goto
fail
;
goto
fail
;
add_filter
(
filter
,
&
install_filters
);
add_filter
(
filter
,
FILTER_TYPE_INSTALL
);
}
else
if
(
strcmp
(
token
,
"interface"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"interface"
)
==
0
)
{
struct
interface_conf
*
if_conf
;
struct
interface_conf
*
if_conf
;
c
=
parse_ifconf
(
c
,
gnc
,
closure
,
&
if_conf
);
c
=
parse_ifconf
(
c
,
gnc
,
closure
,
&
if_conf
);
...
@@ -1531,7 +1549,7 @@ finalise_config()
...
@@ -1531,7 +1549,7 @@ finalise_config()
filter
->
proto
=
RTPROT_BABEL_LOCAL
;
filter
->
proto
=
RTPROT_BABEL_LOCAL
;
filter
->
plen_le
=
128
;
filter
->
plen_le
=
128
;
filter
->
src_plen_le
=
128
;
filter
->
src_plen_le
=
128
;
add_filter
(
filter
,
&
redistribute_filters
);
add_filter
(
filter
,
FILTER_TYPE_REDISTRIBUTE
);
while
(
interface_confs
)
{
while
(
interface_confs
)
{
struct
interface_conf
*
if_conf
;
struct
interface_conf
*
if_conf
;
...
...
configuration.h
View file @
7c053fe7
...
@@ -33,6 +33,11 @@ THE SOFTWARE.
...
@@ -33,6 +33,11 @@ THE SOFTWARE.
#define AUTH_TYPE_SHA256 1
#define AUTH_TYPE_SHA256 1
#define AUTH_TYPE_BLAKE2S128 2
#define AUTH_TYPE_BLAKE2S128 2
#define FILTER_TYPE_INPUT 0
#define FILTER_TYPE_OUTPUT 1
#define FILTER_TYPE_REDISTRIBUTE 2
#define FILTER_TYPE_INSTALL 3
struct
filter_result
{
struct
filter_result
{
unsigned
int
add_metric
;
/* allow = 0, deny = INF, metric = <0..INF> */
unsigned
int
add_metric
;
/* allow = 0, deny = INF, metric = <0..INF> */
unsigned
char
*
src_prefix
;
unsigned
char
*
src_prefix
;
...
@@ -64,6 +69,7 @@ void flush_ifconf(struct interface_conf *if_conf);
...
@@ -64,6 +69,7 @@ void flush_ifconf(struct interface_conf *if_conf);
int
parse_config_from_file
(
const
char
*
filename
,
int
*
line_return
);
int
parse_config_from_file
(
const
char
*
filename
,
int
*
line_return
);
int
parse_config_from_string
(
char
*
string
,
int
n
,
const
char
**
message_return
);
int
parse_config_from_string
(
char
*
string
,
int
n
,
const
char
**
message_return
);
int
add_filter
(
struct
filter
*
filter
,
int
type
);
void
renumber_filters
(
void
);
void
renumber_filters
(
void
);
int
input_filter
(
const
unsigned
char
*
id
,
int
input_filter
(
const
unsigned
char
*
id
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment