aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/pcbit/capi.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-19 22:52:38 -0500
committerJoe Perches <joe@perches.com>2012-02-21 12:04:01 -0500
commit475be4d85a274d0961593db41cf85689db1d583c (patch)
treeb2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/pcbit/capi.c
parent0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff)
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/pcbit/capi.c')
-rw-r--r--drivers/isdn/pcbit/capi.c585
1 files changed, 290 insertions, 295 deletions
diff --git a/drivers/isdn/pcbit/capi.c b/drivers/isdn/pcbit/capi.c
index ac5a91ccde81..4e3cbf857d60 100644
--- a/drivers/isdn/pcbit/capi.c
+++ b/drivers/isdn/pcbit/capi.c
@@ -3,10 +3,10 @@
3 * Portugal Telecom CAPI 2.0 3 * Portugal Telecom CAPI 2.0
4 * 4 *
5 * Copyright (C) 1996 Universidade de Lisboa 5 * Copyright (C) 1996 Universidade de Lisboa
6 * 6 *
7 * Written by Pedro Roque Marques (roque@di.fc.ul.pt) 7 * Written by Pedro Roque Marques (roque@di.fc.ul.pt)
8 * 8 *
9 * This software may be used and distributed according to the terms of 9 * This software may be used and distributed according to the terms of
10 * the GNU General Public License, incorporated herein by reference. 10 * the GNU General Public License, incorporated herein by reference.
11 * 11 *
12 * Not compatible with the AVM Gmbh. CAPI 2.0 12 * Not compatible with the AVM Gmbh. CAPI 2.0
@@ -51,39 +51,39 @@
51 * 51 *
52 */ 52 */
53 53
54int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto) 54int capi_conn_req(const char *calledPN, struct sk_buff **skb, int proto)
55{ 55{
56 ushort len; 56 ushort len;
57 57
58 /* 58 /*
59 * length 59 * length
60 * AppInfoMask - 2 60 * AppInfoMask - 2
61 * BC0 - 3 61 * BC0 - 3
62 * BC1 - 1 62 * BC1 - 1
63 * Chan - 2 63 * Chan - 2
64 * Keypad - 1 64 * Keypad - 1
65 * CPN - 1 65 * CPN - 1
66 * CPSA - 1 66 * CPSA - 1
67 * CalledPN - 2 + strlen 67 * CalledPN - 2 + strlen
68 * CalledPSA - 1 68 * CalledPSA - 1
69 * rest... - 4 69 * rest... - 4
70 * ---------------- 70 * ----------------
71 * Total 18 + strlen 71 * Total 18 + strlen
72 */ 72 */
73 73
74 len = 18 + strlen(calledPN); 74 len = 18 + strlen(calledPN);
75 75
76 if (proto == ISDN_PROTO_L2_TRANS) 76 if (proto == ISDN_PROTO_L2_TRANS)
77 len++; 77 len++;
78 78
79 if ((*skb = dev_alloc_skb(len)) == NULL) { 79 if ((*skb = dev_alloc_skb(len)) == NULL) {
80 80
81 printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n"); 81 printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n");
82 return -1; 82 return -1;
83 } 83 }
84 84
85 /* InfoElmMask */ 85 /* InfoElmMask */
86 *((ushort*) skb_put(*skb, 2)) = AppInfoMask; 86 *((ushort *)skb_put(*skb, 2)) = AppInfoMask;
87 87
88 if (proto == ISDN_PROTO_L2_TRANS) 88 if (proto == ISDN_PROTO_L2_TRANS)
89 { 89 {
@@ -101,162 +101,162 @@ int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto)
101 *(skb_put(*skb, 1)) = 0x90; /* BC0.Octect4 */ 101 *(skb_put(*skb, 1)) = 0x90; /* BC0.Octect4 */
102 } 102 }
103 103
104 /* Bearer Capability - Optional*/ 104 /* Bearer Capability - Optional*/
105 *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */ 105 *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */
106 106
107 *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */ 107 *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */
108 *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */ 108 *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */
109 109
110 *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */ 110 *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */
111
112 111
113 *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */
114 *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */
115 112
116 /* Called Party Number */ 113 *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */
117 *(skb_put(*skb, 1)) = strlen(calledPN) + 1; 114 *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */
118 *(skb_put(*skb, 1)) = 0x81;
119 memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN));
120 115
121 /* '#' */ 116 /* Called Party Number */
117 *(skb_put(*skb, 1)) = strlen(calledPN) + 1;
118 *(skb_put(*skb, 1)) = 0x81;
119 memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN));
122 120
123 *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */ 121 /* '#' */
124 122
125 /* LLC.Length = 0; */ 123 *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */
126 /* HLC0.Length = 0; */
127 /* HLC1.Length = 0; */
128 /* UTUS.Length = 0; */
129 memset(skb_put(*skb, 4), 0, 4);
130 124
131 return len; 125 /* LLC.Length = 0; */
126 /* HLC0.Length = 0; */
127 /* HLC1.Length = 0; */
128 /* UTUS.Length = 0; */
129 memset(skb_put(*skb, 4), 0, 4);
130
131 return len;
132} 132}
133 133
134int capi_conn_resp(struct pcbit_chan* chan, struct sk_buff **skb) 134int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb)
135{ 135{
136 136
137 if ((*skb = dev_alloc_skb(5)) == NULL) { 137 if ((*skb = dev_alloc_skb(5)) == NULL) {
138 138
139 printk(KERN_WARNING "capi_conn_resp: alloc_skb failed\n"); 139 printk(KERN_WARNING "capi_conn_resp: alloc_skb failed\n");
140 return -1; 140 return -1;
141 } 141 }
142 142
143 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 143 *((ushort *)skb_put(*skb, 2)) = chan->callref;
144 *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */ 144 *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */
145 *(skb_put(*skb, 1)) = 0; 145 *(skb_put(*skb, 1)) = 0;
146 *(skb_put(*skb, 1)) = 0; 146 *(skb_put(*skb, 1)) = 0;
147 147
148 return 5; 148 return 5;
149} 149}
150 150
151int capi_conn_active_req(struct pcbit_chan* chan, struct sk_buff **skb) 151int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb)
152{ 152{
153 /* 153 /*
154 * 8 bytes 154 * 8 bytes
155 */ 155 */
156 156
157 if ((*skb = dev_alloc_skb(8)) == NULL) { 157 if ((*skb = dev_alloc_skb(8)) == NULL) {
158 158
159 printk(KERN_WARNING "capi_conn_active_req: alloc_skb failed\n"); 159 printk(KERN_WARNING "capi_conn_active_req: alloc_skb failed\n");
160 return -1; 160 return -1;
161 } 161 }
162 162
163 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 163 *((ushort *)skb_put(*skb, 2)) = chan->callref;
164 164
165#ifdef DEBUG 165#ifdef DEBUG
166 printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); 166 printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref);
167#endif 167#endif
168 168
169 *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */ 169 *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */
170 *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */ 170 *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */
171 *(skb_put(*skb, 1)) = 0; /* PSA.Length */ 171 *(skb_put(*skb, 1)) = 0; /* PSA.Length */
172 *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */ 172 *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */
173 *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */ 173 *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */
174 *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ 174 *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */
175 175
176 return 8; 176 return 8;
177} 177}
178 178
179int capi_conn_active_resp(struct pcbit_chan* chan, struct sk_buff **skb) 179int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb)
180{ 180{
181 /* 181 /*
182 * 2 bytes 182 * 2 bytes
183 */ 183 */
184 184
185 if ((*skb = dev_alloc_skb(2)) == NULL) { 185 if ((*skb = dev_alloc_skb(2)) == NULL) {
186 186
187 printk(KERN_WARNING "capi_conn_active_resp: alloc_skb failed\n"); 187 printk(KERN_WARNING "capi_conn_active_resp: alloc_skb failed\n");
188 return -1; 188 return -1;
189 } 189 }
190 190
191 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 191 *((ushort *)skb_put(*skb, 2)) = chan->callref;
192 192
193 return 2; 193 return 2;
194} 194}
195 195
196 196
197int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, 197int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb,
198 int outgoing) 198 int outgoing)
199{ 199{
200 200
201 /* 201 /*
202 * 18 bytes 202 * 18 bytes
203 */ 203 */
204 204
205 if ((*skb = dev_alloc_skb(18)) == NULL) { 205 if ((*skb = dev_alloc_skb(18)) == NULL) {
206 206
207 printk(KERN_WARNING "capi_select_proto_req: alloc_skb failed\n"); 207 printk(KERN_WARNING "capi_select_proto_req: alloc_skb failed\n");
208 return -1; 208 return -1;
209 } 209 }
210 210
211 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 211 *((ushort *)skb_put(*skb, 2)) = chan->callref;
212 212
213 /* Layer2 protocol */ 213 /* Layer2 protocol */
214 214
215 switch (chan->proto) { 215 switch (chan->proto) {
216 case ISDN_PROTO_L2_X75I: 216 case ISDN_PROTO_L2_X75I:
217 *(skb_put(*skb, 1)) = 0x05; /* LAPB */ 217 *(skb_put(*skb, 1)) = 0x05; /* LAPB */
218 break; 218 break;
219 case ISDN_PROTO_L2_HDLC: 219 case ISDN_PROTO_L2_HDLC:
220 *(skb_put(*skb, 1)) = 0x02; 220 *(skb_put(*skb, 1)) = 0x02;
221 break; 221 break;
222 case ISDN_PROTO_L2_TRANS: 222 case ISDN_PROTO_L2_TRANS:
223 /* 223 /*
224 * Voice (a-law) 224 * Voice (a-law)
225 */ 225 */
226 *(skb_put(*skb, 1)) = 0x06; 226 *(skb_put(*skb, 1)) = 0x06;
227 break; 227 break;
228 default: 228 default:
229#ifdef DEBUG 229#ifdef DEBUG
230 printk(KERN_DEBUG "Transparent\n"); 230 printk(KERN_DEBUG "Transparent\n");
231#endif 231#endif
232 *(skb_put(*skb, 1)) = 0x03; 232 *(skb_put(*skb, 1)) = 0x03;
233 break; 233 break;
234 } 234 }
235 235
236 *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */ 236 *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */
237 *(skb_put(*skb, 1)) = 0x00; 237 *(skb_put(*skb, 1)) = 0x00;
238 238
239 *((ushort *) skb_put(*skb, 2)) = MRU; 239 *((ushort *) skb_put(*skb, 2)) = MRU;
240 240
241 241
242 *(skb_put(*skb, 1)) = 0x08; /* Modulo */ 242 *(skb_put(*skb, 1)) = 0x08; /* Modulo */
243 *(skb_put(*skb, 1)) = 0x07; /* Max Window */ 243 *(skb_put(*skb, 1)) = 0x07; /* Max Window */
244 244
245 *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */ 245 *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */
246 246
247 /* 247 /*
248 * 2 - layer3 MTU [10] 248 * 2 - layer3 MTU [10]
249 * - Modulo [12] 249 * - Modulo [12]
250 * - Window 250 * - Window
251 * - layer1 proto [14] 251 * - layer1 proto [14]
252 * - bitrate 252 * - bitrate
253 * - sub-channel [16] 253 * - sub-channel [16]
254 * - layer1dataformat [17] 254 * - layer1dataformat [17]
255 */ 255 */
256 256
257 memset(skb_put(*skb, 8), 0, 8); 257 memset(skb_put(*skb, 8), 0, 8);
258 258
259 return 18; 259 return 18;
260} 260}
261 261
262 262
@@ -264,45 +264,45 @@ int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb)
264{ 264{
265 265
266 if ((*skb = dev_alloc_skb(7)) == NULL) { 266 if ((*skb = dev_alloc_skb(7)) == NULL) {
267 267
268 printk(KERN_WARNING "capi_activate_transp_req: alloc_skb failed\n"); 268 printk(KERN_WARNING "capi_activate_transp_req: alloc_skb failed\n");
269 return -1; 269 return -1;
270 } 270 }
271 271
272 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 272 *((ushort *)skb_put(*skb, 2)) = chan->callref;
273 273
274
275 *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */
276 *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */
277 274
278 *((ushort *) skb_put(*skb, 2)) = MRU; 275 *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */
276 *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */
279 277
280 *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/ 278 *((ushort *) skb_put(*skb, 2)) = MRU;
281 279
282 return 7; 280 *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/
281
282 return 7;
283} 283}
284 284
285int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb) 285int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb)
286{ 286{
287 ushort data_len; 287 ushort data_len;
288
289 288
290 /* 289
291 * callref - 2 290 /*
291 * callref - 2
292 * layer2link - 1 292 * layer2link - 1
293 * wBlockLength - 2 293 * wBlockLength - 2
294 * data - 4 294 * data - 4
295 * sernum - 1 295 * sernum - 1
296 */ 296 */
297 297
298 data_len = skb->len; 298 data_len = skb->len;
299 299
300 if(skb_headroom(skb) < 10) 300 if (skb_headroom(skb) < 10)
301 { 301 {
302 printk(KERN_CRIT "No headspace (%u) on headroom %p for capi header\n", skb_headroom(skb), skb); 302 printk(KERN_CRIT "No headspace (%u) on headroom %p for capi header\n", skb_headroom(skb), skb);
303 } 303 }
304 else 304 else
305 { 305 {
306 skb_push(skb, 10); 306 skb_push(skb, 10);
307 } 307 }
308 308
@@ -318,58 +318,58 @@ int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb)
318 return 10; 318 return 10;
319} 319}
320 320
321int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff ** skb) 321int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb)
322 322
323{ 323{
324 if ((*skb = dev_alloc_skb(4)) == NULL) { 324 if ((*skb = dev_alloc_skb(4)) == NULL) {
325 325
326 printk(KERN_WARNING "capi_tdata_resp: alloc_skb failed\n"); 326 printk(KERN_WARNING "capi_tdata_resp: alloc_skb failed\n");
327 return -1; 327 return -1;
328 } 328 }
329 329
330 *((ushort*) skb_put(*skb, 2) ) = chan->callref; 330 *((ushort *)skb_put(*skb, 2)) = chan->callref;
331 331
332 *(skb_put(*skb, 1)) = chan->layer2link; 332 *(skb_put(*skb, 1)) = chan->layer2link;
333 *(skb_put(*skb, 1)) = chan->r_refnum; 333 *(skb_put(*skb, 1)) = chan->r_refnum;
334 334
335 return (*skb)->len; 335 return (*skb)->len;
336} 336}
337 337
338int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause) 338int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause)
339{ 339{
340 340
341 if ((*skb = dev_alloc_skb(6)) == NULL) { 341 if ((*skb = dev_alloc_skb(6)) == NULL) {
342 342
343 printk(KERN_WARNING "capi_disc_req: alloc_skb failed\n"); 343 printk(KERN_WARNING "capi_disc_req: alloc_skb failed\n");
344 return -1; 344 return -1;
345 } 345 }
346 346
347 *((ushort*) skb_put(*skb, 2) ) = callref; 347 *((ushort *)skb_put(*skb, 2)) = callref;
348 348
349 *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */ 349 *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */
350 *(skb_put(*skb, 1)) = 0x80; 350 *(skb_put(*skb, 1)) = 0x80;
351 *(skb_put(*skb, 1)) = 0x80 | cause; 351 *(skb_put(*skb, 1)) = 0x80 | cause;
352 352
353 /* 353 /*
354 * Change it: we should send 'Sic transit gloria Mundi' here ;-) 354 * Change it: we should send 'Sic transit gloria Mundi' here ;-)
355 */ 355 */
356 356
357 *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ 357 *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */
358 358
359 return 6; 359 return 6;
360} 360}
361 361
362int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb) 362int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb)
363{ 363{
364 if ((*skb = dev_alloc_skb(2)) == NULL) { 364 if ((*skb = dev_alloc_skb(2)) == NULL) {
365 365
366 printk(KERN_WARNING "capi_disc_resp: alloc_skb failed\n"); 366 printk(KERN_WARNING "capi_disc_resp: alloc_skb failed\n");
367 return -1; 367 return -1;
368 } 368 }
369 369
370 *((ushort*) skb_put(*skb, 2)) = chan->callref; 370 *((ushort *)skb_put(*skb, 2)) = chan->callref;
371 371
372 return 2; 372 return 2;
373} 373}
374 374
375 375
@@ -378,57 +378,57 @@ int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb)
378 * 378 *
379 */ 379 */
380 380
381int capi_decode_conn_ind(struct pcbit_chan * chan, 381int capi_decode_conn_ind(struct pcbit_chan *chan,
382 struct sk_buff *skb, 382 struct sk_buff *skb,
383 struct callb_data *info) 383 struct callb_data *info)
384{ 384{
385 int CIlen, len; 385 int CIlen, len;
386 386
387 /* Call Reference [CAPI] */ 387 /* Call Reference [CAPI] */
388 chan->callref = *((ushort*) skb->data); 388 chan->callref = *((ushort *)skb->data);
389 skb_pull(skb, 2); 389 skb_pull(skb, 2);
390 390
391#ifdef DEBUG 391#ifdef DEBUG
392 printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); 392 printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref);
393#endif 393#endif
394 394
395 /* Channel Identification */ 395 /* Channel Identification */
396 396
397 /* Expect 397 /* Expect
398 Len = 1 398 Len = 1
399 Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ] 399 Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ]
400 */ 400 */
401 401
402 CIlen = skb->data[0]; 402 CIlen = skb->data[0];
403#ifdef DEBUG 403#ifdef DEBUG
404 if (CIlen == 1) { 404 if (CIlen == 1) {
405 405
406 if ( ((skb->data[1]) & 0xFC) == 0x48 ) 406 if (((skb->data[1]) & 0xFC) == 0x48)
407 printk(KERN_DEBUG "decode_conn_ind: chan ok\n"); 407 printk(KERN_DEBUG "decode_conn_ind: chan ok\n");
408 printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03); 408 printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03);
409 } 409 }
410 else 410 else
411 printk(KERN_DEBUG "conn_ind: CIlen = %d\n", CIlen); 411 printk(KERN_DEBUG "conn_ind: CIlen = %d\n", CIlen);
412#endif 412#endif
413 skb_pull(skb, CIlen + 1); 413 skb_pull(skb, CIlen + 1);
414 414
415 /* Calling Party Number */ 415 /* Calling Party Number */
416 /* An "additional service" as far as Portugal Telecom is concerned */ 416 /* An "additional service" as far as Portugal Telecom is concerned */
417 417
418 len = skb->data[0]; 418 len = skb->data[0];
419 419
420 if (len > 0) { 420 if (len > 0) {
421 int count = 1; 421 int count = 1;
422 422
423#ifdef DEBUG 423#ifdef DEBUG
424 printk(KERN_DEBUG "CPN: Octect 3 %02x\n", skb->data[1]); 424 printk(KERN_DEBUG "CPN: Octect 3 %02x\n", skb->data[1]);
425#endif 425#endif
426 if ((skb->data[1] & 0x80) == 0) 426 if ((skb->data[1] & 0x80) == 0)
427 count = 2; 427 count = 2;
428 428
429 if (!(info->data.setup.CallingPN = kmalloc(len - count + 1, GFP_ATOMIC))) 429 if (!(info->data.setup.CallingPN = kmalloc(len - count + 1, GFP_ATOMIC)))
430 return -1; 430 return -1;
431 431
432 skb_copy_from_linear_data_offset(skb, count + 1, 432 skb_copy_from_linear_data_offset(skb, count + 1,
433 info->data.setup.CallingPN, 433 info->data.setup.CallingPN,
434 len - count); 434 len - count);
@@ -442,22 +442,22 @@ int capi_decode_conn_ind(struct pcbit_chan * chan,
442 442
443 skb_pull(skb, len + 1); 443 skb_pull(skb, len + 1);
444 444
445 /* Calling Party Subaddress */ 445 /* Calling Party Subaddress */
446 skb_pull(skb, skb->data[0] + 1); 446 skb_pull(skb, skb->data[0] + 1);
447 447
448 /* Called Party Number */ 448 /* Called Party Number */
449 449
450 len = skb->data[0]; 450 len = skb->data[0];
451 451
452 if (len > 0) { 452 if (len > 0) {
453 int count = 1; 453 int count = 1;
454 454
455 if ((skb->data[1] & 0x80) == 0) 455 if ((skb->data[1] & 0x80) == 0)
456 count = 2; 456 count = 2;
457 457
458 if (!(info->data.setup.CalledPN = kmalloc(len - count + 1, GFP_ATOMIC))) 458 if (!(info->data.setup.CalledPN = kmalloc(len - count + 1, GFP_ATOMIC)))
459 return -1; 459 return -1;
460 460
461 skb_copy_from_linear_data_offset(skb, count + 1, 461 skb_copy_from_linear_data_offset(skb, count + 1,
462 info->data.setup.CalledPN, 462 info->data.setup.CalledPN,
463 len - count); 463 len - count);
@@ -471,73 +471,73 @@ int capi_decode_conn_ind(struct pcbit_chan * chan,
471 471
472 skb_pull(skb, len + 1); 472 skb_pull(skb, len + 1);
473 473
474 /* Called Party Subaddress */ 474 /* Called Party Subaddress */
475 skb_pull(skb, skb->data[0] + 1); 475 skb_pull(skb, skb->data[0] + 1);
476 476
477 /* LLC */ 477 /* LLC */
478 skb_pull(skb, skb->data[0] + 1); 478 skb_pull(skb, skb->data[0] + 1);
479 479
480 /* HLC */ 480 /* HLC */
481 skb_pull(skb, skb->data[0] + 1); 481 skb_pull(skb, skb->data[0] + 1);
482 482
483 /* U2U */ 483 /* U2U */
484 skb_pull(skb, skb->data[0] + 1); 484 skb_pull(skb, skb->data[0] + 1);
485 485
486 return 0; 486 return 0;
487} 487}
488 488
489/* 489/*
490 * returns errcode 490 * returns errcode
491 */ 491 */
492 492
493int capi_decode_conn_conf(struct pcbit_chan * chan, struct sk_buff *skb, 493int capi_decode_conn_conf(struct pcbit_chan *chan, struct sk_buff *skb,
494 int *complete) 494 int *complete)
495{ 495{
496 int errcode; 496 int errcode;
497 497
498 chan->callref = *((ushort *) skb->data); /* Update CallReference */ 498 chan->callref = *((ushort *)skb->data); /* Update CallReference */
499 skb_pull(skb, 2); 499 skb_pull(skb, 2);
500
501 errcode = *((ushort *) skb->data); /* read errcode */
502 skb_pull(skb, 2);
500 503
501 errcode = *((ushort *) skb->data); /* read errcode */ 504 *complete = *(skb->data);
502 skb_pull(skb, 2); 505 skb_pull(skb, 1);
503 506
504 *complete = *(skb->data); 507 /* FIX ME */
505 skb_pull(skb, 1); 508 /* This is actually a firmware bug */
509 if (!*complete)
510 {
511 printk(KERN_DEBUG "complete=%02x\n", *complete);
512 *complete = 1;
513 }
506 514
507 /* FIX ME */
508 /* This is actually a firmware bug */
509 if (!*complete)
510 {
511 printk(KERN_DEBUG "complete=%02x\n", *complete);
512 *complete = 1;
513 }
514 515
516 /* Optional Bearer Capability */
517 skb_pull(skb, *(skb->data) + 1);
515 518
516 /* Optional Bearer Capability */ 519 /* Channel Identification */
517 skb_pull(skb, *(skb->data) + 1); 520 skb_pull(skb, *(skb->data) + 1);
518
519 /* Channel Identification */
520 skb_pull(skb, *(skb->data) + 1);
521 521
522 /* High Layer Compatibility follows */ 522 /* High Layer Compatibility follows */
523 skb_pull(skb, *(skb->data) + 1); 523 skb_pull(skb, *(skb->data) + 1);
524 524
525 return errcode; 525 return errcode;
526} 526}
527 527
528int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb) 528int capi_decode_conn_actv_ind(struct pcbit_chan *chan, struct sk_buff *skb)
529{ 529{
530 ushort len; 530 ushort len;
531#ifdef DEBUG 531#ifdef DEBUG
532 char str[32]; 532 char str[32];
533#endif 533#endif
534 534
535 /* Yet Another Bearer Capability */ 535 /* Yet Another Bearer Capability */
536 skb_pull(skb, *(skb->data) + 1); 536 skb_pull(skb, *(skb->data) + 1);
537
538 537
539 /* Connected Party Number */ 538
540 len=*(skb->data); 539 /* Connected Party Number */
540 len = *(skb->data);
541 541
542#ifdef DEBUG 542#ifdef DEBUG
543 if (len > 1 && len < 31) { 543 if (len > 1 && len < 31) {
@@ -549,106 +549,101 @@ int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb)
549 printk(KERN_DEBUG "actv_ind CPN len = %d\n", len); 549 printk(KERN_DEBUG "actv_ind CPN len = %d\n", len);
550#endif 550#endif
551 551
552 skb_pull(skb, len + 1); 552 skb_pull(skb, len + 1);
553 553
554 /* Connected Subaddress */ 554 /* Connected Subaddress */
555 skb_pull(skb, *(skb->data) + 1); 555 skb_pull(skb, *(skb->data) + 1);
556 556
557 /* Low Layer Capability */ 557 /* Low Layer Capability */
558 skb_pull(skb, *(skb->data) + 1); 558 skb_pull(skb, *(skb->data) + 1);
559 559
560 /* High Layer Capability */ 560 /* High Layer Capability */
561 skb_pull(skb, *(skb->data) + 1); 561 skb_pull(skb, *(skb->data) + 1);
562 562
563 return 0; 563 return 0;
564} 564}
565 565
566int capi_decode_conn_actv_conf(struct pcbit_chan * chan, struct sk_buff *skb) 566int capi_decode_conn_actv_conf(struct pcbit_chan *chan, struct sk_buff *skb)
567{ 567{
568 ushort errcode; 568 ushort errcode;
569 569
570 errcode = *((ushort*) skb->data); 570 errcode = *((ushort *)skb->data);
571 skb_pull(skb, 2); 571 skb_pull(skb, 2);
572 572
573 /* Channel Identification 573 /* Channel Identification
574 skb_pull(skb, skb->data[0] + 1); 574 skb_pull(skb, skb->data[0] + 1);
575 */ 575 */
576 return errcode; 576 return errcode;
577} 577}
578 578
579 579
580int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb) 580int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb)
581{ 581{
582 ushort errcode; 582 ushort errcode;
583
584 chan->layer2link = *(skb->data);
585 skb_pull(skb, 1);
586 583
587 errcode = *((ushort*) skb->data); 584 chan->layer2link = *(skb->data);
588 skb_pull(skb, 2); 585 skb_pull(skb, 1);
589 586
590 return errcode; 587 errcode = *((ushort *)skb->data);
588 skb_pull(skb, 2);
589
590 return errcode;
591} 591}
592 592
593int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb) 593int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb)
594{ 594{
595 ushort errcode; 595 ushort errcode;
596 596
597 if (chan->layer2link != *(skb->data) ) 597 if (chan->layer2link != *(skb->data))
598 printk("capi_decode_actv_trans_conf: layer2link doesn't match\n"); 598 printk("capi_decode_actv_trans_conf: layer2link doesn't match\n");
599 599
600 skb_pull(skb, 1); 600 skb_pull(skb, 1);
601 601
602 errcode = *((ushort*) skb->data); 602 errcode = *((ushort *)skb->data);
603 skb_pull(skb, 2); 603 skb_pull(skb, 2);
604 604
605 return errcode; 605 return errcode;
606} 606}
607 607
608int capi_decode_disc_ind(struct pcbit_chan *chan, struct sk_buff *skb) 608int capi_decode_disc_ind(struct pcbit_chan *chan, struct sk_buff *skb)
609{ 609{
610 ushort len; 610 ushort len;
611#ifdef DEBUG 611#ifdef DEBUG
612 int i; 612 int i;
613#endif 613#endif
614 /* Cause */ 614 /* Cause */
615 615
616 len = *(skb->data); 616 len = *(skb->data);
617 skb_pull(skb, 1); 617 skb_pull(skb, 1);
618 618
619#ifdef DEBUG 619#ifdef DEBUG
620 620
621 for (i=0; i<len; i++) 621 for (i = 0; i < len; i++)
622 printk(KERN_DEBUG "Cause Octect %d: %02x\n", i+3, 622 printk(KERN_DEBUG "Cause Octect %d: %02x\n", i + 3,
623 *(skb->data + i)); 623 *(skb->data + i));
624#endif 624#endif
625 625
626 skb_pull(skb, len); 626 skb_pull(skb, len);
627 627
628 return 0; 628 return 0;
629} 629}
630 630
631#ifdef DEBUG 631#ifdef DEBUG
632int capi_decode_debug_188(u_char *hdr, ushort hdrlen) 632int capi_decode_debug_188(u_char *hdr, ushort hdrlen)
633{ 633{
634 char str[64]; 634 char str[64];
635 int len; 635 int len;
636
637 len = hdr[0];
638
639 if (len < 64 && len == hdrlen - 1) {
640 memcpy(str, hdr + 1, hdrlen - 1);
641 str[hdrlen - 1] = 0;
642 printk("%s\n", str);
643 }
644 else
645 printk("debug message incorrect\n");
646
647 return 0;
648}
649#endif
650
651
652 636
637 len = hdr[0];
653 638
639 if (len < 64 && len == hdrlen - 1) {
640 memcpy(str, hdr + 1, hdrlen - 1);
641 str[hdrlen - 1] = 0;
642 printk("%s\n", str);
643 }
644 else
645 printk("debug message incorrect\n");
654 646
647 return 0;
648}
649#endif