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
ISC Open Source Projects
Kea
Commits
69950d29
Commit
69950d29
authored
Nov 28, 2012
by
Marcin Siodelski
Browse files
[2365] Added packOptions and unpackOptions.
parent
8b10f38a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/option.cc
View file @
69950d29
...
...
@@ -114,7 +114,7 @@ Option::pack4(isc::util::OutputBuffer& buf) {
buf
.
writeData
(
&
data_
[
0
],
data_
.
size
());
}
LibDHCP
::
packOptions
(
buf
,
options_
);
packOptions
(
buf
);
}
else
{
isc_throw
(
BadValue
,
"Invalid universe type "
<<
universe_
);
...
...
@@ -131,18 +131,46 @@ void Option::pack6(isc::util::OutputBuffer& buf) {
buf
.
writeData
(
&
data_
[
0
],
data_
.
size
());
}
LibDHCP
::
packOptions
6
(
buf
,
options_
);
packOptions
(
buf
);
}
else
{
isc_throw
(
BadValue
,
"Invalid universe type "
<<
universe_
);
}
return
;
}
void
Option
::
packOptions
(
isc
::
util
::
OutputBuffer
&
buf
)
{
switch
(
universe_
)
{
case
V4
:
LibDHCP
::
packOptions
(
buf
,
options_
);
return
;
case
V6
:
LibDHCP
::
packOptions6
(
buf
,
options_
);
return
;
default:
isc_throw
(
isc
::
BadValue
,
"Invalid universe type "
<<
universe_
);
}
}
void
Option
::
unpack
(
OptionBufferConstIter
begin
,
OptionBufferConstIter
end
)
{
data_
=
OptionBuffer
(
begin
,
end
);
}
void
Option
::
unpackOptions
(
const
OptionBuffer
&
buf
)
{
switch
(
universe_
)
{
case
V4
:
LibDHCP
::
unpackOptions4
(
buf
,
options_
);
return
;
case
V6
:
LibDHCP
::
unpackOptions6
(
buf
,
options_
);
return
;
default:
isc_throw
(
isc
::
BadValue
,
"Invalid universe type "
<<
universe_
);
}
}
uint16_t
Option
::
len
()
{
// Returns length of the complete option (data length + DHCPv4/DHCPv6
// option header)
...
...
src/lib/dhcp/option.h
View file @
69950d29
...
...
@@ -312,6 +312,25 @@ protected:
/// @throw BadValue Universe is not V6.
virtual
void
pack6
(
isc
::
util
::
OutputBuffer
&
buf
);
/// @brief Store sub options in a buffer.
///
/// This method stores all sub-options defined for a particular
/// option in a on-wire format in output buffer provided.
/// This function is called by pack function in this class or
/// derived classes that override pack.
///
/// @param [out] buf output buffer.
void
packOptions
(
isc
::
util
::
OutputBuffer
&
buf
);
/// @brief Builds a collection of sub options from the buffer.
///
/// This method parses the provided buffer and builds a collection
/// of objects representing sub options. This function may throw
/// different exceptions when option assembly fails.
///
/// @param buf buffer to be parsed.
void
unpackOptions
(
const
OptionBuffer
&
buf
);
/// @brief A private method used for option correctness.
///
/// It is used in constructors. In there are any problems detected
...
...
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