lwip

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BufSize = 4096

Variables

View Source
var OutputFn func([]byte) (int, error) = defaultOutputFn

Functions

func FreeBytes

func FreeBytes(b []byte)

func FreeConnKeyArg

func FreeConnKeyArg(p unsafe.Pointer)

func GetConnKeyVal

func GetConnKeyVal(p unsafe.Pointer) uint32

func GetIP4Addr

func GetIP4Addr(ipaddr C.struct_ip_addr) string

func GetSyncMapLen

func GetSyncMapLen(m sync.Map) int

func Input

func Input(pkt []byte) error

func MustResolveTCPAddr

func MustResolveTCPAddr(addr string, port uint16) net.Addr

func MustResolveUDPAddr

func MustResolveUDPAddr(addr string, port uint16) net.Addr

func NewBytes

func NewBytes(size int) []byte

func NewConnKeyArg

func NewConnKeyArg() unsafe.Pointer

We need such a key-value mechanism because when passing a Go pointer to C, the Go pointer will only be valid during the call. If we pass a Go pointer to tcp_arg(), this pointer will not be usable in subsequent callbacks (e.g.: tcp_recv(), tcp_err()).

Instead we need to pass a C pointer to tcp_arg(), we manually allocate the memory in C and return its pointer to Go code. After the connection end, the memory should be freed manually.

See also: https://github.com/golang/go/issues/12416

func NewUDPConnection

func NewUDPConnection(pcb *C.struct_udp_pcb, handler tun2socks.ConnectionHandler, localAddr, remoteAddr C.ip_addr_t, localPort, remotePort C.u16_t) (tun2socks.Connection, error)

func Output

func Output(p *C.struct_pbuf) C.err_t

func RegisterOutputFn

func RegisterOutputFn(fn func([]byte) (int, error))

func RegisterTCPConnectionHandler

func RegisterTCPConnectionHandler(h tun2socks.ConnectionHandler)

func RegisterUDPConnectionHandler

func RegisterUDPConnectionHandler(h tun2socks.ConnectionHandler)

func SetConnKeyVal

func SetConnKeyVal(p unsafe.Pointer, val uint32)

func SetTCPAcceptCallback

func SetTCPAcceptCallback(pcb *C.struct_tcp_pcb)

func SetTCPErrCallback

func SetTCPErrCallback(pcb *C.struct_tcp_pcb)

func SetTCPPollCallback

func SetTCPPollCallback(pcb *C.struct_tcp_pcb, interval C.u8_t)

func SetTCPRecvCallback

func SetTCPRecvCallback(pcb *C.struct_tcp_pcb)

func SetTCPSentCallback

func SetTCPSentCallback(pcb *C.struct_tcp_pcb)

func SetUDPRecvCallback

func SetUDPRecvCallback(pcb *C.struct_udp_pcb, recvArg unsafe.Pointer)

func Setup

func Setup()

func TCPAcceptFn

func TCPAcceptFn(arg unsafe.Pointer, newpcb *C.struct_tcp_pcb, err C.err_t) C.err_t

func TCPErrFn

func TCPErrFn(arg unsafe.Pointer, err C.err_t)

func TCPPollFn

func TCPPollFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb) C.err_t

func TCPRecvFn

func TCPRecvFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb, p *C.struct_pbuf, err C.err_t) C.err_t

func TCPSentFn

func TCPSentFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb, len C.u16_t) C.err_t

func UDPRecvFn

func UDPRecvFn(arg unsafe.Pointer, pcb *C.struct_udp_pcb, p *C.struct_pbuf, addr *C.ip_addr_t, port C.u16_t, destAddr *C.ip_addr_t, destPort C.u16_t)

Types

This section is empty.

Jump to

Keyboard shortcuts

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