1 /* Copyright 2005 Renzo davoli VDE-2
2 * Some code from vde_switch Copyright 2002 Jeff Dike
3 * Licensed under the GPLv2
9 typedef unsigned char uchar
;
10 /* FAST SPANNING TREE PROTOCOL (experimental)*/
12 /* POLL Main LOOP Optimization */
16 #define free(X) ({ printf("MDBG-FREE %p %s %d\n",(X),__FILE__,__LINE__); \
18 #define malloc(X) ({ void *x; x=malloc(X); \
19 printf("MDBG-MALLOC %p %s %d\n",x,__FILE__,__LINE__); \
21 #define strdup(X) ({ void *x; x=strdup(X); \
22 printf("MDBG-STRDUP %p %s %d\n",x,__FILE__,__LINE__); \
24 #define realloc(Y,X) ({ void *x,*old; \
27 printf("MDBG-REALLOC %p->%p %s %d\n",old,x,__FILE__,__LINE__); \
32 char *swmname
; /* module name */
33 char swmtag
; /* module tag - computer by the load sequence */
34 char swmnopts
; /* number of options for getopt */
35 struct option
*swmopts
; /* options for getopt */
36 void (*usage
)(void); /* usage function: command line opts explanation */
37 int (*parseopt
)(int parm
,char *optarg
); /* parse getopt output */
38 void (*init
)(void); /* init */
39 void (*handle_io
)(unsigned char type
,int fd
,int revents
,void *private_data
); /* handle input */
40 void (*cleanup
)(unsigned char type
,int fd
,void *private_data
); /*cleanup for files or final if fd == -1 */
41 struct swmodule
*next
;
44 void add_swm(struct swmodule
*new);
45 void del_swm(struct swmodule
*old
);
46 unsigned char add_type(struct swmodule
*mgr
,int prio
);
47 void del_type(unsigned char type
);
48 void add_fd(int fd
,unsigned char type
,void *private_data
);
49 void remove_fd(int fd
);
50 void *mainloop_get_private_data(int fd
);
51 void mainloop_set_private_data(int fd
,void *private_data
);
52 short mainloop_pollmask_get(int fd
);
53 void mainloop_pollmask_add(int fd
, short events
);
54 void mainloop_pollmask_del(int fd
, short events
);
55 void mainloop_pollmask_set(int fd
, short events
);
57 #define STDRCFILE "/etc/vde2/vde_switch.rc"
61 #define INIT_HASH_SIZE 128
62 #define DEFAULT_PRIORITY 0x8000
63 #define INIT_NUMPORTS 32
64 #define DEFAULT_COST 20000000 /* 1Mbit line */
67 extern unsigned char switchmac
[];
68 extern unsigned int priority
;
70 #define NUMOFVLAN 4095