Broadcast address can be specified when adding address.

This commit is contained in:
kishiguro 2017-01-23 00:50:38 -08:00 committed by Vish Ishaya
parent 3c27c1c1e3
commit 6b895203a7
2 changed files with 9 additions and 4 deletions

View File

@ -10,10 +10,11 @@ import (
// include a mask, so it stores the address as a net.IPNet.
type Addr struct {
*net.IPNet
Label string
Flags int
Scope int
Peer *net.IPNet
Label string
Flags int
Scope int
Peer *net.IPNet
Broadcast net.IP
}
// String returns $ip/$netmask $label

View File

@ -90,6 +90,10 @@ func (h *Handle) addrHandle(link Link, addr *Addr, req *nl.NetlinkRequest) error
}
}
if addr.Broadcast != nil {
req.AddData(nl.NewRtAttr(syscall.IFA_BROADCAST, addr.Broadcast))
}
if addr.Label != "" {
labelData := nl.NewRtAttr(syscall.IFA_LABEL, nl.ZeroTerminated(addr.Label))
req.AddData(labelData)