package rawlink

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

Install

Dune Dependency

Authors

Maintainers

Sources

rawlink-1.2.tbz
sha256=a712be95f636466536327fd92ce476fb72a4e06e1b82a85d5b471db8289a91e4
sha512=006a1d57b6e3093c929d0c1d3a53075059d0a35196eebb0b2f444aab3c7492a86befe22de700d40fb479a789470bfe4b1e8b83f02c878cf85b1b5b9d67778aad

doc/rawlink.lwt/Lwt_rawlink/index.html

Module Lwt_rawlinkSource

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.

Sourcetype t

open_link ~filter ~promisc interface. Creates a rawlink on the specified interface, a BPF program filter can be passed to filter out incoming packets. If promisc is true, sets interface to promiscuous mode, defaults to false.

close_link. Closes a rawlink.

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

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

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

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

Sourceval 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).

Sourceval 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.