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
1fbd6fe7
Commit
1fbd6fe7
authored
Jun 14, 2013
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make high-level parse functions return next character.
This avoids various unpleasant edge-cases.
parent
4852003e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
configuration.c
configuration.c
+23
-20
No files found.
configuration.c
View file @
1fbd6fe7
...
@@ -273,8 +273,8 @@ getnet(int c, unsigned char **p_r, unsigned char *plen_r, int *af_r,
...
@@ -273,8 +273,8 @@ getnet(int c, unsigned char **p_r, unsigned char *plen_r, int *af_r,
return
c
;
return
c
;
}
}
static
struct
filter
*
static
int
parse_filter
(
int
c
,
gnc_t
gnc
,
void
*
closure
)
parse_filter
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
struct
filter
**
filter_return
)
{
{
char
*
token
;
char
*
token
;
struct
filter
*
filter
;
struct
filter
*
filter
;
...
@@ -368,16 +368,18 @@ parse_filter(int c, gnc_t gnc, void *closure)
...
@@ -368,16 +368,18 @@ parse_filter(int c, gnc_t gnc, void *closure)
filter
->
plen_le
+=
96
;
filter
->
plen_le
+=
96
;
filter
->
plen_ge
+=
96
;
filter
->
plen_ge
+=
96
;
}
}
return
filter
;
*
filter_return
=
filter
;
return
c
;
error:
error:
free
(
filter
);
free
(
filter
);
return
NULL
;
return
-
2
;
}
}
static
struct
interface_conf
*
static
int
parse_anonymous_ifconf
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
parse_anonymous_ifconf
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
struct
interface_conf
*
if_conf
)
struct
interface_conf
*
if_conf
,
struct
interface_conf
**
if_conf_return
)
{
{
char
*
token
;
char
*
token
;
...
@@ -468,15 +470,17 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
...
@@ -468,15 +470,17 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
free
(
token
);
free
(
token
);
}
}
return
if_conf
;
*
if_conf_return
=
if_conf
;
return
c
;
error:
error:
free
(
if_conf
);
free
(
if_conf
);
return
NULL
;
return
-
2
;
}
}
static
struct
interface_conf
*
static
int
parse_ifconf
(
int
c
,
gnc_t
gnc
,
void
*
closure
)
parse_ifconf
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
struct
interface_conf
**
if_conf_return
)
{
{
char
*
token
;
char
*
token
;
struct
interface_conf
*
if_conf
;
struct
interface_conf
*
if_conf
;
...
@@ -495,11 +499,11 @@ parse_ifconf(int c, gnc_t gnc, void *closure)
...
@@ -495,11 +499,11 @@ parse_ifconf(int c, gnc_t gnc, void *closure)
if_conf
->
ifname
=
token
;
if_conf
->
ifname
=
token
;
return
parse_anonymous_ifconf
(
c
,
gnc
,
closure
,
if_conf
);
return
parse_anonymous_ifconf
(
c
,
gnc
,
closure
,
if_conf
,
if_conf_return
);
error:
error:
free
(
if_conf
);
free
(
if_conf
);
return
NULL
;
return
-
2
;
}
}
static
void
static
void
...
@@ -707,31 +711,31 @@ parse_config(gnc_t gnc, void *closure)
...
@@ -707,31 +711,31 @@ parse_config(gnc_t gnc, void *closure)
if
(
strcmp
(
token
,
"in"
)
==
0
)
{
if
(
strcmp
(
token
,
"in"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
filter
=
parse_filter
(
c
,
gnc
,
closure
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
filter
==
NULL
)
if
(
filter
==
NULL
)
return
-
1
;
return
-
1
;
add_filter
(
filter
,
&
input_filters
);
add_filter
(
filter
,
&
input_filters
);
}
else
if
(
strcmp
(
token
,
"out"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"out"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
filter
=
parse_filter
(
c
,
gnc
,
closure
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
filter
==
NULL
)
if
(
filter
==
NULL
)
return
-
1
;
return
-
1
;
add_filter
(
filter
,
&
output_filters
);
add_filter
(
filter
,
&
output_filters
);
}
else
if
(
strcmp
(
token
,
"redistribute"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"redistribute"
)
==
0
)
{
struct
filter
*
filter
;
struct
filter
*
filter
;
filter
=
parse_filter
(
c
,
gnc
,
closure
);
c
=
parse_filter
(
c
,
gnc
,
closure
,
&
filter
);
if
(
filter
==
NULL
)
if
(
filter
==
NULL
)
return
-
1
;
return
-
1
;
add_filter
(
filter
,
&
redistribute_filters
);
add_filter
(
filter
,
&
redistribute_filters
);
}
else
if
(
strcmp
(
token
,
"interface"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"interface"
)
==
0
)
{
struct
interface_conf
*
if_conf
;
struct
interface_conf
*
if_conf
;
if_conf
=
parse_ifconf
(
c
,
gnc
,
closure
);
c
=
parse_ifconf
(
c
,
gnc
,
closure
,
&
if_conf
);
if
(
if_conf
==
NULL
)
if
(
if_conf
==
NULL
)
return
-
1
;
return
-
1
;
add_ifconf
(
if_conf
,
&
interface_confs
);
add_ifconf
(
if_conf
,
&
interface_confs
);
}
else
if
(
strcmp
(
token
,
"default"
)
==
0
)
{
}
else
if
(
strcmp
(
token
,
"default"
)
==
0
)
{
struct
interface_conf
*
if_conf
;
struct
interface_conf
*
if_conf
;
if_conf
=
parse_anonymous_ifconf
(
c
,
gnc
,
closure
,
NULL
);
c
=
parse_anonymous_ifconf
(
c
,
gnc
,
closure
,
NULL
,
&
if_conf
);
if
(
if_conf
==
NULL
)
if
(
if_conf
==
NULL
)
return
-
1
;
return
-
1
;
if
(
default_interface_conf
==
NULL
)
if
(
default_interface_conf
==
NULL
)
...
@@ -742,9 +746,8 @@ parse_config(gnc_t gnc, void *closure)
...
@@ -742,9 +746,8 @@ parse_config(gnc_t gnc, void *closure)
free
(
if_conf
);
free
(
if_conf
);
}
}
}
else
{
}
else
{
int
rc
;
c
=
parse_option
(
c
,
gnc
,
closure
,
token
);
rc
=
parse_option
(
c
,
gnc
,
closure
,
token
);
if
(
c
<
-
2
)
if
(
rc
<
0
)
return
-
1
;
return
-
1
;
}
}
free
(
token
);
free
(
token
);
...
...
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