當前位置: 首頁>>代碼示例>>Golang>>正文


Golang PacketBuilder.AddLayer方法代碼示例

本文整理匯總了Golang中code/google/com/p/gopacket.PacketBuilder.AddLayer方法的典型用法代碼示例。如果您正苦於以下問題:Golang PacketBuilder.AddLayer方法的具體用法?Golang PacketBuilder.AddLayer怎麽用?Golang PacketBuilder.AddLayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/google/com/p/gopacket.PacketBuilder的用法示例。


在下文中一共展示了PacketBuilder.AddLayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: decodeSCTPEmptyLayer

func decodeSCTPEmptyLayer(data []byte, p gopacket.PacketBuilder) error {
	sc := &SCTPEmptyLayer{
		SCTPChunk: decodeSCTPChunk(data),
	}
	p.AddLayer(sc)
	return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
開發者ID:pombredanne,項目名稱:geard,代碼行數:7,代碼來源:sctp.go

示例2: decodeSCTPChunkTypeUnknown

func decodeSCTPChunkTypeUnknown(data []byte, p gopacket.PacketBuilder) error {
	sc := &SCTPUnknownChunkType{SCTPChunk: decodeSCTPChunk(data)}
	sc.bytes = data[:sc.ActualLength]
	p.AddLayer(sc)
	p.SetErrorLayer(sc)
	return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix))
}
開發者ID:pombredanne,項目名稱:geard,代碼行數:7,代碼來源:sctp.go

示例3: 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:pombredanne,項目名稱:geard,代碼行數:8,代碼來源:sctp.go

示例4: 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:pombredanne,項目名稱:geard,代碼行數:8,代碼來源:sctp.go

示例5: decodeLinuxSLL

func decodeLinuxSLL(data []byte, p gopacket.PacketBuilder) error {
	sll := &LinuxSLL{}
	if err := sll.DecodeFromBytes(data, p); err != nil {
		return err
	}
	p.AddLayer(sll)
	p.SetLinkLayer(sll)
	return p.NextDecoder(sll.EthernetType)
}
開發者ID:dazer-chen,項目名稱:gopacket,代碼行數:9,代碼來源:linux_sll.go

示例6: 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:dazer-chen,項目名稱:gopacket,代碼行數:9,代碼來源:ip6.go

示例7: 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:dazer-chen,項目名稱:gopacket,代碼行數:10,代碼來源:ipsec.go

示例8: decodeIPv4

func decodeIPv4(data []byte, p gopacket.PacketBuilder) error {
	ip := &IPv4{}
	err := ip.DecodeFromBytes(data, p)
	p.AddLayer(ip)
	p.SetNetworkLayer(ip)
	if err != nil {
		return err
	}
	return p.NextDecoder(ip.NextLayerType())
}
開發者ID:dazer-chen,項目名稱:gopacket,代碼行數:10,代碼來源:ip4.go

示例9: decodeEthernet

func decodeEthernet(data []byte, p gopacket.PacketBuilder) error {
	eth := &Ethernet{}
	err := eth.DecodeFromBytes(data, p)
	if err != nil {
		return err
	}
	p.AddLayer(eth)
	p.SetLinkLayer(eth)
	return p.NextDecoder(eth.EthernetType)
}
開發者ID:dazer-chen,項目名稱:gopacket,代碼行數:10,代碼來源:ethernet.go

示例10: decodeUDP

func decodeUDP(data []byte, p gopacket.PacketBuilder) error {
	udp := &UDP{}
	err := udp.DecodeFromBytes(data, p)
	p.AddLayer(udp)
	p.SetTransportLayer(udp)
	if err != nil {
		return err
	}
	return p.NextDecoder(gopacket.LayerTypePayload)
}
開發者ID:jcantrill,項目名稱:geard,代碼行數:10,代碼來源:udp.go

示例11: decodeIPSecAH

func decodeIPSecAH(data []byte, p gopacket.PacketBuilder) error {
	i := &IPSecAH{
		ipv6ExtensionBase: decodeIPv6ExtensionBase(data),
		Reserved:          binary.BigEndian.Uint16(data[2:4]),
		SPI:               binary.BigEndian.Uint32(data[4:8]),
		Seq:               binary.BigEndian.Uint32(data[8:12]),
	}
	i.AuthenticationData = i.Contents[12:]
	p.AddLayer(i)
	return p.NextDecoder(i.NextHeader)
}
開發者ID:dazer-chen,項目名稱:gopacket,代碼行數:11,代碼來源:ipsec.go

示例12: decodeMPLS

func decodeMPLS(data []byte, p gopacket.PacketBuilder) error {
	decoded := binary.BigEndian.Uint32(data[:4])
	p.AddLayer(&MPLS{
		Label:        decoded >> 12,
		TrafficClass: uint8(decoded>>9) & 0x7,
		StackBottom:  decoded&0x100 != 0,
		TTL:          uint8(decoded),
		BaseLayer:    BaseLayer{data[:4], data[4:]},
	})
	return p.NextDecoder(MPLSPayloadDecoder)
}
開發者ID:jcantrill,項目名稱:geard,代碼行數:11,代碼來源:mpls.go

示例13: 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:dazer-chen,項目名稱:gopacket,代碼行數:11,代碼來源:ctp.go

示例14: 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:dazer-chen,項目名稱:gopacket,代碼行數:12,代碼來源:base.go

示例15: decodeFDDI

func decodeFDDI(data []byte, p gopacket.PacketBuilder) error {
	f := &FDDI{
		FrameControl: FDDIFrameControl(data[0] & 0xF8),
		Priority:     data[0] & 0x07,
		SrcMAC:       net.HardwareAddr(data[1:7]),
		DstMAC:       net.HardwareAddr(data[7:13]),
		BaseLayer:    BaseLayer{data[:13], data[13:]},
	}
	p.SetLinkLayer(f)
	p.AddLayer(f)
	return p.NextDecoder(f.FrameControl)
}
開發者ID:dazer-chen,項目名稱:gopacket,代碼行數:12,代碼來源:fddi.go


注:本文中的code/google/com/p/gopacket.PacketBuilder.AddLayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。