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

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