本文整理汇总了Golang中github.com/google/gopacket.PacketBuilder类的典型用法代码示例。如果您正苦于以下问题:Golang PacketBuilder类的具体用法?Golang PacketBuilder怎么用?Golang PacketBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PacketBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: decodeVXLAN
func decodeVXLAN(data []byte, p gopacket.PacketBuilder) error {
vx := &VXLAN{}
// VNI is a 24bit number, Uint32 requires 32 bits
var buf [4]byte
copy(buf[1:], data[4:7])
// RFC 7348 https://tools.ietf.org/html/rfc7348
vx.ValidIDFlag = data[0]&0x08 > 0 // 'I' bit per RFC7348
vx.VNI = binary.BigEndian.Uint32(buf[:]) // VXLAN Network Identifier per RFC7348
// Group Based Policy https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00
vx.GBPExtension = data[0]&0x80 > 0 // 'G' bit per the group policy draft
vx.GBPDontLearn = data[1]&0x40 > 0 // 'D' bit - the egress VTEP MUST NOT learn the source address of the encapsulated frame.
vx.GBPApplied = data[1]&0x80 > 0 // 'A' bit - indicates that the group policy has already been applied to this packet.
vx.GBPGroupPolicyID = binary.BigEndian.Uint16(data[2:4]) // Policy ID as per the group policy draft
// Layer information
const vxlanLength = 8
vx.Contents = data[:vxlanLength]
vx.Payload = data[vxlanLength:]
p.AddLayer(vx)
return p.NextDecoder(LinkTypeEthernet)
}
开发者ID:jesseward,项目名称:gopacket,代码行数:25,代码来源:vxlan.go
示例2: decodeSCTPEmptyLayer
func decodeSCTPEmptyLayer(data []byte, p gopacket.PacketBuilder) error {
sc := &SCTPEmptyLayer{
SCTPChunk: decodeSCTPChunk(data),
}
p.AddLayer(sc)
return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
开发者ID:CNDonny,项目名称:scope,代码行数:7,代码来源:sctp.go
示例3: decodeMach
func decodeMach(data []byte, p gopacket.PacketBuilder) (err error) {
panic("FIXME")
defer errs.PassE(&err)
m := &Mach{}
errs.CheckE(m.DecodeFromBytes(data, p))
p.AddLayer(m)
return p.NextDecoder(m.NextLayerType())
}
开发者ID:ikravets,项目名称:ev,代码行数:8,代码来源:mach.go
示例4: decodeMoldUDP64
func decodeMoldUDP64(data []byte, p gopacket.PacketBuilder) error {
m := &MoldUDP64{}
if err := m.DecodeFromBytes(data, p); err != nil {
return err
}
p.AddLayer(m)
return p.NextDecoder(m.NextLayerType())
}
开发者ID:ikravets,项目名称:ev,代码行数:8,代码来源:moldudp64.go
示例5: decodeSCTPShutdown
func decodeSCTPShutdown(data []byte, p gopacket.PacketBuilder) error {
sc := &SCTPShutdown{
SCTPChunk: decodeSCTPChunk(data),
CumulativeTSNAck: binary.BigEndian.Uint32(data[4:8]),
}
p.AddLayer(sc)
return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
开发者ID:CNDonny,项目名称:scope,代码行数:8,代码来源:sctp.go
示例6: Decode
func (a TomMessageType) Decode(data []byte, p gopacket.PacketBuilder) error {
layer := TomMessageTypeMetadata[a].CreateLayer()
if err := layer.DecodeFromBytes(data, p); err != nil {
return err
}
p.AddLayer(layer)
return p.NextDecoder(layer.NextLayerType())
}
开发者ID:ikravets,项目名称:ev,代码行数:8,代码来源:tom.go
示例7: decodeLoopback
func decodeLoopback(data []byte, p gopacket.PacketBuilder) error {
l := Loopback{}
if err := l.DecodeFromBytes(data, gopacket.NilDecodeFeedback); err != nil {
return err
}
p.AddLayer(&l)
return p.NextDecoder(l.Family)
}
开发者ID:nplanel,项目名称:gopacket,代码行数:8,代码来源:loopback.go
示例8: decodeSCTPCookieEcho
func decodeSCTPCookieEcho(data []byte, p gopacket.PacketBuilder) error {
sc := &SCTPCookieEcho{
SCTPChunk: decodeSCTPChunk(data),
}
sc.Cookie = data[4:sc.Length]
p.AddLayer(sc)
return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
开发者ID:CNDonny,项目名称:scope,代码行数:8,代码来源:sctp.go
示例9: decodeICMPv4
func decodeICMPv4(data []byte, p gopacket.PacketBuilder) error {
i := &ICMPv4{}
err := i.DecodeFromBytes(data, p)
if err != nil {
return err
}
p.AddLayer(i)
return p.NextDecoder(gopacket.LayerTypePayload)
}
开发者ID:CNDonny,项目名称:scope,代码行数:9,代码来源:icmp4.go
示例10: decodeDHCPv4
func decodeDHCPv4(data []byte, p gopacket.PacketBuilder) error {
dhcp := &DHCPv4{}
err := dhcp.DecodeFromBytes(data, p)
if err != nil {
return err
}
p.AddLayer(dhcp)
return p.NextDecoder(gopacket.LayerTypePayload)
}
开发者ID:jesseward,项目名称:gopacket,代码行数:9,代码来源:dhcpv4.go
示例11: decodeVxlan
func decodeVxlan(data []byte, p gopacket.PacketBuilder) error {
v := &VXLAN{BaseLayer: BaseLayer{Contents: data}}
err := v.DecodeFromBytes(data, p)
p.AddLayer(v)
if err != nil {
return err
}
return p.NextDecoder(v.NextLayerType())
}
开发者ID:ccordes-snaproute,项目名称:gopacket,代码行数:9,代码来源:vxlan.go
示例12: decodeIPv6HopByHop
func decodeIPv6HopByHop(data []byte, p gopacket.PacketBuilder) error {
i := &IPv6HopByHop{}
err := i.DecodeFromBytes(data, p)
p.AddLayer(i)
if err != nil {
return err
}
return p.NextDecoder(i.NextHeader)
}
开发者ID:read-later,项目名称:gopacket,代码行数:9,代码来源:ip6.go
示例13: decodeIPSecESP
func decodeIPSecESP(data []byte, p gopacket.PacketBuilder) error {
i := &IPSecESP{
BaseLayer: BaseLayer{data, nil},
SPI: binary.BigEndian.Uint32(data[:4]),
Seq: binary.BigEndian.Uint32(data[4:8]),
Encrypted: data[8:],
}
p.AddLayer(i)
return nil
}
开发者ID:CNDonny,项目名称:scope,代码行数:10,代码来源:ipsec.go
示例14: decodeDNS
// decodeDNS decodes the byte slice into a DNS type. It also
// setups the application Layer in PacketBuilder.
func decodeDNS(data []byte, p gopacket.PacketBuilder) error {
d := &DNS{}
err := d.DecodeFromBytes(data, p)
if err != nil {
return err
}
p.AddLayer(d)
p.SetApplicationLayer(d)
return nil
}
开发者ID:nhooyr,项目名称:gopacket,代码行数:12,代码来源:dns.go
示例15: decodeSCTPEmptyLayer
func decodeSCTPEmptyLayer(data []byte, p gopacket.PacketBuilder) error {
chunk, err := decodeSCTPChunk(data)
if err != nil {
return err
}
sc := &SCTPEmptyLayer{
SCTPChunk: chunk,
}
p.AddLayer(sc)
return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
开发者ID:cdshann,项目名称:minimega,代码行数:11,代码来源:sctp.go
示例16: decodeCapwapDataKeepAlive
func decodeCapwapDataKeepAlive(data []byte, p gopacket.PacketBuilder) error {
length := binary.BigEndian.Uint16(data)
p.AddLayer(&CapwapDataKeepAlive{
BaseLayer: layers.BaseLayer{
Contents: data[:2],
Payload: data[2:length],
},
MessageElementLength: length,
})
return p.NextDecoder(gopacket.LayerTypePayload)
}
开发者ID:skyportsystems,项目名称:suppl,代码行数:11,代码来源:suppl.go
示例17: decodeEthernetCTP
func decodeEthernetCTP(data []byte, p gopacket.PacketBuilder) error {
c := &EthernetCTP{
SkipCount: binary.LittleEndian.Uint16(data[:2]),
BaseLayer: BaseLayer{data[:2], data[2:]},
}
if c.SkipCount%2 != 0 {
return fmt.Errorf("EthernetCTP skip count is odd: %d", c.SkipCount)
}
p.AddLayer(c)
return p.NextDecoder(gopacket.DecodeFunc(decodeEthernetCTPFromFunctionType))
}
开发者ID:nplanel,项目名称:gopacket,代码行数:11,代码来源:ctp.go
示例18: decodingLayerDecoder
func decodingLayerDecoder(d layerDecodingLayer, data []byte, p gopacket.PacketBuilder) error {
err := d.DecodeFromBytes(data, p)
if err != nil {
return err
}
p.AddLayer(d)
next := d.NextLayerType()
if next == gopacket.LayerTypeZero {
return nil
}
return p.NextDecoder(next)
}
开发者ID:CNDonny,项目名称:scope,代码行数:12,代码来源:base.go
示例19: decodePPPoE
// decodePPPoE decodes the PPPoE header (see http://tools.ietf.org/html/rfc2516).
func decodePPPoE(data []byte, p gopacket.PacketBuilder) error {
pppoe := &PPPoE{
Version: data[0] >> 4,
Type: data[0] & 0x0F,
Code: PPPoECode(data[1]),
SessionId: binary.BigEndian.Uint16(data[2:4]),
Length: binary.BigEndian.Uint16(data[4:6]),
}
pppoe.BaseLayer = BaseLayer{data[:6], data[6 : 6+pppoe.Length]}
p.AddLayer(pppoe)
return p.NextDecoder(pppoe.Code)
}
开发者ID:hgGeorg,项目名称:mongo,代码行数:13,代码来源:pppoe.go
示例20: decodeDot11NoFCS
func decodeDot11NoFCS(data []byte, p gopacket.PacketBuilder) error {
payload := append(data, 0, 0, 0, 0)
h := crc32.NewIEEE()
h.Write(data)
binary.LittleEndian.PutUint32(payload[len(data):], h.Sum32())
p.AddLayer(&Dot11NoFCS{
BaseLayer: layers.BaseLayer{
Payload: payload,
},
})
return p.NextDecoder(layers.LayerTypeDot11)
}
开发者ID:skyportsystems,项目名称:suppl,代码行数:12,代码来源:suppl.go
注:本文中的github.com/google/gopacket.PacketBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论