tagging vde-2 version 2.3.2
[vde.git] / 2.3.2 / include / libvdeplug.h
blob09e2e4c4b9482ea263b140310e81b05fbba819e0
1 /*
2 * libvdeplug - A library to connect to a VDE Switch.
3 * Copyright (C) 2006 Renzo Davoli, University of Bologna
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation version 2.1 of the License, or (at
8 * your option) any later version.
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
13 * General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef _VDELIB_H
21 #define _VDELIB_H
22 #include <sys/types.h>
23 #define LIBVDEPLUG_INTERFACE_VERSION 1
25 struct vdeconn;
27 typedef struct vdeconn VDECONN;
29 /* Open a VDE connection.
30 * vde_open_options:
31 * port: connect to a specific port of the switch (0=any)
32 * group: change the ownership of the communication port to a specific group
33 * (NULL=no change)
34 * mode: set communication port mode (if 0 standard socket mode applies)
36 struct vde_open_args {
37 int port;
38 char *group;
39 mode_t mode;
42 /* vde_open args:
43 * vde_switch: switch id (path)
44 * descr: description (it will appear in the port description on the switch)
46 #define vde_open(vde_switch,descr,open_args) \
47 vde_open_real((vde_switch),(descr),LIBVDEPLUG_INTERFACE_VERSION,(open_args))
48 VDECONN *vde_open_real(char *vde_switch,char *descr,int interface_version,
49 struct vde_open_args *open_args);
51 ssize_t vde_recv(VDECONN *conn,void *buf,size_t len,int flags);
53 ssize_t vde_send(VDECONN *conn,const void *buf,size_t len,int flags);
55 /* for select/poll when this fd receive data, there are packets to recv
56 * (call vde_recv) */
57 int vde_datafd(VDECONN *conn);
59 /* for select/poll. the ctl socket is silent after the initial handshake.
60 * when EOF the switch has closed the connection */
61 int vde_ctlfd(VDECONN *conn);
63 int vde_close(VDECONN *conn);
65 /* vdestream */
67 struct vdestream;
69 typedef struct vdestream VDESTREAM;
71 #define PACKET_LENGTH_ERROR 1
73 VDESTREAM *vdestream_open(void *opaque,
74 int fdout,
75 ssize_t (*frecv)(void *opaque, void *buf, size_t count),
76 void (*ferr)(void *opaque, int type, char *format, ...)
79 ssize_t vdestream_send(VDESTREAM *vdestream, const void *buf, size_t len);
81 void vdestream_recv(VDESTREAM *vdestream, unsigned char *buf, size_t len);
83 void vdestream_close(VDESTREAM *vdestream);
85 #endif