mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-01 20:59:01 +00:00
sdk: replace custom transport protocol by Capnproto
Initial patch by @talex5 Signed-off-by: Thomas Gazagnaire <thomas@gazagnaire.org>
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/filter.h>
|
||||
|
||||
@@ -87,3 +89,5 @@ CAMLprim value bpf_filter(value vunit)
|
||||
memcpy(String_val(vfilter), bootp_bpf_filter, sizeof(bootp_bpf_filter));
|
||||
CAMLreturn (vfilter);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -83,13 +83,18 @@ let run () cmd ethif path =
|
||||
| Some f -> read_cmd f
|
||||
in
|
||||
Lwt_main.run (
|
||||
Lwt_switch.with_switch @@ fun switch ->
|
||||
let routes = [
|
||||
["ip"] , [`Write];
|
||||
["mac"] , [`Read ];
|
||||
["gateway"], [`Write];
|
||||
] in
|
||||
Ctl.v path >>= fun db ->
|
||||
let ctl fd = Ctl.Server.listen ~routes db fd in
|
||||
let ctl fd =
|
||||
let service = Ctl.Server.service ~routes db in
|
||||
let endpoint = Capnp_rpc_lwt.Endpoint.of_flow ~switch (module Sdk.IO) fd in
|
||||
ignore (Capnp_rpc_lwt.CapTP.of_endpoint ~switch ~offer:service endpoint)
|
||||
in
|
||||
let handlers () = Handlers.watch ~ethif db in
|
||||
let net = Init.rawlink ~filter:(dhcp_filter ()) ethif in
|
||||
Net.mac ethif >>= fun mac ->
|
||||
|
||||
Reference in New Issue
Block a user