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
8ab137ec
Commit
8ab137ec
authored
Oct 14, 2009
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use getopt rather than homebrew code.
parent
ea464f18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
90 deletions
+80
-90
babeld.c
babeld.c
+80
-90
No files found.
babeld.c
View file @
8ab137ec
...
...
@@ -102,12 +102,11 @@ int
main
(
int
argc
,
char
**
argv
)
{
struct
sockaddr_in6
sin6
;
int
rc
,
fd
,
rfd
,
i
;
int
rc
,
fd
,
rfd
,
i
,
opt
;
time_t
expiry_time
,
source_expiry_time
,
kernel_dump_time
;
char
*
config_file
=
NULL
;
void
*
vrc
;
unsigned
int
seed
;
char
**
arg
;
struct
network
*
net
;
gettime
(
&
now
);
...
...
@@ -127,108 +126,109 @@ main(int argc, char **argv)
parse_address
(
"ff02::cca6:c0f9:e182:5373"
,
protocol_group
,
NULL
);
protocol_port
=
8475
;
#define SHIFT() do { arg++; } while(0)
#define SHIFTE() do { arg++; if(*arg == NULL) goto syntax; } while(0)
arg
=
argv
;
SHIFT
();
while
(
*
arg
&&
(
*
arg
)[
0
]
==
'-'
)
{
if
(
strcmp
(
*
arg
,
"--"
)
==
0
)
{
SHIFTE
();
while
(
1
)
{
opt
=
getopt
(
argc
,
argv
,
"m:p:h:H:i:k:PsS:d:g:lwt:T:c:C:DL:I:"
);
if
(
opt
<
0
)
break
;
}
else
if
(
strcmp
(
*
arg
,
"-m"
)
==
0
)
{
SHIFTE
();
rc
=
parse_address
(
*
arg
,
protocol_group
,
NULL
);
switch
(
opt
)
{
case
'm'
:
rc
=
parse_address
(
optarg
,
protocol_group
,
NULL
);
if
(
rc
<
0
)
goto
syntax
;
goto
usage
;
if
(
protocol_group
[
0
]
!=
0xff
)
{
fprintf
(
stderr
,
"%s is not a multicast address
\n
"
,
*
arg
);
goto
syntax
;
"%s is not a multicast address
\n
"
,
opt
arg
);
goto
usage
;
}
if
(
protocol_group
[
1
]
!=
2
)
{
fprintf
(
stderr
,
"Warning: %s is not a link-local multicast address
\n
"
,
*
arg
);
opt
arg
);
}
}
else
if
(
strcmp
(
*
arg
,
"-p"
)
==
0
)
{
SHIFTE
();
protocol_port
=
atoi
(
*
arg
);
}
else
if
(
strcmp
(
*
arg
,
"-h"
)
==
0
)
{
SHIFTE
();
wireless_hello_interval
=
parse_msec
(
*
arg
);
break
;
case
'p'
:
protocol_port
=
atoi
(
opt
arg
);
break
;
case
'h'
:
wireless_hello_interval
=
parse_msec
(
opt
arg
);
if
(
wireless_hello_interval
<=
0
||
wireless_hello_interval
>
0xFFFF
*
10
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-H"
)
==
0
)
{
SHIFTE
();
wired_hello_interval
=
parse_msec
(
*
arg
);
goto
usage
;
break
;
case
'H'
:
wired_hello_interval
=
parse_msec
(
opt
arg
);
if
(
wired_hello_interval
<=
0
||
wired_hello_interval
>
0xFFFF
*
10
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-i"
)
==
0
)
{
SHIFTE
();
idle_hello_interval
=
parse_msec
(
*
arg
);
goto
usage
;
break
;
case
'i'
:
idle_hello_interval
=
parse_msec
(
opt
arg
);
if
(
idle_hello_interval
<=
0
||
idle_hello_interval
>
0xFFFF
*
10
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-k"
)
==
0
)
{
SHIFTE
();
kernel_metric
=
atoi
(
*
arg
);
goto
usage
;
break
;
case
'k'
:
kernel_metric
=
atoi
(
opt
arg
);
if
(
kernel_metric
<
0
||
kernel_metric
>
0xFFFF
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-P"
)
==
0
)
{
goto
usage
;
break
;
case
'P'
:
parasitic
=
1
;
}
else
if
(
strcmp
(
*
arg
,
"-s"
)
==
0
)
{
break
;
case
's'
:
split_horizon
=
0
;
}
else
if
(
strcmp
(
*
arg
,
"-S"
)
==
0
)
{
SHIFTE
();
state_file
=
*
arg
;
}
else
if
(
strcmp
(
*
arg
,
"-d"
)
==
0
)
{
SHIFTE
();
debug
=
atoi
(
*
arg
);
#ifndef NO_LOCAL_INTERFACE
}
else
if
(
strcmp
(
*
arg
,
"-g"
)
==
0
)
{
SHIFTE
();
local_server_port
=
atoi
(
*
arg
);
break
;
case
'S'
:
state_file
=
optarg
;
break
;
case
'd'
:
debug
=
atoi
(
optarg
);
break
;
case
'g'
:
#ifdef NO_LOCAL_INTERFACE
fprintf
(
stderr
,
"Warning: no local interface in this version.
\n
"
);
#else
local_server_port
=
atoi
(
optarg
);
#endif
}
else
if
(
strcmp
(
*
arg
,
"-l"
)
==
0
)
{
break
;
case
'l'
:
link_detect
=
1
;
}
else
if
(
strcmp
(
*
arg
,
"-w"
)
==
0
)
{
break
;
case
'w'
:
all_wireless
=
1
;
}
else
if
(
strcmp
(
*
arg
,
"-t"
)
==
0
)
{
SHIFTE
();
export_table
=
atoi
(
*
arg
);
break
;
case
't'
:
export_table
=
atoi
(
opt
arg
);
if
(
export_table
<
0
||
export_table
>
0xFFFF
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-T"
)
==
0
)
{
SHIFTE
();
import_table
=
atoi
(
*
arg
);
goto
usage
;
break
;
case
'T'
:
import_table
=
atoi
(
opt
arg
);
if
(
import_table
<
0
||
import_table
>
0xFFFF
)
goto
syntax
;
}
else
if
(
strcmp
(
*
arg
,
"-c"
)
==
0
)
{
SHIFTE
();
config_file
=
*
arg
;
}
else
if
(
strcmp
(
*
arg
,
"-C"
)
==
0
)
{
SHIFTE
();
rc
=
parse_config_from_string
(
*
arg
);
goto
usage
;
break
;
case
'c'
:
config_file
=
opt
arg
;
break
;
case
'C'
:
rc
=
parse_config_from_string
(
opt
arg
);
if
(
rc
<
0
)
{
fprintf
(
stderr
,
"Couldn't parse configuration from command line.
\n
"
);
exit
(
1
);
}
}
else
if
(
strcmp
(
*
arg
,
"-D"
)
==
0
)
{
break
;
case
'D'
:
do_daemonise
=
1
;
}
else
if
(
strcmp
(
*
arg
,
"-L"
)
==
0
)
{
SHIFTE
();
logfile
=
*
arg
;
}
else
if
(
strcmp
(
*
arg
,
"-I"
)
==
0
)
{
SHIFTE
();
pidfile
=
*
arg
;
}
else
{
goto
syntax
;
break
;
case
'L'
:
logfile
=
optarg
;
break
;
case
'I'
:
pidfile
=
optarg
;
break
;
default:
goto
usage
;
}
SHIFT
();
}
...
...
@@ -328,27 +328,17 @@ main(int argc, char **argv)
goto
fail_pid
;
}
if
(
*
arg
)
{
unsigned
char
dummy
[
16
];
rc
=
parse_address
(
*
arg
,
dummy
,
NULL
);
if
(
rc
>=
0
)
{
fprintf
(
stderr
,
"Warning: obsolete router-id given.
\n
"
);
SHIFT
();
}
}
rc
=
finalise_config
();
if
(
rc
<
0
)
{
fprintf
(
stderr
,
"Couldn't finalise configuration.
\n
"
);
goto
fail
;
}
while
(
*
arg
)
{
debugf
(
"Adding network %s.
\n
"
,
*
arg
);
vrc
=
add_network
(
*
arg
,
NULL
);
for
(
i
=
optind
;
i
<
argc
;
i
++
)
{
debugf
(
"Adding network %s.
\n
"
,
argv
[
i
]
);
vrc
=
add_network
(
argv
[
i
]
,
NULL
);
if
(
vrc
==
NULL
)
goto
fail
;
SHIFT
();
}
if
(
networks
==
NULL
)
{
...
...
@@ -775,7 +765,7 @@ main(int argc, char **argv)
debugf
(
"Done.
\n
"
);
return
0
;
syntax
:
usage
:
fprintf
(
stderr
,
"Syntax: %s "
"[-m multicast_address] [-p port] [-S state-file]
\n
"
...
...
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