Crate hypertube

source ·
Expand description

To create a TUN device, use a DeviceBuilder. There are several ways to create a DeviceBuilder:

Eg.

let device = builder()
    .build()
    .unwrap();

Now to write to a Device. In order to write to or read from a Device you need to create a Queue. There are two types of queues, blocking and nonblocking.

let device = builder()
    .with_num_queues(2)
    .build()
    .unwrap();

let queue1 = device.queue(0);
let queue2 = device.queue_nonblocking(1);

queue2.write(&[some bytes here]);

let mut buf = [0; some size];

queue1.read(&mut buf);

Blocking and nonblocking queues are accessed from the same pool of queues. The pool of queues is created when the device is built. In the future, the ability to add or remove queues after the Device is created should be added.

Re-exports

Modules

  • Builder for Device
  • Main TUN device implementation. Does not include the code for writing to and reading from the TUN device. For that go to queue.
  • Queue implementation for Devices. Used to read and write packets to said Devices.

Functions