package frenetic

  1. Overview
  2. Docs
The Frenetic Programming Language and Runtime System

Install

Dune Dependency

Authors

Maintainers

Sources

5.0.5.tar.gz
md5=baf754df13a759c32f2c86a1b6f328da
sha512=80140900e7009ccab14b25e244fe7edab87d858676f8a4b3799b4fea16825013cf68363fe5faec71dd54ba825bb4ea2f812c2c666390948ab217ffa75d9cbd29

doc/src/frenetic.kernel/OpenFlow_Header.ml.html

Source file OpenFlow_Header.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
open Core

type xid = Int32.t [@@deriving sexp]

type t = {
  version: int;
  type_code: int;
  length: int;
  xid: xid
} [@@deriving sexp]

[%%cstruct 
type ofp_header = {
  version: uint8_t;
  typ: uint8_t;
  length: uint16_t;
  xid: uint32_t
} [@@big_endian]]

let size = sizeof_ofp_header

let parse (buf : Cstruct.t) : t =
  assert (Cstruct.length buf >= size);
  {
    version = get_ofp_header_version buf;
    type_code = get_ofp_header_typ buf;
    length = get_ofp_header_length buf;
    xid = get_ofp_header_xid buf
  }

let marshal (buf : Cstruct.t) (t : t) : unit =
  assert (Cstruct.length buf >= size);  
  set_ofp_header_version buf t.version;
  set_ofp_header_typ buf t.type_code;
  set_ofp_header_length buf t.length;
  set_ofp_header_xid buf t.xid

let to_string hdr =
  Format.sprintf "{ version = %x, code = %d, len = %d, xid = %ld }"
    hdr.version hdr.type_code hdr.length hdr.xid

OCaml

Innovation. Community. Security.