pcapraw

package
v0.0.0-...-5c98b36 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MulanPSL-2.0 Imports: 10 Imported by: 0

README

pcapraw 读取和写入网络接口的数据

此包依赖 pcap 库,如果是 windows 系统则需要安装 win10pcap,如果是 linux 系统需要安装 libpcap-dev。

windows系统使用 pcap 读取和写入网络接口,linux系统仅仅使用 pcap 编译 BPF,使用 github.com/mdlayher/raw 读取和写入网络接口。

实例

  • gitee.com/sillyman/simpleUtil/network/arpresolve 使用 ARP 请求获取局域网内某个主机的MAC地址

Documentation

Overview

package pcapraw

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(localIP net.IP, ethtype uint16, bpfExpr string) (*linuxRaw, error)

New 创建 PcapRaw 实例

Types

type PcapRaw

type PcapRaw interface {
	// ReadGoPkt 读取一个 gopacket.Packet
	ReadGoPkt(timeout time.Duration) (gopacket.Packet, error)

	// WriteLayers 向网络接口注入一个报文
	WriteLayers(layers []gopacket.SerializableLayer) error

	// WriteRaw 向网络接口注入一个 raw 报文
	WriteRaw(data []byte) error

	// Close 关闭句柄
	Close()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL