A forgotten debug printf has been commented out.
[vde.git] / vde-2 / port.h
blob9a3a3958621c6b43de7a96cb7ff8774fec819240
1 /* Copyright 2005 Renzo Davoli
2 * Copyright 2002 Jeff Dike
3 * Licensed under the GPLv2
4 */
6 #ifndef __PORT_H__
7 #define __PORT_H__
9 #include <sys/socket.h>
10 #include <switch.h>
11 #include <bitarray.h>
13 #define ETH_HEADER_SIZE 14
14 /* a full ethernet 802.3 frame */
15 struct ethheader {
16 unsigned char dest[ETH_ALEN];
17 unsigned char src[ETH_ALEN];
18 unsigned char proto[2];
21 struct packet {
22 struct ethheader header;
23 unsigned char data[1504]; /*including trailer, IF ANY */
26 struct bipacket {
27 char filler[4];
28 struct packet p;
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); })
38 struct mod_support {
39 char *modname;
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,
47 void *data,
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);
58 #define P_SETFLAG 1
59 #define P_ADDFLAG 2
60 #define P_CLRFLAG 3
62 #define HUB_TAG 0x1
64 void port_init(int numports);
67 #define DISCARDING 0
68 #define LEARNING 1
69 /* forwarding implies learning */
70 #define FORWARDING 3
72 #ifdef FSTP
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);
78 #endif
80 #endif