1 /* Copyright (c) 2016 Google Inc
2 * Barret Rhoden <brho@cs.berkeley.edu>
3 * See LICENSE for details.
5 * Networking for VMMs. */
11 #include <vmm/virtio.h>
12 #include <vmm/virtio_net.h>
14 /***** Global control variables */
16 /* Mirror virtio_net traffic to #srv/snoop-PID, default off. */
17 extern bool vnet_snoop;
19 /* Style of IP addressing, default off (qemu)
21 * For qemu-style networking:
22 * guest_ip = 10.0.2.15, mask = 255.255.255.0, router = 10.0.2.2.
23 * For real-addr networking:
24 * guest_ip = host_v4, mask = host_mask, router = host_router
25 * In either case, the guest sees the *real* DNS server. */
26 extern bool vnet_real_ip_addrs;
28 /* Have "notify 9" print NAT mappings to stderr. Default off. */
29 extern bool vnet_map_diagnostics;
31 /* Timeout controls when we drop NAT mappings. The value is a minimum, in
32 * seconds. Max is 2 * timeout. E[X] is 1.5 * timeout. Default 200.*/
33 extern unsigned long vnet_nat_timeout;
36 /***** Functional interface */
38 /* Control variables must be set before calling vnet_init() */
39 void vnet_init(struct virtual_machine *vm, struct virtio_vq_dev *vqdev);
40 void vnet_port_forward(char *protocol, char *host_port, char *guest_port);
43 /***** Glue between virtio and NAT */
44 int vnet_transmit_packet(struct iovec *iov, int iovcnt);
45 int vnet_receive_packet(struct iovec *iov, int iovcnt);