diff options
Diffstat (limited to 'src/lib/dhcp/pkt6.cc')
-rwxr-xr-x | src/lib/dhcp/pkt6.cc | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/lib/dhcp/pkt6.cc b/src/lib/dhcp/pkt6.cc index 54cb1e0483..5b750e7385 100755 --- a/src/lib/dhcp/pkt6.cc +++ b/src/lib/dhcp/pkt6.cc @@ -22,6 +22,7 @@ #include <util/io_utilities.h> #include <exceptions/exceptions.h> #include <dhcp/duid.h> +#include <dhcp/iface_mgr.h> #include <iostream> #include <sstream> @@ -615,7 +616,7 @@ Pkt6::getMACFromIPv6RelayOpt() { if (opt) { const OptionBuffer data = opt->getData(); if (data.size() < 3) { - // This client link address option is trucnated. It's supposed to be + // This client link address option is truncated. It's supposed to be // 2 bytes of link-layer type followed by link-layer address. return (HWAddrPtr()); } @@ -683,5 +684,39 @@ Pkt6::getMACFromDocsisCMTS() { } } +HWAddrPtr +Pkt6::getMACFromRemoteIdRelayOption() { + if (relay_info_.empty()) { + // This is a direct message + return (HWAddrPtr()); + } + + // Get remote-id option from a relay agent closest to the client + OptionPtr opt = getAnyRelayOption(D6O_REMOTE_ID, RELAY_GET_FIRST); + if (opt) { + const OptionBuffer data = opt->getData(); + if (data.size() < 5) { + // This remote-id option is truncated. It's supposed to be + // 4 bytes of enterprise-number followed by remote-id. + return (HWAddrPtr()); + } + + // Let's get the interface this packet was received on. We need it to get + // the hardware type. + Iface* iface = IfaceMgr::instance().getIface(iface_); + uint16_t hwtype = 0; // not specified + + // If we get the interface HW type, great! If not, let's not panic. + if (iface) { + hwtype = iface->getHWType(); + } + + // Skip the initial 4 bytes which are enterprise-number. + return (HWAddrPtr(new HWAddr(&data[0] + 4, data.size() - 4, hwtype))); + } else { + return (HWAddrPtr()); + } +} + } // end of isc::dhcp namespace } // end of isc namespace |