本文整理匯總了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
}