1 /* $Id: l3dss1.c,v 2.32.2.3 2004/01/13 14:31:25 keil Exp $
3 * EURO/DSS1 D-channel protocol
5 * German 1TR6 D-channel protocol
8 * based on the teles driver from Jan den Ouden
9 * Copyright by Karsten Keil <keil@isdn4linux.de>
11 * This software may be used and distributed according to the terms
12 * of the GNU General Public License, incorporated herein by reference.
14 * For changes and modifications please read
15 * Documentation/isdn/HiSax.cert
17 * Thanks to Jan den Ouden
25 #include <linux/ctype.h>
26 #include <linux/slab.h>
28 extern char *HiSax_getrev(const char *revision);
29 static const char *dss1_revision = "$Revision: 2.32.2.3 $";
31 #define EXT_BEARER_CAPS 1
33 #define MsgHead(ptr, cref, mty) \
44 /**********************************************/
45 /* get a new invoke id for remote operations. */
46 /* Only a return value != 0 is valid */
47 /**********************************************/
48 static unsigned char new_invoke_id(struct PStack *p)
53 i = 32; /* maximum search depth */
55 retval = p->prot.dss1.last_invoke_id + 1; /* try new id */
56 while ((i) && (p->prot.dss1.invoke_used[retval >> 3] == 0xFF)) {
57 p->prot.dss1.last_invoke_id = (retval & 0xF8) + 8;
61 while (p->prot.dss1.invoke_used[retval >> 3] & (1 << (retval & 7)))
65 p->prot.dss1.last_invoke_id = retval;
66 p->prot.dss1.invoke_used[retval >> 3] |= (1 << (retval & 7));
70 /*************************/
71 /* free a used invoke id */
72 /*************************/
73 static void free_invoke_id(struct PStack *p, unsigned char id)
76 if (!id) return; /* 0 = invalid value */
78 p->prot.dss1.invoke_used[id >> 3] &= ~(1 << (id & 7));
79 } /* free_invoke_id */
82 /**********************************************************/
83 /* create a new l3 process and fill in dss1 specific data */
84 /**********************************************************/
85 static struct l3_process
86 *dss1_new_l3_process(struct PStack *st, int cr)
87 { struct l3_process *proc;
89 if (!(proc = new_l3_process(st, cr)))
92 proc->prot.dss1.invoke_id = 0;
93 proc->prot.dss1.remote_operation = 0;
94 proc->prot.dss1.uus1_data[0] = '\0';
97 } /* dss1_new_l3_process */
99 /************************************************/
100 /* free a l3 process and all dss1 specific data */
101 /************************************************/
103 dss1_release_l3_process(struct l3_process *p)
105 free_invoke_id(p->st, p->prot.dss1.invoke_id);
106 release_l3_process(p);
107 } /* dss1_release_l3_process */
109 /********************************************************/
110 /* search a process with invoke id id and dummy callref */
111 /********************************************************/
112 static struct l3_process *
113 l3dss1_search_dummy_proc(struct PStack *st, int id)
114 { struct l3_process *pc = st->l3.proc; /* start of processes */
116 if (!id) return (NULL);
119 { if ((pc->callref == -1) && (pc->prot.dss1.invoke_id == id))
124 } /* l3dss1_search_dummy_proc */
126 /*******************************************************************/
127 /* called when a facility message with a dummy callref is received */
128 /* and a return result is delivered. id specifies the invoke id. */
129 /*******************************************************************/
131 l3dss1_dummy_return_result(struct PStack *st, int id, u_char *p, u_char nlen)
133 struct IsdnCardState *cs;
134 struct l3_process *pc = NULL;
136 if ((pc = l3dss1_search_dummy_proc(st, id)))
137 { L3DelTimer(&pc->timer); /* remove timer */
139 cs = pc->st->l1.hardware;
140 ic.driver = cs->myid;
141 ic.command = ISDN_STAT_PROT;
142 ic.arg = DSS1_STAT_INVOKE_RES;
143 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
144 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
145 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
146 ic.parm.dss1_io.timeout = 0;
147 ic.parm.dss1_io.datalen = nlen;
148 ic.parm.dss1_io.data = p;
149 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
150 pc->prot.dss1.invoke_id = 0; /* reset id */
152 cs->iif.statcallb(&ic);
153 dss1_release_l3_process(pc);
156 l3_debug(st, "dummy return result id=0x%x result len=%d", id, nlen);
157 } /* l3dss1_dummy_return_result */
159 /*******************************************************************/
160 /* called when a facility message with a dummy callref is received */
161 /* and a return error is delivered. id specifies the invoke id. */
162 /*******************************************************************/
164 l3dss1_dummy_error_return(struct PStack *st, int id, ulong error)
166 struct IsdnCardState *cs;
167 struct l3_process *pc = NULL;
169 if ((pc = l3dss1_search_dummy_proc(st, id)))
170 { L3DelTimer(&pc->timer); /* remove timer */
172 cs = pc->st->l1.hardware;
173 ic.driver = cs->myid;
174 ic.command = ISDN_STAT_PROT;
175 ic.arg = DSS1_STAT_INVOKE_ERR;
176 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
177 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
178 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
179 ic.parm.dss1_io.timeout = error;
180 ic.parm.dss1_io.datalen = 0;
181 ic.parm.dss1_io.data = NULL;
182 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
183 pc->prot.dss1.invoke_id = 0; /* reset id */
185 cs->iif.statcallb(&ic);
186 dss1_release_l3_process(pc);
189 l3_debug(st, "dummy return error id=0x%x error=0x%lx", id, error);
190 } /* l3dss1_error_return */
192 /*******************************************************************/
193 /* called when a facility message with a dummy callref is received */
194 /* and a invoke is delivered. id specifies the invoke id. */
195 /*******************************************************************/
197 l3dss1_dummy_invoke(struct PStack *st, int cr, int id,
198 int ident, u_char *p, u_char nlen)
200 struct IsdnCardState *cs;
202 l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d",
203 (cr == -1) ? "local" : "broadcast", id, ident, nlen);
204 if (cr >= -1) return; /* ignore local data */
206 cs = st->l1.hardware;
207 ic.driver = cs->myid;
208 ic.command = ISDN_STAT_PROT;
209 ic.arg = DSS1_STAT_INVOKE_BRD;
210 ic.parm.dss1_io.hl_id = id;
211 ic.parm.dss1_io.ll_id = 0;
212 ic.parm.dss1_io.proc = ident;
213 ic.parm.dss1_io.timeout = 0;
214 ic.parm.dss1_io.datalen = nlen;
215 ic.parm.dss1_io.data = p;
217 cs->iif.statcallb(&ic);
218 } /* l3dss1_dummy_invoke */
221 l3dss1_parse_facility(struct PStack *st, struct l3_process *pc,
225 unsigned char nlen = 0, ilen, cp_tag;
230 st = pc->st; /* valid Stack */
232 if ((!st) || (cr >= 0)) return; /* neither pc nor st specified */
237 l3_debug(st, "qd_len == 0");
240 if ((*p & 0x1F) != 0x11) { /* Service discriminator, supplementary service */
241 l3_debug(st, "supplementary service != 0x11");
244 while (qd_len > 0 && !(*p & 0x80)) { /* extension ? */
249 l3_debug(st, "qd_len < 2");
254 if ((*p & 0xE0) != 0xA0) { /* class and form */
255 l3_debug(st, "class and form != 0xA0");
259 cp_tag = *p & 0x1F; /* remember tag value */
264 { l3_debug(st, "qd_len < 1");
268 { /* length format indefinite or limited */
269 nlen = *p++ & 0x7F; /* number of len bytes or indefinite */
270 if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) ||
272 { l3_debug(st, "length format error or not implemented");
276 { nlen = *p++; /* complete length */
280 { qd_len -= 2; /* trailing null bytes */
281 if ((*(p + qd_len)) || (*(p + qd_len + 1)))
282 { l3_debug(st, "length format indefinite error");
293 { l3_debug(st, "qd_len < nlen");
299 { l3_debug(st, "nlen < 2");
303 { /* invoke identifier tag */
304 l3_debug(st, "invoke identifier tag !=0x02");
310 { /* length format */
311 l3_debug(st, "invoke id length format 2");
316 if (ilen > nlen || ilen == 0)
317 { l3_debug(st, "ilen > nlen || ilen == 0");
323 { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */
327 switch (cp_tag) { /* component tag */
330 l3_debug(st, "nlen < 2 22");
333 if (*p != 0x02) { /* operation value */
334 l3_debug(st, "operation value !=0x02");
341 if (ilen > nlen || ilen == 0) {
342 l3_debug(st, "ilen > nlen || ilen == 0 22");
348 ident = (ident << 8) | (*p++ & 0xFF);
353 { l3dss1_dummy_invoke(st, cr, id, ident, p, nlen);
359 #define FOO1(s, a, b) \
362 if (nlen < ilen + 2) { \
363 l3_debug(st, "FOO1 nlen < ilen+2"); \
367 if ((*p & 0xFF) == (a)) { \
377 case 0x22: /* during */
378 FOO1("1A", 0x30, FOO1("1C", 0xA1, FOO1("1D", 0x30, FOO1("1E", 0x02, ( {
380 nlen = (nlen) ? nlen : 0; /* Make gcc happy */
382 ident = (ident << 8) | *p++;
385 if (ident > pc->para.chargeinfo) {
386 pc->para.chargeinfo = ident;
387 st->l3.l3l4(st, CC_CHARGE | INDICATION, pc);
389 if (st->l3.debug & L3_DEB_CHARGE) {
391 l3_debug(st, "charging info during %d", pc->para.chargeinfo);
394 l3_debug(st, "charging info final %d", pc->para.chargeinfo);
400 case 0x24: /* final */
401 FOO1("2A", 0x30, FOO1("2B", 0x30, FOO1("2C", 0xA1, FOO1("2D", 0x30, FOO1("2E", 0x02, ( {
403 nlen = (nlen) ? nlen : 0; /* Make gcc happy */
405 ident = (ident << 8) | *p++;
408 if (ident > pc->para.chargeinfo) {
409 pc->para.chargeinfo = ident;
410 st->l3.l3l4(st, CC_CHARGE | INDICATION, pc);
412 if (st->l3.debug & L3_DEB_CHARGE) {
413 l3_debug(st, "charging info final %d", pc->para.chargeinfo);
419 l3_debug(st, "invoke break invalid ident %02x", ident);
425 #else /* not CONFIG_DE_AOC */
426 l3_debug(st, "invoke break");
427 #endif /* not CONFIG_DE_AOC */
429 case 2: /* return result */
430 /* if no process available handle separately */
433 l3dss1_dummy_return_result(st, id, p, nlen);
436 if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id))
437 { /* Diversion successful */
438 free_invoke_id(st, pc->prot.dss1.invoke_id);
439 pc->prot.dss1.remote_result = 0; /* success */
440 pc->prot.dss1.invoke_id = 0;
441 pc->redir_result = pc->prot.dss1.remote_result;
442 st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */
444 l3_debug(st, "return error unknown identifier");
446 case 3: /* return error */
449 { l3_debug(st, "return error nlen < 2");
454 l3_debug(st, "invoke error tag !=0x02");
460 { /* length format */
461 l3_debug(st, "invoke return errlen > 4 ");
466 if (ilen > nlen || ilen == 0)
467 { l3_debug(st, "error return ilen > nlen || ilen == 0");
472 { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */
475 /* if no process available handle separately */
478 l3dss1_dummy_error_return(st, id, err_ret);
481 if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id))
482 { /* Deflection error */
483 free_invoke_id(st, pc->prot.dss1.invoke_id);
484 pc->prot.dss1.remote_result = err_ret; /* result */
485 pc->prot.dss1.invoke_id = 0;
486 pc->redir_result = pc->prot.dss1.remote_result;
487 st->l3.l3l4(st, CC_REDIR | INDICATION, pc);
488 } /* Deflection error */
490 l3_debug(st, "return result unknown identifier");
493 l3_debug(st, "facility default break tag=0x%02x", cp_tag);
499 l3dss1_message(struct l3_process *pc, u_char mt)
504 if (!(skb = l3_alloc_skb(4)))
507 MsgHead(p, pc->callref, mt);
508 l3_msg(pc->st, DL_DATA | REQUEST, skb);
512 l3dss1_message_cause(struct l3_process *pc, u_char mt, u_char cause)
519 MsgHead(p, pc->callref, mt);
526 if (!(skb = l3_alloc_skb(l)))
528 skb_put_data(skb, tmp, l);
529 l3_msg(pc->st, DL_DATA | REQUEST, skb);
533 l3dss1_status_send(struct l3_process *pc, u_char pr, void *arg)
540 MsgHead(p, pc->callref, MT_STATUS);
545 *p++ = pc->para.cause | 0x80;
547 *p++ = IE_CALL_STATE;
549 *p++ = pc->state & 0x3f;
552 if (!(skb = l3_alloc_skb(l)))
554 skb_put_data(skb, tmp, l);
555 l3_msg(pc->st, DL_DATA | REQUEST, skb);
559 l3dss1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg)
561 /* This routine is called if here was no SETUP made (checks in dss1up and in
562 * l3dss1_setup) and a RELEASE_COMPLETE have to be sent with an error code
563 * MT_STATUS_ENQUIRE in the NULL state is handled too
570 switch (pc->para.cause) {
571 case 81: /* invalid callreference */
572 case 88: /* incomp destination */
573 case 96: /* mandory IE missing */
574 case 100: /* invalid IE contents */
575 case 101: /* incompatible Callstate */
576 MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
580 *p++ = pc->para.cause | 0x80;
583 printk(KERN_ERR "HiSax l3dss1_msg_without_setup wrong cause %d\n",
588 if (!(skb = l3_alloc_skb(l)))
590 skb_put_data(skb, tmp, l);
591 l3_msg(pc->st, DL_DATA | REQUEST, skb);
592 dss1_release_l3_process(pc);
595 static int ie_ALERTING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
596 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC,
598 static int ie_CALL_PROCEEDING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
599 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1};
600 static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
601 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL,
602 IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1};
603 static int ie_CONNECT_ACKNOWLEDGE[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_SIGNAL, -1};
604 static int ie_DISCONNECT[] = {IE_CAUSE | IE_MANDATORY, IE_FACILITY,
605 IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1};
606 static int ie_INFORMATION[] = {IE_COMPLETE, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL,
608 static int ie_NOTIFY[] = {IE_BEARER, IE_NOTIFY | IE_MANDATORY, IE_DISPLAY, -1};
609 static int ie_PROGRESS[] = {IE_BEARER, IE_CAUSE, IE_FACILITY, IE_PROGRESS |
610 IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1};
611 static int ie_RELEASE[] = {IE_CAUSE | IE_MANDATORY_1, IE_FACILITY, IE_DISPLAY,
612 IE_SIGNAL, IE_USER_USER, -1};
613 /* a RELEASE_COMPLETE with errors don't require special actions
614 static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1};
616 static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY,
618 static int ie_RESUME_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
619 static int ie_SETUP[] = {IE_COMPLETE, IE_BEARER | IE_MANDATORY,
620 IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, IE_PROGRESS,
621 IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN,
622 IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR,
623 IE_LLC, IE_HLC, IE_USER_USER, -1};
624 static int ie_SETUP_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY,
625 IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1};
626 static int ie_STATUS[] = {IE_CAUSE | IE_MANDATORY, IE_CALL_STATE |
627 IE_MANDATORY, IE_DISPLAY, -1};
628 static int ie_STATUS_ENQUIRY[] = {IE_DISPLAY, -1};
629 static int ie_SUSPEND_ACKNOWLEDGE[] = {IE_DISPLAY, IE_FACILITY, -1};
630 static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
632 * static int ie_CONGESTION_CONTROL[] = {IE_CONGESTION | IE_MANDATORY,
633 * IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
634 * static int ie_USER_INFORMATION[] = {IE_MORE_DATA, IE_USER_USER | IE_MANDATORY, -1};
635 * static int ie_RESTART[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_RESTART_IND |
638 static int ie_FACILITY[] = {IE_FACILITY | IE_MANDATORY, IE_DISPLAY, -1};
639 static int comp_required[] = {1, 2, 3, 5, 6, 7, 9, 10, 11, 14, 15, -1};
640 static int l3_valid_states[] = {0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 15, 17, 19, 25, -1};
648 struct ie_len max_ie_len[] = {
666 {IE_PACK_BINPARA, 3},
667 {IE_PACK_WINSIZE, 4},
672 {IE_CALLING_SUB, 23},
685 getmax_ie_len(u_char ie) {
687 while (max_ie_len[i].ie != -1) {
688 if (max_ie_len[i].ie == ie)
689 return (max_ie_len[i].len);
696 ie_in_set(struct l3_process *pc, u_char ie, int *checklist) {
699 while (*checklist != -1) {
700 if ((*checklist & 0xff) == ie) {
713 check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist)
718 int l, newpos, oldpos;
719 int err_seq = 0, err_len = 0, err_compr = 0, err_ureg = 0;
721 u_char old_codeset = 0;
731 while ((p - skb->data) < skb->len) {
732 if ((*p & 0xf0) == 0x90) { /* shift codeset */
733 old_codeset = codeset;
739 if (pc->debug & L3_DEB_CHECK)
740 l3_debug(pc->st, "check IE shift%scodeset %d->%d",
741 codelock ? " locking " : " ", old_codeset, codeset);
745 if (!codeset) { /* only codeset 0 */
746 if ((newpos = ie_in_set(pc, *p, cl))) {
754 if (ie_in_set(pc, *p, comp_required))
768 if (!codeset && (l > getmax_ie_len(ie)))
771 if (pc->debug & L3_DEB_CHECK)
772 l3_debug(pc->st, "check IE shift back codeset %d->%d",
773 codeset, old_codeset);
774 codeset = old_codeset;
778 if (err_compr | err_ureg | err_len | err_seq) {
779 if (pc->debug & L3_DEB_CHECK)
780 l3_debug(pc->st, "check IE MT(%x) %d/%d/%d/%d",
781 mt, err_compr, err_ureg, err_len, err_seq);
783 return (ERR_IE_COMPREHENSION);
785 return (ERR_IE_UNRECOGNIZED);
787 return (ERR_IE_LENGTH);
789 return (ERR_IE_SEQUENCE);
794 /* verify if a message type exists and contain no IE error */
796 l3dss1_check_messagetype_validity(struct l3_process *pc, int mt, void *arg)
800 case MT_CALL_PROCEEDING:
802 case MT_CONNECT_ACKNOWLEDGE:
809 case MT_RELEASE_COMPLETE:
811 case MT_SETUP_ACKNOWLEDGE:
812 case MT_RESUME_ACKNOWLEDGE:
813 case MT_RESUME_REJECT:
814 case MT_SUSPEND_ACKNOWLEDGE:
815 case MT_SUSPEND_REJECT:
816 case MT_USER_INFORMATION:
818 case MT_RESTART_ACKNOWLEDGE:
819 case MT_CONGESTION_CONTROL:
821 case MT_STATUS_ENQUIRY:
822 if (pc->debug & L3_DEB_CHECK)
823 l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) OK", mt);
825 case MT_RESUME: /* RESUME only in user->net */
826 case MT_SUSPEND: /* SUSPEND only in user->net */
828 if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN))
829 l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) fail", mt);
831 l3dss1_status_send(pc, 0, NULL);
838 l3dss1_std_ie_err(struct l3_process *pc, int ret) {
840 if (pc->debug & L3_DEB_CHECK)
841 l3_debug(pc->st, "check_infoelements ret %d", ret);
845 case ERR_IE_COMPREHENSION:
847 l3dss1_status_send(pc, 0, NULL);
849 case ERR_IE_UNRECOGNIZED:
851 l3dss1_status_send(pc, 0, NULL);
854 pc->para.cause = 100;
855 l3dss1_status_send(pc, 0, NULL);
857 case ERR_IE_SEQUENCE:
864 l3dss1_get_channel_id(struct l3_process *pc, struct sk_buff *skb) {
868 if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
870 if (*p != 1) { /* len for BRI = 1 */
871 if (pc->debug & L3_DEB_WARN)
872 l3_debug(pc->st, "wrong chid len %d", *p);
876 if (*p & 0x60) { /* only base rate interface */
877 if (pc->debug & L3_DEB_WARN)
878 l3_debug(pc->st, "wrong chid %x", *p);
887 l3dss1_get_cause(struct l3_process *pc, struct sk_buff *skb) {
894 if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
905 if (l && !(pc->para.loc & 0x80)) {
907 p++; /* skip recommendation */
910 pc->para.cause = *p++;
912 if (!(pc->para.cause & 0x80))
916 while (l && (i < 6)) {
917 pc->para.diag[i++] = *p++;
926 l3dss1_msg_with_uus(struct l3_process *pc, u_char cmd)
933 MsgHead(p, pc->callref, cmd);
935 if (pc->prot.dss1.uus1_data[0])
936 { *p++ = IE_USER_USER; /* UUS info element */
937 *p++ = strlen(pc->prot.dss1.uus1_data) + 1;
938 *p++ = 0x04; /* IA5 chars */
939 strcpy(p, pc->prot.dss1.uus1_data);
940 p += strlen(pc->prot.dss1.uus1_data);
941 pc->prot.dss1.uus1_data[0] = '\0';
945 if (!(skb = l3_alloc_skb(l)))
947 skb_put_data(skb, tmp, l);
948 l3_msg(pc->st, DL_DATA | REQUEST, skb);
949 } /* l3dss1_msg_with_uus */
952 l3dss1_release_req(struct l3_process *pc, u_char pr, void *arg)
956 if (!pc->prot.dss1.uus1_data[0])
957 l3dss1_message(pc, MT_RELEASE);
959 l3dss1_msg_with_uus(pc, MT_RELEASE);
960 L3AddTimer(&pc->timer, T308, CC_T308_1);
964 l3dss1_release_cmpl(struct l3_process *pc, u_char pr, void *arg)
966 struct sk_buff *skb = arg;
969 if ((ret = l3dss1_get_cause(pc, skb)) > 0) {
970 if (pc->debug & L3_DEB_WARN)
971 l3_debug(pc->st, "RELCMPL get_cause ret(%d)", ret);
973 pc->para.cause = NO_CAUSE;
976 pc->st->l3.l3l4(pc->st, CC_RELEASE | CONFIRM, pc);
977 dss1_release_l3_process(pc);
980 #ifdef EXT_BEARER_CAPS
983 EncodeASyncParams(u_char *p, u_char si2)
984 { // 7c 06 88 90 21 42 00 bb
987 p[1] = 0x40; // Intermediate rate: 16 kbit/s jj 2000.02.19
989 if (si2 & 32) // 7 data bits
996 if (si2 & 16) // 2 stop bits
1003 if (si2 & 8) // even parity
1010 switch (si2 & 0x07) {
1012 p[0] = 66; // 1200 bit/s
1016 p[0] = 88; // 1200/75 bit/s
1020 p[0] = 87; // 75/1200 bit/s
1024 p[0] = 67; // 2400 bit/s
1028 p[0] = 69; // 4800 bit/s
1032 p[0] = 72; // 9600 bit/s
1036 p[0] = 73; // 14400 bit/s
1040 p[0] = 75; // 19200 bit/s
1048 EncodeSyncParams(u_char si2, u_char ai)
1053 return ai + 2; // 1200 bit/s
1056 return ai + 24; // 1200/75 bit/s
1059 return ai + 23; // 75/1200 bit/s
1062 return ai + 3; // 2400 bit/s
1065 return ai + 5; // 4800 bit/s
1068 return ai + 8; // 9600 bit/s
1071 return ai + 9; // 14400 bit/s
1074 return ai + 11; // 19200 bit/s
1077 return ai + 14; // 48000 bit/s
1080 return ai + 15; // 56000 bit/s
1083 return ai + 40; // negotiate bit/s
1093 DecodeASyncParams(u_char si2, u_char *p)
1098 case 66: // 1200 bit/s
1100 break; // si2 don't change
1102 case 88: // 1200/75 bit/s
1106 case 87: // 75/1200 bit/s
1110 case 67: // 2400 bit/s
1114 case 69: // 4800 bit/s
1118 case 72: // 9600 bit/s
1122 case 73: // 14400 bit/s
1126 case 75: // 19200 bit/s
1133 if ((info & 16) && (!(info & 8))) // 7 data bits
1135 si2 += 32; // else 8 data bits
1137 if ((info & 96) == 96) // 2 stop bits
1139 si2 += 16; // else 1 stop bit
1141 if ((info & 2) && (!(info & 1))) // even parity
1143 si2 += 8; // else no parity
1150 DecodeSyncParams(u_char si2, u_char info)
1154 case 40: // bit/s negotiation failed ai := 165 not 175!
1157 case 15: // 56000 bit/s failed, ai := 0 not 169 !
1160 case 14: // 48000 bit/s
1163 case 11: // 19200 bit/s
1166 case 9: // 14400 bit/s
1169 case 8: // 9600 bit/s
1172 case 5: // 4800 bit/s
1175 case 3: // 2400 bit/s
1178 case 23: // 75/1200 bit/s
1181 case 24: // 1200/75 bit/s
1184 default: // 1200 bit/s
1191 DecodeSI2(struct sk_buff *skb)
1193 u_char *p; //, *pend=skb->data + skb->len;
1195 if ((p = findie(skb->data, skb->len, 0x7c, 0))) {
1196 switch (p[4] & 0x0f) {
1198 if (p[1] == 0x04) // sync. Bitratenadaption
1200 return DecodeSyncParams(160, p[5]); // V.110/X.30
1202 else if (p[1] == 0x06) // async. Bitratenadaption
1204 return DecodeASyncParams(192, p); // V.110/X.30
1207 case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption
1209 return DecodeSyncParams(176, p[5]); // V.120
1220 l3dss1_setup_req(struct l3_process *pc, u_char pr,
1223 struct sk_buff *skb;
1229 u_char screen = 0x80;
1236 MsgHead(p, pc->callref, MT_SETUP);
1238 teln = pc->para.setup.phone;
1239 #ifndef CONFIG_HISAX_NO_KEYPAD
1240 send_keypad = (strchr(teln, '*') || strchr(teln, '#')) ? 1 : 0;
1244 #ifndef CONFIG_HISAX_NO_SENDCOMPLETE
1246 *p++ = 0xa1; /* complete indicator */
1249 * Set Bearer Capability, Map info from 1TR6-convention to EDSS1
1251 switch (pc->para.setup.si1) {
1252 case 1: /* Telephony */
1254 *p++ = 0x3; /* Length */
1255 *p++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1256 *p++ = 0x90; /* Circuit-Mode 64kbps */
1257 *p++ = 0xa3; /* A-Law Audio */
1259 case 5: /* Datatransmission 64k, BTX */
1260 case 7: /* Datatransmission 64k */
1263 *p++ = 0x2; /* Length */
1264 *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1265 *p++ = 0x90; /* Circuit-Mode 64kbps */
1271 *p++ = strlen(teln);
1273 *p++ = (*teln++) & 0x7F;
1277 * What about info2? Mapping to High-Layer-Compatibility?
1279 if ((*teln) && (!send_keypad)) {
1280 /* parse number for special things */
1281 if (!isdigit(*teln)) {
1282 switch (0x5f & *teln) {
1302 if (pc->debug & L3_DEB_WARN)
1303 l3_debug(pc->st, "Wrong MSN Code");
1310 *p++ = IE_CHANNEL_ID;
1314 msn = pc->para.setup.eazmsn;
1325 *p++ = IE_CALLING_PN;
1326 *p++ = strlen(msn) + (screen ? 2 : 1);
1327 /* Classify as AnyPref. */
1329 *p++ = 0x01; /* Ext = '0'B, Type = '000'B, Plan = '0001'B. */
1332 *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1334 *p++ = *msn++ & 0x7f;
1338 *p++ = IE_CALLING_SUB;
1339 *p++ = strlen(sub) + 2;
1340 *p++ = 0x80; /* NSAP coded */
1341 *p++ = 0x50; /* local IDI format */
1343 *p++ = *sub++ & 0x7f;
1356 *p++ = IE_CALLED_PN;
1357 *p++ = strlen(teln) + 1;
1358 /* Classify as AnyPref. */
1359 *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1361 *p++ = *teln++ & 0x7f;
1365 *p++ = IE_CALLED_SUB;
1366 *p++ = strlen(sub) + 2;
1367 *p++ = 0x80; /* NSAP coded */
1368 *p++ = 0x50; /* local IDI format */
1370 *p++ = *sub++ & 0x7f;
1373 #ifdef EXT_BEARER_CAPS
1374 if ((pc->para.setup.si2 >= 160) && (pc->para.setup.si2 <= 175)) { // sync. Bitratenadaption, V.110/X.30
1381 *p++ = EncodeSyncParams(pc->para.setup.si2 - 160, 0x80);
1382 } else if ((pc->para.setup.si2 >= 176) && (pc->para.setup.si2 <= 191)) { // sync. Bitratenadaption, V.120
1389 *p++ = EncodeSyncParams(pc->para.setup.si2 - 176, 0);
1391 } else if (pc->para.setup.si2 >= 192) { // async. Bitratenadaption, V.110/X.30
1398 p = EncodeASyncParams(p, pc->para.setup.si2 - 192);
1399 #ifndef CONFIG_HISAX_NO_LLC
1401 switch (pc->para.setup.si1) {
1402 case 1: /* Telephony */
1404 *p++ = 0x3; /* Length */
1405 *p++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1406 *p++ = 0x90; /* Circuit-Mode 64kbps */
1407 *p++ = 0xa3; /* A-Law Audio */
1409 case 5: /* Datatransmission 64k, BTX */
1410 case 7: /* Datatransmission 64k */
1413 *p++ = 0x2; /* Length */
1414 *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1415 *p++ = 0x90; /* Circuit-Mode 64kbps */
1422 if (!(skb = l3_alloc_skb(l)))
1424 skb_put_data(skb, tmp, l);
1425 L3DelTimer(&pc->timer);
1426 L3AddTimer(&pc->timer, T303, CC_T303);
1428 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1432 l3dss1_call_proc(struct l3_process *pc, u_char pr, void *arg)
1434 struct sk_buff *skb = arg;
1437 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1438 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
1439 if (pc->debug & L3_DEB_WARN)
1440 l3_debug(pc->st, "setup answer with wrong chid %x", id);
1441 pc->para.cause = 100;
1442 l3dss1_status_send(pc, pr, NULL);
1445 pc->para.bchannel = id;
1446 } else if (1 == pc->state) {
1447 if (pc->debug & L3_DEB_WARN)
1448 l3_debug(pc->st, "setup answer wrong chid (ret %d)", id);
1450 pc->para.cause = 96;
1452 pc->para.cause = 100;
1453 l3dss1_status_send(pc, pr, NULL);
1456 /* Now we are on none mandatory IEs */
1457 ret = check_infoelements(pc, skb, ie_CALL_PROCEEDING);
1458 if (ERR_IE_COMPREHENSION == ret) {
1459 l3dss1_std_ie_err(pc, ret);
1462 L3DelTimer(&pc->timer);
1464 L3AddTimer(&pc->timer, T310, CC_T310);
1465 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
1466 l3dss1_std_ie_err(pc, ret);
1467 pc->st->l3.l3l4(pc->st, CC_PROCEEDING | INDICATION, pc);
1471 l3dss1_setup_ack(struct l3_process *pc, u_char pr, void *arg)
1473 struct sk_buff *skb = arg;
1476 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1477 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
1478 if (pc->debug & L3_DEB_WARN)
1479 l3_debug(pc->st, "setup answer with wrong chid %x", id);
1480 pc->para.cause = 100;
1481 l3dss1_status_send(pc, pr, NULL);
1484 pc->para.bchannel = id;
1486 if (pc->debug & L3_DEB_WARN)
1487 l3_debug(pc->st, "setup answer wrong chid (ret %d)", id);
1489 pc->para.cause = 96;
1491 pc->para.cause = 100;
1492 l3dss1_status_send(pc, pr, NULL);
1495 /* Now we are on none mandatory IEs */
1496 ret = check_infoelements(pc, skb, ie_SETUP_ACKNOWLEDGE);
1497 if (ERR_IE_COMPREHENSION == ret) {
1498 l3dss1_std_ie_err(pc, ret);
1501 L3DelTimer(&pc->timer);
1503 L3AddTimer(&pc->timer, T304, CC_T304);
1504 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
1505 l3dss1_std_ie_err(pc, ret);
1506 pc->st->l3.l3l4(pc->st, CC_MORE_INFO | INDICATION, pc);
1510 l3dss1_disconnect(struct l3_process *pc, u_char pr, void *arg)
1512 struct sk_buff *skb = arg;
1518 if ((ret = l3dss1_get_cause(pc, skb))) {
1519 if (pc->debug & L3_DEB_WARN)
1520 l3_debug(pc->st, "DISC get_cause ret(%d)", ret);
1526 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0)))
1527 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
1528 ret = check_infoelements(pc, skb, ie_DISCONNECT);
1529 if (ERR_IE_COMPREHENSION == ret)
1531 else if ((!cause) && (ERR_IE_UNRECOGNIZED == ret))
1538 pc->st->l3.l3l4(pc->st, CC_DISCONNECT | INDICATION, pc);
1540 l3dss1_release_req(pc, pr, NULL);
1542 l3dss1_message_cause(pc, MT_RELEASE, cause);
1543 L3AddTimer(&pc->timer, T308, CC_T308_1);
1548 l3dss1_connect(struct l3_process *pc, u_char pr, void *arg)
1550 struct sk_buff *skb = arg;
1553 ret = check_infoelements(pc, skb, ie_CONNECT);
1554 if (ERR_IE_COMPREHENSION == ret) {
1555 l3dss1_std_ie_err(pc, ret);
1558 L3DelTimer(&pc->timer); /* T310 */
1560 pc->para.chargeinfo = 0;
1561 /* here should inserted COLP handling KKe */
1563 l3dss1_std_ie_err(pc, ret);
1564 pc->st->l3.l3l4(pc->st, CC_SETUP | CONFIRM, pc);
1568 l3dss1_alerting(struct l3_process *pc, u_char pr, void *arg)
1570 struct sk_buff *skb = arg;
1573 ret = check_infoelements(pc, skb, ie_ALERTING);
1574 if (ERR_IE_COMPREHENSION == ret) {
1575 l3dss1_std_ie_err(pc, ret);
1578 L3DelTimer(&pc->timer); /* T304 */
1581 l3dss1_std_ie_err(pc, ret);
1582 pc->st->l3.l3l4(pc->st, CC_ALERTING | INDICATION, pc);
1586 l3dss1_setup(struct l3_process *pc, u_char pr, void *arg)
1591 struct sk_buff *skb = arg;
1596 * Bearer Capabilities
1599 /* only the first occurrence 'll be detected ! */
1600 if ((p = findie(p, skb->len, 0x04, 0))) {
1601 if ((p[1] < 2) || (p[1] > 11))
1604 pc->para.setup.si2 = 0;
1605 switch (p[2] & 0x7f) {
1606 case 0x00: /* Speech */
1607 case 0x10: /* 3.1 Khz audio */
1608 pc->para.setup.si1 = 1;
1610 case 0x08: /* Unrestricted digital information */
1611 pc->para.setup.si1 = 7;
1612 /* JIM, 05.11.97 I wanna set service indicator 2 */
1613 #ifdef EXT_BEARER_CAPS
1614 pc->para.setup.si2 = DecodeSI2(skb);
1617 case 0x09: /* Restricted digital information */
1618 pc->para.setup.si1 = 2;
1621 /* Unrestr. digital information with
1622 * tones/announcements ( or 7 kHz audio
1624 pc->para.setup.si1 = 3;
1626 case 0x18: /* Video */
1627 pc->para.setup.si1 = 4;
1633 switch (p[3] & 0x7f) {
1634 case 0x40: /* packed mode */
1635 pc->para.setup.si1 = 8;
1637 case 0x10: /* 64 kbit */
1638 case 0x11: /* 2*64 kbit */
1639 case 0x13: /* 384 kbit */
1640 case 0x15: /* 1536 kbit */
1641 case 0x17: /* 1920 kbit */
1642 pc->para.moderate = p[3] & 0x7f;
1649 if (pc->debug & L3_DEB_SI)
1650 l3_debug(pc->st, "SI=%d, AI=%d",
1651 pc->para.setup.si1, pc->para.setup.si2);
1653 if (pc->debug & L3_DEB_WARN)
1654 l3_debug(pc->st, "setup with wrong bearer(l=%d:%x,%x)",
1656 pc->para.cause = 100;
1657 l3dss1_msg_without_setup(pc, pr, NULL);
1661 if (pc->debug & L3_DEB_WARN)
1662 l3_debug(pc->st, "setup without bearer capabilities");
1663 /* ETS 300-104 1.3.3 */
1664 pc->para.cause = 96;
1665 l3dss1_msg_without_setup(pc, pr, NULL);
1669 * Channel Identification
1671 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1672 if ((pc->para.bchannel = id)) {
1673 if ((3 == id) && (0x10 == pc->para.moderate)) {
1674 if (pc->debug & L3_DEB_WARN)
1675 l3_debug(pc->st, "setup with wrong chid %x",
1677 pc->para.cause = 100;
1678 l3dss1_msg_without_setup(pc, pr, NULL);
1683 { if (pc->debug & L3_DEB_WARN)
1684 l3_debug(pc->st, "setup without bchannel, call waiting");
1688 if (pc->debug & L3_DEB_WARN)
1689 l3_debug(pc->st, "setup with wrong chid ret %d", id);
1691 pc->para.cause = 96;
1693 pc->para.cause = 100;
1694 l3dss1_msg_without_setup(pc, pr, NULL);
1697 /* Now we are on none mandatory IEs */
1698 err = check_infoelements(pc, skb, ie_SETUP);
1699 if (ERR_IE_COMPREHENSION == err) {
1700 pc->para.cause = 96;
1701 l3dss1_msg_without_setup(pc, pr, NULL);
1705 if ((p = findie(p, skb->len, 0x70, 0)))
1706 iecpy(pc->para.setup.eazmsn, p, 1);
1708 pc->para.setup.eazmsn[0] = 0;
1711 if ((p = findie(p, skb->len, 0x71, 0))) {
1712 /* Called party subaddress */
1713 if ((p[1] >= 2) && (p[2] == 0x80) && (p[3] == 0x50)) {
1715 iecpy(&tmp[1], p, 2);
1716 strcat(pc->para.setup.eazmsn, tmp);
1717 } else if (pc->debug & L3_DEB_WARN)
1718 l3_debug(pc->st, "wrong called subaddress");
1721 if ((p = findie(p, skb->len, 0x6c, 0))) {
1722 pc->para.setup.plan = p[2];
1724 iecpy(pc->para.setup.phone, p, 1);
1725 pc->para.setup.screen = 0;
1727 iecpy(pc->para.setup.phone, p, 2);
1728 pc->para.setup.screen = p[3];
1731 pc->para.setup.phone[0] = 0;
1732 pc->para.setup.plan = 0;
1733 pc->para.setup.screen = 0;
1736 if ((p = findie(p, skb->len, 0x6d, 0))) {
1737 /* Calling party subaddress */
1738 if ((p[1] >= 2) && (p[2] == 0x80) && (p[3] == 0x50)) {
1740 iecpy(&tmp[1], p, 2);
1741 strcat(pc->para.setup.phone, tmp);
1742 } else if (pc->debug & L3_DEB_WARN)
1743 l3_debug(pc->st, "wrong calling subaddress");
1746 if (err) /* STATUS for none mandatory IE errors after actions are taken */
1747 l3dss1_std_ie_err(pc, err);
1748 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
1752 l3dss1_reset(struct l3_process *pc, u_char pr, void *arg)
1754 dss1_release_l3_process(pc);
1758 l3dss1_disconnect_req(struct l3_process *pc, u_char pr, void *arg)
1760 struct sk_buff *skb;
1761 u_char tmp[16 + 40];
1766 if (pc->para.cause != NO_CAUSE)
1767 cause = pc->para.cause;
1771 MsgHead(p, pc->callref, MT_DISCONNECT);
1776 *p++ = cause | 0x80;
1778 if (pc->prot.dss1.uus1_data[0])
1779 { *p++ = IE_USER_USER; /* UUS info element */
1780 *p++ = strlen(pc->prot.dss1.uus1_data) + 1;
1781 *p++ = 0x04; /* IA5 chars */
1782 strcpy(p, pc->prot.dss1.uus1_data);
1783 p += strlen(pc->prot.dss1.uus1_data);
1784 pc->prot.dss1.uus1_data[0] = '\0';
1788 if (!(skb = l3_alloc_skb(l)))
1790 skb_put_data(skb, tmp, l);
1792 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1793 L3AddTimer(&pc->timer, T305, CC_T305);
1797 l3dss1_setup_rsp(struct l3_process *pc, u_char pr,
1800 if (!pc->para.bchannel)
1801 { if (pc->debug & L3_DEB_WARN)
1802 l3_debug(pc->st, "D-chan connect for waiting call");
1803 l3dss1_disconnect_req(pc, pr, arg);
1807 l3dss1_message(pc, MT_CONNECT);
1808 L3DelTimer(&pc->timer);
1809 L3AddTimer(&pc->timer, T313, CC_T313);
1813 l3dss1_connect_ack(struct l3_process *pc, u_char pr, void *arg)
1815 struct sk_buff *skb = arg;
1818 ret = check_infoelements(pc, skb, ie_CONNECT_ACKNOWLEDGE);
1819 if (ERR_IE_COMPREHENSION == ret) {
1820 l3dss1_std_ie_err(pc, ret);
1824 L3DelTimer(&pc->timer);
1826 l3dss1_std_ie_err(pc, ret);
1827 pc->st->l3.l3l4(pc->st, CC_SETUP_COMPL | INDICATION, pc);
1831 l3dss1_reject_req(struct l3_process *pc, u_char pr, void *arg)
1833 struct sk_buff *skb;
1839 if (pc->para.cause != NO_CAUSE)
1840 cause = pc->para.cause;
1842 MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
1847 *p++ = cause | 0x80;
1850 if (!(skb = l3_alloc_skb(l)))
1852 skb_put_data(skb, tmp, l);
1853 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1854 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
1856 dss1_release_l3_process(pc);
1860 l3dss1_release(struct l3_process *pc, u_char pr, void *arg)
1862 struct sk_buff *skb = arg;
1867 if ((ret = l3dss1_get_cause(pc, skb)) > 0) {
1868 if (pc->debug & L3_DEB_WARN)
1869 l3_debug(pc->st, "REL get_cause ret(%d)", ret);
1871 pc->para.cause = NO_CAUSE;
1872 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) {
1873 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
1875 if ((ret < 0) && (pc->state != 11))
1879 ret = check_infoelements(pc, skb, ie_RELEASE);
1880 if (ERR_IE_COMPREHENSION == ret)
1882 else if ((ERR_IE_UNRECOGNIZED == ret) && (!cause))
1885 l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, cause);
1887 l3dss1_message(pc, MT_RELEASE_COMPLETE);
1888 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
1890 dss1_release_l3_process(pc);
1894 l3dss1_alert_req(struct l3_process *pc, u_char pr,
1898 if (!pc->prot.dss1.uus1_data[0])
1899 l3dss1_message(pc, MT_ALERTING);
1901 l3dss1_msg_with_uus(pc, MT_ALERTING);
1905 l3dss1_proceed_req(struct l3_process *pc, u_char pr,
1909 l3dss1_message(pc, MT_CALL_PROCEEDING);
1910 pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc);
1914 l3dss1_setup_ack_req(struct l3_process *pc, u_char pr,
1918 L3DelTimer(&pc->timer);
1919 L3AddTimer(&pc->timer, T302, CC_T302);
1920 l3dss1_message(pc, MT_SETUP_ACKNOWLEDGE);
1923 /********************************************/
1924 /* deliver a incoming display message to HL */
1925 /********************************************/
1927 l3dss1_deliver_display(struct l3_process *pc, int pr, u_char *infp)
1930 struct IsdnCardState *cs;
1933 if (*infp++ != IE_DISPLAY) return;
1934 if ((len = *infp++) > 80) return; /* total length <= 82 */
1935 if (!pc->chan) return;
1937 p = ic.parm.display;
1941 ic.command = ISDN_STAT_DISPLAY;
1942 cs = pc->st->l1.hardware;
1943 ic.driver = cs->myid;
1944 ic.arg = pc->chan->chan;
1945 cs->iif.statcallb(&ic);
1946 } /* l3dss1_deliver_display */
1950 l3dss1_progress(struct l3_process *pc, u_char pr, void *arg)
1952 struct sk_buff *skb = arg;
1956 if ((p = findie(skb->data, skb->len, IE_PROGRESS, 0))) {
1959 pc->para.cause = 100;
1960 } else if (!(p[2] & 0x70)) {
1978 pc->para.cause = 100;
1984 pc->para.cause = 100;
1989 pc->para.cause = 96;
1993 if (pc->debug & L3_DEB_WARN)
1994 l3_debug(pc->st, "progress error %d", err);
1995 l3dss1_status_send(pc, pr, NULL);
1998 /* Now we are on none mandatory IEs */
1999 err = check_infoelements(pc, skb, ie_PROGRESS);
2001 l3dss1_std_ie_err(pc, err);
2002 if (ERR_IE_COMPREHENSION != err)
2003 pc->st->l3.l3l4(pc->st, CC_PROGRESS | INDICATION, pc);
2007 l3dss1_notify(struct l3_process *pc, u_char pr, void *arg)
2009 struct sk_buff *skb = arg;
2013 if ((p = findie(skb->data, skb->len, IE_NOTIFY, 0))) {
2016 pc->para.cause = 100;
2024 pc->para.cause = 100;
2030 pc->para.cause = 96;
2034 if (pc->debug & L3_DEB_WARN)
2035 l3_debug(pc->st, "notify error %d", err);
2036 l3dss1_status_send(pc, pr, NULL);
2039 /* Now we are on none mandatory IEs */
2040 err = check_infoelements(pc, skb, ie_NOTIFY);
2042 l3dss1_std_ie_err(pc, err);
2043 if (ERR_IE_COMPREHENSION != err)
2044 pc->st->l3.l3l4(pc->st, CC_NOTIFY | INDICATION, pc);
2048 l3dss1_status_enq(struct l3_process *pc, u_char pr, void *arg)
2051 struct sk_buff *skb = arg;
2053 ret = check_infoelements(pc, skb, ie_STATUS_ENQUIRY);
2054 l3dss1_std_ie_err(pc, ret);
2055 pc->para.cause = 30; /* response to STATUS_ENQUIRY */
2056 l3dss1_status_send(pc, pr, NULL);
2060 l3dss1_information(struct l3_process *pc, u_char pr, void *arg)
2063 struct sk_buff *skb = arg;
2067 ret = check_infoelements(pc, skb, ie_INFORMATION);
2069 l3dss1_std_ie_err(pc, ret);
2070 if (pc->state == 25) { /* overlap receiving */
2071 L3DelTimer(&pc->timer);
2073 if ((p = findie(p, skb->len, 0x70, 0))) {
2075 strcat(pc->para.setup.eazmsn, tmp);
2076 pc->st->l3.l3l4(pc->st, CC_MORE_INFO | INDICATION, pc);
2078 L3AddTimer(&pc->timer, T302, CC_T302);
2082 /******************************/
2083 /* handle deflection requests */
2084 /******************************/
2085 static void l3dss1_redir_req(struct l3_process *pc, u_char pr, void *arg)
2087 struct sk_buff *skb;
2091 u_char len_phone = 0;
2096 strcpy(pc->prot.dss1.uus1_data, pc->chan->setup.eazmsn); /* copy uus element if available */
2097 if (!pc->chan->setup.phone[0])
2098 { pc->para.cause = -1;
2099 l3dss1_disconnect_req(pc, pr, arg); /* disconnect immediately */
2103 if (pc->prot.dss1.invoke_id)
2104 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
2106 if (!(pc->prot.dss1.invoke_id = new_invoke_id(pc->st)))
2109 MsgHead(p, pc->callref, MT_FACILITY);
2111 for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */
2112 if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */
2114 *p++ = 0x1c; /* Facility info element */
2115 *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */
2116 *p++ = 0x91; /* remote operations protocol */
2117 *p++ = 0xa1; /* invoke component */
2119 *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */
2120 *p++ = 0x02; /* invoke id tag, integer */
2121 *p++ = 0x01; /* length */
2122 *p++ = pc->prot.dss1.invoke_id; /* invoke id */
2123 *p++ = 0x02; /* operation value tag, integer */
2124 *p++ = 0x01; /* length */
2125 *p++ = 0x0D; /* Call Deflect */
2127 *p++ = 0x30; /* sequence phone number */
2128 *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */
2130 *p++ = 0x30; /* Deflected to UserNumber */
2131 *p++ = len_phone + 2 + len_sub; /* length */
2132 *p++ = 0x80; /* NumberDigits */
2133 *p++ = len_phone; /* length */
2134 for (l = 0; l < len_phone; l++)
2135 *p++ = pc->chan->setup.phone[l];
2138 { *p++ = 0x04; /* called party subaddress */
2140 while (*subp) *p++ = *subp++;
2143 *p++ = 0x01; /* screening identifier */
2145 *p++ = pc->chan->setup.screen;
2148 if (!(skb = l3_alloc_skb(l))) return;
2149 skb_put_data(skb, tmp, l);
2151 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2152 } /* l3dss1_redir_req */
2154 /********************************************/
2155 /* handle deflection request in early state */
2156 /********************************************/
2157 static void l3dss1_redir_req_early(struct l3_process *pc, u_char pr, void *arg)
2159 l3dss1_proceed_req(pc, pr, arg);
2160 l3dss1_redir_req(pc, pr, arg);
2161 } /* l3dss1_redir_req_early */
2163 /***********************************************/
2164 /* handle special commands for this protocol. */
2165 /* Examples are call independent services like */
2166 /* remote operations with dummy callref. */
2167 /***********************************************/
2168 static int l3dss1_cmd_global(struct PStack *st, isdn_ctrl *ic)
2173 struct sk_buff *skb;
2174 struct l3_process *pc = NULL;
2177 { case DSS1_CMD_INVOKE:
2178 if (ic->parm.dss1_io.datalen < 0) return (-2); /* invalid parameter */
2180 for (proc_len = 1, i = ic->parm.dss1_io.proc >> 8; i; i++)
2181 i = i >> 8; /* add one byte */
2182 l = ic->parm.dss1_io.datalen + proc_len + 8; /* length excluding ie header */
2184 return (-2); /* too long */
2186 if (!(id = new_invoke_id(st)))
2187 return (0); /* first get a invoke id -> return if no available */
2190 MsgHead(p, i, MT_FACILITY); /* build message head */
2191 *p++ = 0x1C; /* Facility IE */
2192 *p++ = l; /* length of ie */
2193 *p++ = 0x91; /* remote operations */
2194 *p++ = 0xA1; /* invoke */
2195 *p++ = l - 3; /* length of invoke */
2196 *p++ = 0x02; /* invoke id tag */
2197 *p++ = 0x01; /* length is 1 */
2198 *p++ = id; /* invoke id */
2199 *p++ = 0x02; /* operation */
2200 *p++ = proc_len; /* length of operation */
2202 for (i = proc_len; i; i--)
2203 *p++ = (ic->parm.dss1_io.proc >> (i - 1)) & 0xFF;
2204 memcpy(p, ic->parm.dss1_io.data, ic->parm.dss1_io.datalen); /* copy data */
2205 l = (p - temp) + ic->parm.dss1_io.datalen; /* total length */
2207 if (ic->parm.dss1_io.timeout > 0)
2208 if (!(pc = dss1_new_l3_process(st, -1)))
2209 { free_invoke_id(st, id);
2212 pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */
2213 pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */
2215 if (!(skb = l3_alloc_skb(l)))
2216 { free_invoke_id(st, id);
2217 if (pc) dss1_release_l3_process(pc);
2220 skb_put_data(skb, temp, l);
2223 { pc->prot.dss1.invoke_id = id; /* remember id */
2224 L3AddTimer(&pc->timer, ic->parm.dss1_io.timeout, CC_TDSS1_IO | REQUEST);
2227 l3_msg(st, DL_DATA | REQUEST, skb);
2228 ic->parm.dss1_io.hl_id = id; /* return id */
2231 case DSS1_CMD_INVOKE_ABORT:
2232 if ((pc = l3dss1_search_dummy_proc(st, ic->parm.dss1_io.hl_id)))
2233 { L3DelTimer(&pc->timer); /* remove timer */
2234 dss1_release_l3_process(pc);
2238 { l3_debug(st, "l3dss1_cmd_global abort unknown id");
2244 l3_debug(st, "l3dss1_cmd_global unknown cmd 0x%lx", ic->arg);
2246 } /* switch ic-> arg */
2248 } /* l3dss1_cmd_global */
2251 l3dss1_io_timer(struct l3_process *pc)
2253 struct IsdnCardState *cs = pc->st->l1.hardware;
2255 L3DelTimer(&pc->timer); /* remove timer */
2257 ic.driver = cs->myid;
2258 ic.command = ISDN_STAT_PROT;
2259 ic.arg = DSS1_STAT_INVOKE_ERR;
2260 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
2261 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
2262 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
2263 ic.parm.dss1_io.timeout = -1;
2264 ic.parm.dss1_io.datalen = 0;
2265 ic.parm.dss1_io.data = NULL;
2266 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
2267 pc->prot.dss1.invoke_id = 0; /* reset id */
2269 cs->iif.statcallb(&ic);
2271 dss1_release_l3_process(pc);
2272 } /* l3dss1_io_timer */
2275 l3dss1_release_ind(struct l3_process *pc, u_char pr, void *arg)
2278 struct sk_buff *skb = arg;
2282 if ((p = findie(p, skb->len, IE_CALL_STATE, 0))) {
2287 if (callState == 0) {
2288 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1... and 16.1
2289 * set down layer 3 without sending any message
2291 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2293 dss1_release_l3_process(pc);
2295 pc->st->l3.l3l4(pc->st, CC_IGNORE | INDICATION, pc);
2300 l3dss1_dummy(struct l3_process *pc, u_char pr, void *arg)
2305 l3dss1_t302(struct l3_process *pc, u_char pr, void *arg)
2307 L3DelTimer(&pc->timer);
2309 pc->para.cause = 28; /* invalid number */
2310 l3dss1_disconnect_req(pc, pr, NULL);
2311 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2315 l3dss1_t303(struct l3_process *pc, u_char pr, void *arg)
2319 L3DelTimer(&pc->timer);
2320 l3dss1_setup_req(pc, pr, arg);
2322 L3DelTimer(&pc->timer);
2323 l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, 102);
2324 pc->st->l3.l3l4(pc->st, CC_NOSETUP_RSP, pc);
2325 dss1_release_l3_process(pc);
2330 l3dss1_t304(struct l3_process *pc, u_char pr, void *arg)
2332 L3DelTimer(&pc->timer);
2334 pc->para.cause = 102;
2335 l3dss1_disconnect_req(pc, pr, NULL);
2336 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2341 l3dss1_t305(struct l3_process *pc, u_char pr, void *arg)
2346 struct sk_buff *skb;
2349 L3DelTimer(&pc->timer);
2350 if (pc->para.cause != NO_CAUSE)
2351 cause = pc->para.cause;
2353 MsgHead(p, pc->callref, MT_RELEASE);
2358 *p++ = cause | 0x80;
2361 if (!(skb = l3_alloc_skb(l)))
2363 skb_put_data(skb, tmp, l);
2365 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2366 L3AddTimer(&pc->timer, T308, CC_T308_1);
2370 l3dss1_t310(struct l3_process *pc, u_char pr, void *arg)
2372 L3DelTimer(&pc->timer);
2374 pc->para.cause = 102;
2375 l3dss1_disconnect_req(pc, pr, NULL);
2376 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2380 l3dss1_t313(struct l3_process *pc, u_char pr, void *arg)
2382 L3DelTimer(&pc->timer);
2384 pc->para.cause = 102;
2385 l3dss1_disconnect_req(pc, pr, NULL);
2386 pc->st->l3.l3l4(pc->st, CC_CONNECT_ERR, pc);
2390 l3dss1_t308_1(struct l3_process *pc, u_char pr, void *arg)
2393 L3DelTimer(&pc->timer);
2394 l3dss1_message(pc, MT_RELEASE);
2395 L3AddTimer(&pc->timer, T308, CC_T308_2);
2399 l3dss1_t308_2(struct l3_process *pc, u_char pr, void *arg)
2401 L3DelTimer(&pc->timer);
2402 pc->st->l3.l3l4(pc->st, CC_RELEASE_ERR, pc);
2403 dss1_release_l3_process(pc);
2407 l3dss1_t318(struct l3_process *pc, u_char pr, void *arg)
2409 L3DelTimer(&pc->timer);
2410 pc->para.cause = 102; /* Timer expiry */
2411 pc->para.loc = 0; /* local */
2412 pc->st->l3.l3l4(pc->st, CC_RESUME_ERR, pc);
2414 l3dss1_message(pc, MT_RELEASE);
2415 L3AddTimer(&pc->timer, T308, CC_T308_1);
2419 l3dss1_t319(struct l3_process *pc, u_char pr, void *arg)
2421 L3DelTimer(&pc->timer);
2422 pc->para.cause = 102; /* Timer expiry */
2423 pc->para.loc = 0; /* local */
2424 pc->st->l3.l3l4(pc->st, CC_SUSPEND_ERR, pc);
2429 l3dss1_restart(struct l3_process *pc, u_char pr, void *arg)
2431 L3DelTimer(&pc->timer);
2432 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2433 dss1_release_l3_process(pc);
2437 l3dss1_status(struct l3_process *pc, u_char pr, void *arg)
2440 struct sk_buff *skb = arg;
2442 u_char cause = 0, callState = 0;
2444 if ((ret = l3dss1_get_cause(pc, skb))) {
2445 if (pc->debug & L3_DEB_WARN)
2446 l3_debug(pc->st, "STATUS get_cause ret(%d)", ret);
2452 if ((p = findie(skb->data, skb->len, IE_CALL_STATE, 0))) {
2456 if (!ie_in_set(pc, *p, l3_valid_states))
2462 if (!cause) { /* no error before */
2463 ret = check_infoelements(pc, skb, ie_STATUS);
2464 if (ERR_IE_COMPREHENSION == ret)
2466 else if (ERR_IE_UNRECOGNIZED == ret)
2472 if (pc->debug & L3_DEB_WARN)
2473 l3_debug(pc->st, "STATUS error(%d/%d)", ret, cause);
2474 tmp = pc->para.cause;
2475 pc->para.cause = cause;
2476 l3dss1_status_send(pc, 0, NULL);
2478 pc->para.cause = tmp;
2482 cause = pc->para.cause;
2483 if (((cause & 0x7f) == 111) && (callState == 0)) {
2484 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1...
2485 * if received MT_STATUS with cause == 111 and call
2486 * state == 0, then we must set down layer 3
2488 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2490 dss1_release_l3_process(pc);
2495 l3dss1_facility(struct l3_process *pc, u_char pr, void *arg)
2497 struct sk_buff *skb = arg;
2500 ret = check_infoelements(pc, skb, ie_FACILITY);
2501 l3dss1_std_ie_err(pc, ret);
2504 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0)))
2505 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
2510 l3dss1_suspend_req(struct l3_process *pc, u_char pr, void *arg)
2512 struct sk_buff *skb;
2516 u_char *msg = pc->chan->setup.phone;
2518 MsgHead(p, pc->callref, MT_SUSPEND);
2520 if (l && (l <= 10)) { /* Max length 10 octets */
2523 for (i = 0; i < l; i++)
2526 l3_debug(pc->st, "SUS wrong CALL_ID len %d", l);
2530 if (!(skb = l3_alloc_skb(l)))
2532 skb_put_data(skb, tmp, l);
2533 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2535 L3AddTimer(&pc->timer, T319, CC_T319);
2539 l3dss1_suspend_ack(struct l3_process *pc, u_char pr, void *arg)
2541 struct sk_buff *skb = arg;
2544 L3DelTimer(&pc->timer);
2546 pc->para.cause = NO_CAUSE;
2547 pc->st->l3.l3l4(pc->st, CC_SUSPEND | CONFIRM, pc);
2548 /* We don't handle suspend_ack for IE errors now */
2549 if ((ret = check_infoelements(pc, skb, ie_SUSPEND_ACKNOWLEDGE)))
2550 if (pc->debug & L3_DEB_WARN)
2551 l3_debug(pc->st, "SUSPACK check ie(%d)", ret);
2552 dss1_release_l3_process(pc);
2556 l3dss1_suspend_rej(struct l3_process *pc, u_char pr, void *arg)
2558 struct sk_buff *skb = arg;
2561 if ((ret = l3dss1_get_cause(pc, skb))) {
2562 if (pc->debug & L3_DEB_WARN)
2563 l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)", ret);
2565 pc->para.cause = 96;
2567 pc->para.cause = 100;
2568 l3dss1_status_send(pc, pr, NULL);
2571 ret = check_infoelements(pc, skb, ie_SUSPEND_REJECT);
2572 if (ERR_IE_COMPREHENSION == ret) {
2573 l3dss1_std_ie_err(pc, ret);
2576 L3DelTimer(&pc->timer);
2577 pc->st->l3.l3l4(pc->st, CC_SUSPEND_ERR, pc);
2579 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2580 l3dss1_std_ie_err(pc, ret);
2584 l3dss1_resume_req(struct l3_process *pc, u_char pr, void *arg)
2586 struct sk_buff *skb;
2590 u_char *msg = pc->para.setup.phone;
2592 MsgHead(p, pc->callref, MT_RESUME);
2595 if (l && (l <= 10)) { /* Max length 10 octets */
2598 for (i = 0; i < l; i++)
2601 l3_debug(pc->st, "RES wrong CALL_ID len %d", l);
2605 if (!(skb = l3_alloc_skb(l)))
2607 skb_put_data(skb, tmp, l);
2608 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2610 L3AddTimer(&pc->timer, T318, CC_T318);
2614 l3dss1_resume_ack(struct l3_process *pc, u_char pr, void *arg)
2616 struct sk_buff *skb = arg;
2619 if ((id = l3dss1_get_channel_id(pc, skb)) > 0) {
2620 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
2621 if (pc->debug & L3_DEB_WARN)
2622 l3_debug(pc->st, "resume ack with wrong chid %x", id);
2623 pc->para.cause = 100;
2624 l3dss1_status_send(pc, pr, NULL);
2627 pc->para.bchannel = id;
2628 } else if (1 == pc->state) {
2629 if (pc->debug & L3_DEB_WARN)
2630 l3_debug(pc->st, "resume ack without chid (ret %d)", id);
2631 pc->para.cause = 96;
2632 l3dss1_status_send(pc, pr, NULL);
2635 ret = check_infoelements(pc, skb, ie_RESUME_ACKNOWLEDGE);
2636 if (ERR_IE_COMPREHENSION == ret) {
2637 l3dss1_std_ie_err(pc, ret);
2640 L3DelTimer(&pc->timer);
2641 pc->st->l3.l3l4(pc->st, CC_RESUME | CONFIRM, pc);
2643 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2644 l3dss1_std_ie_err(pc, ret);
2648 l3dss1_resume_rej(struct l3_process *pc, u_char pr, void *arg)
2650 struct sk_buff *skb = arg;
2653 if ((ret = l3dss1_get_cause(pc, skb))) {
2654 if (pc->debug & L3_DEB_WARN)
2655 l3_debug(pc->st, "RES_REJ get_cause ret(%d)", ret);
2657 pc->para.cause = 96;
2659 pc->para.cause = 100;
2660 l3dss1_status_send(pc, pr, NULL);
2663 ret = check_infoelements(pc, skb, ie_RESUME_REJECT);
2664 if (ERR_IE_COMPREHENSION == ret) {
2665 l3dss1_std_ie_err(pc, ret);
2668 L3DelTimer(&pc->timer);
2669 pc->st->l3.l3l4(pc->st, CC_RESUME_ERR, pc);
2671 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2672 l3dss1_std_ie_err(pc, ret);
2673 dss1_release_l3_process(pc);
2677 l3dss1_global_restart(struct l3_process *pc, u_char pr, void *arg)
2681 u_char ri, ch = 0, chan = 0;
2683 struct sk_buff *skb = arg;
2684 struct l3_process *up;
2687 L3DelTimer(&pc->timer);
2689 if ((p = findie(p, skb->len, IE_RESTART_IND, 0))) {
2691 l3_debug(pc->st, "Restart %x", ri);
2693 l3_debug(pc->st, "Restart without restart IE");
2697 if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
2700 if (pc->st->l3.debug)
2701 l3_debug(pc->st, "Restart for channel %d", chan);
2704 up = pc->st->l3.proc;
2707 up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up);
2708 else if (up->para.bchannel == chan)
2709 up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up);
2713 MsgHead(p, pc->callref, MT_RESTART_ACKNOWLEDGE);
2715 *p++ = IE_CHANNEL_ID;
2719 *p++ = 0x79; /* RESTART Ind */
2723 if (!(skb = l3_alloc_skb(l)))
2725 skb_put_data(skb, tmp, l);
2727 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2731 l3dss1_dl_reset(struct l3_process *pc, u_char pr, void *arg)
2733 pc->para.cause = 0x29; /* Temporary failure */
2735 l3dss1_disconnect_req(pc, pr, NULL);
2736 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2740 l3dss1_dl_release(struct l3_process *pc, u_char pr, void *arg)
2743 pc->para.cause = 0x1b; /* Destination out of order */
2745 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2746 release_l3_process(pc);
2750 l3dss1_dl_reestablish(struct l3_process *pc, u_char pr, void *arg)
2752 L3DelTimer(&pc->timer);
2753 L3AddTimer(&pc->timer, T309, CC_T309);
2754 l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL);
2758 l3dss1_dl_reest_status(struct l3_process *pc, u_char pr, void *arg)
2760 L3DelTimer(&pc->timer);
2762 pc->para.cause = 0x1F; /* normal, unspecified */
2763 l3dss1_status_send(pc, 0, NULL);
2767 static struct stateentry downstatelist[] =
2770 CC_SETUP | REQUEST, l3dss1_setup_req},
2772 CC_RESUME | REQUEST, l3dss1_resume_req},
2773 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(25),
2774 CC_DISCONNECT | REQUEST, l3dss1_disconnect_req},
2776 CC_RELEASE | REQUEST, l3dss1_release_req},
2778 CC_RESTART | REQUEST, l3dss1_restart},
2779 {SBIT(6) | SBIT(25),
2780 CC_IGNORE | REQUEST, l3dss1_reset},
2781 {SBIT(6) | SBIT(25),
2782 CC_REJECT | REQUEST, l3dss1_reject_req},
2783 {SBIT(6) | SBIT(25),
2784 CC_PROCEED_SEND | REQUEST, l3dss1_proceed_req},
2786 CC_MORE_INFO | REQUEST, l3dss1_setup_ack_req},
2788 CC_MORE_INFO | REQUEST, l3dss1_dummy},
2789 {SBIT(6) | SBIT(9) | SBIT(25),
2790 CC_ALERTING | REQUEST, l3dss1_alert_req},
2791 {SBIT(6) | SBIT(7) | SBIT(9) | SBIT(25),
2792 CC_SETUP | RESPONSE, l3dss1_setup_rsp},
2794 CC_SUSPEND | REQUEST, l3dss1_suspend_req},
2795 {SBIT(7) | SBIT(9) | SBIT(25),
2796 CC_REDIR | REQUEST, l3dss1_redir_req},
2798 CC_REDIR | REQUEST, l3dss1_redir_req_early},
2799 {SBIT(9) | SBIT(25),
2800 CC_DISCONNECT | REQUEST, l3dss1_disconnect_req},
2802 CC_T302, l3dss1_t302},
2804 CC_T303, l3dss1_t303},
2806 CC_T304, l3dss1_t304},
2808 CC_T310, l3dss1_t310},
2810 CC_T313, l3dss1_t313},
2812 CC_T305, l3dss1_t305},
2814 CC_T319, l3dss1_t319},
2816 CC_T318, l3dss1_t318},
2818 CC_T308_1, l3dss1_t308_1},
2820 CC_T308_2, l3dss1_t308_2},
2822 CC_T309, l3dss1_dl_release},
2825 static struct stateentry datastatelist[] =
2828 MT_STATUS_ENQUIRY, l3dss1_status_enq},
2830 MT_FACILITY, l3dss1_facility},
2832 MT_STATUS, l3dss1_release_ind},
2834 MT_STATUS, l3dss1_status},
2836 MT_SETUP, l3dss1_setup},
2837 {SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(12) |
2838 SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2839 MT_SETUP, l3dss1_dummy},
2841 MT_CALL_PROCEEDING, l3dss1_call_proc},
2843 MT_SETUP_ACKNOWLEDGE, l3dss1_setup_ack},
2845 MT_ALERTING, l3dss1_alerting},
2847 MT_PROGRESS, l3dss1_progress},
2848 {SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) |
2849 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2850 MT_INFORMATION, l3dss1_information},
2851 {SBIT(10) | SBIT(11) | SBIT(15),
2852 MT_NOTIFY, l3dss1_notify},
2853 {SBIT(0) | SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
2854 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2855 MT_RELEASE_COMPLETE, l3dss1_release_cmpl},
2856 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(25),
2857 MT_RELEASE, l3dss1_release},
2858 {SBIT(19), MT_RELEASE, l3dss1_release_ind},
2859 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(15) | SBIT(17) | SBIT(25),
2860 MT_DISCONNECT, l3dss1_disconnect},
2862 MT_DISCONNECT, l3dss1_dummy},
2863 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4),
2864 MT_CONNECT, l3dss1_connect},
2866 MT_CONNECT_ACKNOWLEDGE, l3dss1_connect_ack},
2868 MT_SUSPEND_ACKNOWLEDGE, l3dss1_suspend_ack},
2870 MT_SUSPEND_REJECT, l3dss1_suspend_rej},
2872 MT_RESUME_ACKNOWLEDGE, l3dss1_resume_ack},
2874 MT_RESUME_REJECT, l3dss1_resume_rej},
2877 static struct stateentry globalmes_list[] =
2880 MT_STATUS, l3dss1_status},
2882 MT_RESTART, l3dss1_global_restart},
2884 MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack},
2888 static struct stateentry manstatelist[] =
2891 DL_ESTABLISH | INDICATION, l3dss1_dl_reset},
2893 DL_ESTABLISH | CONFIRM, l3dss1_dl_reest_status},
2895 DL_RELEASE | INDICATION, l3dss1_dl_reestablish},
2897 DL_RELEASE | INDICATION, l3dss1_dl_release},
2904 global_handler(struct PStack *st, int mt, struct sk_buff *skb)
2910 struct l3_process *proc = st->l3.global;
2912 proc->callref = skb->data[2]; /* cr flag */
2913 for (i = 0; i < ARRAY_SIZE(globalmes_list); i++)
2914 if ((mt == globalmes_list[i].primitive) &&
2915 ((1 << proc->state) & globalmes_list[i].state))
2917 if (i == ARRAY_SIZE(globalmes_list)) {
2918 if (st->l3.debug & L3_DEB_STATE) {
2919 l3_debug(st, "dss1 global state %d mt %x unhandled",
2922 MsgHead(p, proc->callref, MT_STATUS);
2926 *p++ = 81 | 0x80; /* invalid cr */
2927 *p++ = 0x14; /* CallState */
2929 *p++ = proc->state & 0x3f;
2931 if (!(skb = l3_alloc_skb(l)))
2933 skb_put_data(skb, tmp, l);
2934 l3_msg(proc->st, DL_DATA | REQUEST, skb);
2936 if (st->l3.debug & L3_DEB_STATE) {
2937 l3_debug(st, "dss1 global %d mt %x",
2940 globalmes_list[i].rout(proc, mt, skb);
2945 dss1up(struct PStack *st, int pr, void *arg)
2947 int i, mt, cr, callState;
2950 struct sk_buff *skb = arg;
2951 struct l3_process *proc;
2954 case (DL_DATA | INDICATION):
2955 case (DL_UNIT_DATA | INDICATION):
2957 case (DL_ESTABLISH | CONFIRM):
2958 case (DL_ESTABLISH | INDICATION):
2959 case (DL_RELEASE | INDICATION):
2960 case (DL_RELEASE | CONFIRM):
2961 l3_msg(st, pr, arg);
2965 printk(KERN_ERR "HiSax dss1up unknown pr=%04x\n", pr);
2969 l3_debug(st, "dss1up frame too short(%d)", skb->len);
2974 if (skb->data[0] != PROTO_DIS_EURO) {
2975 if (st->l3.debug & L3_DEB_PROTERR) {
2976 l3_debug(st, "dss1up%sunexpected discriminator %x message len %d",
2977 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
2978 skb->data[0], skb->len);
2983 cr = getcallref(skb->data);
2984 if (skb->len < ((skb->data[1] & 0x0f) + 3)) {
2985 l3_debug(st, "dss1up frame too short(%d)", skb->len);
2989 mt = skb->data[skb->data[1] + 2];
2990 if (st->l3.debug & L3_DEB_STATE)
2991 l3_debug(st, "dss1up cr %d", cr);
2992 if (cr == -2) { /* wrong Callref */
2993 if (st->l3.debug & L3_DEB_WARN)
2994 l3_debug(st, "dss1up wrong Callref");
2997 } else if (cr == -1) { /* Dummy Callref */
2998 if (mt == MT_FACILITY)
2999 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) {
3000 l3dss1_parse_facility(st, NULL,
3001 (pr == (DL_DATA | INDICATION)) ? -1 : -2, p);
3005 if (st->l3.debug & L3_DEB_WARN)
3006 l3_debug(st, "dss1up dummy Callref (no facility msg or ie)");
3009 } else if ((((skb->data[1] & 0x0f) == 1) && (0 == (cr & 0x7f))) ||
3010 (((skb->data[1] & 0x0f) == 2) && (0 == (cr & 0x7fff)))) { /* Global CallRef */
3011 if (st->l3.debug & L3_DEB_STATE)
3012 l3_debug(st, "dss1up Global CallRef");
3013 global_handler(st, mt, skb);
3016 } else if (!(proc = getl3proc(st, cr))) {
3017 /* No transaction process exist, that means no call with
3018 * this callreference is active
3020 if (mt == MT_SETUP) {
3021 /* Setup creates a new transaction process */
3022 if (skb->data[2] & 0x80) {
3023 /* Setup with wrong CREF flag */
3024 if (st->l3.debug & L3_DEB_STATE)
3025 l3_debug(st, "dss1up wrong CRef flag");
3029 if (!(proc = dss1_new_l3_process(st, cr))) {
3030 /* May be to answer with RELEASE_COMPLETE and
3031 * CAUSE 0x2f "Resource unavailable", but this
3032 * need a new_l3_process too ... arghh
3037 } else if (mt == MT_STATUS) {
3038 if ((ptr = findie(skb->data, skb->len, IE_CAUSE, 0)) != NULL) {
3044 if ((ptr = findie(skb->data, skb->len, IE_CALL_STATE, 0)) != NULL) {
3050 /* ETS 300-104 part 2.4.1
3051 * if setup has not been made and a message type
3052 * MT_STATUS is received with call state == 0,
3053 * we must send nothing
3055 if (callState != 0) {
3056 /* ETS 300-104 part 2.4.2
3057 * if setup has not been made and a message type
3058 * MT_STATUS is received with call state != 0,
3059 * we must send MT_RELEASE_COMPLETE cause 101
3061 if ((proc = dss1_new_l3_process(st, cr))) {
3062 proc->para.cause = 101;
3063 l3dss1_msg_without_setup(proc, 0, NULL);
3068 } else if (mt == MT_RELEASE_COMPLETE) {
3072 /* ETS 300-104 part 2
3073 * if setup has not been made and a message type
3074 * (except MT_SETUP and RELEASE_COMPLETE) is received,
3075 * we must send MT_RELEASE_COMPLETE cause 81 */
3077 if ((proc = dss1_new_l3_process(st, cr))) {
3078 proc->para.cause = 81;
3079 l3dss1_msg_without_setup(proc, 0, NULL);
3084 if (l3dss1_check_messagetype_validity(proc, mt, skb)) {
3088 if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL)
3089 l3dss1_deliver_display(proc, pr, p); /* Display IE included */
3090 for (i = 0; i < ARRAY_SIZE(datastatelist); i++)
3091 if ((mt == datastatelist[i].primitive) &&
3092 ((1 << proc->state) & datastatelist[i].state))
3094 if (i == ARRAY_SIZE(datastatelist)) {
3095 if (st->l3.debug & L3_DEB_STATE) {
3096 l3_debug(st, "dss1up%sstate %d mt %#x unhandled",
3097 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
3100 if ((MT_RELEASE_COMPLETE != mt) && (MT_RELEASE != mt)) {
3101 proc->para.cause = 101;
3102 l3dss1_status_send(proc, pr, skb);
3105 if (st->l3.debug & L3_DEB_STATE) {
3106 l3_debug(st, "dss1up%sstate %d mt %x",
3107 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
3110 datastatelist[i].rout(proc, pr, skb);
3117 dss1down(struct PStack *st, int pr, void *arg)
3120 struct l3_process *proc;
3121 struct Channel *chan;
3123 if ((DL_ESTABLISH | REQUEST) == pr) {
3124 l3_msg(st, pr, NULL);
3126 } else if (((CC_SETUP | REQUEST) == pr) || ((CC_RESUME | REQUEST) == pr)) {
3130 if ((proc = dss1_new_l3_process(st, cr))) {
3133 memcpy(&proc->para.setup, &chan->setup, sizeof(setup_parm));
3140 printk(KERN_ERR "HiSax dss1down without proc pr=%04x\n", pr);
3144 if (pr == (CC_TDSS1_IO | REQUEST)) {
3145 l3dss1_io_timer(proc); /* timer expires */
3149 for (i = 0; i < ARRAY_SIZE(downstatelist); i++)
3150 if ((pr == downstatelist[i].primitive) &&
3151 ((1 << proc->state) & downstatelist[i].state))
3153 if (i == ARRAY_SIZE(downstatelist)) {
3154 if (st->l3.debug & L3_DEB_STATE) {
3155 l3_debug(st, "dss1down state %d prim %#x unhandled",
3159 if (st->l3.debug & L3_DEB_STATE) {
3160 l3_debug(st, "dss1down state %d prim %#x",
3163 downstatelist[i].rout(proc, pr, arg);
3168 dss1man(struct PStack *st, int pr, void *arg)
3171 struct l3_process *proc = arg;
3174 printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr);
3177 for (i = 0; i < ARRAY_SIZE(manstatelist); i++)
3178 if ((pr == manstatelist[i].primitive) &&
3179 ((1 << proc->state) & manstatelist[i].state))
3181 if (i == ARRAY_SIZE(manstatelist)) {
3182 if (st->l3.debug & L3_DEB_STATE) {
3183 l3_debug(st, "cr %d dss1man state %d prim %#x unhandled",
3184 proc->callref & 0x7f, proc->state, pr);
3187 if (st->l3.debug & L3_DEB_STATE) {
3188 l3_debug(st, "cr %d dss1man state %d prim %#x",
3189 proc->callref & 0x7f, proc->state, pr);
3191 manstatelist[i].rout(proc, pr, arg);
3196 setstack_dss1(struct PStack *st)
3201 st->lli.l4l3 = dss1down;
3202 st->lli.l4l3_proto = l3dss1_cmd_global;
3203 st->l2.l2l3 = dss1up;
3204 st->l3.l3ml3 = dss1man;
3206 st->prot.dss1.last_invoke_id = 0;
3207 st->prot.dss1.invoke_used[0] = 1; /* Bit 0 must always be set to 1 */
3210 st->prot.dss1.invoke_used[i++] = 0;
3212 if (!(st->l3.global = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) {
3213 printk(KERN_ERR "HiSax can't get memory for dss1 global CR\n");
3215 st->l3.global->state = 0;
3216 st->l3.global->callref = 0;
3217 st->l3.global->next = NULL;
3218 st->l3.global->debug = L3_DEB_WARN;
3219 st->l3.global->st = st;
3220 st->l3.global->N303 = 1;
3221 st->l3.global->prot.dss1.invoke_id = 0;
3223 L3InitTimer(st->l3.global, &st->l3.global->timer);
3225 strcpy(tmp, dss1_revision);
3226 printk(KERN_INFO "HiSax: DSS1 Rev. %s\n", HiSax_getrev(tmp));