lwip2transport

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

The network/lwip2transport package translates between IP packets and TCP/UDP protocols. It uses a modified lwIP go library, which is based on the original lwIP library (A Lightweight TCP/IP stack). The device is singleton, so only one instance can be created per process.

To configure the instance with TCP/UDP handlers:

// tcpHandler will be used to handle TCP streams, and udpHandler to handle UDP packets
t2s, err := lwip2transport.ConfigureDevice(tcpHandler, udpHandler)
if err != nil {
	// handle error
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureDevice

func ConfigureDevice(sd transport.StreamDialer, pp network.PacketProxy) (network.IPDevice, error)

ConfigureDevice configures the singleton LwIP device using the transport.StreamDialer to handle TCP streams and the transport.PacketProxy to handle UDP packets.

LwIP device is a network.IPDevice that can translate IP packets to TCP/UDP traffic and vice versa. It uses the lwIP library to perform the translation.

LwIP device must be a singleton object due to limitations in lwIP library. If you try to call ConfigureDevice more than once, we will Close the previous device and reconfigure it.

To use a LwIP device:

  1. Call ConfigureDevice with two handlers for TCP and UDP traffic.
  2. Write IP packets to the device. The device will translate the IP packets to TCP/UDP traffic and send them to the appropriate handlers.
  3. Read IP packets from the device to get the TCP/UDP responses.

A LwIP device is NOT thread-safe. However it is safe to use Write, Read/WriteTo and Close in different goroutines. Keep in mind that only one goroutine can call Write at a time, and only one goroutine can use either Read or WriteTo at a time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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