Пример #1
0
Файл: tom.go Проект: ikravets/ev
func init() {
	layerTypes := make([]gopacket.LayerType, 0, 256)
	for i := 0; i < 256; i++ {
		if TomMessageTypeNames[i] == "" {
			continue
		}
		tomMessageType := TomMessageType(i)
		layerTypeMetadata := gopacket.LayerTypeMetadata{
			Name:    TomMessageTypeNames[i],
			Decoder: tomMessageType,
		}
		layerType := gopacket.RegisterLayerType(TOM_LAYERS_BASE_NUM+i, layerTypeMetadata)
		layerTypes = append(layerTypes, layerType)
		creator := TomMessageCreators[i]
		createLayer := func() TomMessage {
			m := creator()
			m.Base().Type = tomMessageType
			return m
		}
		TomMessageTypeMetadata[i] = EnumMessageTypeMetadata{
			Name:        TomMessageTypeNames[i],
			LayerType:   layerType,
			CreateLayer: createLayer,
		}
	}
	for i := 0; i < 256; i++ {
		if TomMessageTypeMetadata[i].Name == "" {
			// unknown message type
			TomMessageTypeMetadata[i] = TomMessageTypeMetadata[TomMessageTypeUnknown]
		}
	}
	LayerClassTom = gopacket.NewLayerClass(layerTypes)
}
Пример #2
0
func init() {
	layerTypes := make([]gopacket.LayerType, 0, 256)
	for i := 0; i < 256; i++ {
		if IttoMessageTypeNames[i] == "" {
			continue
		}
		ittoMessageType := IttoMessageType(i)
		layerTypeMetadata := gopacket.LayerTypeMetadata{
			Name:    IttoMessageTypeNames[i],
			Decoder: ittoMessageType,
		}
		layerType := gopacket.RegisterLayerType(ITTO_LAYERS_BASE_NUM+i, layerTypeMetadata)
		layerTypes = append(layerTypes, layerType)
		creator := IttoMessageCreators[i]
		createLayer := func() IttoMessage {
			m := creator()
			m.Base().Type = ittoMessageType
			return m
		}
		IttoMessageTypeMetadata[i] = EnumMessageTypeMetadata{
			Name:        IttoMessageTypeNames[i],
			IsShort:     IttoMessageIsShort[i],
			LayerType:   layerType,
			CreateLayer: createLayer,
		}
	}
	for i := 0; i < 256; i++ {
		if IttoMessageTypeMetadata[i].Name == "" {
			// unknown message type
			IttoMessageTypeMetadata[i] = IttoMessageTypeMetadata[IttoMessageTypeUnknown]
		}
	}
	LayerClassItto = gopacket.NewLayerClass(layerTypes)
}
Пример #3
0
	LayerTypeUSBControl                  = gopacket.RegisterLayerType(110, gopacket.LayerTypeMetadata{Name: "USBControl", Decoder: gopacket.DecodeFunc(decodeUSBControl)})
	LayerTypeUSBInterrupt                = gopacket.RegisterLayerType(111, gopacket.LayerTypeMetadata{Name: "USBInterrupt", Decoder: gopacket.DecodeFunc(decodeUSBInterrupt)})
	LayerTypeUSBBulk                     = gopacket.RegisterLayerType(112, gopacket.LayerTypeMetadata{Name: "USBBulk", Decoder: gopacket.DecodeFunc(decodeUSBBulk)})
	LayerTypeLinuxSLL                    = gopacket.RegisterLayerType(113, gopacket.LayerTypeMetadata{Name: "Linux SLL", Decoder: gopacket.DecodeFunc(decodeLinuxSLL)})
	LayerTypeSFlow                       = gopacket.RegisterLayerType(114, gopacket.LayerTypeMetadata{Name: "SFlow", Decoder: gopacket.DecodeFunc(decodeSFlow)})
	LayerTypePrismHeader                 = gopacket.RegisterLayerType(115, gopacket.LayerTypeMetadata{Name: "Prism monitor mode header", Decoder: gopacket.DecodeFunc(decodePrismHeader)})
	LayerTypeVXLAN                       = gopacket.RegisterLayerType(116, gopacket.LayerTypeMetadata{Name: "VXLAN", Decoder: gopacket.DecodeFunc(decodeVXLAN)})
	LayerTypeNTP                         = gopacket.RegisterLayerType(117, gopacket.LayerTypeMetadata{Name: "NTP", Decoder: gopacket.DecodeFunc(decodeNTP)})
	LayerTypeDHCPv4                      = gopacket.RegisterLayerType(118, gopacket.LayerTypeMetadata{Name: "DHCPv4", Decoder: gopacket.DecodeFunc(decodeDHCPv4)})
	LayerTypeVRRP                        = gopacket.RegisterLayerType(119, gopacket.LayerTypeMetadata{Name: "VRRP", Decoder: gopacket.DecodeFunc(decodeVRRP)})
)

var (
	// LayerClassIPNetwork contains TCP/IP network layer types.
	LayerClassIPNetwork = gopacket.NewLayerClass([]gopacket.LayerType{
		LayerTypeIPv4,
		LayerTypeIPv6,
	})
	// LayerClassIPTransport contains TCP/IP transport layer types.
	LayerClassIPTransport = gopacket.NewLayerClass([]gopacket.LayerType{
		LayerTypeTCP,
		LayerTypeUDP,
		LayerTypeSCTP,
	})
	// LayerClassIPControl contains TCP/IP control protocols.
	LayerClassIPControl = gopacket.NewLayerClass([]gopacket.LayerType{
		LayerTypeICMPv4,
		LayerTypeICMPv6,
	})
	// LayerClassSCTPChunk contains SCTP chunk types (not the top-level SCTP
	// layer).
	LayerClassSCTPChunk = gopacket.NewLayerClass([]gopacket.LayerType{