ethernetdecode

package module
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: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
y or Y : Canonical URL