netboot: Index | Files

package pcap

import ""

Package pcap implements reading and writing the "classic" libpcap format.


Package Files

reader.go writer.go

type LinkType Uses

type LinkType uint32

LinkType describes the contents of each packet in a pcap.

const (
    LinkEthernet LinkType = 1
    LinkRaw      LinkType = 101

Some of the more commonly used LinkTypes.

type Packet Uses

type Packet struct {
    Timestamp time.Time
    Length    int
    Bytes     []byte

Packet is one raw packet and its metadata.

type Reader Uses

type Reader struct {
    LinkType LinkType
    // contains filtered or unexported fields

Reader extracts packets from a pcap file.

func NewReader Uses

func NewReader(r io.Reader) (*Reader, error)

NewReader returns a new Reader that decodes pcap data from r.

func (*Reader) Err Uses

func (r *Reader) Err() error

Err returns the first non-EOF error encountered by the Reader.

func (*Reader) Next Uses

func (r *Reader) Next() bool

Next advances the Reader to the next packet in the input, which will then be available through the Packet method. It returns false when the Reader stops, either by reaching the end of the input or an error. After Next returns false, the Err method will return any error that occured while reading, except that if it was io.EOF, Err will return nil.

func (*Reader) Packet Uses

func (r *Reader) Packet() *Packet

Packet returns the packet read by the last call to Next.

type Writer Uses

type Writer struct {
    Writer    io.Writer
    LinkType  LinkType
    SnapLen   uint32
    ByteOrder binary.ByteOrder // defaults to binary.LittleEndian
    // contains filtered or unexported fields

Writer serializes Packets to an io.Writer.

func (*Writer) Put Uses

func (w *Writer) Put(pkt *Packet) error

Put serializes pkt to w.Writer.

Package pcap imports 7 packages (graph). Updated 2018-10-11. Refresh now. Tools for package owners.