portmaster: github.com/Safing/portmaster/network/packet Index | Files

package packet

import "github.com/Safing/portmaster/network/packet"


Package Files



const (
    IPv4 = IPVersion(4)
    IPv6 = IPVersion(6)

    InBound  = true
    OutBound = false

    Local  = true
    Remote = false

    // convenience
    IGMP   = IPProtocol(2)
    RAW    = IPProtocol(255)
    TCP    = IPProtocol(6)
    UDP    = IPProtocol(17)
    ICMP   = IPProtocol(1)
    ICMPv6 = IPProtocol(58)

type Endpoint Uses

type Endpoint bool

type IPHeader Uses

type IPHeader struct {
    Version IPVersion

    Tos, TTL uint8
    Protocol IPProtocol
    Src, Dst net.IP

type IPProtocol Uses

type IPProtocol uint8

func (IPProtocol) String Uses

func (p IPProtocol) String() string

type IPVersion Uses

type IPVersion uint8

func (IPVersion) ByteSize Uses

func (v IPVersion) ByteSize() int

Returns the byte size of the ip, IPv4 = 4 bytes, IPv6 = 16

func (IPVersion) String Uses

func (v IPVersion) String() string

type Packet Uses

type Packet interface {
    Accept() error
    Block() error
    Drop() error
    PermanentAccept() error
    PermanentBlock() error
    PermanentDrop() error
    RerouteToNameserver() error
    RerouteToTunnel() error

    // INFO
    GetIPHeader() *IPHeader
    GetTCPUDPHeader() *TCPUDPHeader
    GetPayload() []byte
    IsInbound() bool
    IsOutbound() bool
    GetLinkID() string
    IPVersion() IPVersion

    MatchesAddress(bool, IPProtocol, *net.IPNet, uint16) bool
    MatchesIP(bool, *net.IPNet) bool

    String() string
    FmtPacket() string
    FmtProtocol() string
    FmtRemoteIP() string
    FmtRemotePort() string
    FmtRemoteAddress() string

Packet is an interface to a network packet to provide object behaviour the same across all systems

type PacketBase Uses

type PacketBase struct {
    Direction bool
    InTunnel  bool
    Payload   []byte
    // contains filtered or unexported fields

func (*PacketBase) FmtPacket Uses

func (pkt *PacketBase) FmtPacket() string

FmtPacket returns the most important information about the packet as a string

func (*PacketBase) FmtProtocol Uses

func (pkt *PacketBase) FmtProtocol() string

FmtProtocol returns the protocol as a string

func (*PacketBase) FmtRemoteAddress Uses

func (pkt *PacketBase) FmtRemoteAddress() string

FmtRemoteAddress returns the full remote address (protocol, IP, port) as a string

func (*PacketBase) FmtRemoteIP Uses

func (pkt *PacketBase) FmtRemoteIP() string

FmtRemoteIP returns the remote IP address as a string

func (*PacketBase) FmtRemotePort Uses

func (pkt *PacketBase) FmtRemotePort() string

FmtRemotePort returns the remote port as a string

func (*PacketBase) GetIPHeader Uses

func (pkt *PacketBase) GetIPHeader() *IPHeader

func (*PacketBase) GetLinkID Uses

func (pkt *PacketBase) GetLinkID() string

func (*PacketBase) GetPayload Uses

func (pkt *PacketBase) GetPayload() []byte

func (*PacketBase) GetTCPUDPHeader Uses

func (pkt *PacketBase) GetTCPUDPHeader() *TCPUDPHeader

func (*PacketBase) IPVersion Uses

func (pkt *PacketBase) IPVersion() IPVersion

func (*PacketBase) IsInbound Uses

func (pkt *PacketBase) IsInbound() bool

func (*PacketBase) IsOutbound Uses

func (pkt *PacketBase) IsOutbound() bool

func (*PacketBase) MatchesAddress Uses

func (pkt *PacketBase) MatchesAddress(endpoint bool, protocol IPProtocol, network *net.IPNet, port uint16) bool

Matches checks if a the packet matches a given endpoint (remote or local) in protocol, network and port.


Local Dst Src Remote Src Dst

func (*PacketBase) MatchesIP Uses

func (pkt *PacketBase) MatchesIP(endpoint bool, network *net.IPNet) bool

func (*PacketBase) SetInbound Uses

func (pkt *PacketBase) SetInbound()

func (*PacketBase) SetOutbound Uses

func (pkt *PacketBase) SetOutbound()

func (*PacketBase) String Uses

func (pkt *PacketBase) String() string

type TCPUDPHeader Uses

type TCPUDPHeader struct {
    SrcPort, DstPort uint16
    Checksum         uint16 //not implemented

type Verdict Uses

type Verdict uint8
const (
    DROP Verdict = iota

func (Verdict) String Uses

func (v Verdict) String() string

Package packet imports 2 packages (graph) and is imported by 7 packages. Updated 2019-02-15. Refresh now. Tools for package owners.