summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv6/dhcpv6relay.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go
index d7dc4b9..513d25a 100644
--- a/dhcpv6/dhcpv6relay.go
+++ b/dhcpv6/dhcpv6relay.go
@@ -143,3 +143,27 @@ func (d *DHCPv6Relay) GetInnerMessage() (DHCPv6, error) {
}
}
}
+
+// GetInnerPeerAddr returns the peer address in the inner most relay info
+// header, this is typically the IP address of the client making the request.
+func (r *DHCPv6Relay) GetInnerPeerAddr() (net.IP, error) {
+ var (
+ p DHCPv6
+ err error
+ )
+ p = r
+ hops := r.HopCount()
+ addr := r.PeerAddr()
+ for i := uint8(0); i < hops; i++ {
+ p, err = DecapsulateRelay(p)
+ if err != nil {
+ return nil, err
+ }
+ if p.IsRelay() {
+ addr = p.(*DHCPv6Relay).PeerAddr()
+ } else {
+ return nil, fmt.Errorf("Wrong Hop count")
+ }
+ }
+ return addr, nil
+}