Port 0 management
[vde.git] / vde-2 / consmgmt.h
blob22e51ae372f6ea96652449f14d7428bd82dc1811
1 /* Copyright 2002 Jeff Dike
2 * Licensed under the GPL
3 */
5 #ifndef __CONSMGMT_H__
6 #define __CONSMGMT_H__
7 #include <stdarg.h>
9 struct comlist {
10 char *path;
11 char *syntax;
12 char *help;
13 int (*doit)();
14 unsigned char type;
15 struct comlist *next;
18 #define NOARG 0
19 #define INTARG 1
20 #define STRARG 2
21 #define WITHFILE 0x40
22 #define WITHFD 0x80
24 void printlog(int priority, const char *format, ...);
25 void loadrcfile(void);
26 void setmgmtperm(char *path);
28 void printoutc(FILE *fd, const char *format, ...);
29 void addcl(int ncl,struct comlist *cl);
30 #define ADDCL(CL) addcl(sizeof(CL)/sizeof(struct comlist),(CL))
32 typedef int (*intfun)();
33 #ifdef DEBUGOPT
34 #define D_PACKET 01000
35 #define D_MGMT 02000
36 #define D_IN 01
37 #define D_OUT 02
38 #define D_PLUS 01
39 #define D_MINUS 02
40 #define D_DESCR 03
41 #define D_STATUS 04
42 #define D_ROOT 05
43 #define D_HASH 010
44 #define D_PORT 020
45 #define D_EP 030
46 #define D_FSTP 040
47 struct dbgcl {
48 char *path; /* debug path for add/del */
49 char *help; /* help string. just event mgmt when NULL */
50 int tag; /* tag for event mgmt and simple parsing */
51 int *fds; /* file descriptors for debug */
52 intfun (*fun); /* function call dor plugin events */
53 void **funarg; /* arg for function calls */
54 unsigned short nfds; /* number of active fds */
55 unsigned short nfun; /* number of active fun */
56 unsigned short maxfds; /* current size of fds */
57 unsigned short maxfun; /* current size of both fun and funarg */
58 struct dbgcl *next;
60 void adddbgcl(int ncl, struct dbgcl* cl);
61 #define ADDDBGCL(CL) adddbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
62 void debugout(struct dbgcl* cl, const char *format, ...);
63 void eventout(struct dbgcl* cl, ...);
64 int packetfilter(struct dbgcl* cl, ...);
65 #define DBGOUT(CL, ...) \
66 if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), __VA_ARGS__)
67 #define EVENTOUT(CL, ...) \
68 if (__builtin_expect(((CL)->nfun) > 0, 0)) eventout((CL), __VA_ARGS__)
69 #define PACKETFILTER(CL, PORT, BUF, LEN) \
70 (__builtin_expect((((CL)->nfun) == 0 || ((LEN)=packetfilter((CL), (PORT), (BUF), (LEN)))), 1))
72 #define PACKETFILTER(CL, PORT, BUF, LEN) (LEN)
74 #else
75 #define DBGOUT(CL, ...)
76 #define EVENTOUT(CL, ...)
77 #define PACKETFILTER(CL, PORT, BUF, LEN) (LEN)
78 #endif /* DEBUGOPT */
80 #endif
82 #ifdef VDEPLUGIN
83 struct plugin {
84 char *name;
85 char *help;
86 void *handle;
87 struct plugin *next;
89 #endif