-// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
IfaceMgr::instance().send(packet);
}
+bool
+Dhcpv6Srv::testServerID(const Pkt6Ptr& pkt){
+ OptionCollection server_ids = pkt->getOptions(D6O_SERVERID);
+ // if we find serverid option, lets test it.
+ /// @todo: In case we get message that has ServerID option forbidden
+ /// by the RFC, we will drop this loging DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID
+ /// not RFCViolation. Some things should be double checked here and in sanityCheck
+ if (server_ids.size() == 1){
+ // Let us test received ServerID if it is same as ServerID
+ // which is beeing used by server
+ OptionPtr server_id = pkt->getOption(D6O_SERVERID);
+ if (getServerID()->getData() != server_id->getData()){
+ LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID)
+ .arg(pkt->getName())
+ .arg(pkt->getTransid())
+ .arg(pkt->getIface());
+ return false;
+ }
+ }
+ // retunr True if: no serverid received or ServerIDs matching
+ return true;
+}
+
bool Dhcpv6Srv::run() {
while (!shutdown_) {
/// @todo Calculate actual timeout to the next event (e.g. lease
continue;
}
}
+ // Check received query if it carry ServerID that matches ServerID
+ // that beeing used by the server.
+ if (!testServerID(query)){
+ continue;
+ }
+
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PACKET_RECEIVED)
.arg(query->getName());
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_QUERY_DATA)
return (option_status);
}
-void
-Dhcpv6Srv::testServerid(const Pkt6Ptr& pkt){
- OptionPtr serverid = pkt->getOption(D6O_SERVERID);
-
- // I just want to throw exception when server id's don't mach.
- if (!(getServerID()->getData() == serverid->getData()))
- //if received serverid isn't same with our, drop message
- isc_throw(ServerID_mismatch, "Receievd serverid isn't ours");
-}
-
void
Dhcpv6Srv::sanityCheck(const Pkt6Ptr& pkt, RequirementLevel clientid,
RequirementLevel serverid) {
<< server_ids.size() << "), exactly 1 expected in message "
<< pkt->getName());
}
- // test server received server id to check if that's ours id
- // RFCViolation will be thrown if we didn't get exaclty one server_id so
- // checking server_ids.size() here is pointless.
- testServerid(pkt);
- break;
+ break;
case OPTIONAL:
if (server_ids.size() > 1) {
isc_throw(RFCViolation, "Too many (" << server_ids.size()
<< ") server-id options received in " << pkt->getName());
}
- if (server_ids.size() == 1) {
- // test server received server id to check if that's ours id
- testServerid(pkt);
- }
}
}