datatype

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CIDR_TYPE_WAN = uint8(trident.CidrType_WAN)
	CIDR_TYPE_LAN = uint8(trident.CidrType_LAN)
)
View Source
const (
	HEADER_TYPE_ETH = HEADER_TYPE_L2 + iota
	HEADER_TYPE_ARP
)
View Source
const (
	HEADER_TYPE_IPV4 = HEADER_TYPE_L3 + iota
	HEADER_TYPE_IPV4_ICMP
)
View Source
const (
	HEADER_TYPE_IPV4_TCP = HEADER_TYPE_L4 + iota
	HEADER_TYPE_IPV4_UDP
)
View Source
const (
	HEADER_TYPE_IPV6_TCP = HEADER_TYPE_IPV6_L4 + iota
	HEADER_TYPE_IPV6_UDP
)
View Source
const (
	PACKET_SOURCE_ISP   uint32 = 0x10000
	PACKET_SOURCE_SPINE        = 0x20000
	PACKET_SOURCE_TOR          = 0x30000
)
View Source
const (
	MAC_ADDR_LEN               = 6
	VLANTAG_LEN                = 2
	HEADER_TYPE_LEN            = 1
	PORT_LEN                   = 2
	IP_ADDR_LEN                = 4
	ETH_TYPE_LEN               = 2
	IPV4_TTL_LEN               = 1
	IPV4_PROTO_LEN             = 1
	IPV4_FLAGS_FRAG_OFFSET_LEN = 2
	TCP_WIN_LEN                = 2
	TUNNEL_TYPE_LEN            = 1
	TUNNEL_ID_LEN              = 3

	MAX_TCP_OPTION_SIZE = 40

	ETH_HEADER_SIZE          = MAC_ADDR_LEN*2 + ETH_TYPE_LEN
	ARP_HEADER_SIZE          = 28
	VXLAN_HEADER_SIZE        = 8
	IP_HEADER_SIZE           = 20
	IP6_HEADER_SIZE          = 40
	UDP_HEADER_SIZE          = 8
	GRE_HEADER_SIZE          = 4
	ERSPANI_HEADER_SIZE      = 0
	ERSPANII_HEADER_SIZE     = 8
	ERSPANIII_HEADER_SIZE    = 12
	ERSPANIII_SUBHEADER_SIZE = 8

	MIN_IPV4_HEADER_SIZE = 20
	MIN_TCP_HEADER_SIZE  = 20
	ICMP_HEADER_SIZE     = 8

	TCP_OPT_WIN_SCALE_LEN = 3
	TCP_OPT_MSS_LEN       = 4

	LAYER_TUNNEL_SIZE = IP_ADDR_LEN*2 + TUNNEL_TYPE_LEN + TUNNEL_ID_LEN
	LAYER_L2_SIZE     = HEADER_TYPE_LEN + MAC_ADDR_LEN*2 + VLANTAG_LEN
	LAYER_L3_SIZE     = IP_ADDR_LEN*2 + 6 // DATAOFF_IHL(1B) + ID...TTL(5B)
)
View Source
const (
	OFFSET_DA          = 0
	OFFSET_DA_LOW4B    = 2
	OFFSET_SA          = OFFSET_DA + MAC_ADDR_LEN
	OFFSET_SA_LOW4B    = OFFSET_DA + MAC_ADDR_LEN + 2
	OFFSET_ETH_TYPE    = OFFSET_SA + MAC_ADDR_LEN
	OFFSET_IP_PROTOCOL = 23
	OFFSET_SIP         = 26
	OFFSET_DIP         = 30
	OFFSET_DPORT       = 36
	OFFSET_VXLAN_FLAGS = 42
	OFFSET_VXLAN_VNI   = 46
)
View Source
const (
	GRE_FLAGS_OFFSET    = 0
	GRE_PROTOCOL_OFFSET = 2
	GRE_KEY_OFFSET      = 4

	GRE_FLAGS_VER_MASK  = 0x7
	GRE_FLAGS_SEQ_MASK  = 1 << 12
	GRE_FLAGS_KEY_MASK  = 1 << 13
	GRE_FLAGS_CSUM_MASK = 1 << 15

	GRE_CSUM_LEN = 4 // csum + reserved1
	GRE_SEQ_LEN  = 4
	GRE_KEY_LEN  = 4
)
View Source
const (
	IP_IHL_OFFSET = 0

	IP6_PROTO_OFFSET = 6
	IP6_SIP_OFFSET   = 20 // 用于解析tunnel,仅使用后四个字节
	IP6_DIP_OFFSET   = 36 // 用于解析tunnel,仅使用后四个字节
	UDP_DPORT_OFFSET = 2

	VXLAN_FLAGS_OFFSET = 0
	VXLAN_VNI_OFFSET   = 4

	ERSPAN_ID_OFFSET       = 0 // erspan2和3共用,4字节取0x3ff
	ERSPANIII_FLAGS_OFFSET = 11
)
View Source
const (
	TCP_OPT_FLAG_WIN_SCALE   = 1 << iota // 0000 0001
	TCP_OPT_FLAG_MSS                     // 0000 0010
	TCP_OPT_FLAG_SACK_PERMIT             // 0000 0100
	TCP_OPT_FLAG_SACK        = 0x38      // 0011 1000, 同时也表示SACK的字节数,不要修改
)
View Source
const (
	IPV4_FRAG_DONT_FRAGMENT = 0x4000
	IPV4_FRAG_MORE_FRAGMENT = 0x2000
	IPV4_FRAG_OFFSET_MASK   = 0x1fff
)
View Source
const (
	TUNNEL_TYPE_NONE          = TunnelType(pb.DecapType_DECAP_TYPE_NONE)
	TUNNEL_TYPE_VXLAN         = TunnelType(pb.DecapType_DECAP_TYPE_VXLAN)
	TUNNEL_TYPE_IPIP          = TunnelType(pb.DecapType_DECAP_TYPE_IPIP)
	TUNNEL_TYPE_TENCENT_GRE   = TunnelType(pb.DecapType_DECAP_TYPE_TENCENT) // GRE.ver=0/1 GRE.protoType=IPv4/IPv6
	TUNNEL_TYPE_ERSPAN_OR_TEB = TUNNEL_TYPE_TENCENT_GRE + 1

	LE_IPV4_PROTO_TYPE_I      = 0x0008 // 0x0008's LittleEndian
	LE_IPV6_PROTO_TYPE_I      = 0xDD86 // 0x86dd's LittleEndian
	LE_ERSPAN_PROTO_TYPE_II   = 0xBE88 // 0x88BE's LittleEndian
	LE_ERSPAN_PROTO_TYPE_III  = 0xEB22 // 0x22EB's LittleEndian
	LE_VXLAN_PROTO_UDP_DPORT  = 0xB512 // 0x12B5(4789)'s LittleEndian
	LE_VXLAN_PROTO_UDP_DPORT2 = 0x1821 // 0x2118(8472)'s LittleEndian
	LE_VXLAN_PROTO_UDP_DPORT3 = 0x801A // 0x1A80(6784)'s LittleEndian
	LE_TEB_PROTO              = 0x5865 // 0x6558(25944)'s LittleEndian
	VXLAN_FLAGS               = 8
)
View Source
const (
	MESSAGE_FRAME_SIZE_OFFSET = 0
	MESSAGE_TYPE_OFFSET       = MESSAGE_FRAME_SIZE_OFFSET + 4
	MESSAGE_VALUE_OFFSET      = MESSAGE_TYPE_OFFSET + 1
	MESSAGE_HEADER_LEN        = MESSAGE_VALUE_OFFSET
)
View Source
const (
	FLOW_VERSION_OFFSET  = 0
	FLOW_SEQUENCE_OFFSET = FLOW_VERSION_OFFSET + 4
	FLOW_VTAPID_OFFSET   = FLOW_SEQUENCE_OFFSET + 8
	FLOW_HEADER_LEN      = FLOW_VTAPID_OFFSET + 2
)
View Source
const (
	EPC_FROM_OBSERVATRACE = -1
	EPC_FROM_INTERNET     = -2 // 当流量在所有平台数据建立的map中都无法查询到对应的epcId时,epc为-2, 在函数ModifyInternetEpcId中修改
	EPC_UNKNOWN           = 0
	GROUP_INTERNET        = -2 // Trisolaris下发使用固定值,策略匹配不做特殊处理
)
View Source
const (
	FLOW_METRICS_PEER_SRC = iota
	FLOW_METRICS_PEER_DST
	FLOW_METRICS_PEER_MAX
)
View Source
const (
	NUM_64_OFFSET = 6
	NUM_64_MASK   = 0x3f
)
View Source
const (
	MATCHED_FIELD_BITS_LEN = 144 // 8(TapType) + 8(Proto) + 16(Port)*2 + 16(L3EPC)*2 + 32(IP)*2
	MATCHED_FIELD_LEN      = 3
)
View Source
const (
	MATCHED_FIELD6_BITS_LEN = 336 // 8(TapType) + 8(Proto) + 16(Port)*2 + 16(L3EPC)*2 + 128(IP)*2
	MATCHED_FIELD6_LEN      = 6
)
View Source
const (
	MIN_MASK_LEN      = 0
	STANDARD_MASK_LEN = 16
	MAX_MASK_LEN      = 32
	MAX_MASK6_LEN     = 128
	MASK_LEN_NUM      = MAX_MASK_LEN + 1

	IF_TYPE_WAN = 3

	DATA_VALID_TIME = 1 * time.Minute
	ARP_VALID_TIME  = 1 * time.Minute
)
View Source
const (
	NPB_TUNNEL_TYPE_VXLAN = iota
	NPB_TUNNEL_TYPE_GRE_ERSPAN
	NPB_TUNNEL_TYPE_PCAP
	NPB_TUNNEL_TYPE_NPB_DROP
)
View Source
const (
	TAPSIDE_SRC  = 0x1
	TAPSIDE_DST  = 0x2
	TAPSIDE_MASK = TAPSIDE_SRC | TAPSIDE_DST
	TAPSIDE_ALL  = TAPSIDE_SRC | TAPSIDE_DST
)
View Source
const (
	COM_QUIT = iota + 1
	COM_INIT_DB
	COM_QUERY
	COM_FIELD_LIST
	COM_STMT_PREPARE = 22
	COM_STMT_EXECUTE = 23
	COM_STMT_CLOSE   = 25
	COM_STMT_FETCH   = 28
	COM_MAX          = 29
)
View Source
const (
	MYSQL_RESPONSE_CODE_OK  = 0
	MYSQL_RESPONSE_CODE_ERR = 0xff
	MYSQL_RESPONSE_CODE_EOF = 0xfe
)
View Source
const (
	VERSION                   = 20220128
	LAST_SIMPLE_CODEC_VERSION = 20220111 // 这个版本及之前的版本使用simple_codec, 之后的版本使用pb_codec, 使用pb_codec在版本不匹配时,不丢数据
)
View Source
const (
	TAPPORT_FROM_LOCAL_MAC   = iota
	TAPPORT_FROM_GATEWAY_MAC // 专有云NFV网关镜像流量
	TAPPORT_FROM_TUNNEL_IPV4 // 交换机ERSPAN镜像流量
	TAPPORT_FROM_TUNNEL_IPV6 // 交换机ERSPAN镜像流量
	TAPPORT_FROM_ID          // 其他镜像流量(dispatcher id)
	TAPPORT_FROM_NETFLOW
	TAPPORT_FROM_SFLOW
	TAPPORT_FROM_EBPF
	TAPPORT_FROM_OTEL
)
View Source
const (
	HEADER_TYPE_IPV6 = HEADER_TYPE_IPV6_L3 + iota
)
View Source
const HEADER_TYPE_IPV6_L3 = 0x40
View Source
const HEADER_TYPE_IPV6_L4 = 0xb0
View Source
const HEADER_TYPE_L3 = 0x20
View Source
const HEADER_TYPE_L4 = 0x80
View Source
const (
	IP_GROUP_ID_FLAG = 1e9
)
View Source
const (
	L7PROTOCOL_LOG_RESP_CODE_NONE = -32768
)
View Source
const (
	// pcap压缩包头发送时最大长度为:MESSAGE_HEADER_LEN + compressor header + 14 + 4 * n + 65535
	// otel的数据长度可达300k
	MESSAGE_FRAME_SIZE_MAX = 512000
)
View Source
const (
	META_PACKET_SIZE_PER_BLOCK = 16
)
View Source
const MIRRORED_TRAFFIC = 7
View Source
const VLAN_ID_MASK = uint16((1 << 12) - 1)

Variables

View Source
var (
	INVALID_ENDPOINT_INFO                   = new(EndpointInfo)
	INVALID_ENDPOINT_INFO_L3EPCID           = &EndpointInfo{L3EpcId: EPC_FROM_OBSERVATRACE}
	INVALID_ENDPOINT_INFO_L2END             = &EndpointInfo{L2End: true}
	INVALID_ENDPOINT_INFO_L3END             = &EndpointInfo{L3End: true}
	INVALID_ENDPOINT_INFO_L2AND3END         = &EndpointInfo{L2End: true, L3End: true}
	INVALID_ENDPOINT_INFO_L2END_L3EPCID     = &EndpointInfo{L2End: true, L3EpcId: EPC_FROM_OBSERVATRACE}
	INVALID_ENDPOINT_INFO_L3END_L3EPCID     = &EndpointInfo{L3End: true, L3EpcId: EPC_FROM_OBSERVATRACE}
	INVALID_ENDPOINT_INFO_L2AND3END_L3EPCID = &EndpointInfo{L2End: true, L3End: true, L3EpcId: EPC_FROM_OBSERVATRACE}
	INVALID_ENDPOINT_DATA                   = &EndpointData{SrcInfo: INVALID_ENDPOINT_INFO, DstInfo: INVALID_ENDPOINT_INFO}
	INVALID_ENDPOINT_DATA_L3EPCID           = &EndpointData{SrcInfo: INVALID_ENDPOINT_INFO_L3EPCID, DstInfo: INVALID_ENDPOINT_INFO_L3EPCID}
)
View Source
var DnsCommandString = []string{
	0:   "",
	1:   "A",
	2:   "NS",
	3:   "MD",
	4:   "MF",
	5:   "CNAME",
	6:   "SOA",
	7:   "MB",
	8:   "MG",
	9:   "MR",
	10:  "NULL",
	11:  "WKS",
	12:  "PTR",
	13:  "HINFO",
	14:  "MINFO",
	15:  "MX",
	16:  "TXT",
	28:  "AAAA",
	252: "AXFR",
	253: "MAILB",
	254: "MAILA",
	255: "ANY",
}
View Source
var (
	INVALID_POLICY_DATA = new(PolicyData)
)
View Source
var KafkaCommandString = []string{
	Produce:                      "Produce",
	Fetch:                        "Fetch",
	ListOffsets:                  "ListOffsets",
	Metadata:                     "Metadata",
	LeaderAndIsr:                 "LeaderAndIsr",
	StopReplica:                  "StopReplica",
	UpdateMetadata:               "UpdateMetadata",
	ControlledShutdown:           "ControlledShutdown",
	OffsetCommit:                 "OffsetCommit",
	OffsetFetch:                  "OffsetFetch",
	FindCoordinator:              "FindCoordinator",
	JoinGroup:                    "JoinGroup",
	Heartbeat:                    "Heartbeat",
	LeaveGroup:                   "LeaveGroup",
	SyncGroup:                    "SyncGroup",
	DescribeGroups:               "DescribeGroups",
	ListGroups:                   "ListGroups",
	SaslHandshake:                "SaslHandshake",
	ApiVersions:                  "ApiVersions",
	CreateTopics:                 "CreateTopics",
	DeleteTopics:                 "DeleteTopics",
	DeleteRecords:                "DeleteRecords",
	InitProducerId:               "InitProducerId",
	OffsetForLeaderEpoch:         "OffsetForLeaderEpoch",
	AddPartitionsToTxn:           "AddPartitionsToTxn",
	AddOffsetsToTxn:              "AddOffsetsToTxn",
	EndTxn:                       "EndTxn",
	WriteTxnMarkers:              "WriteTxnMarkers",
	TxnOffsetCommit:              "TxnOffsetCommit",
	DescribeAcls:                 "DescribeAcls",
	CreateAcls:                   "CreateAcls",
	DeleteAcls:                   "DeleteAcls",
	DescribeConfigs:              "DescribeConfigs",
	AlterConfigs:                 "AlterConfigs",
	AlterReplicaLogDirs:          "AlterReplicaLogDirs",
	DescribeLogDirs:              "DescribeLogDirs",
	SaslAuthenticate:             "SaslAuthenticate",
	CreatePartitions:             "CreatePartitions",
	CreateDelegationToken:        "CreateDelegationToken",
	RenewDelegationToken:         "RenewDelegationToken",
	ExpireDelegationToken:        "ExpireDelegationToken",
	DescribeDelegationToken:      "DescribeDelegationToken",
	DeleteGroups:                 "DeleteGroups",
	ElectLeaders:                 "ElectLeaders",
	IncrementalAlterConfigs:      "IncrementalAlterConfigs",
	AlterPartitionReassignments:  "AlterPartitionReassignments",
	ListPartitionReassignments:   "ListPartitionReassignments",
	OffsetDelete:                 "OffsetDelete",
	DescribeClientQuotas:         "DescribeClientQuotas",
	AlterClientQuotas:            "AlterClientQuotas",
	DescribeUserScramCredentials: "DescribeUserScramCredentials",
	AlterUserScramCredentials:    "AlterUserScramCredentials",
	AlterIsr:                     "AlterIsr",
	UpdateFeatures:               "UpdateFeatures",
	DescribeCluster:              "DescribeCluster",
	DescribeProducers:            "DescribeProducers",
	DescribeTransactions:         "DescribeTransactions",
	ListTransactions:             "ListTransactions",
	AllocateProducerIds:          "AllocateProducerIds",
}
View Source
var MessageTypeString = [MESSAGE_TYPE_MAX]string{
	MESSAGE_TYPE_COMPRESS: "compressed_pcap",
	MESSAGE_TYPE_SYSLOG:   "syslog",
	MESSAGE_TYPE_STATSD:   "statsd",

	MESSAGE_TYPE_METRICS:        "metrics",
	MESSAGE_TYPE_TAGGEDFLOW:     "l4_log",
	MESSAGE_TYPE_PROTOCOLLOG:    "l7_log",
	MESSAGE_TYPE_OPENTELEMETRY:  "open_telemetry",
	MESSAGE_TYPE_PROMETHEUS:     "prometheus",
	MESSAGE_TYPE_TELEGRAF:       "telegraf",
	MESSAGE_TYPE_PACKETSEQUENCE: "l4_packet",

	MESSAGE_TYPE_DFSTATS:                  "observatrace_stats",
	MESSAGE_TYPE_OPENTELEMETRY_COMPRESSED: "open_telemetry_compressed",
	MESSAGE_TYPE_RAW_PCAP:                 "raw_pcap",
	MESSAGE_TYPE_PROFILE:                  "profile",
	MESSAGE_TYPE_PROC_EVENT:               "proc_event",
	MESSAGE_TYPE_ALARM_EVENT:              "alarm_event",
}
View Source
var MysqlCommandString = []string{
	// contains filtered or unexported fields
}

Functions

func DecodePB

func DecodePB(decoder *codec.SimpleDecoder, t *pb.TaggedFlow)

func FormatGroupId

func FormatGroupId(id uint32) uint32

func GetDNSQueryType

func GetDNSQueryType(query uint8) string

func GetTunnelIp

func GetTunnelIp(aclGid uint16) net.IP

func GetTunnelIpId

func GetTunnelIpId(aclGid uint16) uint16

func GroupIdToString

func GroupIdToString(id uint32) string

func IpRangeConvert2CIDR

func IpRangeConvert2CIDR(startIp, endIp net.IP) []net.IPNet

func IsGrePseudoInnerMac

func IsGrePseudoInnerMac(mac uint64) bool

func PseudoCloneTaggedFlowHelper

func PseudoCloneTaggedFlowHelper(items []interface{})

func ReleaseAppProtoLogsData

func ReleaseAppProtoLogsData(d *AppProtoLogsData)

func ReleaseDNSInfo

func ReleaseDNSInfo(d *DNSInfo)

func ReleaseDubboInfo

func ReleaseDubboInfo(d *DubboInfo)

func ReleaseEndpointData

func ReleaseEndpointData(d *EndpointData)

func ReleaseEndpointInfo

func ReleaseEndpointInfo(i *EndpointInfo)

func ReleaseFlowPerfStats

func ReleaseFlowPerfStats(s *FlowPerfStats)

func ReleaseHTTPInfo

func ReleaseHTTPInfo(h *HTTPInfo)

func ReleaseKafkaInfo

func ReleaseKafkaInfo(d *KafkaInfo)

func ReleaseMYSQLInfo

func ReleaseMYSQLInfo(d *MysqlInfo)

func ReleaseMetaPacketBlock

func ReleaseMetaPacketBlock(x *MetaPacketBlock)

func ReleaseMqttInfo

func ReleaseMqttInfo(d *MqttInfo)

func ReleaseREDISInfo

func ReleaseREDISInfo(d *RedisInfo)

func ReleaseTaggedFlow

func ReleaseTaggedFlow(taggedFlow *TaggedFlow)

func SplitGroup2Int

func SplitGroup2Int(src []int32) []uint32

func TrimCommand

func TrimCommand(sql string, commandMaxLength int) string

func UpdateTunnelMaps

func UpdateTunnelMaps(aclGids, ipIds []uint16, ips []net.IP)

Types

type ActionFlag

type ActionFlag uint16
const (
	ACTION_PCAP ActionFlag = 1 << iota
	ACTION_NPB
	ACTION_NPB_DROP
)

func (ActionFlag) String

func (f ActionFlag) String() string

type AppProtoHead

type AppProtoHead struct {
	Proto   L7Protocol
	MsgType LogMessageType // HTTP,DNS: request/response
	Status  uint8          // 状态描述:0:正常,1:已废弃使用(先前用于表示异常),2:不存在,3:服务端异常,4:客户端异常
	Code    uint16         // HTTP状态码: 1xx-5xx, DNS状态码: 0-7
	RRT     time.Duration  // HTTP,DNS时延: response-request

}

func (*AppProtoHead) WriteToPB

func (h *AppProtoHead) WriteToPB(p *pb.AppProtoHead)

type AppProtoLogsBaseInfo

type AppProtoLogsBaseInfo struct {
	StartTime time.Duration // 开始时间, packet的时间戳
	EndTime   time.Duration // 结束时间, 初始化时等于开始时间
	FlowId    uint64        // 对应flow的ID
	TapPort   TapPort
	VtapId    uint16
	TapType   uint16
	IsIPv6    bool
	TapSide   uint8
	AppProtoHead

	/* L2 */
	MacSrc uint64
	MacDst uint64
	/* L3 */
	IPSrc IPv4Int
	IPDst IPv4Int
	/* L3 IPv6 */
	IP6Src [net.IPv6len]byte
	IP6Dst [net.IPv6len]byte
	/* L3EpcID */
	L3EpcIDSrc int32
	L3EpcIDDst int32
	/* L4 */
	PortSrc uint16
	PortDst uint16
	/* First L7 TCP Seq */
	ReqTcpSeq  uint32
	RespTcpSeq uint32

	Protocol          uint8
	IsVIPInterfaceSrc bool
	IsVIPInterfaceDst bool
}

func (*AppProtoLogsBaseInfo) String

func (i *AppProtoLogsBaseInfo) String() string

func (*AppProtoLogsBaseInfo) WriteToPB

func (l *AppProtoLogsBaseInfo) WriteToPB(p *pb.AppProtoLogsBaseInfo)

type AppProtoLogsData

type AppProtoLogsData struct {
	AppProtoLogsBaseInfo
	Detail ProtoSpecialInfo

	pool.ReferenceCount
}

func AcquireAppProtoLogsData

func AcquireAppProtoLogsData() *AppProtoLogsData

func CloneAppProtoLogsData

func CloneAppProtoLogsData(d *AppProtoLogsData) *AppProtoLogsData

func (*AppProtoLogsData) EncodePB

func (l *AppProtoLogsData) EncodePB(encoder *codec.SimpleEncoder, i interface{}) error

func (*AppProtoLogsData) Release

func (l *AppProtoLogsData) Release()

func (*AppProtoLogsData) String

func (l *AppProtoLogsData) String() string

func (*AppProtoLogsData) WriteToPB

func (l *AppProtoLogsData) WriteToPB(p *pb.AppProtoLogsData)

type BaseHeader

type BaseHeader struct {
	FrameSize uint32      // tcp发送时,需要按此长度收齐数据后,再decode (FrameSize总长度,包含了 BaseHeader的长度)
	Type      MessageType // 消息类型
}

func (*BaseHeader) Decode

func (h *BaseHeader) Decode(buf []byte) error

func (*BaseHeader) Encode

func (h *BaseHeader) Encode(chunk []byte)

type ByteStream

type ByteStream struct {
	// contains filtered or unexported fields
}

func NewByteStream

func NewByteStream(data []byte) ByteStream

func (*ByteStream) Field

func (s *ByteStream) Field(len int) []byte

func (*ByteStream) Len

func (s *ByteStream) Len() int

func (*ByteStream) Skip

func (s *ByteStream) Skip(n int)

func (*ByteStream) Slice

func (s *ByteStream) Slice() []byte

func (*ByteStream) U16

func (s *ByteStream) U16() uint16

func (*ByteStream) U32

func (s *ByteStream) U32() uint32

func (*ByteStream) U64

func (s *ByteStream) U64() uint64

func (*ByteStream) U8

func (s *ByteStream) U8() uint8

type Cidr

type Cidr struct {
	IpNet    *net.IPNet
	TunnelId uint32
	EpcId    int32
	Type     uint8
	IsVIP    bool
	RegionId uint32
}

IsVIP为true时不影响cidr epcid表的建立, 但是会单独建立VIP表

type CloseType

type CloseType uint8
const (
	CloseTypeUnknown CloseType = iota

	CloseTypeTCPFin       //  1: 正常结束
	CloseTypeTCPServerRst //  2: 传输-服务端重置
	CloseTypeTimeout      //  3: 连接超时

	CloseTypeForcedReport //  5: 周期性上报

	CloseTypeClientSYNRepeat    //  7: 建连-客户端SYN结束
	CloseTypeServerHalfClose    //  8: 断连-服务端半关
	CloseTypeTCPClientRst       //  9: 传输-客户端重置
	CloseTypeServerSYNACKRepeat // 10: 建连-服务端SYN结束
	CloseTypeClientHalfClose    // 11: 断连-客户端半关

	CloseTypeClientSourcePortReuse // 13: 建连-客户端端口复用

	CloseTypeServerReset // 15: 建连-服务端直接重置

	CloseTypeServerQueueLack      // 17: 传输-服务端队列溢出
	CloseTypeClientEstablishReset // 18: 建连-客户端其他重置
	CloseTypeServerEstablishReset // 19: 建连-服务端其他重置
	CloseTypeTCPFinClientRst      // 20: 正常结束-客户端重置
	MaxCloseType
)

func (CloseType) IsClientError

func (t CloseType) IsClientError() bool

func (CloseType) IsServerError

func (t CloseType) IsServerError() bool

type DNSInfo

type DNSInfo struct {
	TransID   uint16
	QueryType uint16
	QueryName string
	// 根据查询类型的不同而不同,如:
	// A: ipv4/ipv6地址
	// NS: name server
	// SOA: primary name server
	Answers string
}

| type | 查询类型 | 说明| | ---- | -------- | --- | | 1 | A |由域名获得IPv4地址| | 2 | NS |查询域名服务器| | 5 | CNAME |查询规范名称| | 6 | SOA |开始授权| | 11 | WKS |熟知服务| | 12 | PTR |把IP地址转换成域名| | 13 | HINFO |主机信息| | 15 | MX |邮件交换| | 28 | AAAA |由域名获得IPv6地址| | 252 | AXFR |传送整个区的请求| | 255 | ANY |对所有记录的请求|

func AcquireDNSInfo

func AcquireDNSInfo() *DNSInfo

func (*DNSInfo) Merge

func (d *DNSInfo) Merge(r interface{})

func (*DNSInfo) String

func (d *DNSInfo) String() string

func (*DNSInfo) WriteToPB

func (h *DNSInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type DeviceType

type DeviceType uint8
const (
	VM DeviceType
	VGw
	ThirdPartyDevice
	VMWAF
	NSPVGateway
	HostDevice
	NetworkDevice
	FloatingIP
)

type DirectionType

type DirectionType uint8
const (
	FORWARD DirectionType = 1 << iota
	BACKWARD
)
const (
	NO_DIRECTION DirectionType = 0
)

type DubboInfo

type DubboInfo struct {
	// header
	SerialID uint8
	Type     uint8
	ID       int64

	// req
	ReqBodyLen     int32
	DubboVersion   string
	ServiceName    string
	ServiceVersion string
	MethodName     string
	TraceId        string

	// resp
	RespBodyLen int32
}

func AcquireDubboInfo

func AcquireDubboInfo() *DubboInfo

func (*DubboInfo) Merge

func (i *DubboInfo) Merge(r interface{})

func (*DubboInfo) String

func (i *DubboInfo) String() string

func (*DubboInfo) WriteToPB

func (i *DubboInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type EndpointData

type EndpointData struct {
	SrcInfo *EndpointInfo
	DstInfo *EndpointInfo
}

func AcquireEndpointData

func AcquireEndpointData(infos ...*EndpointInfo) *EndpointData

func CloneEndpointData

func CloneEndpointData(d *EndpointData) *EndpointData

func ShallowCopyEndpointData

func ShallowCopyEndpointData(d *EndpointData) *EndpointData

func (*EndpointData) ReverseData

func (d *EndpointData) ReverseData() *EndpointData

ReverseData will return a reversed replica of the current EndpointData

func (*EndpointData) SetL2End

func (d *EndpointData) SetL2End(key *LookupKey)

func (*EndpointData) String

func (d *EndpointData) String() string

func (*EndpointData) Valid

func (d *EndpointData) Valid() bool

type EndpointInfo

type EndpointInfo struct {
	RealIP         net.IP // IsVIP为true时,该字段有值
	L2EpcId        int32  // 负数表示特殊值
	L3EpcId        int32  // 负数表示特殊值
	L2End          bool
	L3End          bool
	IsDevice       bool
	IsVIPInterface bool
	IsVIP          bool
	IsLocalMac     bool // 对应平台数据中的IsLocal字段
	IsLocalIp      bool // 对应平台数据中的IsLocal字段
}

func AcquireEndpointInfo

func AcquireEndpointInfo() *EndpointInfo

func CloneEndpointInfo

func CloneEndpointInfo(i *EndpointInfo) *EndpointInfo

func ShallowCopyEndpointInfo

func ShallowCopyEndpointInfo(i *EndpointInfo) *EndpointInfo

浅拷贝 共用同一个资源组信息

func (*EndpointInfo) GetL3Epc

func (i *EndpointInfo) GetL3Epc() uint16

func (*EndpointInfo) GetL3L2End

func (i *EndpointInfo) GetL3L2End() L3L2End

func (*EndpointInfo) SetL2Data

func (i *EndpointInfo) SetL2Data(data *PlatformData)

func (*EndpointInfo) SetL3Data

func (i *EndpointInfo) SetL3Data(data *PlatformData)

func (*EndpointInfo) SetL3L2End

func (i *EndpointInfo) SetL3L2End(ends L3L2End)

func (*EndpointInfo) String

func (i *EndpointInfo) String() string

type EndpointStore

type EndpointStore struct {
	Endpoints *EndpointData

	SrcInfos [L3_L2_END_MAX]EndpointInfo
	DstInfos [L3_L2_END_MAX]EndpointInfo
	Datas    [L3_L2_END_MAX][L3_L2_END_MAX]EndpointData
}

func (*EndpointStore) InitPointer

func (s *EndpointStore) InitPointer(d *EndpointData)

func (*EndpointStore) UpdatePointer

func (s *EndpointStore) UpdatePointer(l2End0, l2End1, l3End0, l3End1 bool) *EndpointData

type FeatureFlags

type FeatureFlags uint32
const (
	NPM FeatureFlags = 1 << iota
	NPB
)

type Flow

type Flow struct {
	// 注意字节对齐!
	FlowKey
	FlowMetricsPeers [FLOW_METRICS_PEER_MAX]FlowMetricsPeer

	Tunnel TunnelField

	FlowID uint64

	// TCP Seq
	SYNSeq           uint32
	SYNACKSeq        uint32
	LastKeepaliveSeq uint32
	LastKeepaliveAck uint32

	/* Timers */
	StartTime    time.Duration
	EndTime      time.Duration
	Duration     time.Duration
	FlowStatTime time.Duration // 取整至流统计周期的开始

	/* L2 */
	VLAN    uint16
	EthType layers.EthernetType

	/* TCP Perf Data */
	*FlowPerfStats

	CloseType
	SignalSource
	IsActiveService bool
	QueueHash       uint8
	IsNewFlow       bool
	Reversed        bool
	TapSide         uint8

	AclGids []uint16
}

结构或顺序变化,需要同步修改Encode和Decode

func (*Flow) Reverse

func (f *Flow) Reverse()

FIXME 注意:由于FlowGenerator中TCPPerfStats在Flow方向调整之后才获取到, 因此这里不包含对TCPPerfStats的反向。

func (*Flow) SequentialMerge

func (f *Flow) SequentialMerge(rhs *Flow)

func (*Flow) String

func (f *Flow) String() string

func (*Flow) WriteToPB

func (f *Flow) WriteToPB(p *pb.Flow)

type FlowHeader

type FlowHeader struct {
	Version  uint32 // 用来校验encode和decode是否配套
	Sequence uint64 // udp发送时,用来校验是否丢包
	VTAPID   uint16 // trident的ID
}

多个document和taggeflow encode时共用一个header

func (*FlowHeader) Decode

func (h *FlowHeader) Decode(buf []byte)

func (*FlowHeader) Encode

func (h *FlowHeader) Encode(chunk []byte)

type FlowKey

type FlowKey struct {
	VtapId  uint16
	TapType TapType
	TapPort TapPort // 采集端口信息类型 + 采集端口信息
	/* L2 */
	MACSrc MacInt
	MACDst MacInt
	/* L3 */
	IPSrc IPv4Int
	IPDst IPv4Int
	/* L3 IPv6 */
	IP6Src net.IP
	IP6Dst net.IP
	/* L4 */
	PortSrc uint16
	PortDst uint16
	Proto   layers.IPProtocol
}

func (*FlowKey) SequentialMerge

func (_ *FlowKey) SequentialMerge(_ *FlowKey)

func (*FlowKey) String

func (f *FlowKey) String() string

func (*FlowKey) WriteToPB

func (f *FlowKey) WriteToPB(p *pb.FlowKey)

type FlowMetricsPeer

type FlowMetricsPeer struct {
	// 注意字节对齐!
	NatRealIp net.IP // IsVIP为true,通过MAC查询对应的IP

	ByteCount        uint64        // 每个流统计周期(目前是自然秒)清零
	L3ByteCount      uint64        // 每个流统计周期的L3载荷量
	L4ByteCount      uint64        // 每个流统计周期的L4载荷量
	PacketCount      uint64        // 每个流统计周期(目前是自然秒)清零
	TotalByteCount   uint64        // 整个Flow生命周期的统计量
	TotalPacketCount uint64        // 整个Flow生命周期的统计量
	First, Last      time.Duration // 整个Flow生命周期首包和尾包的时间戳

	L3EpcID       int32
	IsL2End       bool
	IsL3End       bool
	IsActiveHost  bool
	IsDevice      bool  // true表明是从平台数据中获取的
	TCPFlags      uint8 // 每个流统计周期的TCP Flags或运算
	TotalTCPFlags uint8 // 整个Flow生命周期的TCP Flags或运算
	// TODO: IsVIPInterface、IsVIP流日志没有存储,Encode\Decode可以不做
	IsVIPInterface bool // 目前仅支持微软Mux设备,从grpc Interface中获取
	IsVIP          bool // 从grpc cidr中获取
	IsLocalMac     bool // 同EndpointInfo中的IsLocalMac, 流日志中不需要存储
	IsLocalIp      bool // 同EndpointInfo中的IsLocalIp, 流日志中不需要存储
}

func (*FlowMetricsPeer) SequentialMerge

func (f *FlowMetricsPeer) SequentialMerge(rhs *FlowMetricsPeer)

func (*FlowMetricsPeer) String

func (f *FlowMetricsPeer) String() string

func (*FlowMetricsPeer) WriteToPB

func (f *FlowMetricsPeer) WriteToPB(p *pb.FlowMetricsPeer)

type FlowPerfStats

type FlowPerfStats struct {
	TCPPerfStats
	L7PerfStats
	L4Protocol
	L7Protocol
}

size = 80B + 36B + 2B = 118B

var ZeroFlowPerfStats FlowPerfStats = FlowPerfStats{}

func AcquireFlowPerfStats

func AcquireFlowPerfStats() *FlowPerfStats

func CloneFlowPerfStats

func CloneFlowPerfStats(s *FlowPerfStats) *FlowPerfStats

func (*FlowPerfStats) SequentialMerge

func (f *FlowPerfStats) SequentialMerge(rhs *FlowPerfStats)

func (*FlowPerfStats) String

func (p *FlowPerfStats) String() string

func (*FlowPerfStats) WriteToPB

func (f *FlowPerfStats) WriteToPB(p *pb.FlowPerfStats)

type HTTPInfo

type HTTPInfo struct {
	StreamID uint32 // HTTPv2
	Version  string
	TraceID  string
	SpanID   string

	Method     string
	Path       string
	Host       string
	ClientIP   string
	XRequestId string

	ReqContentLength  int64
	RespContentLength int64
}

HTTPv2根据需要添加

func AcquireHTTPInfo

func AcquireHTTPInfo() *HTTPInfo

func (*HTTPInfo) Merge

func (h *HTTPInfo) Merge(r interface{})

func (*HTTPInfo) String

func (h *HTTPInfo) String() string

func (*HTTPInfo) WriteToPB

func (h *HTTPInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type HeaderType

type HeaderType uint8
const HEADER_TYPE_INVALID HeaderType = 0
const HEADER_TYPE_L2 HeaderType = 0x1

func (HeaderType) IsIpv6

func (t HeaderType) IsIpv6() bool

func (HeaderType) IsL3

func (t HeaderType) IsL3() bool

type IP

type IP struct {
	// contains filtered or unexported fields
}

func NewIPFromInt

func NewIPFromInt(ipInt uint32) *IP

func NewIPFromString

func NewIPFromString(ipStr string) *IP

func (*IP) Equals

func (ip *IP) Equals(other *IP) bool

func (*IP) GobDecode

func (ip *IP) GobDecode(buffer []byte) error

func (*IP) GobEncode

func (ip *IP) GobEncode() ([]byte, error)

func (*IP) Int

func (ip *IP) Int() uint32

func (*IP) String

func (ip *IP) String() string

type IPv4Int

type IPv4Int = uint32 // not native byte order

type IpNet

type IpNet struct {
	RawIp    net.IP
	Netmask  uint32
	SubnetId uint32
}

type KafkaCommand

type KafkaCommand uint8
const (
	Produce                      KafkaCommand = 0
	Fetch                        KafkaCommand = 1
	ListOffsets                  KafkaCommand = 2
	Metadata                     KafkaCommand = 3
	LeaderAndIsr                 KafkaCommand = 4
	StopReplica                  KafkaCommand = 5
	UpdateMetadata               KafkaCommand = 6
	ControlledShutdown           KafkaCommand = 7
	OffsetCommit                 KafkaCommand = 8
	OffsetFetch                  KafkaCommand = 9
	FindCoordinator              KafkaCommand = 10
	JoinGroup                    KafkaCommand = 11
	Heartbeat                    KafkaCommand = 12
	LeaveGroup                   KafkaCommand = 13
	SyncGroup                    KafkaCommand = 14
	DescribeGroups               KafkaCommand = 15
	ListGroups                   KafkaCommand = 16
	SaslHandshake                KafkaCommand = 17
	ApiVersions                  KafkaCommand = 18
	CreateTopics                 KafkaCommand = 19
	DeleteTopics                 KafkaCommand = 20
	DeleteRecords                KafkaCommand = 21
	InitProducerId               KafkaCommand = 22
	OffsetForLeaderEpoch         KafkaCommand = 23
	AddPartitionsToTxn           KafkaCommand = 24
	AddOffsetsToTxn              KafkaCommand = 25
	EndTxn                       KafkaCommand = 26
	WriteTxnMarkers              KafkaCommand = 27
	TxnOffsetCommit              KafkaCommand = 28
	DescribeAcls                 KafkaCommand = 29
	CreateAcls                   KafkaCommand = 30
	DeleteAcls                   KafkaCommand = 31
	DescribeConfigs              KafkaCommand = 32
	AlterConfigs                 KafkaCommand = 33
	AlterReplicaLogDirs          KafkaCommand = 34
	DescribeLogDirs              KafkaCommand = 35
	SaslAuthenticate             KafkaCommand = 36
	CreatePartitions             KafkaCommand = 37
	CreateDelegationToken        KafkaCommand = 38
	RenewDelegationToken         KafkaCommand = 39
	ExpireDelegationToken        KafkaCommand = 40
	DescribeDelegationToken      KafkaCommand = 41
	DeleteGroups                 KafkaCommand = 42
	ElectLeaders                 KafkaCommand = 43
	IncrementalAlterConfigs      KafkaCommand = 44
	AlterPartitionReassignments  KafkaCommand = 45
	ListPartitionReassignments   KafkaCommand = 46
	OffsetDelete                 KafkaCommand = 47
	DescribeClientQuotas         KafkaCommand = 48
	AlterClientQuotas            KafkaCommand = 49
	DescribeUserScramCredentials KafkaCommand = 50
	AlterUserScramCredentials    KafkaCommand = 51
	AlterIsr                     KafkaCommand = 56
	UpdateFeatures               KafkaCommand = 57
	DescribeCluster              KafkaCommand = 60
	DescribeProducers            KafkaCommand = 61
	DescribeTransactions         KafkaCommand = 65
	ListTransactions             KafkaCommand = 66
	AllocateProducerIds          KafkaCommand = 67
)

func (KafkaCommand) String

func (m KafkaCommand) String() string

type KafkaInfo

type KafkaInfo struct {
	CorrelationId uint32

	// request
	ReqMsgSize int32
	ApiVersion uint16
	ApiKey     uint16
	ClientID   string

	// reponse
	RespMsgSize int32
}

func AcquireKafkaInfo

func AcquireKafkaInfo() *KafkaInfo

func (*KafkaInfo) Merge

func (i *KafkaInfo) Merge(r interface{})

func (*KafkaInfo) String

func (i *KafkaInfo) String() string

func (*KafkaInfo) WriteToPB

func (i *KafkaInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type L3L2End

type L3L2End int
const (
	L3_L2_END_FALSE_FALSE L3L2End = iota
	L3_L2_END_FALSE_TRUE
	L3_L2_END_TRUE_FALSE
	L3_L2_END_TRUE_TRUE
	L3_L2_END_MAX
)

func NewL3L2End

func NewL3L2End(l2End, l3End bool) L3L2End

type L4Protocol

type L4Protocol uint8
const (
	L4_PROTOCOL_UNKOWN L4Protocol = iota
	L4_PROTOCOL_TCP
	L4_PROTOCOL_UDP

	L4_PROTOCOL_MAX
)

func (*L4Protocol) String

func (p *L4Protocol) String() string

type L7PerfStats

type L7PerfStats struct {
	RequestCount   uint32
	ResponseCount  uint32
	ErrClientCount uint32 // client端原因导致的响应异常数量
	ErrServerCount uint32 // server端原因导致的响应异常数量
	ErrTimeout     uint32 // request请求timeout数量
	RRTCount       uint32 // u32可记录40000M时延,一条流在一分钟内的请求数远无法达到此数值
	RRTSum         uint64 // us RRT(Request Response Time)
	RRTMax         uint32 // us RRT(Request Response Time),Trident保证在3600s以内
}

size = 9 * 4B = 36B

func (*L7PerfStats) SequentialMerge

func (p *L7PerfStats) SequentialMerge(rhs *L7PerfStats)

func (*L7PerfStats) String

func (p *L7PerfStats) String() string

func (*L7PerfStats) WriteToPB

func (p *L7PerfStats) WriteToPB(b *pb.L7PerfStats)

type L7Protocol

type L7Protocol uint8
const (
	L7_PROTOCOL_UNKNOWN L7Protocol = 0
	L7_PROTOCOL_HTTP_1  L7Protocol = 20
	L7_PROTOCOL_HTTP_2  L7Protocol = 21
	L7_PROTOCOL_DUBBO   L7Protocol = 40
	L7_PROTOCOL_GRPC    L7Protocol = 41
	L7_PROTOCOL_SOFARPC L7Protocol = 43
	L7_PROTOCOL_FASTCGI L7Protocol = 44
	L7_PROTOCOL_MYSQL   L7Protocol = 60
	L7_PROTOCOL_POSTGRE L7Protocol = 61
	L7_PROTOCOL_ORACLE  L7Protocol = 62
	L7_PROTOCOL_REDIS   L7Protocol = 80
	L7_PROTOCOL_MONGODB L7Protocol = 81
	L7_PROTOCOL_KAFKA   L7Protocol = 100
	L7_PROTOCOL_MQTT    L7Protocol = 101
	L7_PROTOCOL_DNS     L7Protocol = 120
	L7_PROTOCOL_CUSTOM  L7Protocol = 127
)

func (L7Protocol) String

func (p L7Protocol) String(isTLS bool) string

type LogMessageStatus

type LogMessageStatus uint8
const (
	STATUS_OK LogMessageStatus = iota
	STATUS_ERROR
	STATUS_NOT_EXIST
	STATUS_SERVER_ERROR
	STATUS_CLIENT_ERROR
)

func (LogMessageStatus) String

func (t LogMessageStatus) String() string

type LogMessageType

type LogMessageType uint8
const (
	MSG_T_REQUEST LogMessageType = iota
	MSG_T_RESPONSE
	MSG_T_SESSION
	MSG_T_OTHER
	MSG_T_MAX
)

func (*LogMessageType) String

func (t *LogMessageType) String() string

type LookupKey

type LookupKey struct {
	Timestamp                         time.Duration
	SrcMac, DstMac                    uint64
	SrcIp, DstIp                      uint32
	Src6Ip, Dst6Ip                    net.IP
	SrcPort, DstPort                  uint16
	EthType                           EthernetType
	L2End0, L2End1                    bool
	L3End0, L3End1                    bool
	L3EpcId0, L3EpcId1                uint16 // 目前仅droplet使用
	Proto                             uint8
	TapType                           TapType
	FeatureFlag                       FeatureFlags
	ForwardMatched, BackwardMatched   MatchedField
	ForwardMatched6, BackwardMatched6 MatchedField6
	FastIndex                         int
	TunnelId                          uint32 // 目前仅是腾讯GRE的key,用来查询L3EpcID
}

func (*LookupKey) GenerateMatchedField

func (k *LookupKey) GenerateMatchedField(srcEpc, dstEpc uint16)

func (*LookupKey) HasFeatureFlag

func (k *LookupKey) HasFeatureFlag(featureFlag FeatureFlags) bool

func (*LookupKey) String

func (k *LookupKey) String() string

type MACAddr

type MACAddr struct {
	// contains filtered or unexported fields
}

func NewMACAddrFromInt

func NewMACAddrFromInt(addrInt uint64) *MACAddr

func NewMACAddrFromString

func NewMACAddrFromString(addrStr string) *MACAddr

func (*MACAddr) Equals

func (m *MACAddr) Equals(other *MACAddr) bool

func (*MACAddr) Int

func (m *MACAddr) Int() uint64

func (*MACAddr) String

func (m *MACAddr) String() string

type MacInt

type MacInt = uint64 // not native byte order

func MacIntFromBytes

func MacIntFromBytes(bytes []byte) MacInt

type MatchFlags

type MatchFlags uint16
const (
	// fields[0]
	MATCHED_SRC_IP MatchFlags = iota
	MATCHED_DST_IP
	// fields[1]
	MATCHED_SRC_EPC
	MATCHED_DST_EPC
	MATCHED_SRC_PORT
	MATCHED_DST_PORT
	// fields[2]
	MATCHED_PROTO
	MATCHED_TAP_TYPE
)
const (
	// fields[0]
	MATCHED6_SRC_IP0 MatchFlags = iota
	// fields[1]
	MATCHED6_SRC_IP1
	// fields[2]
	MATCHED6_DST_IP0
	// fields[3]
	MATCHED6_DST_IP1
	// fields[4]
	MATCHED6_SRC_EPC
	MATCHED6_DST_EPC
	MATCHED6_SRC_PORT
	MATCHED6_DST_PORT
	// fields[5]
	MATCHED6_PROTO
	MATCHED6_TAP_TYPE
)

type MatchedField

type MatchedField struct {
	// contains filtered or unexported fields
}

func (*MatchedField) And

func (*MatchedField) Equal

func (f *MatchedField) Equal(n *MatchedField) bool

func (*MatchedField) Get

func (f *MatchedField) Get(flag MatchFlags) uint64

func (*MatchedField) GetAllTableIndex

func (f *MatchedField) GetAllTableIndex(maskVector, mask *MatchedField, min, max int, vectorBits []int) []uint16

TODO: 这个函数申请的内存比较多,考虑到内存不是常驻内存会GC掉目前不做优化

func (*MatchedField) GetTableIndex

func (f *MatchedField) GetTableIndex(maskVector *MatchedField, min, max int) uint16

func (*MatchedField) GobDecode

func (f *MatchedField) GobDecode(in []byte) error

func (*MatchedField) GobEncode

func (f *MatchedField) GobEncode() ([]byte, error)

func (*MatchedField) IsBitZero

func (f *MatchedField) IsBitZero(offset int) bool

func (*MatchedField) Or

func (*MatchedField) Set

func (f *MatchedField) Set(flag MatchFlags, value uint64)

func (*MatchedField) SetBits

func (f *MatchedField) SetBits(whichs ...int)

func (*MatchedField) SetMask

func (f *MatchedField) SetMask(flag MatchFlags, value uint64)

func (MatchedField) String

func (f MatchedField) String() string

type MatchedField6

type MatchedField6 struct {
	// contains filtered or unexported fields
}

func (*MatchedField6) And

func (*MatchedField6) Equal

func (f *MatchedField6) Equal(n *MatchedField6) bool

func (*MatchedField6) Get

func (f *MatchedField6) Get(flag MatchFlags) uint64

func (*MatchedField6) GetAllTableIndex

func (f *MatchedField6) GetAllTableIndex(maskVector, mask *MatchedField6, min, max int, vectorBits []int) []uint16

func (*MatchedField6) GetTableIndex

func (f *MatchedField6) GetTableIndex(maskVector *MatchedField6, min, max int) uint16

func (*MatchedField6) GobDecode

func (f *MatchedField6) GobDecode(in []byte) error

func (*MatchedField6) GobEncode

func (f *MatchedField6) GobEncode() ([]byte, error)

func (*MatchedField6) IsBitZero

func (f *MatchedField6) IsBitZero(offset int) bool

func (*MatchedField6) Or

func (*MatchedField6) Set

func (f *MatchedField6) Set(flag MatchFlags, value uint64)

func (*MatchedField6) SetBits

func (f *MatchedField6) SetBits(whichs ...int)

func (*MatchedField6) SetMask

func (f *MatchedField6) SetMask(flag MatchFlags, value uint64)

func (MatchedField6) String

func (f MatchedField6) String() string

type MessageHeaderType

type MessageHeaderType uint8
const (
	// 4B + 1B
	HEADER_TYPE_LT MessageHeaderType = iota
	// 4B + 1B, 不校验length
	HEADER_TYPE_LT_NOCHECK
	// 4B + 1B + (4B + 8B +2B)
	HEADER_TYPE_LT_VTAP
	HEADER_TYPE_UNKNOWN
)

type MessageType

type MessageType uint8

本消息格式仅用于同droplet通信:

  1. FrameSize用于粘包,为了简化包头压缩算法逻辑,UDP发送时也需要预留FrameSize但是内容可以为0
  2. MessageType标注消息类型
  3. MessageValue为具体的消息内容

-------------------------------------------------------- | FrameSize(4B) | MessageType(1B) | MessageValue(...) | --------------------------------------------------------

const (
	MESSAGE_TYPE_COMPRESS MessageType = iota
	MESSAGE_TYPE_SYSLOG
	MESSAGE_TYPE_STATSD

	MESSAGE_TYPE_METRICS
	MESSAGE_TYPE_TAGGEDFLOW
	MESSAGE_TYPE_PROTOCOLLOG
	MESSAGE_TYPE_OPENTELEMETRY
	MESSAGE_TYPE_PROMETHEUS
	MESSAGE_TYPE_TELEGRAF
	MESSAGE_TYPE_PACKETSEQUENCE

	MESSAGE_TYPE_DFSTATS
	MESSAGE_TYPE_OPENTELEMETRY_COMPRESSED
	MESSAGE_TYPE_RAW_PCAP
	MESSAGE_TYPE_PROFILE
	MESSAGE_TYPE_PROC_EVENT
	MESSAGE_TYPE_ALARM_EVENT
	MESSAGE_TYPE_MAX
)

func (MessageType) HeaderType

func (m MessageType) HeaderType() MessageHeaderType

func (MessageType) String

func (m MessageType) String() string

type MetaPacket

type MetaPacket struct {
	// 注意字节对齐!
	RawHeader []byte // total packet
	RawIcmp   []byte // icmp header

	Timestamp    time.Duration
	EndpointData EndpointData
	PolicyData   PolicyData

	Tunnel *TunnelInfo

	PacketLen     uint16
	RawHeaderSize uint16
	VtapId        uint16
	TapType       TapType // (8B)
	TapPort       uint32
	L2End0        bool
	L2End1        bool
	L3End0        bool
	L3End1        bool // (8B)
	L3EpcId0      uint16
	L3EpcId1      uint16
	QueueHash     uint8

	MacSrc  MacInt
	MacDst  MacInt
	EthType EthernetType
	Vlan    uint16

	IHL        uint8  // ipv4 ihl or ipv6 fl4b
	TTL        uint8  // ipv4 ttl or ipv6 hop limit
	IpID       uint16 // (8B)
	IpSrc      uint32
	IpDst      uint32 // (8B)
	Ip6Src     net.IP // ipv6
	Ip6Dst     net.IP // ipv6
	Options    []byte
	IpFlags    uint16 // ipv4 Flags and Fragment Offset or ipv6 flow label
	Protocol   IPProtocol
	NextHeader IPProtocol // ipv6

	PortSrc uint16
	PortDst uint16              // (8B)
	TcpData MetaPacketTcpHeader // 绝大多数流量是TCP,不使用指针

	Direction       PacketDirection // flowgenerator负责初始化,表明MetaPacket方向
	IsActiveService bool            // flowgenerator负责初始化,表明服务端是否活跃
}

func (*MetaPacket) String

func (p *MetaPacket) String() string

type MetaPacketBlock

type MetaPacketBlock struct {
	Metas [META_PACKET_SIZE_PER_BLOCK]MetaPacket

	ActionFlags ActionFlag
	Count       uint8
	QueueIndex  uint8
	pool.ReferenceCount
}

func AcquireMetaPacketBlock

func AcquireMetaPacketBlock() *MetaPacketBlock

func (*MetaPacketBlock) String

func (b *MetaPacketBlock) String() string

type MetaPacketTcpHeader

type MetaPacketTcpHeader struct {
	// 注意字节对齐!
	Seq           uint32
	Ack           uint32
	WinSize       uint16
	MSS           uint16
	Flags         uint8
	DataOffset    uint8
	WinScale      uint8
	SACKPermitted bool
	Sack          []byte // sack value
}

func (*MetaPacketTcpHeader) String

func (h *MetaPacketTcpHeader) String() string

type Metering

type Metering struct {
	Timestamp    time.Duration
	InPort0      uint32
	VLAN         uint16
	IPSrc        IP
	IPDst        IP
	Proto        layers.IPProtocol
	PortSrc      uint16
	PortDst      uint16
	ByteCount0   uint64
	ByteCount1   uint64
	PacketCount0 uint64
	PacketCount1 uint64
	L3EpcID0     uint32
	L3EpcID1     uint32
}

func (*Metering) String

func (m *Metering) String() string

type MqttInfo

type MqttInfo struct {
	MqttType string

	// request
	ReqMsgSize   int32
	ProtoVersion uint16
	ClientID     string

	// reponse
	RespMsgSize int32
}

func AcquireMqttInfo

func AcquireMqttInfo() *MqttInfo

func (*MqttInfo) Merge

func (i *MqttInfo) Merge(r interface{})

func (*MqttInfo) String

func (i *MqttInfo) String() string

func (*MqttInfo) WriteToPB

func (i *MqttInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type MysqlCommand

type MysqlCommand uint8

func (MysqlCommand) String

func (m MysqlCommand) String() string

type MysqlInfo

type MysqlInfo struct {
	// Server Greeting
	ProtocolVersion uint8
	ServerVersion   string
	ServerThreadID  uint32
	// Request
	Command uint8
	Context string
	// Response
	ResponseCode uint8
	ErrorCode    uint16
	AffectedRows uint64
	ErrorMessage string
}

func AcquireMYSQLInfo

func AcquireMYSQLInfo() *MysqlInfo

func (*MysqlInfo) Merge

func (i *MysqlInfo) Merge(r interface{})

func (*MysqlInfo) String

func (i *MysqlInfo) String() string

func (*MysqlInfo) WriteToPB

func (i *MysqlInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type NATSource

type NATSource uint8
const (
	NAT_SOURCE_NONE NATSource = iota

	NAT_SOURCE_VIP

	NAT_SOURCE_RTOA

	NAT_SOURCE_TOA
)

func (NATSource) String

func (n NATSource) String() string

type NpbAction

type NpbAction uint64 // aclgid | payload-slice | tunnel-type | TapSide |  tunnel-id

func ToNpbAction

func ToNpbAction(aclGid, id uint32, tunnelType, tapSide uint8, slice uint16) NpbAction

func (*NpbAction) AddTapSide

func (a *NpbAction) AddTapSide(flag int)

func (NpbAction) GetDirections

func (a NpbAction) GetDirections() DirectionType

func (NpbAction) PayloadSlice

func (a NpbAction) PayloadSlice() uint16

func (*NpbAction) ReverseTapSide

func (a *NpbAction) ReverseTapSide() NpbAction

func (*NpbAction) SetPayloadSlice

func (a *NpbAction) SetPayloadSlice(payload uint16)

func (*NpbAction) SetTapSide

func (a *NpbAction) SetTapSide(flag int)

func (*NpbAction) SetTunnelId

func (a *NpbAction) SetTunnelId(id uint32)

func (NpbAction) String

func (a NpbAction) String() string

func (NpbAction) TapSide

func (a NpbAction) TapSide() int

func (NpbAction) TapSideCompare

func (a NpbAction) TapSideCompare(flag int) bool

func (NpbAction) TunnelGid

func (a NpbAction) TunnelGid() uint16

func (NpbAction) TunnelId

func (a NpbAction) TunnelId() uint32

func (NpbAction) TunnelIp

func (a NpbAction) TunnelIp() net.IP

func (NpbAction) TunnelIpId

func (a NpbAction) TunnelIpId() uint16

func (NpbAction) TunnelType

func (a NpbAction) TunnelType() uint8

type NpbActions

type NpbActions struct {
	NpbAction
	// contains filtered or unexported fields
}

func ToNpbActions

func ToNpbActions(aclGid, id uint32, tunnelType, tapSide uint8, slice uint16) NpbActions

func (*NpbActions) AddAclGid

func (a *NpbActions) AddAclGid(aclGids ...uint16)

func (*NpbActions) Decode

func (n *NpbActions) Decode(decoder *codec.SimpleDecoder)

func (*NpbActions) Encode

func (n *NpbActions) Encode(encoder *codec.SimpleEncoder)

func (NpbActions) GetAclGid

func (a NpbActions) GetAclGid() []uint16

func (*NpbActions) ReverseTapSide

func (a *NpbActions) ReverseTapSide() NpbActions

func (NpbActions) String

func (a NpbActions) String() string

type PacketDirection

type PacketDirection uint8
const (
	CLIENT_TO_SERVER PacketDirection = FLOW_METRICS_PEER_SRC // 0
	SERVER_TO_CLIENT PacketDirection = FLOW_METRICS_PEER_DST // 1
)

func OppositePacketDirection

func OppositePacketDirection(d PacketDirection) PacketDirection

type PacketFlag

type PacketFlag uint16
const (
	CFLAG_MAC0 PacketFlag = 1 << iota
	CFLAG_MAC1
	CFLAG_VLANTAG
	CFLAG_HEADER_TYPE

	CFLAG_IP0
	CFLAG_IP1
	CFLAG_PORT0
	CFLAG_PORT1

	CFLAG_TTL
	CFLAG_FLAGS_FRAG_OFFSET
	CFLAG_DATAOFF_IHL

	PFLAG_SRC_L3ENDPOINT
	PFLAG_DST_L3ENDPOINT
	PFLAG_SRC_ENDPOINT
	PFLAG_DST_ENDPOINT
	PFLAG_TUNNEL

	PFLAG_NONE PacketFlag = 0
	CFLAG_FULL            = 0x7FF
)

func (PacketFlag) IsSet

func (f PacketFlag) IsSet(flag PacketFlag) bool

type PeerConnection

type PeerConnection struct {
	Id                  uint32
	LocalEpc, RemoteEpc int32
}

type PlatformData

type PlatformData struct {
	Mac            uint64
	Ips            []IpNet
	EpcId          int32
	Id             uint32
	RegionId       uint32
	PodClusterId   uint32
	PodNodeId      uint32
	IfType         uint8
	DeviceType     uint8
	IsVIPInterface bool
	// 适配windows hyper-v场景出现的在不同Region存在相同MAC,PlatformData查询GRPC下发的Region id,
	// PlatformData不在同一Region中,该字段为True, 若为true不会创建mac表
	SkipMac bool
	// 适配青云场景,同子网跨宿主机时采集中间网卡流量,流量MAC地址均为虚拟机MAC(可以打上L3end),但是无法打上L2end为了区分需要
	// 链路追踪具体统计哪一端,引入该字段
	IsLocal bool // 平台数据为当前宿主机的虚拟机(local segment)设置为true
}

type PolicyData

type PolicyData struct {
	NpbActions  []NpbActions
	AclId       uint32
	ActionFlags ActionFlag
}

func (*PolicyData) ContainNpb

func (d *PolicyData) ContainNpb() bool

func (*PolicyData) ContainPcap

func (d *PolicyData) ContainPcap() bool

func (*PolicyData) Decode

func (p *PolicyData) Decode(decoder *codec.SimpleDecoder)

func (*PolicyData) Dedup

func (d *PolicyData) Dedup(packet *LookupKey)

func (*PolicyData) Encode

func (p *PolicyData) Encode(encoder *codec.SimpleEncoder)

func (*PolicyData) FormatNpbAction

func (d *PolicyData) FormatNpbAction()

如果双方向都匹配了同一策略,对应的NpbActions Merge后会是TAPSIDE_ALL, 此时只保留TAPSIDE_SRC方向,即对应只处理src为true的tx流量

func (*PolicyData) GobDecode

func (d *PolicyData) GobDecode(in []byte) error

func (*PolicyData) GobEncode

func (d *PolicyData) GobEncode() ([]byte, error)

func (*PolicyData) Merge

func (d *PolicyData) Merge(npbActions []NpbActions, aclID uint32, directions ...DirectionType)

func (*PolicyData) MergeAndSwapDirection

func (d *PolicyData) MergeAndSwapDirection(npbActions []NpbActions, aclID uint32)

func (*PolicyData) MergeNpbAction

func (d *PolicyData) MergeNpbAction(actions []NpbActions, aclID uint32, directions ...DirectionType)

func (*PolicyData) MergeNpbAndSwapDirection

func (d *PolicyData) MergeNpbAndSwapDirection(actions []NpbActions, aclID uint32)

func (*PolicyData) String

func (d *PolicyData) String() string

func (*PolicyData) Valid

func (d *PolicyData) Valid() bool

type PortRange

type PortRange uint32

func GetPortRanges

func GetPortRanges(raw []PortRange) []PortRange

func NewPortRange

func NewPortRange(min, max uint16) PortRange

func SplitPort2Int

func SplitPort2Int(src string) []PortRange

func (PortRange) Max

func (p PortRange) Max() uint16

func (PortRange) Min

func (p PortRange) Min() uint16

func (PortRange) String

func (p PortRange) String() string

type PortStatus

type PortStatus uint8
const (
	RANGE_NONE PortStatus = iota
	RANGE_IN
	RANGE_EDGE
	RANGE_LEFT
	RANGE_RIGHT
)

type ProtoSpecialInfo

type ProtoSpecialInfo interface {
	String() string
	Merge(interface{})
}

type RawPacket

type RawPacket = []byte

type RedisInfo

type RedisInfo struct {
	Request     string // 命令字段包括参数例如:"set key value"
	RequestType string // 命令类型不包括参数例如:命令为"set key value",命令类型为:"set"

	Response string // 整数回复 + 批量回复 + 多条批量回复
	Status   string // '+'
	Error    string // '-'
}

func AcquireREDISInfo

func AcquireREDISInfo() *RedisInfo

func (*RedisInfo) Merge

func (i *RedisInfo) Merge(r interface{})

func (*RedisInfo) String

func (i *RedisInfo) String() string

func (*RedisInfo) WriteToPB

func (i *RedisInfo) WriteToPB(p *pb.AppProtoLogsData, msgType LogMessageType)

type SignalSource

type SignalSource uint8
const (
	SIGNAL_SOURCE_PACKET SignalSource = iota
	SIGNAL_SOURCE_XFLOW

	SIGNAL_SOURCE_EBPF
	SIGNAL_SOURCE_OTEL
)

func (SignalSource) String

func (t SignalSource) String() string

type TCPPerfStats

type TCPPerfStats struct {
	RTTClientMax uint32 // us,Trident保证时延最大值不会超过3600s,能容纳在u32内
	RTTServerMax uint32 // us
	SRTMax       uint32 // us
	ARTMax       uint32 // us,UDP复用

	RTT            uint32 // us,TCP建连过程,只会计算出一个RTT
	RTTClientSum   uint32 // us,假定一条流在一分钟内的时延加和不会超过u32
	RTTServerSum   uint32 // us
	SRTSum         uint32 // us
	ARTSum         uint32 // us,UDP复用
	RTTClientCount uint32
	RTTServerCount uint32
	SRTCount       uint32
	ARTCount       uint32 // UDP复用

	TcpPerfCountsPeers [2]TcpPerfCountsPeer
	TotalRetransCount  uint32 // 整个Flow生命周期的统计量
}

size = 20 * 4B = 80Byte UDPPerfStats仅有2个字段,复用ARTSum, ARTCount

func (*TCPPerfStats) Reverse

func (f *TCPPerfStats) Reverse()

func (*TCPPerfStats) SequentialMerge

func (f *TCPPerfStats) SequentialMerge(rhs *TCPPerfStats)

func (*TCPPerfStats) String

func (p *TCPPerfStats) String() string

func (*TCPPerfStats) WriteToPB

func (f *TCPPerfStats) WriteToPB(p *pb.TCPPerfStats, l4Protocol L4Protocol)

type Tag

type Tag struct {
	PolicyData [2]PolicyData
}

func (*Tag) Decode

func (t *Tag) Decode(decoder *codec.SimpleDecoder)

func (*Tag) Encode

func (t *Tag) Encode(encoder *codec.SimpleEncoder)

func (*Tag) Reverse

func (t *Tag) Reverse()

type TaggedFlow

type TaggedFlow struct {
	Flow
	Tag

	pool.ReferenceCount
}

func AcquireTaggedFlow

func AcquireTaggedFlow() *TaggedFlow

func CloneTaggedFlow

func CloneTaggedFlow(taggedFlow *TaggedFlow) *TaggedFlow

func CloneTaggedFlowForPacketStat

func CloneTaggedFlowForPacketStat(taggedFlow *TaggedFlow) *TaggedFlow

注意:不拷贝FlowPerfStats

func (*TaggedFlow) EncodePB

func (f *TaggedFlow) EncodePB(encoder *codec.SimpleEncoder, i interface{}) error

func (*TaggedFlow) Release

func (f *TaggedFlow) Release()

func (*TaggedFlow) Reverse

func (f *TaggedFlow) Reverse()

func (*TaggedFlow) SequentialMerge

func (f *TaggedFlow) SequentialMerge(rhs *TaggedFlow)

func (*TaggedFlow) String

func (f *TaggedFlow) String() string

func (*TaggedFlow) WriteToPB

func (f *TaggedFlow) WriteToPB(p *pb.TaggedFlow) error

type TaggedMetering

type TaggedMetering struct {
	Metering
	Tag
}

func (*TaggedMetering) BitCount

func (m *TaggedMetering) BitCount() uint64

func (*TaggedMetering) PacketCount

func (m *TaggedMetering) PacketCount() uint64

func (*TaggedMetering) String

func (t *TaggedMetering) String() string

type TapPort

type TapPort uint64

64 60 40 36 32 0 +------+----------+------------+----------+-------------------------------------+ | from | RESERVED | NAT SOURCE | TUN_TYPE | ip/id/mac | +------+----------+------------+----------+-------------------------------------+ 注意ip/id/mac不能超过32bit,否则数据存储、四元组聚合都会有歧义

func FromGatewayMAC

func FromGatewayMAC(tunnelType TunnelType, mac uint32) TapPort

func FromID

func FromID(tunnelType TunnelType, id int) TapPort

func FromLocalMAC

func FromLocalMAC(tunnelType TunnelType, mac uint32) TapPort

func FromNetFlow

func FromNetFlow(mac uint32) TapPort

func FromSFlow

func FromSFlow(mac uint32) TapPort

func FromTunnelIP

func FromTunnelIP(ip uint32, isIPv6 bool) TapPort

func (TapPort) SetReservedBytes

func (p TapPort) SetReservedBytes(v uint32) TapPort

用于编码后做为Map Key

func (TapPort) SplitToPortTypeTunnel

func (p TapPort) SplitToPortTypeTunnel() (uint32, uint8, NATSource, TunnelType)

TapPort、TapPortType、TunnelType

func (TapPort) String

func (p TapPort) String() string

type TapType

type TapType uint16

TAP: Traffic Access Point

Indicates the flow data collection location. Currently supports 256 acquisition locations. The traffic in cloud is uniformly represented by a special value `3`, and the other values represent the traffic collected from optical splitting and mirroring at different locations in the IDC.

Note: For historical reasons, we use the confusing term VTAP to refer to observatrace-agent, and vtap_id to represent the id of a observatrace-agent.

const (
	TAP_ANY     TapType = 0 // match any TapType
	TAP_IDC_MIN TapType = 1
	TAP_CLOUD   TapType = 3
	TAP_MAX     TapType = 256 // exclusive

	TAP_MIN TapType = TAP_ANY + 1
)

func (*TapType) CheckTapType

func (t *TapType) CheckTapType(tapType TapType) bool

type TcpPerfCountsPeer

type TcpPerfCountsPeer struct {
	RetransCount uint32
	ZeroWinCount uint32
}

func (*TcpPerfCountsPeer) SequentialMerge

func (f *TcpPerfCountsPeer) SequentialMerge(rhs *TcpPerfCountsPeer)

func (*TcpPerfCountsPeer) WriteToPB

func (t *TcpPerfCountsPeer) WriteToPB(p *pb.TcpPerfCountsPeer)

type TunnelField

type TunnelField struct {
	TxIP0, TxIP1   IPv4Int // 对应发送方向的源目的隧道IP
	RxIP0, RxIP1   IPv4Int // 对应接收方向的源目的隧道IP
	TxMAC0, TxMAC1 uint32  // 对应发送方向的源目的隧道MAC,低4字节
	RxMAC0, RxMAC1 uint32  // 对应接收方向的源目的隧道MAC,低4字节
	TxId, RxId     uint32
	Type           TunnelType
	Tier           uint8
	IsIPv6         bool
}

func (*TunnelField) String

func (t *TunnelField) String() string

func (*TunnelField) WriteToPB

func (f *TunnelField) WriteToPB(p *pb.TunnelField)

type TunnelInfo

type TunnelInfo struct {
	Src    IPv4Int
	Dst    IPv4Int
	MacSrc uint32 // lowest 4B
	MacDst uint32 // lowest 4B
	Id     uint32
	Type   TunnelType
	Tier   uint8
	IsIPv6 bool
}

func (*TunnelInfo) Decapsulate

func (t *TunnelInfo) Decapsulate(packet []byte, l2Len int, tunnelTypeBitmap TunnelTypeBitmap) int

func (*TunnelInfo) Decapsulate6

func (t *TunnelInfo) Decapsulate6(packet []byte, l2Len int, tunnelTypeBitmap TunnelTypeBitmap) int

func (*TunnelInfo) Decapsulate6Vxlan

func (t *TunnelInfo) Decapsulate6Vxlan(packet []byte, l2Len int) int

func (*TunnelInfo) DecapsulateErspan

func (t *TunnelInfo) DecapsulateErspan(packet []byte, l2Len int, flags, greProtocolType uint16, ipHeaderSize int) int

func (*TunnelInfo) DecapsulateGre

func (t *TunnelInfo) DecapsulateGre(packet []byte, l2Len int, tunnelTypeBitmap TunnelTypeBitmap) int

func (*TunnelInfo) DecapsulateIPIP

func (t *TunnelInfo) DecapsulateIPIP(packet []byte, l2Len int, underlayIpv6, overlayIpv6 bool) int

func (*TunnelInfo) DecapsulateTeb

func (t *TunnelInfo) DecapsulateTeb(packet []byte, l2Len int, flags, greProtocolType uint16, ipHeaderSize int) int

func (*TunnelInfo) DecapsulateTencentGre

func (t *TunnelInfo) DecapsulateTencentGre(packet []byte, l2Len int, flags, greProtocolType uint16, ipHeaderSize int) int

func (*TunnelInfo) DecapsulateVxlan

func (t *TunnelInfo) DecapsulateVxlan(packet []byte, l2Len int) int

func (*TunnelInfo) String

func (t *TunnelInfo) String() string

func (*TunnelInfo) Valid

func (t *TunnelInfo) Valid() bool

type TunnelType

type TunnelType uint8

func (TunnelType) String

func (t TunnelType) String() string

type TunnelTypeBitmap

type TunnelTypeBitmap uint16

func NewTunnelTypeBitmap

func NewTunnelTypeBitmap(items ...TunnelType) TunnelTypeBitmap

func (*TunnelTypeBitmap) Add

func (b *TunnelTypeBitmap) Add(tunnelType TunnelType)

func (TunnelTypeBitmap) Has

func (b TunnelTypeBitmap) Has(tunnelType TunnelType) bool

func (TunnelTypeBitmap) IsEmpty

func (b TunnelTypeBitmap) IsEmpty() bool

func (TunnelTypeBitmap) String

func (b TunnelTypeBitmap) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL