本文整理汇总了Golang中github.com/vmware/vic/lib/dhcp.Packet.ServerIP方法的典型用法代码示例。如果您正苦于以下问题:Golang Packet.ServerIP方法的具体用法?Golang Packet.ServerIP怎么用?Golang Packet.ServerIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/lib/dhcp.Packet
的用法示例。
在下文中一共展示了Packet.ServerIP方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: isCompletePacket
func (c *client) isCompletePacket(p *dhcp.Packet) bool {
complete := !ip.IsUnspecifiedIP(p.YourIP()) &&
!ip.IsUnspecifiedIP(p.ServerIP())
if !complete {
return false
}
for _, param := range c.params {
switch dhcp4.OptionCode(param) {
case dhcp4.OptionSubnetMask:
ones, bits := p.SubnetMask().Size()
if ones == 0 || bits == 0 {
return false
}
case dhcp4.OptionRouter:
if ip.IsUnspecifiedIP(p.Gateway()) {
return false
}
case dhcp4.OptionDomainNameServer:
if len(p.DNS()) == 0 {
return false
}
}
}
if p.LeaseTime().Seconds() == 0 {
return false
}
return true
}
示例2: newClient
func (c *client) newClient(ack *dhcp.Packet) (*dhcp4client.Client, error) {
conn, err := dhcp4client.NewInetSock(dhcp4client.SetRemoteAddr(net.UDPAddr{IP: ack.ServerIP(), Port: 67}))
if err != nil {
return nil, err
}
cl, err := dhcp4client.New(dhcp4client.Connection(conn), dhcp4client.Timeout(c.timeout))
if err != nil {
return nil, err
}
return cl, nil
}
示例3: isCompletePacket
func isCompletePacket(p *dhcp.Packet) bool {
complete := !ip.IsUnspecifiedIP(p.Gateway()) &&
!ip.IsUnspecifiedIP(p.YourIP()) &&
!ip.IsUnspecifiedIP(p.ServerIP())
if !complete {
return false
}
ones, bits := p.SubnetMask().Size()
if ones == 0 || bits == 0 {
return false
}
if p.LeaseTime().Seconds() == 0 {
return false
}
return true
}