Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions META.tcpip.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DUNE_GEN

freestanding_linkopts = "-l:libtcpip_freestanding_stubs.a"
2 changes: 1 addition & 1 deletion examples/ping/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executables
(names ping)
(libraries cmdliner logs logs.fmt tcpip.icmpv4-socket tcpip.unix))
(libraries cmdliner logs logs.fmt tcpip.icmpv4-socket tcpip))
23 changes: 23 additions & 0 deletions freestanding/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig

EXISTS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --exists ocaml-freestanding; echo $$?)

.PHONY: all clean
all: libtcpip_freestanding_stubs.a

ifeq ($(EXISTS), 1)
libtcpip_freestanding_stubs.a:
touch $@
else
CC ?= cc
FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding)
CFLAGS := $(FREESTANDING_CFLAGS)

OBJS=checksum_stubs.o

libtcpip_freestanding_stubs.a: $(OBJS)
$(AR) r $@ $^
endif

clean:
$(RM) $(OBJS) libtcpip_freestanding_stubs.a
14 changes: 14 additions & 0 deletions freestanding/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(copy_files# ../src/tcpip_checksum/*.c)

(rule
(deps Makefile checksum_stubs.c)
(targets libtcpip_freestanding_stubs.a)
(action
(no-infer
(progn
(run %{make})))))

(install
(package tcpip)
(section lib)
(files libtcpip_freestanding_stubs.a))
8 changes: 4 additions & 4 deletions src/tcpip_checksum/checksum_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ones_complement_checksum_bigarray(unsigned char *addr, size_t ofs, size_t count,
}

CAMLprim value
caml_tcpip_ones_complement_checksum(value v_cstruct)
caml_mirage_tcpip_ones_complement_checksum(value v_cstruct)
{
CAMLparam1(v_cstruct);
CAMLlocal3(v_ba, v_ofs, v_len);
Expand All @@ -86,7 +86,7 @@ caml_tcpip_ones_complement_checksum(value v_cstruct)
* forward as 16-byte 1s complement addition if there are more buffers in
* the chain. */
CAMLprim value
caml_tcpip_ones_complement_checksum_list(value v_cstruct_list)
caml_mirage_tcpip_ones_complement_checksum_list(value v_cstruct_list)
{
CAMLparam1(v_cstruct_list);
CAMLlocal4(v_hd, v_ba, v_ofs, v_len);
Expand Down Expand Up @@ -264,7 +264,7 @@ checksum_bigarray(unsigned char *addr, size_t ofs, size_t count, uint32_t sum)
}

CAMLprim value
caml_tcpip_ones_complement_checksum(value v_cstruct)
caml_mirage_tcpip_ones_complement_checksum(value v_cstruct)
{
CAMLparam1(v_cstruct);
CAMLlocal3(v_ba, v_ofs, v_len);
Expand All @@ -283,7 +283,7 @@ caml_tcpip_ones_complement_checksum(value v_cstruct)
* forward as 16-byte 1s complement addition if there are more buffers in
* the chain. */
CAMLprim value
caml_tcpip_ones_complement_checksum_list(value v_cstruct_list)
caml_mirage_tcpip_ones_complement_checksum_list(value v_cstruct_list)
{
CAMLparam1(v_cstruct_list);
CAMLlocal4(v_hd, v_ba, v_ofs, v_len);
Expand Down
13 changes: 5 additions & 8 deletions src/tcpip_checksum/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
(instrumentation
(backend bisect_ppx))
(libraries cstruct)
(wrapped false))

(library
(name tcpip_unix)
(public_name tcpip.unix)
(modules tcpip_unix)
(instrumentation
(backend bisect_ppx))
(foreign_stubs
(language c)
(names checksum_stubs)
(flags :standard))
(wrapped false))

(library
(name tcpip_unix)
(public_name tcpip.unix)
(modules tcpip_unix))
4 changes: 2 additions & 2 deletions src/tcpip_checksum/tcpip_checksum.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
*)

(** One's complement checksum, RFC1071 *)
external ones_complement: Cstruct.t -> int = "caml_tcpip_ones_complement_checksum"
external ones_complement: Cstruct.t -> int = "caml_mirage_tcpip_ones_complement_checksum"

external ones_complement_list: Cstruct.t list -> int = "caml_tcpip_ones_complement_checksum_list"
external ones_complement_list: Cstruct.t list -> int = "caml_mirage_tcpip_ones_complement_checksum_list"
9 changes: 8 additions & 1 deletion tcpip.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ build: [
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]
conflicts: [ "mirage-xen" {< "6.0.0"} ]
conflicts: [
"mirage-xen" {< "6.0.0"}
"ocaml-freestanding" {< "0.4.1"}
]
depends: [
"conf-pkg-config" {build}
"dune" {>= "2.7.0"}
"bisect_ppx" {dev & >= "2.5.0"}
"ocaml" {>= "4.06.0"}
Expand Down Expand Up @@ -53,6 +57,9 @@ depends: [
"ipaddr-cstruct" {with-test}
"lru" {>= "0.3.0"}
]
depopts: [
"ocaml-freestanding"
]
synopsis: "OCaml TCP/IP networking stack, used in MirageOS"
description: """
`mirage-tcpip` provides a networking stack for the [Mirage operating
Expand Down
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
mirage-random rresult mirage-protocols mirage-stack arp arp.mirage
ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4
tcpip.udpv4-socket tcpip.tcpv4-socket tcpip.icmpv4-socket
tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct macaddr-cstruct tcpip.unix)
tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct macaddr-cstruct tcpip)
(action
(run %{test} -q -e --color=always)))