Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adam Osuchowski
Kea
Commits
e9610929
Commit
e9610929
authored
Dec 07, 2011
by
Tomek Mrugalski
🛰
Browse files
[1239] DHCPv4 echo server implemented.
parent
be3e7b88
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
e9610929
...
...
@@ -50,9 +50,12 @@ Dhcpv4Srv::run() {
boost
::
shared_ptr
<
Pkt4
>
query
;
// client's message
boost
::
shared_ptr
<
Pkt4
>
rsp
;
// server's response
#if 1
// uncomment this once ticket 1239 is merged.
query
=
IfaceMgr
::
instance
().
receive4
();
#if ECHO_SERVER
query
->
repack
();
IfaceMgr
::
instance
().
send
(
query
);
continue
;
#endif
if
(
query
)
{
...
...
src/lib/dhcp/pkt4.cc
View file @
e9610929
...
...
@@ -156,6 +156,14 @@ Pkt4::unpack() {
return
(
true
);
}
void
Pkt4
::
repack
()
{
cout
<<
"Convering RX packet to TX packet: "
<<
bufferIn_
.
getLength
()
<<
" bytes."
<<
endl
;
vector
<
uint8_t
>
buf
;
bufferIn_
.
readVector
(
buf
,
bufferIn_
.
getLength
());
bufferOut_
.
writeData
(
&
buf
[
0
],
bufferIn_
.
getLength
());
}
std
::
string
Pkt4
::
toText
()
{
stringstream
tmp
;
...
...
src/lib/dhcp/pkt4.h
View file @
e9610929
...
...
@@ -78,6 +78,14 @@ public:
bool
unpack
();
/// @brief Copies content of input buffer to output buffer.
///
/// This is mostly a diagnostic function. It is being used for sending
/// received packet. Received packet is stored in bufferIn_, but
/// transmitted data is stored in bufferOut_. If we want to send packet
/// that we just received, a copy between those two buffers is necessary.
void
repack
();
/// @brief Returns text representation of the packet.
///
/// This function is useful mainly for debugging.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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