1 /* $Id: isdnif.h,v 1.2 1996/04/20 17:02:40 fritz Exp $ 2 * 3 * Linux ISDN subsystem 4 * 5 * Definition of the interface between the subsystem and it's lowlevel-drivers. 6 * 7 * Copyright 1994,95,96 by Fritz Elfert (fritz@wuemaus.franken.de) 8 * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2, or (at your option) 13 * any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * 24 * $Log: isdnif.h,v $ 25 * Revision 1.2 1996/04/20 17:02:40 fritz 26 * Changes to support skbuffs for Lowlevel-Drivers. 27 * Misc. typos 28 * 29 * Revision 1.1 1996/01/09 05:50:51 fritz 30 * Initial revision 31 * 32 */ 33 34 #ifndef isdnif_h 35 #define isdnif_h 36 37 #ifdef STANDALONE 38 #include <linux/k_compat.h> 39 #endif 40 41 /* 42 * Values for general protocol-selection 43 */ 44 #define ISDN_PTYPE_UNKNOWN 0 /* Protocol undefined */ 45 #define ISDN_PTYPE_1TR6 1 /* german 1TR6-protocol */ 46 #define ISDN_PTYPE_EURO 2 /* EDSS1-protocol */ 47 48 /* 49 * Values for Layer-2-protocol-selection 50 */ 51 #define ISDN_PROTO_L2_X75I 0 /* X75/LAPB with I-Frames */ 52 #define ISDN_PROTO_L2_X75UI 1 /* X75/LAPB with UI-Frames */ 53 #define ISDN_PROTO_L2_X75BUI 2 /* X75/LAPB with UI-Frames */ 54 #define ISDN_PROTO_L2_HDLC 3 /* HDLC */ 55 56 /* 57 * Values for Layer-3-protocol-selection 58 */ 59 #define ISDN_PROTO_L3_TRANS 0 /* Transparent */ 60 61 #ifdef __KERNEL__ 62 63 #include <linux/skbuff.h> 64 65 /* 66 * Commands from linklevel to lowlevel 67 * 68 */ 69 #define ISDN_CMD_IOCTL 0 /* Perform ioctl */ 70 #define ISDN_CMD_DIAL 1 /* Dial out */ 71 #define ISDN_CMD_ACCEPTD 2 /* Accept an incoming call on D-Chan. */ 72 #define ISDN_CMD_ACCEPTB 3 /* Request B-Channel connect. */ 73 #define ISDN_CMD_HANGUP 4 /* Hangup */ 74 #define ISDN_CMD_CLREAZ 5 /* Clear EAZ(s) of channel */ 75 #define ISDN_CMD_SETEAZ 6 /* Set EAZ(s) of channel */ 76 #define ISDN_CMD_GETEAZ 7 /* Get EAZ(s) of channel */ 77 #define ISDN_CMD_SETSIL 8 /* Set Service-Indicator-List of channel */ 78 #define ISDN_CMD_GETSIL 9 /* Get Service-Indicator-List of channel */ 79 #define ISDN_CMD_SETL2 10 /* Set B-Chan. Layer2-Parameter */ 80 #define ISDN_CMD_GETL2 11 /* Get B-Chan. Layer2-Parameter */ 81 #define ISDN_CMD_SETL3 12 /* Set B-Chan. Layer3-Parameter */ 82 #define ISDN_CMD_GETL3 13 /* Get B-Chan. Layer3-Parameter */ 83 #define ISDN_CMD_LOCK 14 /* Signal usage by upper levels */ 84 #define ISDN_CMD_UNLOCK 15 /* Release usage-lock */ 85 86 /* 87 * Status-Values delivered from lowlevel to linklevel via 88 * statcallb(). 89 * 90 */ 91 #define ISDN_STAT_STAVAIL 256 /* Raw status-data available */ 92 #define ISDN_STAT_ICALL 257 /* Incoming call detected */ 93 #define ISDN_STAT_RUN 258 /* Signal protocol-code is running */ 94 #define ISDN_STAT_STOP 259 /* Signal halt of protocol-code */ 95 #define ISDN_STAT_DCONN 260 /* Signal D-Channel connect */ 96 #define ISDN_STAT_BCONN 261 /* Signal B-Channel connect */ 97 #define ISDN_STAT_DHUP 262 /* Signal D-Channel disconnect */ 98 #define ISDN_STAT_BHUP 263 /* Signal B-Channel disconnect */ 99 #define ISDN_STAT_CINF 264 /* Charge-Info */ 100 #define ISDN_STAT_LOAD 265 /* Signal new lowlevel-driver is loaded */ 101 #define ISDN_STAT_UNLOAD 266 /* Signal unload of lowlevel-driver */ 102 #define ISDN_STAT_BSENT 267 /* Signal packet sent */ 103 #define ISDN_STAT_NODCH 268 /* Signal no D-Channel */ 104 #define ISDN_STAT_ADDCH 269 /* Add more Channels */ 105 #define ISDN_STAT_CAUSE 270 /* Cause-Message */ 106 107 /* 108 * Values for feature-field of interface-struct. 109 */ 110 /* Layer 2 */ 111 #define ISDN_FEATURE_L2_X75I (0x0001 << ISDN_PROTO_L2_X75I) 112 #define ISDN_FEATURE_L2_X75UI (0x0001 << ISDN_PROTO_L2_X75UI) 113 #define ISDN_FEATURE_L2_X75BUI (0x0001 << ISDN_PROTO_L2_X75BUI) 114 #define ISDN_FEATURE_L2_HDLC (0x0001 << ISDN_PROTO_L2_HDLC) 115 116 /* Layer 3 */ 117 #define ISDN_FEATURE_L3_TRANS (0x0100 << ISDN_PROTO_L3_TRANS) 118 119 /* Signaling */ 120 #define ISDN_FEATURE_P_UNKNOWN (0x1000 << ISDN_PTYPE_UNKNOWN) 121 #define ISDN_FEATURE_P_1TR6 (0x1000 << ISDN_PTYPE_1TR6) 122 #define ISDN_FEATURE_P_EURO (0x1000 << ISDN_PTYPE_EURO) 123 124 /* 125 * Structure for exchanging above infos 126 * 127 */ 128 typedef struct { 129 int driver; /* Lowlevel-Driver-ID */ 130 int command; /* Command or Status (see above) */ 131 ulong arg; /* Additional Data */ 132 char num[50]; /* Additional Data */ 133 } isdn_ctrl; 134 135 /* 136 * The interface-struct itself (initialized at load-time of lowlevel-driver) 137 * 138 * See Documentation/isdn/INTERFACE for a description, how the communication 139 * between the ISDN subsystem and it's drivers is done. 140 * 141 */ 142 typedef struct { 143 /* Number of channels supported by this driver 144 */ 145 int channels; 146 147 /* 148 * Maximum Size of transmit/receive-buffer this driver supports. 149 */ 150 int maxbufsize; 151 152 /* Feature-Flags for this driver. 153 * See defines ISDN_FEATURE_... for Values 154 */ 155 unsigned long features; 156 157 /* 158 * Needed for calculating 159 * dev->hard_header_len = linklayer header + hl_hdrlen; 160 * Drivers, not supporting sk_buff's should set this to 0. 161 */ 162 unsigned short hl_hdrlen; 163 164 /* Receive-Callback 165 * Parameters: 166 * int Driver-ID 167 * int local channel-number (0 ...) 168 * u_char pointer to received data (in Kernel-Space, volatile) 169 * int length of data 170 */ 171 void (*rcvcallb)(int, int, u_char*, int); 172 173 /* 174 * Receive-Callback using sk_buff's 175 * Parameters: 176 * int Driver-ID 177 * int local channel-number (0 ...) 178 * struct sk_buff *skb received Data 179 */ 180 void (*rcvcallb_skb)(int, int, struct sk_buff *); 181 182 /* Status-Callback 183 * Parameters: 184 * isdn_ctrl* 185 * driver = Driver ID. 186 * command = One of above ISDN_STAT_... constants. 187 * arg = depending on status-type. 188 * num = depending on status-type. 189 */ 190 int (*statcallb)(isdn_ctrl*); 191 /* Send command 192 * Parameters: 193 * isdn_ctrl* 194 * driver = Driver ID. 195 * command = One of above ISDN_CMD_... constants. 196 * arg = depending on command. 197 * num = depending on command. 198 */ 199 int (*command)(isdn_ctrl*); 200 /* Send Data 201 * Parameters: 202 * int driverId 203 * int local channel-number (0 ...) 204 * u_char pointer to data 205 * int length of data 206 * int Flag: 0 = Call form Kernel-Space (use memcpy, 207 * no schedule allowed) 208 * 1 = Data is in User-Space (use memcpy_fromfs, 209 * may schedule) 210 */ 211 int (*writebuf)(int, int, const u_char*, int, int); 212 213 /* 214 * Send data using sk_buff's 215 * Parameters: 216 * int driverId 217 * int local channel-number (0...) 218 * struct sk_buff *skb Data to send 219 */ 220 int (*writebuf_skb) (int, int, struct sk_buff *); 221 222 /* Send raw D-Channel-Commands 223 * Parameters: 224 * u_char pointer data 225 * int length of data 226 * int Flag: 0 = Call form Kernel-Space (use memcpy, 227 * no schedule allowed) 228 * 1 = Data is in User-Space (use memcpy_fromfs, 229 * may schedule) 230 */ 231 int (*writecmd)(const u_char*, int, int); 232 /* Read raw Status replies 233 * u_char pointer data (volatile) 234 * int length of buffer 235 * int Flag: 0 = Call form Kernel-Space (use memcpy, 236 * no schedule allowed) 237 * 1 = Data is in User-Space (use memcpy_fromfs, 238 * may schedule) 239 */ 240 int (*readstat)(u_char*, int, int); 241 char id[20]; 242 } isdn_if; 243 244 /* 245 * Function which must be called by lowlevel-driver at loadtime with 246 * the following fields of above struct set: 247 * 248 * channels Number of channels that will be supported. 249 * hl_hdrlen Space to preserve in sk_buff's when sending. Drivers, not 250 * supporting sk_buff's should set this to 0. 251 * command Address of Command-Handler. 252 * features Bitwise coded Features of this driver. (use ISDN_FEATURE_...) 253 * writebuf Address of Send-Command-Handler. 254 * writebuf_skb Address of Skbuff-Send-Handler. (NULL if not supported) 255 * writecmd " " D-Channel " which accepts raw D-Ch-Commands. 256 * readstat " " D-Channel " which delivers raw Status-Data. 257 * 258 * The linklevel-driver fills the following fields: 259 * 260 * channels Driver-ID assigned to this driver. (Must be used on all 261 * subsequent callbacks. 262 * rcvcallb Address of handler for received data. 263 * rcvcallb_skb Address of handler for received Skbuff's. (NULL if not supp.) 264 * statcallb " " " for status-changes. 265 * 266 */ 267 extern int register_isdn(isdn_if*); 268 269 #endif /* __KERNEL__ */ 270 #endif /* isdnif_h */ 271