Merge rd-235 experimental version into trunk.
[vde.git] / vde-2 / src / vde_switch / switch.h
blob64ea786c749ff4028609a495dfd4cd2f245c993b
1 /* Copyright 2005 Renzo davoli VDE-2
2 * Some code from vde_switch Copyright 2002 Jeff Dike
3 * Licensed under the GPLv2
4 */
6 #ifndef __SWITCH_H__
7 #define __SWITCH_H__
9 typedef unsigned char uchar;
10 /* FAST SPANNING TREE PROTOCOL (experimental)*/
11 #define FSTP
12 /* POLL Main LOOP Optimization */
13 #define OPTPOLL
15 #ifdef _MALLOC_DEBUG
16 #define free(X) ({ printf("MDBG-FREE %p %s %d\n",(X),__FILE__,__LINE__); \
17 free(X); })
18 #define malloc(X) ({ void *x; x=malloc(X); \
19 printf("MDBG-MALLOC %p %s %d\n",x,__FILE__,__LINE__); \
20 x; })
21 #define strdup(X) ({ void *x; x=strdup(X); \
22 printf("MDBG-STRDUP %p %s %d\n",x,__FILE__,__LINE__); \
23 x; })
24 #define realloc(Y,X) ({ void *x,*old; \
25 old=(Y);\
26 x=realloc(old,(X)); \
27 printf("MDBG-REALLOC %p->%p %s %d\n",old,x,__FILE__,__LINE__); \
28 x; })
29 #endif
31 struct swmodule {
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"
59 #define ETH_ALEN 6
61 #define INIT_HASH_SIZE 128
62 #define DEFAULT_PRIORITY 0x8000
63 #define INIT_NUMPORTS 32
64 #define DEFAULT_COST 20000000 /* 1Mbit line */
66 extern char *prog;
67 extern unsigned char switchmac[];
68 extern unsigned int priority;
70 #define NUMOFVLAN 4095
71 #define NOVLAN 0xfff
73 #endif