2 * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
3 * Licensed under the GPL.
8 #include <libvdeplug.h>
9 #include "kern_constants.h"
11 #include "um_malloc.h"
15 static int vde_user_init(void *data, void *dev)
17 struct vde_data *pri = data;
23 conn = vde_open(pri->vde_switch, pri->descr, pri->args);
27 printk(UM_KERN_ERR "vde_user_init: vde_open failed, "
28 "errno = %d\n", errno);
32 printk(UM_KERN_INFO "vde backend - connection opened\n");
39 static int vde_user_open(void *data)
41 struct vde_data *pri = data;
43 if (pri->conn != NULL)
44 return vde_datafd(pri->conn);
46 printk(UM_KERN_WARNING "vde_open - we have no VDECONN to open");
50 static void vde_remove(void *data)
52 struct vde_data *pri = data;
54 if (pri->conn != NULL) {
55 printk(UM_KERN_INFO "vde backend - closing connection\n");
63 printk(UM_KERN_WARNING "vde_remove - we have no VDECONN to remove");
66 const struct net_user_info vde_user_info = {
67 .init = vde_user_init,
68 .open = vde_user_open,
72 .delete_address = NULL,
73 .mtu = ETH_MAX_PACKET,
74 .max_packet = ETH_MAX_PACKET + ETH_HEADER_OTHER,
77 void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init)
79 struct vde_open_args *args;
81 vpri->args = kmalloc(sizeof(struct vde_open_args), UM_GFP_KERNEL);
82 if (vpri->args == NULL) {
83 printk(UM_KERN_ERR "vde_init_libstuff - vde_open_args"
90 args->port = init->port;
91 args->group = init->group;
92 args->mode = init->mode ? init->mode : 0700;
94 args->port ? printk(UM_KERN_INFO "port %d", args->port) :
95 printk(UM_KERN_INFO "undefined port");
98 int vde_user_read(void *conn, void *buf, int len)
100 VDECONN *vconn = conn;
106 rv = vde_recv(vconn, buf, len, 0);
118 int vde_user_write(void *conn, void *buf, int len)
120 VDECONN *vconn = conn;
125 return vde_send(vconn, buf, len, 0);