[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cstruct signature generator added



Dave has been using cstruct for his pcap generator, so I extended the syntax 
extension to also work in .mli files.  You can now do something like:

module LE : sig

  val endian : endian

  cstruct pcap_header {
    uint32_t magic_number;   (* magic number *)
    uint16_t version_major;  (* major version number *)
    uint16_t version_minor;  (* minor version number *)
    uint32_t thiszone;       (* GMT to local correction *)
    uint32_t sigfigs;        (* accuracy of timestamps *)
    uint32_t snaplen;        (* max length of captured packets, in octets *)
    uint32_t network         (* data link type *)
  } as little_endian

  cstruct pcap_packet {
    uint32_t ts_sec;         (* timestamp seconds *)
    uint32_t ts_usec;        (* timestamp microseconds *)
    uint32_t incl_len;       (* number of octets of packet saved in file *)
    uint32_t orig_len        (* actual length of packet *)
  } as little_endian

end

... just as you could before in a .ml file.

I also switched the extension over to using a different quotation expander (due 
to some rather obscure historical limitations in the original vs revised 
syntaxes).  This means the changes were a little bigger than usual, so I'll 
wait a few days before releasing cstruct-0.5.0 with the new generator. 

Dave, pull request sent to you for djs55/ocaml-pcap... when it works, lets tag 
a release on mirage/ocaml-pcap.

-anil





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.