Pure OCaml ARP table lookup - reads /proc/net/arp on Linux and arp -a on macOS/BSD
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arp: fix README (was ocaml-sle content)

+11 -43
+11 -43
README.md
··· 1 - # ocaml-sle 1 + # ocaml-arp 2 2 3 - Pure OCaml implementation of CCSDS Space Link Extension (SLE) protocols for 4 - ground station communication. 3 + Pure OCaml ARP table lookup. Reads the system ARP cache to resolve IP 4 + addresses to MAC addresses. 5 5 6 - ## Features 7 - 8 - - **RAF** - Return All Frames (downlink telemetry) 9 - - **RCF** - Return Channel Frames (filtered downlink) 10 - - **FCLTU** - Forward CLTU (uplink telecommands) 11 - - **TML** - Transport Mapping Layer framing 12 - - **ISP1** - Authentication 6 + - Linux: reads `/proc/net/arp` directly 7 + - macOS/BSD: parses output of `arp -a` 13 8 14 9 ## Installation 15 10 16 11 ``` 17 - opam install sle sle-eio 12 + opam install arp 18 13 ``` 19 14 20 15 ## Usage 21 16 22 - The `sle` package provides a pure functional state machine with no I/O effects. 23 - The `sle-eio` package wraps it with Eio for TCP communication. 24 - 25 17 ```ocaml 26 - Eio_main.run @@ fun env -> 27 - Eio.Switch.run @@ fun sw -> 28 - let config = Sle_eio.default_config ~host:"sle-provider.example.com" ~port:5100 in 29 - match Sle_eio.connect ~sw ~net:(Eio.Stdenv.net env) ~clock:(Eio.Stdenv.clock env) config with 30 - | Error e -> Fmt.epr "Connection failed: %a@." Sle_eio.pp_error e 31 - | Ok client -> 32 - match Sle_eio.bind client ~initiator_id:"user" ~responder_port_id:"RAF" 33 - ~service_type:Sle.Bind.Raf_all ~version:5 34 - ~service_instance_id:"sagr=1.spack=..." with 35 - | Error e -> Fmt.epr "Bind failed: %a@." Sle_eio.pp_error e 36 - | Ok _version -> 37 - match Sle_eio.start_raf client ~start_time:None ~stop_time:None 38 - ~requested_quality:Sle.Common.Good with 39 - | Error e -> Fmt.epr "Start failed: %a@." Sle_eio.pp_error e 40 - | Ok () -> 41 - (* Receive frames *) 42 - let rec loop () = 43 - match Sle_eio.recv_frame client with 44 - | Error Sle_eio.Closed -> () 45 - | Error e -> Fmt.epr "Error: %a@." Sle_eio.pp_error e 46 - | Ok frame -> 47 - process_frame frame.data; 48 - loop () 49 - in 50 - loop () 18 + let entries = Arp.read () in 19 + List.iter 20 + (fun (e : Arp.entry) -> 21 + Printf.printf "%s -> %s\n" e.ip e.mac) 22 + entries 51 23 ``` 52 - 53 - ## References 54 - 55 - - [CCSDS 913.1-B-2](https://public.ccsds.org/Pubs/913x1b2.pdf) - Space Link Extension Services 56 24 57 25 ## Licence 58 26