VDE 2.1.6, 2006-12-21
[vde.git] / vde-2 / libvdeplug / libvdeplug.h
blobfd4469616550097d7de9fb18623f257dfca4b890
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,char *buf,size_t len,int flags);
53 ssize_t vde_send(VDECONN *conn,const char *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 #endif