00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef _VDEDYNLIB_H
00055 #define _VDEDYNLIB_H
00056 #include <sys/types.h>
00057 #include <dlfcn.h>
00058 #define LIBVDEPLUG_INTERFACE_VERSION 1
00059
00060 struct vdeconn;
00061
00062 typedef struct vdeconn VDECONN;
00063
00064
00065
00066
00067
00068
00069
00070
00071 struct vde_open_args {
00072 int port;
00073 char *group;
00074 mode_t mode;
00075 };
00076
00077
00078
00079
00080
00081 #define vde_open(vde_switch,descr,open_args) \
00082 vde_open_real((vde_switch),(descr),LIBVDEPLUG_INTERFACE_VERSION,(open_args))
00083
00084 struct vdepluglib {
00085 void *dl_handle;
00086 VDECONN * (*vde_open_real)(const char *vde_switch,char *descr,int interface_version, struct vde_open_args *open_args);
00087 size_t (* vde_recv)(VDECONN *conn,void *buf,size_t len,int flags);
00088 size_t (* vde_send)(VDECONN *conn,const void *buf,size_t len,int flags);
00089 int (* vde_datafd)(VDECONN *conn);
00090 int (* vde_ctlfd)(VDECONN *conn);
00091 int (* vde_close)(VDECONN *conn);
00092 };
00093
00094 typedef VDECONN * (* VDE_OPEN_REAL_T)(const char *vde_switch,char *descr,int interface_version, struct vde_open_args *open_args);
00095 typedef size_t (* VDE_RECV_T)(VDECONN *conn,void *buf,size_t len,int flags);
00096 typedef size_t (* VDE_SEND_T)(VDECONN *conn,const void *buf,size_t len,int flags);
00097 typedef int (* VDE_INT_FUN)(VDECONN *conn);
00098 #define libvdeplug_dynopen(x) ({ \
00099 (x).dl_handle=dlopen("libvdeplug.so",RTLD_NOW); \
00100 if ((x).dl_handle) { \
00101 (x).vde_open_real=(VDE_OPEN_REAL_T) dlsym((x).dl_handle,"vde_open_real"); \
00102 (x).vde_recv=(VDE_RECV_T) dlsym((x).dl_handle,"vde_recv"); \
00103 (x).vde_send=(VDE_SEND_T) dlsym((x).dl_handle,"vde_send"); \
00104 (x).vde_datafd=(VDE_INT_FUN) dlsym((x).dl_handle,"vde_datafd"); \
00105 (x).vde_ctlfd=(VDE_INT_FUN) dlsym((x).dl_handle,"vde_ctlfd"); \
00106 (x).vde_close=(VDE_INT_FUN) dlsym((x).dl_handle,"vde_close"); \
00107 } else { \
00108 (x).vde_open_real=NULL; \
00109 (x).vde_send= NULL; \
00110 (x).vde_recv= NULL; \
00111 (x).vde_datafd= (x).vde_ctlfd= (x).vde_close= NULL; \
00112 }\
00113 })
00114
00115 #define libvdeplug_dynclose(x) ({ \
00116 dlclose((x).dl_handle); \
00117 })
00118
00119 #endif