protocol

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 10

Documentation

Index

Constants

View Source
const (
	Type_Request = 1
	Type_Reply   = 2
)
View Source
const (
	DHCP_MSG_BOOT_REQ byte = iota
	DHCP_MSG_BOOT_RES
)
View Source
const (
	DHCP_OPT_REQUEST_IP     byte = iota + 50 // 0x32, 4, net.IP
	DHCP_OPT_LEASE_TIME                      // 0x33, 4, uint32
	DHCP_OPT_EXT_OPTS                        // 0x34, 1, 1/2/3
	DHCP_OPT_MESSAGE_TYPE                    // 0x35, 1, 1-7
	DHCP_OPT_SERVER_ID                       // 0x36, 4, net.IP
	DHCP_OPT_PARAMS_REQUEST                  // 0x37, n, []byte
	DHCP_OPT_MESSAGE                         // 0x38, n, string
	DHCP_OPT_MAX_DHCP_SIZE                   // 0x39, 2, uint16
	DHCP_OPT_T1                              // 0x3a, 4, uint32
	DHCP_OPT_T2                              // 0x3b, 4, uint32
	DHCP_OPT_CLASS_ID                        // 0x3c, n, []byte
	DHCP_OPT_CLIENT_ID                       // 0x3d, n >=  2, []byte

)
View Source
const (
	DHCP_OPT_PAD                       byte = iota
	DHCP_OPT_SUBNET_MASK                    // 0x01, 4, net.IP
	DHCP_OPT_TIME_OFFSET                    // 0x02, 4, int32 (signed seconds from UTC)
	DHCP_OPT_DEFAULT_GATEWAY                // 0x03, n*4, [n]net.IP
	DHCP_OPT_TIME_SERVER                    // 0x04, n*4, [n]net.IP
	DHCP_OPT_NAME_SERVER                    // 0x05, n*4, [n]net.IP
	DHCP_OPT_DOMAIN_NAME_SERVERS            // 0x06, n*4, [n]net.IP
	DHCP_OPT_LOG_SERVER                     // 0x07, n*4, [n]net.IP
	DHCP_OPT_COOKIE_SERVER                  // 0x08, n*4, [n]net.IP
	DHCP_OPT_LPR_SERVER                     // 0x09, n*4, [n]net.IP
	DHCP_OPT_IMPRESS_SERVER                 // 0x0a, n*4, [n]net.IP
	DHCP_OPT_RLSERVER                       // 0x0b, n*4, [n]net.IP
	DHCP_OPT_HOST_NAME                      // 0x0c, n, string
	DHCP_OPT_BOOTFILE_SIZE                  // 0x0d, 2, uint16
	DHCP_OPT_MERIT_DUMP_FILE                // 0x0e, >1, string
	DHCP_OPT_DOMAIN_NAME                    // 0x0f, n, string
	DHCP_OPT_SWAP_SERVER                    // 0x10, n*4, [n]net.IP
	DHCP_OPT_ROOT_PATH                      // 0x11, n, string
	DHCP_OPT_EXTENSIONS_PATH                // 0x12, n, string
	DHCP_OPT_IP_FORWARDING                  // 0x13, 1, bool
	DHCP_OPT_SOURCE_ROUTING                 // 0x14, 1, bool
	DHCP_OPT_POLICY_FILTER                  // 0x15, 8*n, [n]{net.IP/net.IP}
	DHCP_OPT_DGRAM_MTU                      // 0x16, 2, uint16
	DHCP_OPT_DEFAULT_TTL                    // 0x17, 1, byte
	DHCP_OPT_PATH_MTU_AGING_TIMEOUT         // 0x18, 4, uint32
	DHCP_OPT_PATH_PLATEAU_TABLE_OPTION      // 0x19, 2*n, []uint16
	DHCP_OPT_INTERFACE_MTU                  //0x1a, 2, uint16
	DHCP_OPT_ALL_SUBS_LOCAL                 // 0x1b, 1, bool
	DHCP_OPT_BROADCAST_ADDR                 // 0x1c, 4, net.IP
	DHCP_OPT_MASK_DISCOVERY                 // 0x1d, 1, bool
	DHCP_OPT_MASK_SUPPLIER                  // 0x1e, 1, bool
	DHCP_OPT_ROUTER_DISCOVERY               // 0x1f, 1, bool
	DHCP_OPT_ROUTER_SOLICIT_ADDR            // 0x20, 4, net.IP
	DHCP_OPT_STATIC_ROUTE                   // 0x21, n*8, [n]{net.IP/net.IP} -- note the 2nd is router not mask
	DHCP_OPT_ARP_TRAILERS                   // 0x22, 1, bool
	DHCP_OPT_ARP_TIMEOUT                    // 0x23, 4, uint32
	DHCP_OPT_ETHERNET_ENCAP                 // 0x24, 1, bool
	DHCP_OPT_TCP_TTL                        // 0x25,1, byte
	DHCP_OPT_TCP_KEEPALIVE_INT              // 0x26,4, uint32
	DHCP_OPT_TCP_KEEPALIVE_GARBAGE          // 0x27,1, bool
	DHCP_OPT_NIS_DOMAIN                     // 0x28,n, string
	DHCP_OPT_NIS_SERVERS                    // 0x29,4*n,  [n]net.IP
	DHCP_OPT_NTP_SERVERS                    // 0x2a, 4*n, [n]net.IP
	DHCP_OPT_VENDOR_OPT                     // 0x2b, n, [n]byte // may be encapsulated.
	DHCP_OPT_NETBIOS_IPNS                   // 0x2c, 4*n, [n]net.IP
	DHCP_OPT_NETBIOS_DDS                    // 0x2d, 4*n, [n]net.IP
	DHCP_OPT_NETBIOS_NODE_TYPE              // 0x2e, 1, magic byte
	DHCP_OPT_NETBIOS_SCOPE                  // 0x2f, n, string
	DHCP_OPT_X_FONT_SERVER                  // 0x30, n, string
	DHCP_OPT_X_DISPLAY_MANAGER              // 0x31, n, string

	DHCP_OPT_SIP_SERVERS byte = 0x78 // 0x78!, n, url
	DHCP_OPT_END         byte = 0xff
)

Standard options (RFC1533)

View Source
const (
	IPv4_MSG = 0x0800
	ARP_MSG  = 0x0806
	LLDP_MSG = 0x88cc
	WOL_MSG  = 0x0842
	RARP_MSG = 0x8035
	VLAN_MSG = 0x8100

	IPv6_MSG     = 0x86DD
	STP_MSG      = 0x4242
	STP_BPDU_MSG = 0xAAAA
)

see http://en.wikipedia.org/wiki/EtherType

View Source
const (
	PCP_MASK = 0xe000
	DEI_MASK = 0x1000
	VID_MASK = 0x0fff
)
View Source
const (
	IGMPQuery        = 0x11
	IGMPv1Report     = 0x12
	IGMPv2Report     = 0x16
	IGMPv2LeaveGroup = 0x17
	IGMPv3Report     = 0x22

	IGMPIsIn  = 0x01 // Type MODE_IS_INCLUDE, source addresses x
	IGMPIsEx  = 0x02 // Type MODE_IS_EXCLUDE, source addresses x
	IGMPToIn  = 0x03 // Type CHANGE_TO_INCLUDE_MODE, source addresses x
	IGMPToEx  = 0x04 // Type CHANGE_TO_EXCLUDE_MODE, source addresses x
	IGMPAllow = 0x05 // Type ALLOW_NEW_SOURCES, source addresses x
	IGMPBlock = 0x06 // Type BLOCK_OLD_SOURCES, source addresses x
)
View Source
const (
	Type_ICMP     = 0x01
	Type_IGMP     = 0x02
	Type_TCP      = 0x06
	Type_UDP      = 0x11
	Type_IPv6     = 0x29
	Type_IPv6ICMP = 0x3a
)
View Source
const (
	Type_HBH      = 0x0
	Type_Routing  = 0x2b
	Type_Fragment = 0x2c
)
View Source
const (
	CH_CHASSIS_COMPONENT
	CH_IFACE_ALIAS
	CH_PORT_COMPONENT
	CH_MAC_ADDR
	CH_NET_ADDR
	CH_IFACE_NAME
	CH_LOCAL_ASSGN
)

Chassis ID subtypes

View Source
const (
	PT_IFACE_ALIAS
	PT_PORT_COMPONENT
	PT_MAC_ADDR
	PT_NET_ADDR
	PT_IFACE_NAME
	PT_CIRCUIT_ID
	PT_LOCAL_ASSGN
)

Port ID subtypes

View Source
const (
	DHCP_FLAG_BROADCAST uint16 = 0x80
)
View Source
const (
	DHCP_HW_ETHERNET byte = 0x01
)

Variables

View Source
var DHCPOptionTypeStrings = [256]string{
	DHCP_OPT_PAD:                       "(padding)",
	DHCP_OPT_SUBNET_MASK:               "SubnetMask",
	DHCP_OPT_TIME_OFFSET:               "TimeOffset",
	DHCP_OPT_DEFAULT_GATEWAY:           "DefaultGateway",
	DHCP_OPT_TIME_SERVER:               "rfc868",
	DHCP_OPT_NAME_SERVER:               "ien116",
	DHCP_OPT_DOMAIN_NAME_SERVERS:       "DNS",
	DHCP_OPT_LOG_SERVER:                "mitLCS",
	DHCP_OPT_COOKIE_SERVER:             "OPT_COOKIE_SERVER",
	DHCP_OPT_LPR_SERVER:                "OPT_LPR_SERVER",
	DHCP_OPT_IMPRESS_SERVER:            "OPT_IMPRESS_SERVER",
	DHCP_OPT_RLSERVER:                  "OPT_RLSERVER",
	DHCP_OPT_HOST_NAME:                 "Hostname",
	DHCP_OPT_BOOTFILE_SIZE:             "BootfileSize",
	DHCP_OPT_MERIT_DUMP_FILE:           "OPT_MERIT_DUMP_FILE",
	DHCP_OPT_DOMAIN_NAME:               "DomainName",
	DHCP_OPT_SWAP_SERVER:               "OPT_SWAP_SERVER",
	DHCP_OPT_ROOT_PATH:                 "RootPath",
	DHCP_OPT_EXTENSIONS_PATH:           "OPT_EXTENSIONS_PATH",
	DHCP_OPT_IP_FORWARDING:             "OPT_IP_FORWARDING",
	DHCP_OPT_SOURCE_ROUTING:            "OPT_SOURCE_ROUTING",
	DHCP_OPT_POLICY_FILTER:             "OPT_POLICY_FILTER",
	DHCP_OPT_DGRAM_MTU:                 "OPT_DGRAM_MTU",
	DHCP_OPT_DEFAULT_TTL:               "OPT_DEFAULT_TTL",
	DHCP_OPT_PATH_MTU_AGING_TIMEOUT:    "OPT_PATH_MTU_AGING_TIMEOUT",
	DHCP_OPT_PATH_PLATEAU_TABLE_OPTION: "OPT_PATH_PLATEAU_TABLE_OPTION",
	DHCP_OPT_INTERFACE_MTU:             "OPT_INTERFACE_MTU",
	DHCP_OPT_ALL_SUBS_LOCAL:            "OPT_ALL_SUBS_LOCAL",
	DHCP_OPT_BROADCAST_ADDR:            "OPT_BROADCAST_ADDR",
	DHCP_OPT_MASK_DISCOVERY:            "OPT_MASK_DISCOVERY",
	DHCP_OPT_MASK_SUPPLIER:             "OPT_MASK_SUPPLIER",
	DHCP_OPT_ROUTER_DISCOVERY:          "OPT_ROUTER_DISCOVERY",
	DHCP_OPT_ROUTER_SOLICIT_ADDR:       "OPT_ROUTER_SOLICIT_ADDR",
	DHCP_OPT_STATIC_ROUTE:              "OPT_STATIC_ROUTE",
	DHCP_OPT_ARP_TRAILERS:              "OPT_ARP_TRAILERS",
	DHCP_OPT_ARP_TIMEOUT:               "OPT_ARP_TIMEOUT",
	DHCP_OPT_ETHERNET_ENCAP:            "OPT_ETHERNET_ENCAP",
	DHCP_OPT_TCP_TTL:                   "OPT_TCP_TTL",
	DHCP_OPT_TCP_KEEPALIVE_INT:         "OPT_TCP_KEEPALIVE_INT",
	DHCP_OPT_TCP_KEEPALIVE_GARBAGE:     "OPT_TCP_KEEPALIVE_GARBAGE",
	DHCP_OPT_NIS_DOMAIN:                "OPT_NIS_DOMAIN",
	DHCP_OPT_NIS_SERVERS:               "OPT_NIS_SERVERS",
	DHCP_OPT_NTP_SERVERS:               "OPT_NTP_SERVERS",
	DHCP_OPT_VENDOR_OPT:                "OPT_VENDOR_OPT",
	DHCP_OPT_NETBIOS_IPNS:              "OPT_NETBIOS_IPNS",
	DHCP_OPT_NETBIOS_DDS:               "OPT_NETBIOS_DDS",
	DHCP_OPT_NETBIOS_NODE_TYPE:         "OPT_NETBIOS_NODE_TYPE",
	DHCP_OPT_NETBIOS_SCOPE:             "OPT_NETBIOS_SCOPE",
	DHCP_OPT_X_FONT_SERVER:             "OPT_X_FONT_SERVER",
	DHCP_OPT_X_DISPLAY_MANAGER:         "OPT_X_DISPLAY_MANAGER",
	DHCP_OPT_END:                       "(end)",
	DHCP_OPT_SIP_SERVERS:               "SipServers",
	DHCP_OPT_REQUEST_IP:                "RequestIP",
	DHCP_OPT_LEASE_TIME:                "LeaseTime",
	DHCP_OPT_EXT_OPTS:                  "ExtOpts",
	DHCP_OPT_MESSAGE_TYPE:              "MessageType",
	DHCP_OPT_SERVER_ID:                 "ServerID",
	DHCP_OPT_PARAMS_REQUEST:            "ParamsRequest",
	DHCP_OPT_MESSAGE:                   "Message",
	DHCP_OPT_MAX_DHCP_SIZE:             "MaxDHCPSize",
	DHCP_OPT_T1:                        "Timer1",
	DHCP_OPT_T2:                        "Timer2",
	DHCP_OPT_CLASS_ID:                  "ClassID",
	DHCP_OPT_CLIENT_ID:                 "ClientID",
}

I'm amazed that this is syntactically valid. cool though.

Functions

func DHCPMarshalOption

func DHCPMarshalOption(o DHCPOption) (out []byte, err error)

A more json.Marshal like version of WriteOption.

func DHCPWriteOption

func DHCPWriteOption(w io.Writer, a DHCPOption) (n int, err error)

Write an option to an io.Writer, including tag & length (if length is appropriate to the tag type). Utilizes the MarshalOption as the underlying serializer.

Types

type ARP

type ARP struct {
	HWType      uint16
	ProtoType   uint16
	HWLength    uint8
	ProtoLength uint8
	Operation   uint16
	HWSrc       net.HardwareAddr
	IPSrc       net.IP
	HWDst       net.HardwareAddr
	IPDst       net.IP
}

func NewARP

func NewARP(opt int) (*ARP, error)

func (*ARP) Len

func (a *ARP) Len() (n uint16)

func (*ARP) MarshalBinary

func (a *ARP) MarshalBinary() (data []byte, err error)

func (*ARP) UnmarshalBinary

func (a *ARP) UnmarshalBinary(data []byte) error

type ChassisTLV

type ChassisTLV struct {
	Type    uint8
	Length  uint16
	Subtype uint8
	Data    []uint8
}

func (*ChassisTLV) Read

func (t *ChassisTLV) Read(b []byte) (n int, err error)

func (*ChassisTLV) Write

func (t *ChassisTLV) Write(b []byte) (n int, err error)

type DHCP

type DHCP struct {
	Operation    DHCPOperation
	HardwareType byte
	HardwareLen  uint8
	HardwareOpts uint8
	Xid          uint32
	Secs         uint16
	Flags        uint16
	ClientIP     net.IP
	YourIP       net.IP
	ServerIP     net.IP
	GatewayIP    net.IP
	ClientHWAddr net.HardwareAddr
	ServerName   [64]byte
	File         [128]byte
	Options      []DHCPOption
}

func NewDHCP

func NewDHCP(xid uint32, op DHCPOperation, hwtype byte) (*DHCP, error)

func NewDHCPAck

func NewDHCPAck(xid uint32, hwAddr net.HardwareAddr) (d *DHCP, err error)

func NewDHCPDiscover

func NewDHCPDiscover(xid uint32, hwAddr net.HardwareAddr) (d *DHCP, err error)

func NewDHCPNak

func NewDHCPNak(xid uint32, hwAddr net.HardwareAddr) (d *DHCP, err error)

func NewDHCPOffer

func NewDHCPOffer(xid uint32, hwAddr net.HardwareAddr) (d *DHCP, err error)

func NewDHCPRequest

func NewDHCPRequest(xid uint32, hwAddr net.HardwareAddr) (d *DHCP, err error)

func (*DHCP) Len

func (d *DHCP) Len() (n uint16)

func (*DHCP) Read

func (d *DHCP) Read(b []byte) (n int, err error)

func (*DHCP) Write

func (d *DHCP) Write(b []byte) (n int, err error)

type DHCPOperation

type DHCPOperation byte
const (
	DHCP_MSG_UNSPEC DHCPOperation = iota
	DHCP_MSG_DISCOVER
	DHCP_MSG_OFFER
	DHCP_MSG_REQUEST
	DHCP_MSG_DECLINE
	DHCP_MSG_ACK
	DHCP_MSG_NAK
	DHCP_MSG_RELEASE
	DHCP_MSG_INFORM
)

type DHCPOption

type DHCPOption interface {
	OptionType() byte
	Bytes() []byte
	Len() uint16
}

func DHCPIP4Option

func DHCPIP4Option(tag byte, ips net.IP) (opt DHCPOption, err error)

NB: We don't validate that you have /any/ IP's in the option here, simply that if you do that they're valid. Most DHCP options are only valid with 1(+|) values

func DHCPIP4sOption

func DHCPIP4sOption(tag byte, ips []net.IP) (opt DHCPOption, err error)

NB: We don't validate that you have /any/ IP's in the option here, simply that if you do that they're valid. Most DHCP options are only valid with 1(+|) values

func DHCPNewOption

func DHCPNewOption(tag byte, data []byte) DHCPOption

func DHCPParseOptions

func DHCPParseOptions(in []byte) (opts []DHCPOption, err error)

func DHCPStringOption

func DHCPStringOption(tag byte, s string) (opt DHCPOption, err error)

NB: I'm not checking tag : min length here!

type Ethernet

type Ethernet struct {
	Delimiter uint8
	HWDst     net.HardwareAddr
	HWSrc     net.HardwareAddr
	VLANID    VLAN
	Ethertype uint16
	Data      util.Message
}

func NewEthernet

func NewEthernet() *Ethernet

func (*Ethernet) Len

func (e *Ethernet) Len() (n uint16)

func (*Ethernet) MarshalBinary

func (e *Ethernet) MarshalBinary() (data []byte, err error)

func (*Ethernet) UnmarshalBinary

func (e *Ethernet) UnmarshalBinary(data []byte) error

type FragmentHeader

type FragmentHeader struct {
	NextHeader     uint8
	Reserved       uint8
	FragmentOffset uint16
	MoreFragments  bool
	Identification uint32
}

func NewFragmentHeader

func NewFragmentHeader() *FragmentHeader

func (*FragmentHeader) Len

func (h *FragmentHeader) Len() uint16

func (*FragmentHeader) MarshalBinary

func (h *FragmentHeader) MarshalBinary() (data []byte, err error)

func (*FragmentHeader) UnmarshalBinary

func (h *FragmentHeader) UnmarshalBinary(data []byte) error

type HopByHopHeader

type HopByHopHeader struct {
	NextHeader uint8
	HEL        uint8
	Options    []*Option
}

func NewHopByHopHeader

func NewHopByHopHeader() *HopByHopHeader

func (*HopByHopHeader) Len

func (h *HopByHopHeader) Len() uint16

func (*HopByHopHeader) MarshalBinary

func (h *HopByHopHeader) MarshalBinary() (data []byte, err error)

func (*HopByHopHeader) UnmarshalBinary

func (h *HopByHopHeader) UnmarshalBinary(data []byte) error

type ICMP

type ICMP struct {
	Type     uint8
	Code     uint8
	Checksum uint16
	Data     []byte
}

func NewICMP

func NewICMP() *ICMP

func (*ICMP) Len

func (i *ICMP) Len() (n uint16)

func (*ICMP) MarshalBinary

func (i *ICMP) MarshalBinary() (data []byte, err error)

func (*ICMP) UnmarshalBinary

func (i *ICMP) UnmarshalBinary(data []byte) error

type IGMPMessage added in v0.5.0

type IGMPMessage interface {
	GetMessageType() uint8
}

type IGMPv1or2 added in v0.5.0

type IGMPv1or2 struct {
	Type            uint8
	MaxResponseTime uint8 // It is 0 for IGMPv1 message.
	Checksum        uint16
	GroupAddress    net.IP
}

IGMPv1:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Type  |    Unused     |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Group Address                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

IGMPv2:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      Type     | Max Resp Time |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Group Address                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func NewIGMPv1Query added in v0.5.0

func NewIGMPv1Query(group net.IP) *IGMPv1or2

func NewIGMPv1Report added in v0.5.0

func NewIGMPv1Report(group net.IP) *IGMPv1or2

func NewIGMPv2Leave added in v0.5.0

func NewIGMPv2Leave(group net.IP) *IGMPv1or2

func NewIGMPv2Query added in v0.5.0

func NewIGMPv2Query(group net.IP, maxResponseTime uint8) *IGMPv1or2

func NewIGMPv2Report added in v0.5.0

func NewIGMPv2Report(group net.IP) *IGMPv1or2

func (*IGMPv1or2) GetMessageType added in v0.5.0

func (p *IGMPv1or2) GetMessageType() uint8

func (*IGMPv1or2) Len added in v0.5.0

func (p *IGMPv1or2) Len() uint16

func (*IGMPv1or2) MarshalBinary added in v0.5.0

func (p *IGMPv1or2) MarshalBinary() (data []byte, err error)

func (*IGMPv1or2) UnmarshalBinary added in v0.5.0

func (p *IGMPv1or2) UnmarshalBinary(data []byte) error

type IGMPv3GroupRecord added in v0.5.0

type IGMPv3GroupRecord struct {
	Type             uint8
	AuxDataLen       uint8 // this should always be 0 as per IGMPv3 spec.
	NumberOfSources  uint16
	MulticastAddress net.IP
	SourceAddresses  []net.IP
	AuxData          []uint32 // NOT USED
}

IGMPv3GroupRecord:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Record Type  |  Aux Data Len |     Number of Sources (N)     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Multicast Address                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address [1]                      |
+-                                                             -+
|                       Source Address [2]                      |
+-                                                             -+
.                               .                               .
.                               .                               .
.                               .                               .
+-                                                             -+
|                       Source Address [N]                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                         Auxiliary Data                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func NewGroupRecord added in v0.5.0

func NewGroupRecord(recordType uint8, group net.IP, sources []net.IP) IGMPv3GroupRecord

func (*IGMPv3GroupRecord) Len added in v0.5.0

func (p *IGMPv3GroupRecord) Len() uint16

func (*IGMPv3GroupRecord) MarshalBinary added in v0.5.0

func (p *IGMPv3GroupRecord) MarshalBinary() (data []byte, err error)

func (*IGMPv3GroupRecord) UnmarshalBinary added in v0.5.0

func (p *IGMPv3GroupRecord) UnmarshalBinary(data []byte) error

type IGMPv3MembershipReport added in v0.5.0

type IGMPv3MembershipReport struct {
	Type           uint8
	Reserved       uint8
	Checksum       uint16
	Reserved2      uint16
	NumberOfGroups uint16
	GroupRecords   []IGMPv3GroupRecord
}

IGMPv3MembershipReport:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Type = 0x22  |    Reserved   |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Reserved            |  Number of Group Records (M)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        Group Record [1]                       .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        Group Record [2]                       .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               .                               |
.                               .                               .
|                               .                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        Group Record [M]                       .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func NewIGMPv3Report added in v0.5.0

func NewIGMPv3Report(groups []IGMPv3GroupRecord) *IGMPv3MembershipReport

func (*IGMPv3MembershipReport) GetMessageType added in v0.5.0

func (p *IGMPv3MembershipReport) GetMessageType() uint8

func (*IGMPv3MembershipReport) Len added in v0.5.0

func (p *IGMPv3MembershipReport) Len() uint16

func (*IGMPv3MembershipReport) MarshalBinary added in v0.5.0

func (p *IGMPv3MembershipReport) MarshalBinary() (data []byte, err error)

func (*IGMPv3MembershipReport) UnmarshalBinary added in v0.5.0

func (p *IGMPv3MembershipReport) UnmarshalBinary(data []byte) error

type IGMPv3Query added in v0.5.0

type IGMPv3Query struct {
	Type                     uint8
	MaxResponseTime          uint8
	Checksum                 uint16
	GroupAddress             net.IP
	Reserved                 uint8
	SuppressRouterProcessing bool
	RobustnessValue          uint8
	IntervalTime             uint8
	NumberOfSources          uint16
	SourceAddresses          []net.IP
}

IGMPv3Query:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Type = 0x11  | Max Resp Code |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Group Address                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Resv  |S| QRV |     QQIC      |     Number of Sources (N)     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address [1]                      |
+-                                                             -+
|                       Source Address [2]                      |
+-                              .                              -+
.                               .                               .
.                               .                               .
+-                                                             -+
|                       Source Address [N]                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func NewIGMPv3Query added in v0.5.0

func NewIGMPv3Query(group net.IP, maxResponseTime uint8, queryInterval uint8, sources []net.IP) *IGMPv3Query

func (*IGMPv3Query) GetMessageType added in v0.5.0

func (p *IGMPv3Query) GetMessageType() uint8

func (*IGMPv3Query) Len added in v0.5.0

func (p *IGMPv3Query) Len() uint16

func (*IGMPv3Query) MarshalBinary added in v0.5.0

func (p *IGMPv3Query) MarshalBinary() (data []byte, err error)

func (*IGMPv3Query) UnmarshalBinary added in v0.5.0

func (p *IGMPv3Query) UnmarshalBinary(data []byte) error

type IPv4

type IPv4 struct {
	Version        uint8 //4-bits
	IHL            uint8 //4-bits
	DSCP           uint8 //6-bits
	ECN            uint8 //2-bits
	Length         uint16
	Id             uint16
	Flags          uint16 //3-bits
	FragmentOffset uint16 //13-bits
	TTL            uint8
	Protocol       uint8
	Checksum       uint16
	NWSrc          net.IP
	NWDst          net.IP
	Options        util.Buffer
	Data           util.Message
}

func NewIPv4

func NewIPv4() *IPv4

func (*IPv4) Len

func (i *IPv4) Len() (n uint16)

func (*IPv4) MarshalBinary

func (i *IPv4) MarshalBinary() (data []byte, err error)

func (*IPv4) UnmarshalBinary

func (i *IPv4) UnmarshalBinary(data []byte) error

type IPv6

type IPv6 struct {
	Version        uint8 //4-bits
	TrafficClass   uint8
	FlowLabel      uint32 //20-bits
	Length         uint16
	NextHeader     uint8
	HopLimit       uint8
	NWSrc          net.IP
	NWDst          net.IP
	HbhHeader      *HopByHopHeader
	RoutingHeader  *RoutingHeader
	FragmentHeader *FragmentHeader
	Data           util.Message
}

func (*IPv6) Len

func (i *IPv6) Len() (n uint16)

func (*IPv6) MarshalBinary

func (i *IPv6) MarshalBinary() (data []byte, err error)

func (*IPv6) UnmarshalBinary

func (i *IPv6) UnmarshalBinary(data []byte) error

type LLDP

type LLDP struct {
	Chassis ChassisTLV
	Port    PortTLV
	TTL     TTLTLV
}

func (*LLDP) Len

func (d *LLDP) Len() (n uint16)

func (*LLDP) Read

func (d *LLDP) Read(b []byte) (n int, err error)

func (*LLDP) Write

func (d *LLDP) Write(b []byte) (n int, err error)

type Option

type Option struct {
	Type   uint8
	Length uint8
	Data   []byte
}

func (*Option) Len

func (o *Option) Len() uint16

func (*Option) MarshalBinary

func (o *Option) MarshalBinary() (data []byte, err error)

func (*Option) UnmarshalBinary

func (o *Option) UnmarshalBinary(data []byte) error

type PortTLV

type PortTLV struct {
	Type    uint8  //7bits
	Length  uint16 //9bits
	Subtype uint8
	Data    []uint8
}

func (*PortTLV) Read

func (t *PortTLV) Read(b []byte) (n int, err error)

func (*PortTLV) Write

func (t *PortTLV) Write(b []byte) (n int, err error)

type RoutingHeader

type RoutingHeader struct {
	NextHeader   uint8
	HEL          uint8
	RoutingType  uint8
	SegmentsLeft uint8
	Data         *util.Buffer
}

func NewRoutingHeader

func NewRoutingHeader() *RoutingHeader

func (*RoutingHeader) Len

func (h *RoutingHeader) Len() uint16

func (*RoutingHeader) MarshalBinary

func (h *RoutingHeader) MarshalBinary() (data []byte, err error)

func (*RoutingHeader) UnmarshalBinary

func (h *RoutingHeader) UnmarshalBinary(data []byte) error

type TCP

type TCP struct {
	PortSrc uint16
	PortDst uint16
	SeqNum  uint32
	AckNum  uint32

	HdrLen uint8
	Code   uint8

	WinSize  uint16
	Checksum uint16
	UrgFlag  uint16

	Data []byte
}

func NewTCP

func NewTCP() *TCP

func (*TCP) Len

func (t *TCP) Len() (n uint16)

func (*TCP) MarshalBinary

func (t *TCP) MarshalBinary() (data []byte, err error)

func (*TCP) UnmarshalBinary

func (t *TCP) UnmarshalBinary(data []byte) error

type TTLTLV

type TTLTLV struct {
	Type    uint8  //7 bits
	Length  uint16 //9 bits
	Seconds uint16
}

func (*TTLTLV) Read

func (t *TTLTLV) Read(b []byte) (n int, err error)

func (*TTLTLV) Write

func (t *TTLTLV) Write(b []byte) (n int, err error)

type UDP

type UDP struct {
	PortSrc  uint16
	PortDst  uint16
	Length   uint16
	Checksum uint16
	Data     []byte
}

func NewUDP

func NewUDP() *UDP

func (*UDP) Len

func (u *UDP) Len() (n uint16)

func (*UDP) MarshalBinary

func (u *UDP) MarshalBinary() (data []byte, err error)

func (*UDP) UnmarshalBinary

func (u *UDP) UnmarshalBinary(data []byte) error

type VLAN

type VLAN struct {
	TPID uint16
	PCP  uint8
	DEI  uint8
	VID  uint16
}

func NewVLAN

func NewVLAN() *VLAN

func (*VLAN) Len

func (v *VLAN) Len() (n uint16)

func (*VLAN) MarshalBinary

func (v *VLAN) MarshalBinary() (data []byte, err error)

func (*VLAN) UnmarshalBinary

func (v *VLAN) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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