package rawlink

  1. Overview
  2. Docs
Portable library to read and write raw packets

Install

Dune Dependency

Authors

Maintainers

Sources

rawlink-v1.0.tbz
sha256=f3a8ffb78bc3363905de59d260c72991ea188d46aea274368f4d93acfdd5ec28
md5=90a85604ed73955f9fefedfd6b624598

doc/rawlink.lwt/Lwt_rawlink/index.html

Module Lwt_rawlink

A portable API to send and receive raw packets.

There are times when one needs to construct the full ethernet frame to send/receive. Most unixes support BPF (BSD Packet Filter) to achieve it, but linux provides the same functionality via AF_SOCKET. This API works with either a BPF or AF_SOCKET backend, so it should work on every usable UNIX, as well as linux out there. The module is designed to work with Lwt threads.

type t

open_link ~filter interface. Creates a rawlink on the specified interface, a BPF program filter can be passed to filter out incoming packets.

close_link. Closes a rawlink.

val read_packet : t -> Cstruct.t Lwt.t

read_packet t. Reads a full packet, may raise Unix.Unix_error.

val send_packet : t -> Cstruct.t -> unit Lwt.t

send_packet t. Sends a full packet, may raise Unix.Unix_error.

val dhcp_server_filter : unit -> string

dhcp_server_filter. Returns a BPF program suitable to be passed in open_link ~filter, it accepts UDP packets destined to port 67 (DHCP client).

val dhcp_client_filter : unit -> string

dhcp_client_filter. Returns a BPF program suitable to be passed in open_link ~filter, it accepts UDP packets destined to port 68 (DHCP server).

OCaml

Innovation. Community. Security.