vnet

package
v0.0.0-...-a7e2b7f Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPackSize = 2000

Variables

This section is empty.

Functions

This section is empty.

Types

type Freer

type Freer interface {
	Free(Pack)
}

type Pack

type Pack interface {

	// 所有数据
	// 为了减少内存拷贝,会预先保留二次封装包包头的空间,使得封包时不用再次拷贝。
	GetAllData() []byte

	// tun/tap 包数据
	GetPrefixData() []byte
	GetPackData() []byte
	SetPackLength(int)

	// 释放本包占用的内存
	Free()

	Reset()

	GetPackLayer() PackLayer

	// 不安全,非拷贝副本
	GetIP() (net.IP, net.IP, error)
	GetPort() (int, int, error)
}

type PackLayer

type PackLayer int
const (
	PackLayerLink        PackLayer = 0x10 //以太网
	PackLayerNetwork     PackLayer = 0x20 // ip
	PackLayerTransport   PackLayer = 0x30 //tcp udp
	PackLayerApplication PackLayer = 0x40 //
)

type PackPool

type PackPool interface {
	Malloc() Pack
}

func NewPool

func NewPool(prefixSize, MaxPackDataSize int, packLayer PackLayer) PackPool

Jump to

Keyboard shortcuts

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