rawlinkversion

A platform-independent library to read and write raw packets.

Rawlink is an ocaml library for sending and receiving raw packets at the link layer level. Sometimes you need to have full control of the packet, including building the full ethernet frame.

The API is platform independent, it uses BPF on real UNIXes and AF_SOCKET on linux. Some functionality is sacrificed so that the API is portable enough.

Currently BPF and AF_PACKET are implemented, including filtering capabilities. Writing a BPF program is a pain in the ass, so no facilities are provided for it. If you need a BPF filter, I suggest you write a small .c file with a function that returns the BPF program as a string, check rawlink_stubs.c for an example.

Both normal blocking functions as well as Lwt monadic variants are provided.

A typical code for receiving all packets and just sending them back on a specified interface are detailed below:

let link = Rawlink.open_link "eth0" in
let buf = Rawlink.read_packet link in
Printf.printf "got a packet with %d bytes.\n%!" (Cstruct.len buf);
Rawlink.send_packet link buf

Check the mli interface for more options.

AuthorChristiano F. Haesbaert <haesbaert@haesbaert.org>
LicenseISC
Published
Homepagehttps://github.com/haesbaert/rawlink
Issue Trackerhttps://github.com/haesbaert/rawlink/issues
MaintainerChristiano F. Haesbaert <haesbaert@haesbaert.org>
Dependencies
Source [http] https://github.com/haesbaert/rawlink/archive/v0.2.tar.gz
sha256=0238b3c286ce2e56d43b37086f57c06479cd1796db9d960d09d1bc5286b7c188
md5=7f996d7708e459daeb66d405ebe2f893
Edithttps://github.com/ocaml/opam-repository/tree/master/packages/rawlink/rawlink.0.2/opam
Required by