2 * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
3 * Licensed under the GPL.
8 #include <libvdeplug.h>
10 #include <um_malloc.h>
13 static int vde_user_init(void *data, void *dev)
15 struct vde_data *pri = data;
21 conn = vde_open(pri->vde_switch, pri->descr, pri->args);
25 printk(UM_KERN_ERR "vde_user_init: vde_open failed, "
26 "errno = %d\n", errno);
30 printk(UM_KERN_INFO "vde backend - connection opened\n");
37 static int vde_user_open(void *data)
39 struct vde_data *pri = data;
41 if (pri->conn != NULL)
42 return vde_datafd(pri->conn);
44 printk(UM_KERN_WARNING "vde_open - we have no VDECONN to open");
48 static void vde_remove(void *data)
50 struct vde_data *pri = data;
52 if (pri->conn != NULL) {
53 printk(UM_KERN_INFO "vde backend - closing connection\n");
61 printk(UM_KERN_WARNING "vde_remove - we have no VDECONN to remove");
64 const struct net_user_info vde_user_info = {
65 .init = vde_user_init,
66 .open = vde_user_open,
70 .delete_address = NULL,
71 .mtu = ETH_MAX_PACKET,
72 .max_packet = ETH_MAX_PACKET + ETH_HEADER_OTHER,
75 void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init)
77 struct vde_open_args *args;
79 vpri->args = uml_kmalloc(sizeof(struct vde_open_args), UM_GFP_KERNEL);
80 if (vpri->args == NULL) {
81 printk(UM_KERN_ERR "vde_init_libstuff - vde_open_args "
88 args->port = init->port;
89 args->group = init->group;
90 args->mode = init->mode ? init->mode : 0700;
92 args->port ? printk("port %d", args->port) :
93 printk("undefined port");
96 int vde_user_read(void *conn, void *buf, int len)
98 VDECONN *vconn = conn;
104 rv = vde_recv(vconn, buf, len, 0);
116 int vde_user_write(void *conn, void *buf, int len)
118 VDECONN *vconn = conn;
123 return vde_send(vconn, buf, len, 0);