tagging vde-2 version 2.3.2
[vde.git] / 2.3.2 / src / vde_switch / port.h
blob46c81dffff865b5dd7962998ab8e1f4979aa549e
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 endpoint;
40 struct mod_support {
41 char *modname;
42 int (*sender)(int fd_ctl, int fd_data, void *packet, int len, int port);
43 void (*delep)(int fd_ctl, int fd_data, void *descr);
46 extern struct endpoint *setup_ep(int portno, int fd_ctl,
47 int fd_data,
48 uid_t user,
49 struct mod_support *modfun);
51 extern int ep_get_port(struct endpoint *ep);
53 extern void setup_description(struct endpoint *ep, char *descr);
55 extern int close_ep(struct endpoint *ep);
57 #ifdef VDE_PQ2
58 extern void handle_out_packet(struct endpoint *ep);
59 #endif
61 extern void handle_in_packet(struct endpoint *ep, struct packet *packet, int len);
63 extern bitarray validvlan;
64 int portflag(int op, int f);
65 #define P_GETFLAG 0
66 #define P_SETFLAG 1
67 #define P_ADDFLAG 2
68 #define P_CLRFLAG 3
70 #define HUB_TAG 0x1
72 void port_init(int numports);
75 #define DISCARDING 0
76 #define LEARNING 1
77 /* forwarding implies learning */
78 #define FORWARDING 3
80 #ifdef FSTP
81 void port_send_packet(int portno, void *packet, int len);
82 void portset_send_packet(bitarray portset, void *packet, int len);
83 void port_set_status(int portno, int vlan, int status);
84 int port_get_status(int portno, int vlan);
85 int port_getcost(int port);
86 #endif
88 #endif