Skip to content

Commit ee2e5c0

Browse files
committed
update to ethernet, arp 3.0.0
Signed-off-by: David Scott <[email protected]> ethernet Signed-off-by: David Scott <[email protected]>
1 parent 47cebca commit ee2e5c0

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

src/hostnet/filter.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Make(Input: Sig.VMNET) = struct
3838
let write t ~size fill = Input.write t.input ~size fill >|= lift_error
3939

4040
let filter valid_subnets valid_sources next buf =
41-
match Ethernet_packet.Unmarshal.of_cstruct buf with
41+
match Ethernet.Packet.of_cstruct buf with
4242
| Ok (_header, payload) ->
4343
let src = Ipaddr.V4.of_int32 @@ Ipv4_wire.get_ipv4_src payload in
4444
let from_valid_networks =

src/hostnet/hostnet_dhcp.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ module Make (Clock: Mirage_clock.MCLOCK) (Netif: Mirage_net.S) = struct
173173
pre-allocated IP anyway, but this will present a problem if
174174
that assumption ever changes. *)
175175
let database = ref (Dhcp_server.Lease.make_db ()) in
176-
match Ethernet_packet.Unmarshal.of_cstruct buf with
176+
match Ethernet.Packet.of_cstruct buf with
177177
| Ok (pkt, _payload) when
178-
of_interest t.server_macaddr pkt.Ethernet_packet.destination ->
179-
(match pkt.Ethernet_packet.ethertype with
178+
of_interest t.server_macaddr pkt.Ethernet.Packet.destination ->
179+
(match pkt.Ethernet.Packet.ethertype with
180180
| `IPv4 ->
181181
if Dhcp_wire.is_dhcp buf (Cstruct.length buf) then begin
182182
input t.netif (t.get_dhcp_configuration ()) !database buf

src/hostnet/hostnet_dns.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ struct
253253
packet creation fn *)
254254
let frame = Io_page.to_cstruct (Io_page.get 1) in
255255
let smac = "\000\000\000\000\000\000" in
256-
Ethernet_wire.set_ethernet_src smac 0 frame;
257-
Ethernet_wire.set_ethernet_ethertype frame 0x0800;
258-
let buf = Cstruct.shift frame Ethernet_wire.sizeof_ethernet in
256+
Ethernet__Ethernet_wire.set_ethernet_src smac 0 frame;
257+
Ethernet__Ethernet_wire.set_ethernet_ethertype frame 0x0800;
258+
let buf = Cstruct.shift frame Ethernet.Packet.sizeof_ethernet in
259259
Ipv4_wire.set_ipv4_hlen_version buf ((4 lsl 4) + (5));
260260
Ipv4_wire.set_ipv4_tos buf 0;
261261
Ipv4_wire.set_ipv4_ttl buf 38;
@@ -264,7 +264,7 @@ struct
264264
Ipv4_wire.set_ipv4_src buf (Ipaddr.V4.to_int32 source_ip);
265265
Ipv4_wire.set_ipv4_dst buf (Ipaddr.V4.to_int32 dest_ip);
266266
let header_len =
267-
Ethernet_wire.sizeof_ethernet + Ipv4_wire.sizeof_ipv4
267+
Ethernet.Packet.sizeof_ethernet + Ipv4_wire.sizeof_ipv4
268268
in
269269

270270
let frame = Cstruct.sub frame 0 (header_len + Udp_wire.sizeof_udp) in
@@ -276,12 +276,12 @@ struct
276276
(* Only for recording, no need to set a checksum. *)
277277
(* Ip.writev *)
278278
let bufs = frame :: bufs in
279-
let tlen = Cstruct.lenv bufs - Ethernet_wire.sizeof_ethernet in
279+
let tlen = Cstruct.lenv bufs - Ethernet.Packet.sizeof_ethernet in
280280
let dmac = String.make 6 '\000' in
281281
(* Ip.adjust_output_header *)
282-
Ethernet_wire.set_ethernet_dst dmac 0 frame;
282+
Ethernet__Ethernet_wire.set_ethernet_dst dmac 0 frame;
283283
let buf =
284-
Cstruct.sub frame Ethernet_wire.sizeof_ethernet Ipv4_wire.sizeof_ipv4
284+
Cstruct.sub frame Ethernet.Packet.sizeof_ethernet Ipv4_wire.sizeof_ipv4
285285
in
286286
(* Set the mutable values in the ipv4 header *)
287287
Ipv4_wire.set_ipv4_len buf tlen;

src/hostnet/mux.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module Make (Netif: Mirage_net.S) = struct
8989
let t = { netif; rules; default_callback } in
9090
Lwt.async
9191
(fun () ->
92-
Netif.listen netif ~header_size:Ethernet_wire.sizeof_ethernet @@ callback t >>= function
92+
Netif.listen netif ~header_size:Ethernet.Packet.sizeof_ethernet @@ callback t >>= function
9393
| Ok () -> Lwt.return_unit
9494
| Error _e ->
9595
Log.err (fun f -> f "Mux.connect calling Netif.listen: failed");

src/hostnet/slirp.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ struct
554554
let tcp_stack = { endpoint; udp_nat; dns_ips } in
555555
let open Lwt.Infix in
556556
(* Wire up the listeners to receive future packets: *)
557-
Switch.Port.listen ~header_size:Ethernet_wire.sizeof_ethernet endpoint.Endpoint.netif
557+
Switch.Port.listen ~header_size:Ethernet.Packet.sizeof_ethernet endpoint.Endpoint.netif
558558
(fun buf ->
559559
let open Frame in
560560
match parse [ buf ] with
@@ -681,7 +681,7 @@ struct
681681
let tcp_stack = { endpoint; udp_nat; dns_ips; localhost_names; localhost_ips } in
682682
let open Lwt.Infix in
683683
(* Wire up the listeners to receive future packets: *)
684-
Switch.Port.listen ~header_size:Ethernet_wire.sizeof_ethernet endpoint.Endpoint.netif
684+
Switch.Port.listen ~header_size:Ethernet.Packet.sizeof_ethernet endpoint.Endpoint.netif
685685
(fun buf ->
686686
let open Frame in
687687
match parse [ buf ] with
@@ -780,7 +780,7 @@ struct
780780
let tcp_stack = { endpoint; udp_nat; icmp_nat; localhost_names; localhost_ips } in
781781
let open Lwt.Infix in
782782
(* Wire up the listeners to receive future packets: *)
783-
Switch.Port.listen ~header_size:Ethernet_wire.sizeof_ethernet endpoint.Endpoint.netif
783+
Switch.Port.listen ~header_size:Ethernet.Packet.sizeof_ethernet endpoint.Endpoint.netif
784784
(fun buf ->
785785
let open Frame in
786786
match parse [ buf ] with
@@ -1130,7 +1130,7 @@ struct
11301130
vnet_client_id
11311131
(Macaddr.to_string eth_src)
11321132
(Macaddr.to_string eth_dst));
1133-
(Switch.write ~size:Ethernet_wire.sizeof_ethernet switch (fun toBuf ->
1133+
(Switch.write ~size:Ethernet.Packet.sizeof_ethernet switch (fun toBuf ->
11341134
Cstruct.blit buf 0 toBuf 0 (Cstruct.length buf);
11351135
Cstruct.length buf)
11361136
>|= function
@@ -1144,7 +1144,7 @@ struct
11441144
Log.info (fun f ->
11451145
f "Client mac: %s server mac: %s"
11461146
(Macaddr.to_string client_macaddr) (Macaddr.to_string c.Configuration.server_macaddr));
1147-
Switch.listen switch ~header_size:Ethernet_wire.sizeof_ethernet (fun buf ->
1147+
Switch.listen switch ~header_size:Ethernet.Packet.sizeof_ethernet (fun buf ->
11481148
let open Frame in
11491149
match parse [ buf ] with
11501150
| Ok (Ethernet { src = eth_src ; dst = eth_dst ; _ }) when
@@ -1157,7 +1157,7 @@ struct
11571157
(Macaddr.to_string eth_src) (Macaddr.to_string eth_dst));
11581158
(* pass to virtual network *)
11591159
begin
1160-
Vnet.write vnet_switch t.vnet_client_id ~size:Ethernet_wire.sizeof_ethernet (fun toBuf ->
1160+
Vnet.write vnet_switch t.vnet_client_id ~size:Ethernet.Packet.sizeof_ethernet (fun toBuf ->
11611161
Cstruct.blit buf 0 toBuf 0 (Cstruct.length buf);
11621162
Cstruct.length buf)
11631163
>|= function
@@ -1190,7 +1190,7 @@ struct
11901190
|> Lwt.return)
11911191
end
11921192
>>= fun arp ->
1193-
Global_arp.input arp (Cstruct.shift buf Ethernet_wire.sizeof_ethernet)
1193+
Global_arp.input arp (Cstruct.shift buf Ethernet.Packet.sizeof_ethernet)
11941194
| Ok (Ethernet { payload = Ipv4 ({ src; dst; _ } as ipv4 ); _ }) ->
11951195
(* For any new IP destination, create a stack to proxy for
11961196
the remote system *)

src/hostnet/static_arp.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ let src =
3232

3333
module Log = (val Logs.src_log src : Logs.LOG)
3434

35-
module Make (Ethif: Mirage_protocols.ETHERNET) = struct
35+
module Make (Ethif: Ethernet.S) = struct
3636

3737
module Table = Map.Make(Ipaddr.V4)
3838

3939
type macaddr = Macaddr.t
4040
type t = { ethif: Ethif.t; mutable table: macaddr Table.t }
41-
type error = Mirage_protocols.Arp.error
42-
let pp_error = Mirage_protocols.Arp.pp_error
41+
type error = [ `Timeout ]
42+
let pp_error ppf `Timeout = Fmt.string ppf "Timeout"
4343

4444
let to_string t =
4545
let pp_one (ip, mac) =

src/hostnet/static_arp.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
rely on the dynamic version which can fail with `No_route_to_host` if
33
the other side doesn't respond *)
44

5-
module Make(Ethif: Mirage_protocols.ETHERNET): sig
6-
include Mirage_protocols.ARP
5+
module Make(Ethif: Ethernet.S): sig
6+
include Arp.S
77

88
type ethif = Ethif.t
99

vpnkit.opam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ depends: [
4343
"logs"
4444
"fmt"
4545
"astring"
46-
"arp" {= "2.3.1"}
46+
"ethernet" {>= "3.0.0"}
47+
"arp" {>= "3.0.0"}
4748
"mirage-device" {= "2.0.0"}
4849
"mirage-kv" {= "3.0.1"}
4950
"mirage-net" {= "3.0.1"}

0 commit comments

Comments
 (0)