/// @return 0 upon success, non-zero otherwise.
int buffer4_receive(CalloutHandle& handle) {
CalloutHandle::CalloutNextStep status = handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_DROP ||
- status == CalloutHandle::NEXT_STEP_SKIP) {
+ if (status == CalloutHandle::NEXT_STEP_DROP) {
return (0);
}
handle.getArgument("query4", query);
try {
- // Unpack it (TODO check if it was already unpacked).
- query->unpack();
+ if (handle.getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
+ query->unpack();
+ }
// Not DHCP query nor BOOTP response?
if ((query->getType() == DHCP_NOTYPE) &&
/// @return 0 upon success, non-zero otherwise
int pkt4_send(CalloutHandle& handle) {
CalloutHandle::CalloutNextStep status = handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_DROP ||
- status == CalloutHandle::NEXT_STEP_SKIP) {
+ if (status == CalloutHandle::NEXT_STEP_DROP) {
return (0);
}
handle.getArgument("query4", query);
handle.getArgument("response4", response);
+ if (status == CalloutHandle::NEXT_STEP_SKIP) {
+ isc_throw(InvalidOperation, "packet pack already handled");
+ }
+
try {
impl->process<Pkt4Ptr>(Option::V4, query, response);
} catch (const std::exception& ex) {
/// @return 0 upon success, non-zero otherwise
int pkt6_send(CalloutHandle& handle) {
CalloutHandle::CalloutNextStep status = handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_DROP ||
- status == CalloutHandle::NEXT_STEP_SKIP) {
+ if (status == CalloutHandle::NEXT_STEP_DROP) {
return (0);
}
return (0);
}
+ if (status == CalloutHandle::NEXT_STEP_SKIP) {
+ isc_throw(InvalidOperation, "packet pack already handled");
+ }
+
// Get the parameters.
Pkt6Ptr query;
Pkt6Ptr response;
Pkt4Ptr query4;
callout_handle.getArgument("query4", query4);
- bool unpack = true;
- CalloutHandle::CalloutNextStep status = callout_handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_SKIP) {
- unpack = false;
- }
-
/// @todo Add unit tests to verify the behavior for different
/// malformed packets.
try {
// We have to unpack the query to get access into HW address which is
// used to load balance the packet.
- if (unpack) {
+ if (callout_handle.getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
query4->unpack();
}
Pkt6Ptr query6;
callout_handle.getArgument("query6", query6);
- bool unpack = true;
- CalloutHandle::CalloutNextStep status = callout_handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_SKIP) {
- unpack = false;
- }
-
/// @todo Add unit tests to verify the behavior for different
/// malformed packets.
try {
// We have to unpack the query to get access into DUID which is
// used to load balance the packet.
- if (unpack) {
+ if (callout_handle.getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
query6->unpack();
}
/// @return 0 upon success, non-zero otherwise.
int pkt4_send(CalloutHandle& handle) {
CalloutHandle::CalloutNextStep status = handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_DROP ||
- status == CalloutHandle::NEXT_STEP_SKIP) {
+ if (status == CalloutHandle::NEXT_STEP_DROP) {
return (0);
}
+ if (status == CalloutHandle::NEXT_STEP_SKIP) {
+ isc_throw(InvalidOperation, "packet pack already handled");
+ }
+
try {
Pkt4Ptr response;
handle.getArgument("response4", response);
/// @return 0 upon success, non-zero otherwise.
int pkt6_send(CalloutHandle& handle) {
CalloutHandle::CalloutNextStep status = handle.getStatus();
- if (status == CalloutHandle::NEXT_STEP_DROP ||
- status == CalloutHandle::NEXT_STEP_SKIP) {
+ if (status == CalloutHandle::NEXT_STEP_DROP) {
return (0);
}
+ if (status == CalloutHandle::NEXT_STEP_SKIP) {
+ isc_throw(InvalidOperation, "packet pack already handled");
+ }
+
try {
Pkt6Ptr response;
handle.getArgument("response6", response);
@code
// Get the current setting of the next step status.
- CalloutHandle::CalloutNextStep status = handle.getStatus();
+ auto status = handle.getStatus();
if (status == CalloutHandle::NEXT_STEP_DROP)
// Do something...
set, do not pack/unpack the packet (other library, or even the same library, if
loaded multiple times, has done it already). Some libraries might also need to
throw exceptions in such cases because they need to perform specific actions before
-pack/unpack, which have no effect if pack/unpack is done previously by some other
-library.
+pack/unpack (eg. addOption/delOption before pack action), which have no effect if
+pack/unpack action is done previously by some other library.
As stated before, the order of loading libraries is crucial in achieving the
desired behavior, so please read @ref hooksdgMultipleLibraries when configuring
handle.setStatus(CalloutHandle::NEXT_STEP_SKIP);
// Check the status state.
-CalloutHandle::CalloutNextStep status = handle.getStatus();
+auto status = handle.getStatus();
if (status == CalloutHandle::NEXT_STEP_SKIP) {
...
}