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
3344e8b8
Commit
3344e8b8
authored
Dec 27, 2011
by
Tomek Mrugalski
🛰
Browse files
[1230] Changes after review:
- Vector initialization clean-ups - Typo in comment
parent
a9f48f11
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
3344e8b8
...
...
@@ -169,9 +169,8 @@ void Dhcpv4Srv::copyDefaultFields(const boost::shared_ptr<Pkt4>& question,
answer
->
setHops
(
question
->
getHops
());
// copy MAC address
vector
<
uint8_t
>
mac
;
mac
.
resize
(
Pkt4
::
MAX_CHADDR_LEN
);
memcpy
(
&
mac
[
0
],
question
->
getChaddr
(),
Pkt4
::
MAX_CHADDR_LEN
);
vector
<
uint8_t
>
mac
(
question
->
getChaddr
(),
question
->
getChaddr
()
+
Pkt4
::
MAX_CHADDR_LEN
);
answer
->
setHWAddr
(
question
->
getHtype
(),
question
->
getHlen
(),
mac
);
// relay address
...
...
@@ -230,6 +229,7 @@ void Dhcpv4Srv::assignLease(boost::shared_ptr<Pkt4>& msg) {
opt
=
boost
::
shared_ptr
<
Option
>
(
new
Option
(
Option
::
V4
,
DHO_DHCP_LEASE_TIME
));
opt
->
setUint32
(
HARDCODED_LEASE_TIME
);
msg
->
addOption
(
opt
);
// TODO: create Option_IntArray that holds list of integers, similar to Option4_AddrLst
// Subnet mask (type 1)
opt
=
boost
::
shared_ptr
<
Option
>
...
...
@@ -247,8 +247,6 @@ Dhcpv4Srv::processDiscover(boost::shared_ptr<Pkt4>& discover) {
boost
::
shared_ptr
<
Pkt4
>
offer
=
boost
::
shared_ptr
<
Pkt4
>
(
new
Pkt4
(
DHCPOFFER
,
discover
->
getTransid
()));
boost
::
shared_ptr
<
Option
>
opt
;
copyDefaultFields
(
discover
,
offer
);
appendDefaultOptions
(
offer
,
DHCPOFFER
);
appendRequestedOptions
(
offer
);
...
...
@@ -263,29 +261,11 @@ Dhcpv4Srv::processRequest(boost::shared_ptr<Pkt4>& request) {
boost
::
shared_ptr
<
Pkt4
>
ack
=
boost
::
shared_ptr
<
Pkt4
>
(
new
Pkt4
(
DHCPACK
,
request
->
getTransid
()));
boost
::
shared_ptr
<
Option
>
opt
;
copyDefaultFields
(
request
,
ack
);
appendDefaultOptions
(
ack
,
DHCPACK
);
appendRequestedOptions
(
ack
);
// TODO: Implement actual lease assignment here
ack
->
setYiaddr
(
IOAddress
(
HARDCODED_LEASE
));
// IP Address Lease time (type 51)
opt
=
boost
::
shared_ptr
<
Option
>
(
new
Option
(
Option
::
V4
,
DHO_DHCP_LEASE_TIME
));
opt
->
setUint32
(
HARDCODED_LEASE_TIME
);
ack
->
addOption
(
opt
);
// TODO: create Option_IntArray that holds list of integers, similar to Option4_AddrLst
// Subnet mask (type 1)
opt
=
boost
::
shared_ptr
<
Option
>
(
new
Option4AddrLst
(
DHO_SUBNET_MASK
,
IOAddress
(
HARDCODED_NETMASK
)));
ack
->
addOption
(
opt
);
// Router (type 3)
opt
=
boost
::
shared_ptr
<
Option
>
(
new
Option4AddrLst
(
DHO_ROUTERS
,
IOAddress
(
HARDCODED_GATEWAY
)));
ack
->
addOption
(
opt
);
assignLease
(
ack
);
return
(
ack
);
}
...
...
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
3344e8b8
...
...
@@ -111,8 +111,7 @@ TEST_F(Dhcpv4SrvTest, basic) {
TEST_F
(
Dhcpv4SrvTest
,
processDiscover
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
();
vector
<
uint8_t
>
mac
;
mac
.
resize
(
6
);
vector
<
uint8_t
>
mac
(
6
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
mac
[
i
]
=
255
-
i
;
}
...
...
@@ -170,8 +169,7 @@ TEST_F(Dhcpv4SrvTest, processDiscover) {
TEST_F
(
Dhcpv4SrvTest
,
processRequest
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
();
vector
<
uint8_t
>
mac
;
mac
.
resize
(
6
);
vector
<
uint8_t
>
mac
(
6
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
mac
[
i
]
=
i
*
10
;
}
...
...
src/lib/dhcp/pkt4.cc
View file @
3344e8b8
...
...
@@ -172,7 +172,7 @@ Pkt4::unpack() {
size_t
opts_len
=
bufferIn
.
getLength
()
-
bufferIn
.
getPosition
();
vector
<
uint8_t
>
optsBuffer
;
//
fi
st use of readVector
//
Fir
st use of readVector
.
bufferIn
.
readVector
(
optsBuffer
,
opts_len
);
LibDHCP
::
unpackOptions4
(
optsBuffer
,
options_
);
...
...
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