Import 2.3.18pre1
[davej-history.git] / include / linux / atm.h
blob67a8f346532ba2c1522ea22f5e04100b5355c512
1 /* atm.h - general ATM declarations */
3 /* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
6 /*
7 * WARNING: User-space programs should not #include <linux/atm.h> directly.
8 * Instead, #include <atm.h>
9 */
11 #ifndef _LINUX_ATM_H
12 #define _LINUX_ATM_H
15 * BEGIN_xx and END_xx markers are used for automatic generation of
16 * documentation. Do not change them.
19 #ifdef __KERNEL__
20 #include <linux/socket.h>
21 #include <linux/types.h>
22 #endif
23 #include <linux/atmsap.h>
24 #include <linux/atmioc.h>
27 /* general ATM constants */
28 #define ATM_CELL_SIZE 53 /* ATM cell size incl. header */
29 #define ATM_CELL_PAYLOAD 48 /* ATM payload size */
30 #define ATM_AAL0_SDU 52 /* AAL0 SDU size */
31 #define ATM_MAX_AAL34_PDU 65535 /* maximum AAL3/4 PDU payload */
32 #define ATM_AAL5_TRAILER 8 /* AAL5 trailer size */
33 #define ATM_MAX_AAL5_PDU 65535 /* maximum AAL5 PDU payload */
34 #define ATM_MAX_CDV 9999 /* maximum (default) CDV */
35 #define ATM_NOT_RSV_VCI 32 /* first non-reserved VCI value */
37 #define ATM_MAX_VPI 255 /* maximum VPI at the UNI */
38 #define ATM_MAX_VPI_NNI 4096 /* maximum VPI at the NNI */
39 #define ATM_MAX_VCI 65535 /* maximum VCI */
42 /* "protcol" values for the socket system call */
43 #define ATM_NO_AAL 0 /* AAL not specified */
44 #define ATM_AAL0 13 /* "raw" ATM cells */
45 #define ATM_AAL1 1 /* AAL1 (CBR) */
46 #define ATM_AAL2 2 /* AAL2 (VBR) */
47 #define ATM_AAL34 3 /* AAL3/4 (data) */
48 #define ATM_AAL5 5 /* AAL5 (data) */
51 * socket option name coding functions
53 * Note that __SO_ENCODE and __SO_LEVEL are somewhat a hack since the
54 * << 22 only reserves 9 bits for the level. On some architectures
55 * SOL_SOCKET is 0xFFFF, so that's a bit of a problem
58 #define __SO_ENCODE(l,n,t) ((((l) & 0x1FF) << 22) | ((n) << 16) | \
59 sizeof(t))
60 #define __SO_LEVEL_MATCH(c,m) (((c) >> 22) == ((m) & 0x1FF))
61 #define __SO_NUMBER(c) (((c) >> 16) & 0x3f)
62 #define __SO_SIZE(c) ((c) & 0x3fff)
65 * ATM layer
68 #define SO_SETCLP __SO_ENCODE(SOL_ATM,0,int)
69 /* set CLP bit value - TODO */
70 #define SO_CIRANGE __SO_ENCODE(SOL_ATM,1,struct atm_cirange)
71 /* connection identifier range; socket must be
72 bound or connected */
73 #define SO_ATMQOS __SO_ENCODE(SOL_ATM,2,struct atm_qos)
74 /* Quality of Service setting */
75 #define SO_ATMSAP __SO_ENCODE(SOL_ATM,3,struct atm_sap)
76 /* Service Access Point */
77 #define SO_ATMPVC __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
78 /* "PVC" address (also for SVCs); get only */
81 * Note @@@: since the socket layers don't really distinguish the control and
82 * the data plane but generally seems to be data plane-centric, any layer is
83 * about equally wrong for the SAP. If you have a better idea about this,
84 * please speak up ...
87 /* socket layer */
88 #define SO_BCTXOPT __SO_ENCODE(SOL_SOCKET,16,struct atm_buffconst)
89 /* not ATM specific - should go somewhere else */
90 #define SO_BCRXOPT __SO_ENCODE(SOL_SOCKET,17,struct atm_buffconst)
93 /* for SO_BCTXOPT and SO_BCRXOPT */
95 struct atm_buffconst {
96 unsigned long buf_fac; /* buffer alignment factor */
97 unsigned long buf_off; /* buffer alignment offset */
98 unsigned long size_fac; /* buffer size factor */
99 unsigned long size_off; /* buffer size offset */
100 unsigned long min_size; /* minimum size */
101 unsigned long max_size; /* maximum size, 0 = unlimited */
105 /* ATM cell header (for AAL0) */
107 /* BEGIN_CH */
108 #define ATM_HDR_GFC_MASK 0xf0000000
109 #define ATM_HDR_GFC_SHIFT 28
110 #define ATM_HDR_VPI_MASK 0x0ff00000
111 #define ATM_HDR_VPI_SHIFT 20
112 #define ATM_HDR_VCI_MASK 0x000ffff0
113 #define ATM_HDR_VCI_SHIFT 4
114 #define ATM_HDR_PTI_MASK 0x0000000e
115 #define ATM_HDR_PTI_SHIFT 1
116 #define ATM_HDR_CLP 0x00000001
117 /* END_CH */
120 /* PTI codings */
122 /* BEGIN_PTI */
123 #define ATM_PTI_US0 0 /* user data cell, congestion not exp, SDU-type 0 */
124 #define ATM_PTI_US1 1 /* user data cell, congestion not exp, SDU-type 1 */
125 #define ATM_PTI_UCES0 2 /* user data cell, cong. experienced, SDU-type 0 */
126 #define ATM_PTI_UCES1 3 /* user data cell, cong. experienced, SDU-type 1 */
127 #define ATM_PTI_SEGF5 4 /* segment OAM F5 flow related cell */
128 #define ATM_PTI_E2EF5 5 /* end-to-end OAM F5 flow related cell */
129 #define ATM_PTI_RSV_RM 6 /* reserved for traffic control/resource mgmt */
130 #define ATM_PTI_RSV 7 /* reserved */
131 /* END_PTI */
135 * The following items should stay in linux/atm.h, which should be linked to
136 * netatm/atm.h
139 /* Traffic description */
141 #define ATM_NONE 0 /* no traffic */
142 #define ATM_UBR 1
143 #define ATM_CBR 2
144 #define ATM_VBR 3
145 #define ATM_ABR 4
146 #define ATM_ANYCLASS 5 /* compatible with everything */
148 #define ATM_MAX_PCR -1 /* maximum available PCR */
150 struct atm_trafprm {
151 unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */
152 int max_pcr; /* maximum PCR in cells per second */
153 int pcr; /* desired PCR in cells per second */
154 int min_pcr; /* minimum PCR in cells per second */
155 int max_cdv; /* maximum CDV in microseconds */
156 int max_sdu; /* maximum SDU in bytes */
159 struct atm_qos {
160 struct atm_trafprm txtp; /* parameters in TX direction */
161 struct atm_trafprm rxtp; /* parameters in RX direction */
162 unsigned char aal;
165 /* PVC addressing */
167 #define ATM_ITF_ANY -1 /* "magic" PVC address values */
168 #define ATM_VPI_ANY -1
169 #define ATM_VCI_ANY -1
170 #define ATM_VPI_UNSPEC -2
171 #define ATM_VCI_UNSPEC -2
174 struct sockaddr_atmpvc {
175 unsigned short sap_family; /* address family, AF_ATMPVC */
176 struct { /* PVC address */
177 short itf; /* ATM interface */
178 short vpi; /* VPI (only 8 bits at UNI) */
179 int vci; /* VCI (only 16 bits at UNI) */
180 } sap_addr; /* PVC address */
183 /* SVC addressing */
185 #define ATM_ESA_LEN 20 /* ATM End System Address length */
186 #define ATM_E164_LEN 12 /* maximum E.164 number length */
188 #define ATM_AFI_DCC 0x39 /* DCC ATM Format */
189 #define ATM_AFI_ICD 0x47 /* ICD ATM Format */
190 #define ATM_AFI_E164 0x45 /* E.164 ATM Format */
191 #define ATM_AFI_LOCAL 0x49 /* Local ATM Format */
193 #define ATM_AFI_DCC_GROUP 0xBD /* DCC ATM Group Format */
194 #define ATM_AFI_ICD_GROUP 0xC5 /* ICD ATM Group Format */
195 #define ATM_AFI_E164_GROUP 0xC3 /* E.164 ATM Group Format */
196 #define ATM_AFI_LOCAL_GROUP 0xC7 /* Local ATM Group Format */
198 #define ATM_LIJ_NONE 0 /* no leaf-initiated join */
199 #define ATM_LIJ 1 /* request joining */
200 #define ATM_LIJ_RPJ 2 /* set to root-prompted join */
201 #define ATM_LIJ_NJ 3 /* set to network join */
204 struct sockaddr_atmsvc {
205 unsigned short sas_family; /* address family, AF_ATMSVC */
206 struct { /* SVC address */
207 unsigned char prv[ATM_ESA_LEN];/* private ATM address */
208 char pub[ATM_E164_LEN+1]; /* public address (E.164) */
209 /* unused addresses must be bzero'ed */
210 char lij_type; /* role in LIJ call; one of ATM_LIJ* */
211 uint32_t lij_id; /* LIJ call identifier */
212 } sas_addr; /* SVC address */
216 static __inline__ int atmsvc_addr_in_use(struct sockaddr_atmsvc addr)
218 return *addr.sas_addr.prv || *addr.sas_addr.pub;
222 static __inline__ int atmpvc_addr_in_use(struct sockaddr_atmpvc addr)
224 return addr.sap_addr.itf || addr.sap_addr.vpi || addr.sap_addr.vci;
229 * Some stuff for linux/sockios.h
232 struct atmif_sioc {
233 int number;
234 int length;
235 void *arg;
239 #define ATM_CREATE_LEAF _IO('a',ATMIOC_SPECIAL+2)
240 /* create a point-to-multipoint leaf socket */
243 #ifdef __KERNEL__
245 #include <linux/net.h> /* struct net_proto */
248 void atmpvc_proto_init(struct net_proto *pro);
249 void atmsvc_proto_init(struct net_proto *pro);
251 #endif /* __KERNEL__ */
253 #endif