Documentation ¶
Index ¶
- Constants
- Variables
- func CalcTransportChecksum(header []byte, srcIP, dstIP *Address, headerLen uint16, proto uint8) uint16
- func Checksum(data []byte) uint16
- func VerifyTransportChecksum(header []byte, srcIP, dstIP *Address, headerLen uint16, proto uint8) bool
- type Address
- type Hash
- type IPReadHeader
- type Netmask
- type ReadWriter
- type Reader
- type RoutingTable
- type Writer
Constants ¶
const ( IPProtoICMP = 1 IPProtoUDP = 17 IPProtoTCP = 6 )
IPv4 Protocols
const (
IPMTU = 1500
)
The MTU, or maximum transmission unit
const IPv4AddressLength = 4
The length of an IPv4 Address
Variables ¶
var ( IPAll *Address IPAllHash Hash )
Utilities for binding to all IP addresses
Functions ¶
func CalcTransportChecksum ¶
func CalcTransportChecksum(header []byte, srcIP, dstIP *Address, headerLen uint16, proto uint8) uint16
CalcTransportChecksum calculates a checksum of a transport layer protocol (TCP or UDP)
func Checksum ¶
Checksum computes the 16-bit one's complement checksum of the given data. Done according to the procedure outlined in RFC 1071 (https://tools.ietf.org/html/rfc1071).
Types ¶
type Address ¶
type Address struct {
IP []byte
}
Address represents an IP address
The stack's IP addresses, which are used when sending data
type IPReadHeader ¶
IPReadHeader contains the fields that are passed to transport layer protocols.
type ReadWriter ¶
type ReadWriter interface { ReadFrom() (*IPReadHeader, error) WriteTo(data []byte) (int, error) io.Closer }
ReadWriter allows a bidirectional IP "connection": one that allows both reading and writing
func NewReadWriter ¶
func NewReadWriter(ip *Address, protocol uint8) (ReadWriter, error)
NewReadWriter creates a ReadWriter given an IP Address and an IP protocol
type Reader ¶
type Reader interface { ReadFrom() (*IPReadHeader, error) io.Closer }
Reader allows reading from a specific IP protocol and address
type RoutingTable ¶
type RoutingTable struct {
// contains filtered or unexported fields
}
RoutingTable stores the different routes that may be used
var GlobalRoutingTable *RoutingTable
GlobalRoutingTable is the routing table that is used by IPv4 and all transport layer protocols
func (*RoutingTable) Query ¶
func (table *RoutingTable) Query(dst *Address) (src *Address)
Query returns the source IP address that will be sent from given the IP address that should be sent to.