root/drivers/isdn/teles/l3_1TR6.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mt_trans
  2. l3_1TR6_message
  3. l3_1tr6_setup
  4. l3_1tr6_tu_setup
  5. l3_1tr6_tu_setup_ack
  6. l3_1tr6_tu_call_sent
  7. l3_1tr6_tu_alert
  8. l3_1tr6_tu_info
  9. l3_1tr6_tu_info_s2
  10. l3_1tr6_tu_connect
  11. l3_1tr6_tu_rel
  12. l3_1tr6_tu_rel_ack
  13. l3_1tr6_tu_disc
  14. l3_1tr6_tu_connect_ack
  15. l3_1tr6_alert
  16. l3_1tr6_conn
  17. l3_1tr6_ignore
  18. l3_1tr6_disconn_req
  19. l3_1tr6_rel_req

   1 #define DEBUG_1TR6 0
   2 
   3 char           *
   4 mt_trans(int pd, int mt)
     /* [previous][next][first][last][top][bottom][index][help] */
   5 {
   6         int             i;
   7 
   8         if (pd == PROTO_DIS_N0) {
   9                 for (i = 0; i < (sizeof(mtdesc_n0) / sizeof(struct MTypeDesc)); i++) {
  10                         if (mt == mtdesc_n0[i].mt)
  11                                 return (mtdesc_n0[i].descr);
  12                 }
  13                 return ("unkown Message Type PD=N0");
  14         } else if (pd == PROTO_DIS_N1) {
  15                 for (i = 0; i < (sizeof(mtdesc_n1) / sizeof(struct MTypeDesc)); i++) {
  16                         if (mt == mtdesc_n1[i].mt)
  17                                 return (mtdesc_n1[i].descr);
  18                 }
  19                 return ("unkown Message Type PD=N1");
  20         }
  21         return ("unkown Protokolldiscriminator");
  22 }
  23 
  24 static void
  25 l3_1TR6_message(struct PStack *st, int mt, int pd)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27         struct BufHeader *dibh;
  28         byte           *p;
  29 
  30         BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 18);
  31         p = DATAPTR(dibh);
  32         p += st->l2.ihsize;
  33 
  34         *p++ = pd;
  35         *p++ = 0x1;
  36         *p++ = st->l3.callref;
  37         *p++ = mt;
  38 
  39         dibh->datasize = p - DATAPTR(dibh);
  40         i_down(st, dibh);
  41 }
  42 
  43 static void
  44 l3_1tr6_setup(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46         struct BufHeader *dibh;
  47         byte           *p;
  48         char           *teln;
  49 
  50 #if DEBUG_1TR6
  51         printk(KERN_INFO "1tr6: sent SETUP\n");
  52 #endif
  53 
  54         st->l3.callref = st->pa->callref;
  55         BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 19);
  56         p = DATAPTR(dibh);
  57         p += st->l2.ihsize;
  58 
  59         *p++ = PROTO_DIS_N1;
  60         *p++ = 0x1;
  61         *p++ = st->l3.callref;
  62         *p++ = MT_N1_SETUP;
  63 
  64 
  65         if (st->pa->calling[0] != '\0') {
  66                 *p++ = WE0_origAddr;
  67                 *p++ = strlen(st->pa->calling) + 1;
  68                 /* Classify as AnyPref. */
  69                 *p++ = 0x81;    /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
  70                 teln = st->pa->calling;
  71                 while (*teln)
  72                         *p++ = *teln++ & 0x7f;
  73         }
  74         *p++ = WE0_destAddr;
  75         *p++ = strlen(st->pa->called) + 1;
  76         /* Classify as AnyPref. */
  77         *p++ = 0x81;            /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
  78 
  79         teln = st->pa->called;
  80         while (*teln)
  81                 *p++ = *teln++ & 0x7f;
  82 
  83         *p++ = WE_Shift_F6;
  84         /* Codesatz 6 fuer Service */
  85         *p++ = WE6_serviceInd;
  86         *p++ = 2;               /* len=2 info,info2 */
  87         *p++ = st->pa->info;
  88         *p++ = st->pa->info2;
  89 
  90         dibh->datasize = p - DATAPTR(dibh);
  91 
  92         newl3state(st, 1);
  93         i_down(st, dibh);
  94 
  95 }
  96 
  97 
  98 static void
  99 l3_1tr6_tu_setup(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 100 {
 101         byte           *p;
 102         struct BufHeader *ibh = arg;
 103 
 104 #if DEBUG_1TR6
 105         printk(KERN_INFO "1tr6: TU_SETUP\n");
 106 #endif
 107 
 108         p = DATAPTR(ibh);
 109         p += st->l2.uihsize;
 110         st->pa->callref = getcallref(p);
 111         st->l3.callref = 0x80 + st->pa->callref;
 112 
 113         /*
 114          * Channel Identification
 115          */
 116         p = DATAPTR(ibh);
 117         if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize,
 118                         WE0_chanID, 0))) {
 119                 st->pa->bchannel = p[2] & 0x3;
 120         } else
 121                 printk(KERN_INFO "l3tu_setup: Channel ident not found\n");
 122 
 123         p = DATAPTR(ibh);
 124 
 125         if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, WE6_serviceInd, 6))) {
 126                 st->pa->info = p[2];
 127                 st->pa->info2 = p[3];
 128         } else
 129                 printk(KERN_INFO "l3s12(1TR6): ServiceIndicator not found\n");
 130 
 131         p = DATAPTR(ibh);
 132         if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize,
 133                         WE0_destAddr, 0)))
 134                 iecpy(st->pa->called, p, 1);
 135         else
 136                 strcpy(st->pa->called, "");
 137 
 138         p = DATAPTR(ibh);
 139         if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize,
 140                         WE0_origAddr, 0))) {
 141                 iecpy(st->pa->calling, p, 1);
 142         } else
 143                 strcpy(st->pa->calling, "");
 144 
 145         BufPoolRelease(ibh);
 146 
 147         if (st->pa->info == 7) {
 148                 newl3state(st, 6);
 149                 st->l3.l3l4(st, CC_SETUP_IND, NULL);
 150         }
 151 }
 152 
 153 static void
 154 l3_1tr6_tu_setup_ack(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 155 {
 156         byte           *p;
 157         struct BufHeader *ibh = arg;
 158 
 159 #if DEBUG_1TR6
 160         printk(KERN_INFO "1tr6: SETUP_ACK\n");
 161 #endif
 162 
 163         p = DATAPTR(ibh);
 164         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 165                         WE0_chanID, 0))) {
 166                 st->pa->bchannel = p[2] & 0x3;
 167         } else
 168                 printk(KERN_INFO "octect 3 not found\n");
 169 
 170         BufPoolRelease(ibh);
 171         newl3state(st, 2);
 172 }
 173 
 174 static void
 175 l3_1tr6_tu_call_sent(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 176 {
 177         byte           *p;
 178         struct BufHeader *ibh = arg;
 179 
 180 #if DEBUG_1TR6
 181         printk(KERN_INFO "1tr6: CALL_SENT\n");
 182 #endif
 183 
 184         p = DATAPTR(ibh);
 185         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 186                         WE0_chanID, 0))) {
 187                 st->pa->bchannel = p[2] & 0x3;
 188         } else
 189                 printk(KERN_INFO "octect 3 not found\n");
 190 
 191         BufPoolRelease(ibh);
 192         newl3state(st, 3);
 193         st->l3.l3l4(st, CC_PROCEEDING_IND, NULL);
 194 }
 195 
 196 static void
 197 l3_1tr6_tu_alert(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 198 {
 199         byte           *p;
 200         struct BufHeader *ibh = arg;
 201 
 202 #if DEBUG_1TR6
 203         printk(KERN_INFO "1tr6: TU_ALERT\n");
 204 #endif
 205 
 206         p = DATAPTR(ibh);
 207         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 208                         WE6_statusCalled, 6))) {
 209                 if (DEBUG_1TR6 > 2)
 210                         printk(KERN_INFO "status called %x\n", p[2]);
 211         } else if (DEBUG_1TR6 > 0)
 212                 printk(KERN_INFO "statusCalled not found\n");
 213 
 214         BufPoolRelease(ibh);
 215         newl3state(st, 4);
 216         st->l3.l3l4(st, CC_ALERTING_IND, NULL);
 217 }
 218 
 219 static void
 220 l3_1tr6_tu_info(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 221 {
 222         byte           *p;
 223         int             i;
 224         char            a_charge[8];
 225         struct BufHeader *ibh = arg;
 226 
 227 #if DEBUG_1TR6
 228         printk(KERN_INFO "1tr6: TU_INFO\n");
 229 #endif
 230 
 231         p = DATAPTR(ibh);
 232         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 233                         WE6_chargingInfo, 6))) {
 234                 iecpy(a_charge, p, 1);
 235                 st->pa->chargeinfo = 0;
 236                 for (i = 0; i < strlen(a_charge); i++) {
 237                         st->pa->chargeinfo *= 10;
 238                         st->pa->chargeinfo += a_charge[i] & 0xf;
 239                         st->l3.l3l4(st, CC_INFO_CHARGE, NULL);
 240                 }
 241                 if (DEBUG_1TR6 > 2)
 242                         printk(KERN_INFO "chargingInfo %d\n", st->pa->chargeinfo);
 243         } else if (DEBUG_1TR6 > 2)
 244                 printk(KERN_INFO "chargingInfo not found\n");
 245 
 246         BufPoolRelease(ibh);
 247 }
 248 
 249 static void
 250 l3_1tr6_tu_info_s2(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 251 {
 252         byte           *p;
 253         int             i;
 254         struct BufHeader *ibh = arg;
 255 
 256 #if DEBUG_1TR6
 257         printk(KERN_INFO "1tr6: TU_INFO 2\n");
 258 #endif
 259 
 260         if (DEBUG_1TR6 > 4) {
 261                 p = DATAPTR(ibh);
 262                 for (i = 0; i < ibh->datasize; i++) {
 263                         printk(KERN_INFO "Info DATA %x\n", p[i]);
 264                 }
 265         }
 266         BufPoolRelease(ibh);
 267 }
 268 
 269 static void
 270 l3_1tr6_tu_connect(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 271 {
 272         struct BufHeader *ibh = arg;
 273 
 274 #if DEBUG_1TR6
 275         printk(KERN_INFO "1tr6: CONNECT\n");
 276 #endif
 277 
 278         BufPoolRelease(ibh);
 279         st->l3.l3l4(st, CC_SETUP_CNF, NULL);
 280         newl3state(st, 10);
 281 }
 282 
 283 static void
 284 l3_1tr6_tu_rel(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 285 {
 286         struct BufHeader *ibh = arg;
 287 
 288 #if DEBUG_1TR6
 289         printk(KERN_INFO "1tr6: REL\n");
 290 #endif
 291 
 292 
 293         BufPoolRelease(ibh);
 294         l3_1TR6_message(st, MT_N1_REL_ACK, PROTO_DIS_N1);
 295         st->l3.l3l4(st, CC_RELEASE_IND, NULL);
 296         newl3state(st, 0);
 297 }
 298 
 299 static void
 300 l3_1tr6_tu_rel_ack(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 301 {
 302         struct BufHeader *ibh = arg;
 303 
 304 #if DEBUG_1TR6
 305         printk(KERN_INFO "1tr6: REL_ACK\n");
 306 #endif
 307 
 308 
 309         BufPoolRelease(ibh);
 310         newl3state(st, 0);
 311         st->l3.l3l4(st, CC_RELEASE_CNF, NULL);
 312 }
 313 
 314 static void
 315 l3_1tr6_tu_disc(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 316 {
 317         struct BufHeader *ibh = arg;
 318         byte           *p;
 319         int             i;
 320         char            a_charge[8];
 321 
 322 
 323 #if DEBUG_1TR6
 324         printk(KERN_INFO "1tr6: TU_DISC\n");
 325 #endif
 326 
 327 
 328         p = DATAPTR(ibh);
 329         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 330                         WE6_chargingInfo, 6))) {
 331                 iecpy(a_charge, p, 1);
 332                 st->pa->chargeinfo = 0;
 333                 for (i = 0; i < strlen(a_charge); i++) {
 334                         st->pa->chargeinfo *= 10;
 335                         st->pa->chargeinfo += a_charge[i] & 0xf;
 336                         st->l3.l3l4(st, CC_INFO_CHARGE, NULL);
 337                 }
 338                 if (DEBUG_1TR6 > 2)
 339                         printk(KERN_INFO "chargingInfo %d\n", st->pa->chargeinfo);
 340         } else if (DEBUG_1TR6 > 2)
 341                 printk(KERN_INFO "chargingInfo not found\n");
 342 
 343         p = DATAPTR(ibh);
 344         if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize,
 345                         WE0_cause, 0))) {
 346                 if (p[1] > 0) {
 347                         st->pa->cause = p[2];
 348                 } else {
 349                         st->pa->cause = 0;
 350                 }
 351                 if (DEBUG_1TR6 > 1)
 352                         printk(KERN_INFO "Cause %x\n", st->pa->cause);
 353         } else if (DEBUG_1TR6 > 0)
 354                 printk(KERN_INFO "Cause not found\n");
 355 
 356         BufPoolRelease(ibh);
 357         newl3state(st, 12);
 358         st->l3.l3l4(st, CC_DISCONNECT_IND, NULL);
 359 }
 360 
 361 
 362 static void
 363 l3_1tr6_tu_connect_ack(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 364 {
 365         struct BufHeader *ibh = arg;
 366 
 367 #if DEBUG_1TR6
 368         printk(KERN_INFO "1tr6: CONN_ACK\n");
 369 #endif
 370 
 371 
 372         BufPoolRelease(ibh);
 373         st->l3.l3l4(st, CC_SETUP_COMPLETE_IND, NULL);
 374         newl3state(st, 10);
 375 }
 376 
 377 static void
 378 l3_1tr6_alert(struct PStack *st, byte pr,
     /* [previous][next][first][last][top][bottom][index][help] */
 379               void *arg)
 380 {
 381 #if DEBUG_1TR6
 382         printk(KERN_INFO "1tr6: send ALERT\n");
 383 #endif
 384 
 385         l3_1TR6_message(st, MT_N1_ALERT, PROTO_DIS_N1);
 386         newl3state(st, 7);
 387 }
 388 
 389 static void
 390 l3_1tr6_conn(struct PStack *st, byte pr,
     /* [previous][next][first][last][top][bottom][index][help] */
 391              void *arg)
 392 {
 393 #if DEBUG_1TR6
 394         printk(KERN_INFO "1tr6: send CONNECT\n");
 395 #endif
 396 
 397         st->l3.callref = 0x80 + st->pa->callref;
 398         l3_1TR6_message(st, MT_N1_CONN, PROTO_DIS_N1);
 399         newl3state(st, 8);
 400 }
 401 
 402 static void
 403 l3_1tr6_ignore(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 404 {
 405 #if DEBUG_1TR6
 406         printk(KERN_INFO "1tr6: IGNORE\n");
 407 #endif
 408 
 409         newl3state(st, 0);
 410 }
 411 
 412 static void
 413 l3_1tr6_disconn_req(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 414 {
 415         struct BufHeader *dibh;
 416         byte           *p;
 417 
 418 #if DEBUG_1TR6
 419         printk(KERN_INFO "1tr6: send DISCON\n");
 420 #endif
 421 
 422         BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 20);
 423         p = DATAPTR(dibh);
 424         p += st->l2.ihsize;
 425 
 426         *p++ = PROTO_DIS_N1;
 427         *p++ = 0x1;
 428         *p++ = st->l3.callref;
 429         *p++ = MT_N1_DISC;
 430 
 431         *p++ = WE0_cause;
 432         *p++ = 0x0;             /* Laenge = 0 normales Ausloesen */
 433 
 434         dibh->datasize = p - DATAPTR(dibh);
 435 
 436         i_down(st, dibh);
 437 
 438         newl3state(st, 11);
 439 }
 440 
 441 static void
 442 l3_1tr6_rel_req(struct PStack *st, byte pr, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 443 {
 444         l3_1TR6_message(st, MT_N1_REL, PROTO_DIS_N1);
 445         newl3state(st, 19);
 446 }
 447 
 448 
 449 
 450 static struct stateentry downstatelist_1tr6t[] =
 451 {
 452         {0, CC_SETUP_REQ, l3_1tr6_setup},
 453         {6, CC_REJECT_REQ, l3_1tr6_ignore},
 454         {6, CC_SETUP_RSP, l3_1tr6_conn},
 455         {6, CC_ALERTING_REQ, l3_1tr6_alert},
 456         {7, CC_SETUP_RSP, l3_1tr6_conn},
 457         {7, CC_DISCONNECT_REQ, l3_1tr6_disconn_req},
 458         {8, CC_DISCONNECT_REQ, l3_1tr6_disconn_req},
 459         {10, CC_DISCONNECT_REQ, l3_1tr6_disconn_req},
 460         {12, CC_RELEASE_REQ, l3_1tr6_rel_req}
 461 };
 462 
 463 static int      downsl_1tr6t_len = sizeof(downstatelist_1tr6t) /
 464 sizeof(struct stateentry);
 465 
 466 static struct stateentry datastatelist_1tr6t[] =
 467 {
 468         {0, MT_N1_SETUP, l3_1tr6_tu_setup},
 469         {0, MT_N1_REL, l3_1tr6_tu_rel},
 470         {1, MT_N1_SETUP_ACK, l3_1tr6_tu_setup_ack},
 471         {1, MT_N1_CALL_SENT, l3_1tr6_tu_call_sent},
 472         {1, MT_N1_REL, l3_1tr6_tu_rel},
 473         {1, MT_N1_DISC, l3_1tr6_tu_disc},
 474         {2, MT_N1_CALL_SENT, l3_1tr6_tu_call_sent},
 475         {2, MT_N1_ALERT, l3_1tr6_tu_alert},
 476         {2, MT_N1_CONN, l3_1tr6_tu_connect},
 477         {2, MT_N1_REL, l3_1tr6_tu_rel},
 478         {2, MT_N1_DISC, l3_1tr6_tu_disc},
 479         {2, MT_N1_INFO, l3_1tr6_tu_info_s2},
 480         {3, MT_N1_ALERT, l3_1tr6_tu_alert},
 481         {3, MT_N1_CONN, l3_1tr6_tu_connect},
 482         {3, MT_N1_REL, l3_1tr6_tu_rel},
 483         {3, MT_N1_DISC, l3_1tr6_tu_disc},
 484         {4, MT_N1_ALERT, l3_1tr6_tu_alert},
 485         {4, MT_N1_CONN, l3_1tr6_tu_connect},
 486         {4, MT_N1_REL, l3_1tr6_tu_rel},
 487         {4, MT_N1_DISC, l3_1tr6_tu_disc},
 488         {7, MT_N1_REL, l3_1tr6_tu_rel},
 489         {7, MT_N1_DISC, l3_1tr6_tu_disc},
 490         {8, MT_N1_REL, l3_1tr6_tu_rel},
 491         {8, MT_N1_DISC, l3_1tr6_tu_disc},
 492         {8, MT_N1_CONN_ACK, l3_1tr6_tu_connect_ack},
 493         {10, MT_N1_REL, l3_1tr6_tu_rel},
 494         {10, MT_N1_DISC, l3_1tr6_tu_disc},
 495         {10, MT_N1_INFO, l3_1tr6_tu_info},
 496         {11, MT_N1_REL, l3_1tr6_tu_rel},
 497         {12, MT_N1_REL, l3_1tr6_tu_rel},
 498         {19, MT_N1_REL_ACK, l3_1tr6_tu_rel_ack}
 499 };
 500 
 501 static int      datasl_1tr6t_len = sizeof(datastatelist_1tr6t) /
 502 sizeof(struct stateentry);

/* [previous][next][first][last][top][bottom][index][help] */