From d7e60a8310885746d83ed785f47ef575aba185ba Mon Sep 17 00:00:00 2001 From: Nicolas C Date: Wed, 1 Apr 2015 09:22:08 +0200 Subject: [PATCH 1/2] Add "query4" argument to hook point pkt4_send This allows the user hook library to perform correlation between the response packet about to be sent back and the corresponding query packet. (note: to be consistent, the same change should be applied to pkt6_send. I did not do it because I cannot test it). --- src/bin/dhcp4/dhcp4_hooks.dox | 5 +++-- src/bin/dhcp4/dhcp4_srv.cc | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/dhcp4/dhcp4_hooks.dox b/src/bin/dhcp4/dhcp4_hooks.dox index 4cd6e42b59..cc1b5f127d 100644 --- a/src/bin/dhcp4/dhcp4_hooks.dox +++ b/src/bin/dhcp4/dhcp4_hooks.dox @@ -176,16 +176,17 @@ packet processing. Hook points that are not specific to packet processing - @b Arguments: - name: @b response4, type: isc::dhcp::Pkt4Ptr, direction: in/out + - name: @b query4, type: isc::dhcp::Pkt4Ptr, direction: in - @b Description: this callout is executed when server's response - is about to be sent back to the client. The sole argument - response4 - + is about to be sent back to the client. The argument response4 contains a pointer to an isc::dhcp::Pkt4 object that contains the packet, with source and destination addresses set, interface over which it will be sent, and a list of all options and relay information. All fields of the Pkt4 object can be modified at this time, except buffer_out_. (This is scratch space used for constructing the packet after all pkt4_send callouts are complete, so any changes to that field will - be overwritten.) + be overwritten.)\n\n - Skip flag action: if any callout sets the skip flag, the server will not construct raw buffer. The expectation is that if the callout diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 914e46ed13..aa668d2ff6 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -527,6 +527,9 @@ Dhcpv4Srv::run() { // Set our response callout_handle->setArgument("response4", rsp); + // Also pass the corresponding query packet as argument + callout_handle->setArgument("query4", query); + // Call all installed callouts HooksManager::callCallouts(hook_index_pkt4_send_, *callout_handle); From d6fff287a240bf87078d0f49cdd93a1195f69c94 Mon Sep 17 00:00:00 2001 From: Nicolas C Date: Wed, 1 Apr 2015 09:22:57 +0200 Subject: [PATCH 2/2] Document the change --- src/bin/dhcp4/dhcp4_hooks.dox | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bin/dhcp4/dhcp4_hooks.dox b/src/bin/dhcp4/dhcp4_hooks.dox index cc1b5f127d..e286a6d479 100644 --- a/src/bin/dhcp4/dhcp4_hooks.dox +++ b/src/bin/dhcp4/dhcp4_hooks.dox @@ -187,6 +187,9 @@ packet processing. Hook points that are not specific to packet processing (This is scratch space used for constructing the packet after all pkt4_send callouts are complete, so any changes to that field will be overwritten.)\n\n + The argument query4 contains a pointer to the corresponding query packet + (allowing to perform correlation between response and query). This object + cannot be modified. - Skip flag action: if any callout sets the skip flag, the server will not construct raw buffer. The expectation is that if the callout