Help us shape the future of Go! Take the 2026 Go Developer Survey

protos

package
v1.67.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_RTCP_SR   = 200
	TYPE_RTCP_RR   = 201
	TYPE_RTCP_SDES = 202
	TYPE_RTCP_BYE  = 203
	TYPE_RTCP_APP  = 204
	TYPE_RTCP_XR   = 207
)

Variables

View Source
var (
	ErrHeaderLengthMSB        = fmt.Errorf("ws header most significant bit must be 0")
	ErrHeaderLengthUnexpected = fmt.Errorf("ws header unexpected payload length bits")
)

Errors used by ReadWSHeader.

Functions

func NewRTP

func NewRTP(raw []byte) string

func ParseDNS

func ParseDNS(d *layers.DNS) []byte

func ParseRTCP

func ParseRTCP(data []byte) ([]byte, []byte, string)

func WSPayload

func WSPayload(data []byte) (b []byte, err error)

WSPayload returns the Websocket payload from r.

Types

type DHCP

type DHCP struct {
	Operation    layers.DHCPOp
	HardwareType layers.LinkType
	HardwareLen  uint8
	HardwareOpts uint8
	Xid          uint32
	Secs         uint16
	Flags        uint16
	ClientIP     net.IP
	YourClientIP net.IP
	NextServerIP net.IP
	RelayAgentIP net.IP
	ClientHWAddr net.HardwareAddr
	ServerName   []byte
	File         []byte
	Options      layers.DHCPOptions
}

func NewDHCP

func NewDHCP(dhcp *layers.DHCPv4) (d *DHCP)

TODO: complete this

type DNS

type DNS struct {
	ID     uint16           `json:"id"`
	QR     bool             `json:"qr"`
	OpCode layers.DNSOpCode `json:"opcode"`

	AA bool  `json:"aa"` // Authoritative answer
	TC bool  `json:"tc"` // Truncated
	RD bool  `json:"rd"` // Recursion desired
	RA bool  `json:"ra"` // Recursion available
	Z  uint8 `json:"z"`  // For future use

	ResponseCode layers.DNSResponseCode `json:"rescode"`
	QDCount      uint16                 `json:"qdc"` // Expected questions
	ANCount      uint16                 `json:"anc"` // Expected answers
	NSCount      uint16                 `json:"nsc"` // Expected authorities
	ARCount      uint16                 `json:"arc"` // Expected additional records

	Questions []DNSQuestion       `json:"questions,omitempty"`
	Answers   []DNSResourceRecord `json:"answers,omitempty"`
}

func (*DNS) MarshalJSON

func (d *DNS) MarshalJSON() ([]byte, error)

type DNSQuestion

type DNSQuestion struct {
	Name  string          `json:"name"`
	Type  layers.DNSType  `json:"type"`
	Class layers.DNSClass `json:"class"`
}

type DNSResourceRecord

type DNSResourceRecord struct {
	Name  string          `json:"name"`
	Type  layers.DNSType  `json:"type"`
	Class layers.DNSClass `json:"class"`
	TTL   uint32          `json:"ttl"`

	IP    net.IP `json:"ip,omitempty"`
	NS    string `json:"ns,omitempty"`
	CNAME string `json:"cname,omitempty"`
}

type IPv4

type IPv4 struct {
	Version    uint8               `json:"version"`
	IHL        uint8               `json:"ihl"`
	TOS        uint8               `json:"tos"`
	Length     uint16              `json:"len"`
	Id         uint16              `json:"id"`
	Flags      layers.IPv4Flag     `json:"flags"`
	FragOffset uint16              `json:"offset"`
	TTL        uint8               `json:"ttl"`
	Protocol   layers.IPProtocol   `json:"proto"`
	Checksum   uint16              `json:"checksum"`
	SrcIP      net.IP              `json:"srcip"`
	DstIP      net.IP              `json:"dstip"`
	Options    []layers.IPv4Option `json:"-"`
	Padding    []byte              `json:"padding,omitempty"`
}

func NewIP4

func NewIP4(ip *layers.IPv4) *IPv4

type IPv6

type IPv6 struct {
	Version      uint8                `json:"version"`
	TrafficClass uint8                `json:"tc"`
	FlowLabel    uint32               `json:"flow"`
	Length       uint16               `json:"len"`
	NextHeader   layers.IPProtocol    `json:"proto"`
	HopLimit     uint8                `json:"hoplimit"`
	SrcIP        net.IP               `json:"srcip"`
	DstIP        net.IP               `json:"dstip"`
	HopByHop     *layers.IPv6HopByHop `json:"-"`
}

func NewIP6

func NewIP6(ip6 *layers.IPv6) *IPv6

type RTCP_Packet

type RTCP_Packet struct {
	SenderInformation struct {
		Ntp_timestamp_MSW uint32 `json:"ntp_timestamp_sec"`
		Ntp_timestamp_LSW uint32 `json:"ntp_timestamp_usec"`
		Rtp_timestamp     uint32 `json:"rtp_timestamp"`
		Pkt_count         uint32 `json:"packets"`
		Octet_count       uint32 `json:"octets"`
	} `json:"sender_information"`
	Ssrc           uint32               `json:"ssrc"`
	Type           uint8                `json:"type"`
	ReportCount    uint8                `json:"report_count"`
	ReportBlocks   []RTCP_report_block  `json:"report_blocks"`
	ReportBlocksXr RTCP_report_block_xr `json:"report_blocks_xr"`
	Sdes_ssrc      uint32               `json:"sdes_ssrc"`
}

func (*RTCP_Packet) AddReportBlock

func (rp *RTCP_Packet) AddReportBlock(rb RTCP_report_block) []RTCP_report_block

func (*RTCP_Packet) MarshalJSON

func (rp *RTCP_Packet) MarshalJSON() ([]byte, error)

type RTCP_header

type RTCP_header struct {
	Version     uint8  `json:"version"`      // 2 bit
	Padding     uint8  `json:"padding"`      // 1 bit
	ReportCount uint8  `json:"report_count"` // 5 bit
	RTCPType    uint8  `json:"type"`
	Length      uint16 `json:"length"`
}

type RTCP_report_block

type RTCP_report_block struct {
	SourceSsrc      uint32 `json:"source_ssrc"`
	Fraction_lost   uint8  `json:"fraction_lost"`
	Cumulative_lost uint32 `json:"packets_lost"` // 24 bit
	Highest_seq_no  uint32 `json:"highest_seq_no"`
	Jitter          uint32 `json:"ia_jitter"`
	LastSR          uint32 `json:"lsr"`
	Delay_last_SR   uint32 `json:"dlsr"`
}

type RTCP_report_block_xr

type RTCP_report_block_xr struct {
	Type             uint8  `json:"type"`
	ID               uint32 `json:"id"`
	Fraction_lost    uint8  `json:"fraction_lost"`
	Fraction_discard uint8  `json:"fraction_discard"`
	Burst_density    uint8  `json:"burst_density"`
	Gap_density      uint8  `json:"gap_density"`
	Burst_duration   uint16 `json:"burst_duration"`
	Gap_duration     uint16 `json:"gap_duration"`
	Round_trip_delay uint16 `json:"round_trip_delay"`
	End_system_delay uint16 `json:"end_system_delay"`
}

type TCP

type TCP struct {
	SrcPort layers.TCPPort `json:"srcport"`
	DstPort layers.TCPPort `json:"dstport"`
	Payload []byte         `json:"payload,omitempty"`
}

func NewTCP

func NewTCP(tcp *layers.TCP) (t *TCP)

type UDP

type UDP struct {
	SrcPort layers.UDPPort `json:"srcport"`
	DstPort layers.UDPPort `json:"dstport"`
	Payload []byte         `json:"payload,omitempty"`
}

func NewUDP

func NewUDP(udp *layers.UDP) (u *UDP)

type WSHeader

type WSHeader struct {
	Fin    bool
	Rsv    byte
	OpCode WSOpCode
	Masked bool
	Mask   [4]byte
	Length int64
	Offset int
}

WSHeader represents a Websocket header.

func ReadWSHeader

func ReadWSHeader(data []byte) (h WSHeader, err error)

ReadWSHeader reads a Websocket header from r.

type WSOpCode

type WSOpCode byte

WSOpCode represents operation code.

Jump to

Keyboard shortcuts

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