package tcpip

Build not yet checked
  1. Overview
  2. Docs
OCaml TCP/IP networking stack, used in MirageOS

Install

dune-project
 Dependency

Authors

Maintainers

Sources

tcpip-9.0.2.tbz
sha256=6ed788e5eb5a5735e674d3c9690996162f28a7665f9b69e509c383bd0afb70c7
sha512=e02b4986b4170ed06c6206459ef34042b919201545a5ed50047808c32190ade7b0902c928e0608e59ed5e9e5bcdf673752f69f190852122fcfd1b10ab549bda8

doc/src/tcpip.ipv4/ipv4_wire.ml.html

Source file ipv4_wire.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
42
let sizeof_ipv4 = 20

let hlen_version_off = 0
let tos_off = 1
let len_off = 2
let id_off = 4
let off_off = 6
let ttl_off = 8
let proto_off = 9
let csum_off = 10
let src_off = 12
let dst_off = 16

let get_hlen_version buf = Cstruct.get_uint8 buf hlen_version_off
let set_hlen_version buf v = Cstruct.set_uint8 buf hlen_version_off v

let get_tos buf = Cstruct.get_uint8 buf tos_off
let set_tos buf v = Cstruct.set_uint8 buf tos_off v

let get_len buf = Cstruct.BE.get_uint16 buf len_off
let set_len buf v = Cstruct.BE.set_uint16 buf len_off v

let get_id buf = Cstruct.BE.get_uint16 buf id_off
let set_id buf v = Cstruct.BE.set_uint16 buf id_off v

let get_off buf = Cstruct.BE.get_uint16 buf off_off
let set_off buf v = Cstruct.BE.set_uint16 buf off_off v

let get_ttl buf = Cstruct.get_uint8 buf ttl_off
let set_ttl buf v = Cstruct.set_uint8 buf ttl_off v

let get_proto buf = Cstruct.get_uint8 buf proto_off
let set_proto buf v = Cstruct.set_uint8 buf proto_off v

let get_checksum buf = Cstruct.BE.get_uint16 buf csum_off
let set_checksum buf value = Cstruct.BE.set_uint16 buf csum_off value

let get_src buf = Ipaddr.V4.of_int32 (Cstruct.BE.get_uint32 buf src_off)
let set_src buf v = Cstruct.BE.set_uint32 buf src_off (Ipaddr.V4.to_int32 v)

let get_dst buf = Ipaddr.V4.of_int32 (Cstruct.BE.get_uint32 buf dst_off)
let set_dst buf v = Cstruct.BE.set_uint32 buf dst_off (Ipaddr.V4.to_int32 v)