Skip to content

Commit

Permalink
Merge pull request #128 from hannesm/refactor
Browse files Browse the repository at this point in the history
Remove ppx_cstruct, ppx_sexp_conv, and sexplib from dependencies, shorten options
  • Loading branch information
hannesm authored Nov 14, 2024
2 parents 3fb6663 + d378cea commit 15f3f9a
Show file tree
Hide file tree
Showing 15 changed files with 738 additions and 1,310 deletions.
5 changes: 0 additions & 5 deletions charrua-server.opam
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ bug-reports: "https://github.com/mirage/charrua/issues"
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "1.4.0"}
"ppx_sexp_conv" {>= "v0.9.0"}
"menhir" {build & >= "20180523"}
"charrua" {= version}
"cstruct" {>= "6.0.0"}
"sexplib"
"ipaddr" {>= "5.0.0"}
"macaddr" {>= "4.0.0"}
"ipaddr-sexp"
"macaddr-sexp"
"cstruct-unix" {with-test}
"ppx_cstruct" {>= "6.0.0" & with-test}
"tcpip" {>= "7.0.0" & with-test}
"alcotest" {with-test & >= "1.4.0"}
]
Expand Down
6 changes: 1 addition & 5 deletions charrua.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ build: [
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "1.4.0"}
"ppx_sexp_conv" {>="v0.10.0"}
"ppx_cstruct"
"cstruct" {>= "6.0.0"}
"sexplib"
"ipaddr" {>= "5.0.0"}
"macaddr" {>= "4.0.0"}
"ipaddr-sexp"
"macaddr-sexp"
"ethernet" {>= "3.0.0"}
"tcpip" {>= "7.0.0"}
"ohex" {>= "0.2.0"}
]
conflicts: [ "result" {< "1.5"} ]
synopsis: "DHCP wire frame encoder and decoder"
Expand Down
17 changes: 10 additions & 7 deletions client/dhcp_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ let default_requests =

(* a pretty-printer for the client, useful for debugging and logging. *)
let pp fmt p =
let pr = Dhcp_wire.pkt_to_string in
let pp_state fmt = function
| Selecting pkt -> Format.fprintf fmt "SELECTING. Generated %s" @@ pr pkt
| Requesting (received, sent) -> Format.fprintf fmt
"REQUESTING. Received %s, and generated response %s" (pr received) (pr sent)
| Bound pkt -> Format.fprintf fmt "BOUND. Received %s" @@ pr pkt
| Renewing (ack, request) -> Format.fprintf fmt
"RENEWING. Have lease %s, generated request %s" (pr ack) (pr request)
| Selecting pkt -> Format.fprintf fmt "SELECTING. Generated %a" Dhcp_wire.pp_pkt pkt
| Requesting (received, sent) ->
Format.fprintf fmt
"REQUESTING. Received %a, and generated response %a"
Dhcp_wire.pp_pkt received Dhcp_wire.pp_pkt sent
| Bound pkt -> Format.fprintf fmt "BOUND. Received %a" Dhcp_wire.pp_pkt pkt
| Renewing (ack, request) ->
Format.fprintf fmt
"RENEWING. Have lease %a, generated request %a"
Dhcp_wire.pp_pkt ack Dhcp_wire.pp_pkt request
in
Format.fprintf fmt "%a: %a" Macaddr.pp p.srcmac pp_state p.state

Expand Down
2 changes: 1 addition & 1 deletion client/mirage/dhcp_client_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let config_of_lease lease =
match Dhcp_wire.find_subnet_mask lease.options with
| None ->
Log.info (fun f -> f "Lease obtained with no subnet mask; discarding it");
Log.debug (fun f -> f "Unusable lease: %s" @@ Dhcp_wire.pkt_to_string lease);
Log.debug (fun f -> f "Unusable lease: %a" Dhcp_wire.pp_pkt lease);
None
| Some subnet ->
match Ipaddr.V4.Prefix.of_netmask ~netmask:subnet ~address with
Expand Down
Loading

0 comments on commit 15f3f9a

Please sign in to comment.