Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetKAT JSON IP4 Inconsistency #450

Closed
mwhittaker opened this issue Oct 27, 2015 · 5 comments
Closed

NetKAT JSON IP4 Inconsistency #450

mwhittaker opened this issue Oct 27, 2015 · 5 comments

Comments

@mwhittaker
Copy link

There are some inconsistencies between the parsing and serialization of IPv4 headers to and from JSON. More specifically, Frenetic_NetKAT_Json.ml serializes IP4Src and IP4Dst header values into JSON objects, but it parses IP source and destination addresses expecting they're just strings. There are some other discrepancies too (e.g. "ip4dst" vs "ipDst").

I can write up a fix.

mwhittaker added a commit to mwhittaker/frenetic that referenced this issue Oct 27, 2015
@jnfoster
Copy link
Member

Oh man :-( Thanks for fixing this.

@arjunguha
Copy link
Member

Oh wow.

@seliopou
Copy link
Collaborator

type ip_addr = Ipaddr.V4.Prefix.t

let ip_addr_to_yojson ip =
  `String (Ipaddr.V4.Prefix.to_string ip)

let ip_addr_of_yojson = function
  | `String str ->
    begin match Ipaddr.V4.Prefix.of_string str with
    | None -> `Error (Printf.sprintf "unable to parse: %S" str)
    | Some ip -> `Ok ip
    end
  | _ -> `Error "expecting string but got someting else"

Also see ocaml-ppx/ppx_deriving_yojson#37. Haven't gotten around to it yet.

craig-riecke added a commit that referenced this issue Dec 3, 2015
Fix JSON inconsistencies mentioned in #450
@craig-riecke
Copy link
Contributor

Ok fixed is merged in. Thanks for pointing this out @mwhittaker and for fixing it @smolkaj.

@mwhittaker
Copy link
Author

Oops, I had forgotten about this :P. Thanks for the fix @smolkaj!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants