package cstruct

  1. Overview
  2. Docs
Access C-like structures directly from OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

cstruct-6.2.0.tbz
sha256=9a78073392580e8349148fa3ab4b1b2e989dc9d30d07401b04c96b7c60f03e62
sha512=8d33fe6b3707a3994d0225cd33cadde0bb2ca834ef01096e3df33a08e4a8c6d02ebccddf558a73988b8a5595b65fdc10de61efbf872c6c9e55c719c7e19c463d

doc/cstruct/Cstruct_cap/BE/index.html

Module Cstruct_cap.BESource

Big-endian Byte Order

The following operations assume a big-endian byte ordering of the cstruct. If the machine-native byte ordering differs, then the get operations will reorder the bytes so that they are in machine-native byte order before returning the result, and the set operations will reorder the bytes so that they are written out in the appropriate order.

Network byte order is big-endian, so you may need these operations when dealing with raw frames, for example, in a userland networking stack.

Sourceval get_uint16 : 'a rd t -> int -> uint16

get_uint16 t off returns the two bytes in t starting at offset off, interpreted as an uint16. t needs at least read capability rd.

Sourceval get_uint32 : 'a rd t -> int -> uint32

get_uint32 t off returns the four bytes in t starting at offset off. t needs at least read capability rd.

Sourceval get_uint64 : 'a rd t -> int -> uint64

get_uint64 t off returns the eight bytes in t starting at offset off. t needs at least read capability rd.

Sourceval set_uint16 : 'a wr t -> int -> uint16 -> unit

set_uint16 t off v sets the two bytes in t starting at offset off to the value v. t needs at least write capability wr.

Sourceval set_uint32 : 'a wr t -> int -> uint32 -> unit

set_uint32 t off v sets the four bytes in t starting at offset off to the value v. t needs at least write capability wr.

Sourceval set_uint64 : 'a wr t -> int -> uint64 -> unit

set_uint64 t off v sets the eight bytes in t starting at offset off to the value v. t needs at least write capability wr.