BIND 10 trac3186, updated. 11ec18030d858c037a862cc806a0329d3271d53a [3186] user_chk hook selects subnet4 based on user registry.
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Oct 14 22:45:36 UTC 2013
The branch, trac3186 has been updated
via 11ec18030d858c037a862cc806a0329d3271d53a (commit)
from c95421cd2f4719b166700bac51361254483787ef (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 11ec18030d858c037a862cc806a0329d3271d53a
Author: Thomas Markwalder <tmark at isc.org>
Date: Mon Oct 14 18:43:45 2013 -0400
[3186] user_chk hook selects subnet4 based on user registry.
Interrim checkin. Subnet4 selection is working.
-----------------------------------------------------------------------
Summary of changes:
src/hooks/dhcp/user_chk/subnet_select_co.cc | 37 ++++++++++++++++++---------
1 file changed, 25 insertions(+), 12 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/hooks/dhcp/user_chk/subnet_select_co.cc b/src/hooks/dhcp/user_chk/subnet_select_co.cc
index 83e5f2c..d6b1e3d 100644
--- a/src/hooks/dhcp/user_chk/subnet_select_co.cc
+++ b/src/hooks/dhcp/user_chk/subnet_select_co.cc
@@ -2,6 +2,7 @@
#include <dhcp/pkt4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/pkt6.h>
+#include <dhcpsrv/subnet.h>
#include <user_registry.h>
extern UserRegistryPtr user_registry;
@@ -32,18 +33,24 @@ int subnet4_select(CalloutHandle& handle) {
// Look for the user.
UserPtr registered_user = user_registry->findUser(*hwaddr);
if (registered_user) {
- //@todo give them an unrestricted subnet
- std::cout << "DHCP4 User is registered! :"
+ // User is in the registry, so leave the pre-selected
+ // subnet alone.
+ std::cout << "DHCP4 User is registered! :"
<< registered_user->getUserId() << std::endl;
} else {
- //@todo give them a restricted subnet
- std::cout << "DHCP4 User is NOT registered! :"
+ // User is not in the registry, so assign them to
+ // the last subnet in the collection. By convention
+ // we are assuming this is the restricted subnet.
+ std::cout << "DHCP4 User is NOT registered! :"
<< hwaddr->toText() << std::endl;
+ const isc::dhcp::Subnet4Collection *subnets = NULL;
+ handle.getArgument("subnet4collection", subnets);
+ handle.setArgument("subnet4", subnets->back());
}
} catch (const std::exception& ex) {
- std::cout << "Exception in subnet4_select callout:" << ex.what()
+ std::cout << "Exception in subnet4_select callout:" << ex.what()
<< std::endl;
-
+
}
return (0);
@@ -74,18 +81,24 @@ int subnet6_select(CalloutHandle& handle) {
// Look for the user.
UserPtr registered_user = user_registry->findUser(*duid);
if (registered_user) {
- //@todo give them an unrestricted subnet
- std::cout << "DHCP6 User is registered! :"
+ // User is in the registry, so leave the pre-selected
+ // subnet alone.
+ std::cout << "DHCP6 User is registered! :"
<< registered_user->getUserId() << std::endl;
} else {
- //@todo give them a restricted subnet
- std::cout << "DHCP6 User is NOT registered! :"
+ // User is not in the registry, so assign them to
+ // the last subnet in the collection. By convention
+ // we are assuming this is the restricted subnet.
+ std::cout << "DHCP6 User is NOT registered! :"
<< duid->toText() << std::endl;
+ const isc::dhcp::Subnet6Collection *subnets = NULL;
+ handle.getArgument("subnet6collection", subnets);
+ handle.setArgument("subnet6", subnets->back());
}
} catch (const std::exception& ex) {
- std::cout << "Exception in subnet6_select callout:" << ex.what()
+ std::cout << "Exception in subnet6_select callout:" << ex.what()
<< std::endl;
-
+
}
return (0);
More information about the bind10-changes
mailing list