1 /* Copyright 2005 Renzo Davoli
2 * Copyright 2002 Jeff Dike
3 * Licensed under the GPLv2
9 #include <sys/socket.h>
13 #define ETH_HEADER_SIZE 14
14 /* a full ethernet 802.3 frame */
16 unsigned char dest
[ETH_ALEN
];
17 unsigned char src
[ETH_ALEN
];
18 unsigned char proto
[2];
22 struct ethheader header
;
23 unsigned char data
[1504]; /*including trailer, IF ANY */
31 #define pgetprio(X) ((X)[0] >> 5)
32 #define pgetcfi(X) (((X)[0] >> 4) & 1)
33 #define pgetvlan(X) (((X)[0] & 0xf) << 8 + (X)[1])
34 #define psetprio(X,V) ((X)[0]= ((X)[0] & 0x1f) | (V)<<5)
35 #define psetcfi(X,V) ((X)[0]= ((X)[0] & 0xef) | (V&1)<<4)
36 #define psetvlan(X,V) ({(X)[1]=(V)&0xff;(X)[0]=((X)[0] & 0xf0) | ((V)>>8) & 0xf; (V); })
40 int (*sender
)(int fd
, int fd_ctl
, void *packet
, int len
, void *data
, int port
);
41 int (*newport
)(int fd_ctl
,int portno
);
42 void (*delep
)(int fd
, void* data
, void *descr
);
43 void (*delport
)(int fd
,int portno
);
46 extern int setup_ep(int portno
, int fd_ctl
,
48 struct mod_support
*modfun
);
50 extern void setup_description(int portno
, int fd_ctl
, char *descr
);
52 extern int close_ep(int portno
, int fd_ctl
);
54 extern void handle_in_packet(int port
, struct packet
*packet
, int len
);
56 extern bitarray validvlan
;
57 int portflag(int op
, int f
);
64 void port_init(int numports
);
69 /* forwarding implies learning */
73 void port_send_packet(int portno
, void *packet
, int len
);
74 void portset_send_packet(bitarray portset
, void *packet
, int len
);
75 void port_set_status(int portno
, int vlan
, int status
);
76 int port_get_status(int portno
, int vlan
);
77 int port_getcost(int port
);