本文整理汇总了Golang中github.com/krolaw/dhcp4.Packet.HType方法的典型用法代码示例。如果您正苦于以下问题:Golang Packet.HType方法的具体用法?Golang Packet.HType怎么用?Golang Packet.HType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/krolaw/dhcp4.Packet
的用法示例。
在下文中一共展示了Packet.HType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: informReplyPacket
// ReplyPacket creates a reply packet that a Server would send to a client.
// It uses the req Packet param to copy across common/necessary fields to
// associate the reply with the request.
func informReplyPacket(req dhcp4.Packet, mt dhcp4.MessageType, serverID net.IP, options []dhcp4.Option) dhcp4.Packet {
p := dhcp4.NewPacket(dhcp4.BootReply)
p.SetXId(req.XId())
p.SetHType(req.HType())
p[2] = req.HLen() // dhcp4 library does not provide a setter
p.SetFlags(req.Flags())
p.SetCIAddr(req.CIAddr())
p.SetCHAddr(req.CHAddr())
p.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(mt)})
p.AddOption(dhcp4.OptionServerIdentifier, []byte(serverID))
for _, o := range options {
p.AddOption(o.Code, o.Value)
}
p.PadToMinSize()
return p
}