ethernetdecode

package module
Version: v0.0.0-...-74a2268 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2015 License: MIT Imports: 3 Imported by: 2

README

Please use my proto package instead.


ethernetdecode Build Status

A tiny Go package for decoding ethernet frame headers into more useful IP header structs.

Still a work-in-progress.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(header []byte) (EthernetHeader, IpHeader, ProtocolHeader)

Decode decodes an ethernet frame header and returns an IP header and a TCP or UDP header.

Types

type EthernetHeader

type EthernetHeader struct {
	Source      net.HardwareAddr
	Destination net.HardwareAddr
	VlanTag     uint32
	EtherType   uint16
}

type IpHeader

type IpHeader interface {
	IpVersion() int
}

type Ipv4Header

type Ipv4Header struct {
	VersionAndHeaderLen uint8
	Tos                 uint8
	Len                 uint16
	Id                  uint16
	FragOff             uint16
	Ttl                 uint8
	Protocol            uint8
	Checksum            uint16
	Source              [4]byte
	Destination         [4]byte
}

func (Ipv4Header) IpVersion

func (h Ipv4Header) IpVersion() int

type Ipv6Header

type Ipv6Header struct {
	VersionTrafficClassFlowLabel uint32
	PayloadLength                uint16
	NextHeader                   uint8
	HopLimit                     uint8
	Source                       [16]byte
	Destination                  [16]byte
}

func (Ipv6Header) IpVersion

func (h Ipv6Header) IpVersion() int

type Protocol

type Protocol uint8
const (
	ProtocolTcp Protocol = 6
	ProtocolUdp Protocol = 17
)

type ProtocolHeader

type ProtocolHeader interface {
	Protocol() Protocol
}

type TcpHeader

type TcpHeader struct {
	SourcePort      uint16
	DestinationPort uint16
	SeqNum          uint32
	AckNum          uint32
	OffsetReserved  uint8
	Flags           uint8
	WindowSize      uint16
	Checksum        uint16
	UrgentPointer   uint16
}

func (TcpHeader) Protocol

func (h TcpHeader) Protocol() Protocol

type UdpHeader

type UdpHeader struct {
	SourcePort      uint16
	DestinationPort uint16
	Length          uint16
	Checksum        uint16
}

func (UdpHeader) Protocol

func (h UdpHeader) Protocol() Protocol

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL