~ubuntu-branches/ubuntu/lucid/vde2/lucid-proposed

« back to all changes in this revision

Viewing changes to plugin/vdeplugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Filippo Giunchedi
  • Date: 2008-06-17 15:36:32 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617153632-5318x7iv0zwmu3zu
Tags: 2.2.1-1
* New upstream release
  - fix vlan commands on amd64 (Closes: #484295)
  - fix mac addresses switch between ports (Closes: #469098)
* Suggest: qemu and kvm as requested in #461514
* Expand and spell-check README.Debian, add manual method example
  (Closes: #466363)
* Do not assume MAKEDEV presence in postinst
* Remove /usr/bin/daemon usage from ifupdown scripts (and Recommends)
* Add manpage for vde_tunctl
* Upgrade to S-V 3.8.0 (add Homepage field) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _VDEPLUGIN_H
2
 
#define _VDEPLUGIN_H
3
 
#include <stdarg.h>
4
 
#include <stdio.h>
5
 
 
6
 
/* command type constants */
7
 
/* doit signature:
8
 
 * int doit (
9
 
 *            FILE *f,        *** only when WITHFILE
10
 
 *            int fd,         *** only when WITHFD
11
 
 *            int|char *arg)  *** when INTARG or STRARG */
12
 
/* if type==NOARG  int doit()
13
 
 * if type==INTARG   int doit(int arg)
14
 
 * if type==WITHFILE|WITHFD|STRARG int doit(FILE *f,int fd,char *arg)
15
 
 * doit returns 0 on success otherwise it returns a valid errno code */
16
 
#define NOARG 0 /*the command require no args */
17
 
#define INTARG 1 /* arg is an integer */
18
 
#define STRARG 2 /* arg is a string */
19
 
#define WITHFILE 0x40 /* command needs to return text output.
20
 
                                                                                                 (the output will be sent to the user using
21
 
                                                                                                 "0000 DATA END WITH '.'") */
22
 
#define WITHFD 0x80 /* fd is the identifier of the mgmt connection issuing
23
 
                                                                                         the command. fd== -1 when the command is executed by
24
 
                                                                                         an rc file. Fd should not be considered a file
25
 
                                                                                         descriptor, */
26
 
 
27
 
typedef int (*intfun)();
28
 
 
29
 
/* command structure */
30
 
struct comlist {
31
 
        char *path; /*pathname of the command: pathname structured */
32
 
        char *syntax; /*description of the syntax */
33
 
        char *help; /*description of the command for help listings */
34
 
        int (*doit)(); /* the call back to the command code */
35
 
        unsigned char type; /* types of command: see constants above */
36
 
        /* the following field is for management. never set or change it*/
37
 
        struct comlist *next;
38
 
};
39
 
 
40
 
/* pre-defined TAGs */
41
 
#define D_PACKET 01000
42
 
#define D_MGMT 02000
43
 
#define D_IN 01
44
 
#define D_OUT 02
45
 
#define D_PLUS 01
46
 
#define D_MINUS 02
47
 
#define D_DESCR 03
48
 
#define D_STATUS 04
49
 
#define D_ROOT 05
50
 
#define D_HASH 010
51
 
#define D_PORT 020
52
 
#define D_EP 030
53
 
#define D_FSTP 040
54
 
/* debug/event structure */
55
 
struct dbgcl {
56
 
        char *path; /* pathname structured debug/event request */
57
 
        char *help; /* description for debug options listing
58
 
                                                                 if help==NULL the entry will be used only for 
59
 
                                                                 plugin event publish/subscribe not directly accessible
60
 
                                                                 from the user interface */
61
 
        int tag;    /* numerical tag of the debug/event */
62
 
        /* the following fields are for management. never set or change them*/
63
 
        int *fds;
64
 
        intfun (*fun);
65
 
        void **funarg;
66
 
        unsigned short nfds;
67
 
        unsigned short nfun;
68
 
        unsigned short maxfds;
69
 
        unsigned short maxfun;
70
 
        struct dbgcl *next;
71
 
};
72
 
 
73
 
/* plugin element: one element named "vde_plugin_data" must
74
 
 * be defined otherwise the dynamic library will not be recognized
75
 
 * as a vde plugin module */
76
 
struct plugin {
77
 
        /* name of the plugin, it should be unique, maybe pathname structured.
78
 
         * it identifies the plugin for listing and unloading plugins */
79
 
        char *name;
80
 
        /* description of the plugin for listings */
81
 
        char *help;
82
 
        /* the following fields should never be set or changed by
83
 
         * plugin modules */
84
 
        void *handle;
85
 
        struct plugin *next;
86
 
};
87
 
 
88
 
/* this adds a new management fd */
89
 
void mgmtnewfd(int new);
90
 
 
91
 
#define ADDCL(CL) addcl(sizeof(CL)/sizeof(struct comlist),(CL))
92
 
#define ADDDBGCL(CL) adddbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
93
 
#define DELCL(CL) delcl(sizeof(CL)/sizeof(struct comlist),(CL))
94
 
#define DELDBGCL(CL) deldbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
95
 
#define DBGOUT(CL, ...) \
96
 
          if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), __VA_ARGS__)
97
 
#define EVENTOUT(CL, ...) \
98
 
          if (__builtin_expect(((CL)->nfun) > 0, 0)) eventout((CL), __VA_ARGS__)
99
 
 
100
 
#endif