Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
b524d5e0
Commit
b524d5e0
authored
Jun 22, 2012
by
Tomek Mrugalski
🛰
Browse files
[1708] msgq connection in dhcp{4,6} is now optional.
parent
ed478d28
Changes
5
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
b524d5e0
451. [func] tomek
b10-dhcp6: DHCPv6 server component is now integrated into
BIND10 framework. It can be started from BIND10 (using bindctl)
and can receive commands. The only supported command for now
is 'Dhcp6 shutdown'.
b10-dhcp4: Command line-switch '-s' to disable msgq was added.
b10-dhcp6: Command line-switch '-s' to disable msgq was added.
(Trac #1708, git tbd)
450. [func]* tomek
b10-dhcp4: DHCPv4 server component is now integrated into
BIND10 framework. It can be started from BIND10 (using bindctl)
...
...
src/bin/dhcp4/main.cc
View file @
b524d5e0
...
...
@@ -39,6 +39,7 @@ usage() {
cerr
<<
"Usage: b10-dhcp4 [-v]"
<<
endl
;
cerr
<<
"
\t
-v: verbose output"
<<
endl
;
cerr
<<
"
\t
-s: stand-alone mode (don't connect to BIND10)"
<<
endl
;
cerr
<<
"
\t
-p number: specify non-standard port number 1-65535 "
<<
"(useful for testing only)"
<<
endl
;
exit
(
EXIT_FAILURE
);
...
...
@@ -51,13 +52,17 @@ main(int argc, char* argv[]) {
bool
verbose_mode
=
false
;
// should server be verbose?
int
port_number
=
DHCP4_SERVER_PORT
;
// The default. any other values are
// useful for testing only.
bool
stand_alone
=
false
;
// should be connect to BIND10 msgq?
while
((
ch
=
getopt
(
argc
,
argv
,
"vp:"
))
!=
-
1
)
{
while
((
ch
=
getopt
(
argc
,
argv
,
"v
s
p:"
))
!=
-
1
)
{
switch
(
ch
)
{
case
'v'
:
verbose_mode
=
true
;
isc
::
log
::
denabled
=
true
;
break
;
case
's'
:
stand_alone
=
true
;
break
;
case
'p'
:
port_number
=
strtol
(
optarg
,
NULL
,
10
);
if
(
port_number
==
0
)
{
...
...
@@ -77,8 +82,9 @@ main(int argc, char* argv[]) {
(
verbose_mode
?
isc
::
log
::
DEBUG
:
isc
::
log
::
INFO
),
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
);
cout
<<
"b10-dhcp4: My pid="
<<
getpid
()
<<
", binding to port "
<<
port_number
<<
", verbose "
<<
(
verbose_mode
?
"yes"
:
"no"
)
<<
endl
;
cout
<<
"b10-dhcp4: My pid="
<<
getpid
()
<<
", binding to port "
<<
port_number
<<
", verbose "
<<
(
verbose_mode
?
"yes"
:
"no"
)
<<
", stand-alone="
<<
(
stand_alone
?
"yes"
:
"no"
)
<<
endl
;
if
(
argc
-
optind
>
0
)
{
usage
();
...
...
@@ -92,6 +98,20 @@ main(int argc, char* argv[]) {
/// @todo: pass verbose to the actul server once logging is implemented
ControlledDhcpv4Srv
*
server
=
new
ControlledDhcpv4Srv
(
port_number
);
if
(
!
stand_alone
)
{
try
{
server
->
establishSession
();
}
catch
(
const
std
::
exception
&
ex
)
{
cerr
<<
"Failed to establish BIND10 session. "
"Running in stand-alone mode:"
<<
ex
.
what
()
<<
endl
;
// Let's continue. It is useful to have the ability to run
// DHCP server in stand-alone mode, e.g. for testing
}
}
else
{
cout
<<
"Skipping connection to the BIND10 msgq."
<<
endl
;
}
server
->
run
();
delete
server
;
server
=
NULL
;
...
...
src/bin/dhcp4/tests/dhcp4_test.py
View file @
b524d5e0
...
...
@@ -166,5 +166,18 @@ class TestDhcpv4Daemon(unittest.TestCase):
# Check that there is an error message about invalid port number printed on stderr
self
.
assertEqual
(
str
(
output
).
count
(
"opening sockets on port 10057"
),
1
)
def
test_skip_msgq
(
self
):
print
(
"Check that connection to BIND10 msgq can be disabled."
)
(
returncode
,
output
,
error
)
=
self
.
runDhcp4
([
'../b10-dhcp4'
,
'-s'
,
'-p'
,
'10057'
])
# When invalid port number is specified, return code must not be success
# TODO: Temporarily commented out as socket binding on systems that do not have
# interface detection implemented currently fails.
# self.assertTrue(returncode == 0)
# Check that there is an error message about invalid port number printed on stderr
self
.
assertEqual
(
str
(
output
).
count
(
"Skipping connection to the BIND10 msgq."
),
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
src/bin/dhcp6/main.cc
View file @
b524d5e0
...
...
@@ -39,6 +39,7 @@ usage() {
cerr
<<
"Usage: b10-dhcp6 [-v]"
<<
endl
;
cerr
<<
"
\t
-v: verbose output"
<<
endl
;
cerr
<<
"
\t
-s: stand-alone mode (don't connect to BIND10)"
<<
endl
;
cerr
<<
"
\t
-p number: specify non-standard port number 1-65535 "
<<
"(useful for testing only)"
<<
endl
;
exit
(
EXIT_FAILURE
);
...
...
@@ -51,13 +52,17 @@ main(int argc, char* argv[]) {
int
port_number
=
DHCP6_SERVER_PORT
;
// The default. Any other values are
// useful for testing only.
bool
verbose_mode
=
false
;
// Should server be verbose?
bool
stand_alone
=
false
;
// should be connect to BIND10 msgq?
while
((
ch
=
getopt
(
argc
,
argv
,
"vp:"
))
!=
-
1
)
{
while
((
ch
=
getopt
(
argc
,
argv
,
"v
s
p:"
))
!=
-
1
)
{
switch
(
ch
)
{
case
'v'
:
verbose_mode
=
true
;
isc
::
log
::
denabled
=
true
;
break
;
case
's'
:
stand_alone
=
true
;
break
;
case
'p'
:
port_number
=
strtol
(
optarg
,
NULL
,
10
);
if
(
port_number
==
0
)
{
...
...
@@ -78,7 +83,8 @@ main(int argc, char* argv[]) {
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
);
cout
<<
"b10-dhcp6: My pid="
<<
getpid
()
<<
", binding to port "
<<
port_number
<<
", verbose "
<<
(
verbose_mode
?
"yes"
:
"no"
)
<<
endl
;
<<
port_number
<<
", verbose "
<<
(
verbose_mode
?
"yes"
:
"no"
)
<<
", stand-alone="
<<
(
stand_alone
?
"yes"
:
"no"
)
<<
endl
;
if
(
argc
-
optind
>
0
)
{
usage
();
...
...
@@ -90,18 +96,26 @@ main(int argc, char* argv[]) {
cout
<<
"b10-dhcp6: Initiating DHCPv6 server operation."
<<
endl
;
/// @todo: pass verbose to the actual server once logging is implemented
ControlledDhcpv6Srv
*
server
=
new
ControlledDhcpv6Srv
(
port_number
);
if
(
!
stand_alone
)
{
try
{
server
->
establishSession
();
}
catch
(
const
std
::
exception
&
ex
)
{
cerr
<<
"Failed to establish BIND10 session. "
"Running in stand-alone mode:"
<<
ex
.
what
()
<<
endl
;
// Let's continue. It is useful to have the ability to run
// DHCP server in stand-alone mode, e.g. for testing
}
}
else
{
cout
<<
"Skipping connection to the BIND10 msgq."
<<
endl
;
}
server
->
run
();
delete
server
;
server
=
NULL
;
cout
<<
"[b10-dhcp6] Initiating DHCPv6 operation."
<<
endl
;
/// @todo: pass verbose to the actual server once logging is implemented
Dhcpv6Srv
*
srv
=
new
Dhcpv6Srv
(
port_number
);
srv
->
run
();
}
catch
(
const
std
::
exception
&
ex
)
{
cerr
<<
"[b10-dhcp6] Server failed: "
<<
ex
.
what
()
<<
endl
;
ret
=
EXIT_FAILURE
;
...
...
src/bin/dhcp6/tests/dhcp6_test.py
View file @
b524d5e0
...
...
@@ -158,7 +158,7 @@ class TestDhcpv6Daemon(unittest.TestCase):
def
test_portnumber_nonroot
(
self
):
print
(
"Check that specifying unprivileged port number will work."
)
(
returncode
,
output
,
error
)
=
self
.
runCommand
([
'../b10-dhcp6'
,
'-p'
,
'10
0
57'
])
(
returncode
,
output
,
error
)
=
self
.
runCommand
([
'../b10-dhcp6'
,
'-p'
,
'105
4
7'
])
# When invalid port number is specified, return code must not be success
# TODO: Temporarily commented out as socket binding on systems that do not have
...
...
@@ -166,7 +166,21 @@ class TestDhcpv6Daemon(unittest.TestCase):
# self.assertTrue(returncode == 0)
# Check that there is a message on stdout about opening proper port
self
.
assertEqual
(
str
(
output
).
count
(
"opening sockets on port 10057"
),
1
)
self
.
assertEqual
(
str
(
output
).
count
(
"opening sockets on port 10547"
),
1
)
def
test_skip_msgq
(
self
):
print
(
"Check that connection to BIND10 msgq can be disabled."
)
(
returncode
,
output
,
error
)
=
self
.
runDhcp4
([
'../b10-dhcp6'
,
'-s'
,
'-p'
,
'10547'
])
# When invalid port number is specified, return code must not be success
# TODO: Temporarily commented out as socket binding on systems that do not have
# interface detection implemented currently fails.
# self.assertTrue(returncode == 0)
# Check that there is an error message about invalid port number printed on stderr
self
.
assertEqual
(
str
(
output
).
count
(
"Skipping connection to the BIND10 msgq."
),
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Supports
Markdown
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