1 /* $Id: l3dss1.c,v 1.1.4.1 2001/11/20 14:19:36 kai 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
22 #define __NO_VERSION__
26 #include <linux/ctype.h>
27 #include <linux/config.h>
29 extern char *HiSax_getrev(const char *revision);
30 const char *dss1_revision = "$Revision: 1.1.4.1 $";
32 #define EXT_BEARER_CAPS 1
34 #define MsgHead(ptr, cref, mty) \
45 /**********************************************/
46 /* get a new invoke id for remote operations. */
47 /* Only a return value != 0 is valid */
48 /**********************************************/
49 static unsigned char new_invoke_id(struct PStack *p)
55 i = 32; /* maximum search depth */
60 retval = p->prot.dss1.last_invoke_id + 1; /* try new id */
61 while ((i) && (p->prot.dss1.invoke_used[retval >> 3] == 0xFF)) {
62 p->prot.dss1.last_invoke_id = (retval & 0xF8) + 8;
66 while (p->prot.dss1.invoke_used[retval >> 3] & (1 << (retval & 7)))
70 p->prot.dss1.last_invoke_id = retval;
71 p->prot.dss1.invoke_used[retval >> 3] |= (1 << (retval & 7));
77 /*************************/
78 /* free a used invoke id */
79 /*************************/
80 static void free_invoke_id(struct PStack *p, unsigned char id)
81 { unsigned long flags;
83 if (!id) return; /* 0 = invalid value */
87 p->prot.dss1.invoke_used[id >> 3] &= ~(1 << (id & 7));
89 } /* free_invoke_id */
92 /**********************************************************/
93 /* create a new l3 process and fill in dss1 specific data */
94 /**********************************************************/
95 static struct l3_process
96 *dss1_new_l3_process(struct PStack *st, int cr)
97 { struct l3_process *proc;
99 if (!(proc = new_l3_process(st, cr)))
102 proc->prot.dss1.invoke_id = 0;
103 proc->prot.dss1.remote_operation = 0;
104 proc->prot.dss1.uus1_data[0] = '\0';
107 } /* dss1_new_l3_process */
109 /************************************************/
110 /* free a l3 process and all dss1 specific data */
111 /************************************************/
113 dss1_release_l3_process(struct l3_process *p)
115 free_invoke_id(p->st,p->prot.dss1.invoke_id);
116 release_l3_process(p);
117 } /* dss1_release_l3_process */
119 /********************************************************/
120 /* search a process with invoke id id and dummy callref */
121 /********************************************************/
122 static struct l3_process *
123 l3dss1_search_dummy_proc(struct PStack *st, int id)
124 { struct l3_process *pc = st->l3.proc; /* start of processes */
126 if (!id) return(NULL);
129 { if ((pc->callref == -1) && (pc->prot.dss1.invoke_id == id))
134 } /* l3dss1_search_dummy_proc */
136 /*******************************************************************/
137 /* called when a facility message with a dummy callref is received */
138 /* and a return result is delivered. id specifies the invoke id. */
139 /*******************************************************************/
141 l3dss1_dummy_return_result(struct PStack *st, int id, u_char *p, u_char nlen)
143 struct IsdnCardState *cs;
144 struct l3_process *pc = NULL;
146 if ((pc = l3dss1_search_dummy_proc(st, id)))
147 { L3DelTimer(&pc->timer); /* remove timer */
149 cs = pc->st->l1.hardware;
150 ic.driver = cs->myid;
151 ic.command = ISDN_STAT_PROT;
152 ic.arg = DSS1_STAT_INVOKE_RES;
153 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
154 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
155 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
156 ic.parm.dss1_io.timeout= 0;
157 ic.parm.dss1_io.datalen = nlen;
158 ic.parm.dss1_io.data = p;
159 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
160 pc->prot.dss1.invoke_id = 0; /* reset id */
162 cs->iif.statcallb(&ic);
163 dss1_release_l3_process(pc);
166 l3_debug(st, "dummy return result id=0x%x result len=%d",id,nlen);
167 } /* l3dss1_dummy_return_result */
169 /*******************************************************************/
170 /* called when a facility message with a dummy callref is received */
171 /* and a return error is delivered. id specifies the invoke id. */
172 /*******************************************************************/
174 l3dss1_dummy_error_return(struct PStack *st, int id, ulong error)
176 struct IsdnCardState *cs;
177 struct l3_process *pc = NULL;
179 if ((pc = l3dss1_search_dummy_proc(st, id)))
180 { L3DelTimer(&pc->timer); /* remove timer */
182 cs = pc->st->l1.hardware;
183 ic.driver = cs->myid;
184 ic.command = ISDN_STAT_PROT;
185 ic.arg = DSS1_STAT_INVOKE_ERR;
186 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
187 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
188 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
189 ic.parm.dss1_io.timeout= error;
190 ic.parm.dss1_io.datalen = 0;
191 ic.parm.dss1_io.data = NULL;
192 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
193 pc->prot.dss1.invoke_id = 0; /* reset id */
195 cs->iif.statcallb(&ic);
196 dss1_release_l3_process(pc);
199 l3_debug(st, "dummy return error id=0x%x error=0x%lx",id,error);
200 } /* l3dss1_error_return */
202 /*******************************************************************/
203 /* called when a facility message with a dummy callref is received */
204 /* and a invoke is delivered. id specifies the invoke id. */
205 /*******************************************************************/
207 l3dss1_dummy_invoke(struct PStack *st, int cr, int id,
208 int ident, u_char *p, u_char nlen)
210 struct IsdnCardState *cs;
212 l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d",
213 (cr == -1) ? "local" : "broadcast",id,ident,nlen);
214 if (cr >= -1) return; /* ignore local data */
216 cs = st->l1.hardware;
217 ic.driver = cs->myid;
218 ic.command = ISDN_STAT_PROT;
219 ic.arg = DSS1_STAT_INVOKE_BRD;
220 ic.parm.dss1_io.hl_id = id;
221 ic.parm.dss1_io.ll_id = 0;
222 ic.parm.dss1_io.proc = ident;
223 ic.parm.dss1_io.timeout= 0;
224 ic.parm.dss1_io.datalen = nlen;
225 ic.parm.dss1_io.data = p;
227 cs->iif.statcallb(&ic);
228 } /* l3dss1_dummy_invoke */
231 l3dss1_parse_facility(struct PStack *st, struct l3_process *pc,
235 unsigned char nlen = 0, ilen, cp_tag;
240 st = pc->st; /* valid Stack */
242 if ((!st) || (cr >= 0)) return; /* neither pc nor st specified */
247 l3_debug(st, "qd_len == 0");
250 if ((*p & 0x1F) != 0x11) { /* Service discriminator, supplementary service */
251 l3_debug(st, "supplementary service != 0x11");
254 while (qd_len > 0 && !(*p & 0x80)) { /* extension ? */
259 l3_debug(st, "qd_len < 2");
264 if ((*p & 0xE0) != 0xA0) { /* class and form */
265 l3_debug(st, "class and form != 0xA0");
269 cp_tag = *p & 0x1F; /* remember tag value */
274 { l3_debug(st, "qd_len < 1");
278 { /* length format indefinite or limited */
279 nlen = *p++ & 0x7F; /* number of len bytes or indefinite */
280 if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) ||
282 { l3_debug(st, "length format error or not implemented");
286 { nlen = *p++; /* complete length */
290 { qd_len -= 2; /* trailing null bytes */
291 if ((*(p+qd_len)) || (*(p+qd_len+1)))
292 { l3_debug(st,"length format indefinite error");
303 { l3_debug(st, "qd_len < nlen");
309 { l3_debug(st, "nlen < 2");
313 { /* invoke identifier tag */
314 l3_debug(st, "invoke identifier tag !=0x02");
320 { /* length format */
321 l3_debug(st, "invoke id length format 2");
326 if (ilen > nlen || ilen == 0)
327 { l3_debug(st, "ilen > nlen || ilen == 0");
333 { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */
337 switch (cp_tag) { /* component tag */
340 l3_debug(st, "nlen < 2 22");
343 if (*p != 0x02) { /* operation value */
344 l3_debug(st, "operation value !=0x02");
351 if (ilen > nlen || ilen == 0) {
352 l3_debug(st, "ilen > nlen || ilen == 0 22");
358 ident = (ident << 8) | (*p++ & 0xFF);
363 { l3dss1_dummy_invoke(st, cr, id, ident, p, nlen);
369 #define FOO1(s,a,b) \
372 if(nlen < ilen+2) { \
373 l3_debug(st, "FOO1 nlen < ilen+2"); \
377 if((*p & 0xFF) == (a)) { \
387 case 0x22: /* during */
388 FOO1("1A", 0x30, FOO1("1C", 0xA1, FOO1("1D", 0x30, FOO1("1E", 0x02, ( {
390 nlen = (nlen)?nlen:0; /* Make gcc happy */
392 ident = (ident << 8) | *p++;
395 if (ident > pc->para.chargeinfo) {
396 pc->para.chargeinfo = ident;
397 st->l3.l3l4(st, CC_CHARGE | INDICATION, pc);
399 if (st->l3.debug & L3_DEB_CHARGE) {
401 l3_debug(st, "charging info during %d", pc->para.chargeinfo);
404 l3_debug(st, "charging info final %d", pc->para.chargeinfo);
410 case 0x24: /* final */
411 FOO1("2A", 0x30, FOO1("2B", 0x30, FOO1("2C", 0xA1, FOO1("2D", 0x30, FOO1("2E", 0x02, ( {
413 nlen = (nlen)?nlen:0; /* Make gcc happy */
415 ident = (ident << 8) | *p++;
418 if (ident > pc->para.chargeinfo) {
419 pc->para.chargeinfo = ident;
420 st->l3.l3l4(st, CC_CHARGE | INDICATION, pc);
422 if (st->l3.debug & L3_DEB_CHARGE) {
423 l3_debug(st, "charging info final %d", pc->para.chargeinfo);
429 l3_debug(st, "invoke break invalid ident %02x",ident);
435 #else /* not HISAX_DE_AOC */
436 l3_debug(st, "invoke break");
437 #endif /* not HISAX_DE_AOC */
439 case 2: /* return result */
440 /* if no process available handle separately */
443 l3dss1_dummy_return_result(st, id, p, nlen);
446 if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id))
447 { /* Diversion successful */
448 free_invoke_id(st,pc->prot.dss1.invoke_id);
449 pc->prot.dss1.remote_result = 0; /* success */
450 pc->prot.dss1.invoke_id = 0;
451 pc->redir_result = pc->prot.dss1.remote_result;
452 st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */
454 l3_debug(st,"return error unknown identifier");
456 case 3: /* return error */
459 { l3_debug(st, "return error nlen < 2");
464 l3_debug(st, "invoke error tag !=0x02");
470 { /* length format */
471 l3_debug(st, "invoke return errlen > 4 ");
476 if (ilen > nlen || ilen == 0)
477 { l3_debug(st, "error return ilen > nlen || ilen == 0");
482 { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */
485 /* if no process available handle separately */
488 l3dss1_dummy_error_return(st, id, err_ret);
491 if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id))
492 { /* Deflection error */
493 free_invoke_id(st,pc->prot.dss1.invoke_id);
494 pc->prot.dss1.remote_result = err_ret; /* result */
495 pc->prot.dss1.invoke_id = 0;
496 pc->redir_result = pc->prot.dss1.remote_result;
497 st->l3.l3l4(st, CC_REDIR | INDICATION, pc);
498 } /* Deflection error */
500 l3_debug(st,"return result unknown identifier");
503 l3_debug(st, "facility default break tag=0x%02x",cp_tag);
509 l3dss1_message(struct l3_process *pc, u_char mt)
514 if (!(skb = l3_alloc_skb(4)))
517 MsgHead(p, pc->callref, mt);
518 l3_msg(pc->st, DL_DATA | REQUEST, skb);
522 l3dss1_message_cause(struct l3_process *pc, u_char mt, u_char cause)
529 MsgHead(p, pc->callref, mt);
536 if (!(skb = l3_alloc_skb(l)))
538 memcpy(skb_put(skb, l), tmp, l);
539 l3_msg(pc->st, DL_DATA | REQUEST, skb);
543 l3dss1_status_send(struct l3_process *pc, u_char pr, void *arg)
550 MsgHead(p, pc->callref, MT_STATUS);
555 *p++ = pc->para.cause | 0x80;
557 *p++ = IE_CALL_STATE;
559 *p++ = pc->state & 0x3f;
562 if (!(skb = l3_alloc_skb(l)))
564 memcpy(skb_put(skb, l), tmp, l);
565 l3_msg(pc->st, DL_DATA | REQUEST, skb);
569 l3dss1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg)
571 /* This routine is called if here was no SETUP made (checks in dss1up and in
572 * l3dss1_setup) and a RELEASE_COMPLETE have to be sent with an error code
573 * MT_STATUS_ENQUIRE in the NULL state is handled too
580 switch (pc->para.cause) {
581 case 81: /* invalid callreference */
582 case 88: /* incomp destination */
583 case 96: /* mandory IE missing */
584 case 100: /* invalid IE contents */
585 case 101: /* incompatible Callstate */
586 MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
590 *p++ = pc->para.cause | 0x80;
593 printk(KERN_ERR "HiSax l3dss1_msg_without_setup wrong cause %d\n",
598 if (!(skb = l3_alloc_skb(l)))
600 memcpy(skb_put(skb, l), tmp, l);
601 l3_msg(pc->st, DL_DATA | REQUEST, skb);
602 dss1_release_l3_process(pc);
605 static int ie_ALERTING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
606 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC,
608 static int ie_CALL_PROCEEDING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
609 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1};
610 static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1,
611 IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL,
612 IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1};
613 static int ie_CONNECT_ACKNOWLEDGE[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_SIGNAL, -1};
614 static int ie_DISCONNECT[] = {IE_CAUSE | IE_MANDATORY, IE_FACILITY,
615 IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1};
616 static int ie_INFORMATION[] = {IE_COMPLETE, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL,
618 static int ie_NOTIFY[] = {IE_BEARER, IE_NOTIFY | IE_MANDATORY, IE_DISPLAY, -1};
619 static int ie_PROGRESS[] = {IE_BEARER, IE_CAUSE, IE_FACILITY, IE_PROGRESS |
620 IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1};
621 static int ie_RELEASE[] = {IE_CAUSE | IE_MANDATORY_1, IE_FACILITY, IE_DISPLAY,
622 IE_SIGNAL, IE_USER_USER, -1};
623 /* a RELEASE_COMPLETE with errors don't require special actions
624 static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1};
626 static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY,
628 static int ie_RESUME_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
629 static int ie_SETUP[] = {IE_COMPLETE, IE_BEARER | IE_MANDATORY,
630 IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY, IE_PROGRESS,
631 IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN,
632 IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR,
633 IE_LLC, IE_HLC, IE_USER_USER, -1};
634 static int ie_SETUP_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY,
635 IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1};
636 static int ie_STATUS[] = {IE_CAUSE | IE_MANDATORY, IE_CALL_STATE |
637 IE_MANDATORY, IE_DISPLAY, -1};
638 static int ie_STATUS_ENQUIRY[] = {IE_DISPLAY, -1};
639 static int ie_SUSPEND_ACKNOWLEDGE[] = {IE_DISPLAY, IE_FACILITY, -1};
640 static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
642 * static int ie_CONGESTION_CONTROL[] = {IE_CONGESTION | IE_MANDATORY,
643 * IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
644 * static int ie_USER_INFORMATION[] = {IE_MORE_DATA, IE_USER_USER | IE_MANDATORY, -1};
645 * static int ie_RESTART[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_RESTART_IND |
648 static int ie_FACILITY[] = {IE_FACILITY | IE_MANDATORY, IE_DISPLAY, -1};
649 static int comp_required[] = {1,2,3,5,6,7,9,10,11,14,15,-1};
650 static int l3_valid_states[] = {0,1,2,3,4,6,7,8,9,10,11,12,15,17,19,25,-1};
658 struct ie_len max_ie_len[] = {
676 {IE_PACK_BINPARA, 3},
677 {IE_PACK_WINSIZE, 4},
682 {IE_CALLING_SUB, 23},
695 getmax_ie_len(u_char ie) {
697 while (max_ie_len[i].ie != -1) {
698 if (max_ie_len[i].ie == ie)
699 return(max_ie_len[i].len);
706 ie_in_set(struct l3_process *pc, u_char ie, int *checklist) {
709 while (*checklist != -1) {
710 if ((*checklist & 0xff) == ie) {
723 check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist)
728 int l, newpos, oldpos;
729 int err_seq = 0, err_len = 0, err_compr = 0, err_ureg = 0;
731 u_char old_codeset = 0;
741 while ((p - skb->data) < skb->len) {
742 if ((*p & 0xf0) == 0x90) { /* shift codeset */
743 old_codeset = codeset;
749 if (pc->debug & L3_DEB_CHECK)
750 l3_debug(pc->st, "check IE shift%scodeset %d->%d",
751 codelock ? " locking ": " ", old_codeset, codeset);
755 if (!codeset) { /* only codeset 0 */
756 if ((newpos = ie_in_set(pc, *p, cl))) {
764 if (ie_in_set(pc, *p, comp_required))
778 if (!codeset && (l > getmax_ie_len(ie)))
781 if (pc->debug & L3_DEB_CHECK)
782 l3_debug(pc->st, "check IE shift back codeset %d->%d",
783 codeset, old_codeset);
784 codeset = old_codeset;
788 if (err_compr | err_ureg | err_len | err_seq) {
789 if (pc->debug & L3_DEB_CHECK)
790 l3_debug(pc->st, "check IE MT(%x) %d/%d/%d/%d",
791 mt, err_compr, err_ureg, err_len, err_seq);
793 return(ERR_IE_COMPREHENSION);
795 return(ERR_IE_UNRECOGNIZED);
797 return(ERR_IE_LENGTH);
799 return(ERR_IE_SEQUENCE);
804 /* verify if a message type exists and contain no IE error */
806 l3dss1_check_messagetype_validity(struct l3_process *pc, int mt, void *arg)
810 case MT_CALL_PROCEEDING:
812 case MT_CONNECT_ACKNOWLEDGE:
819 case MT_RELEASE_COMPLETE:
821 case MT_SETUP_ACKNOWLEDGE:
822 case MT_RESUME_ACKNOWLEDGE:
823 case MT_RESUME_REJECT:
824 case MT_SUSPEND_ACKNOWLEDGE:
825 case MT_SUSPEND_REJECT:
826 case MT_USER_INFORMATION:
828 case MT_RESTART_ACKNOWLEDGE:
829 case MT_CONGESTION_CONTROL:
831 case MT_STATUS_ENQUIRY:
832 if (pc->debug & L3_DEB_CHECK)
833 l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) OK", mt);
835 case MT_RESUME: /* RESUME only in user->net */
836 case MT_SUSPEND: /* SUSPEND only in user->net */
838 if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN))
839 l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) fail", mt);
841 l3dss1_status_send(pc, 0, NULL);
848 l3dss1_std_ie_err(struct l3_process *pc, int ret) {
850 if (pc->debug & L3_DEB_CHECK)
851 l3_debug(pc->st, "check_infoelements ret %d", ret);
855 case ERR_IE_COMPREHENSION:
857 l3dss1_status_send(pc, 0, NULL);
859 case ERR_IE_UNRECOGNIZED:
861 l3dss1_status_send(pc, 0, NULL);
864 pc->para.cause = 100;
865 l3dss1_status_send(pc, 0, NULL);
867 case ERR_IE_SEQUENCE:
874 l3dss1_get_channel_id(struct l3_process *pc, struct sk_buff *skb) {
878 if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
880 if (*p != 1) { /* len for BRI = 1 */
881 if (pc->debug & L3_DEB_WARN)
882 l3_debug(pc->st, "wrong chid len %d", *p);
886 if (*p & 0x60) { /* only base rate interface */
887 if (pc->debug & L3_DEB_WARN)
888 l3_debug(pc->st, "wrong chid %x", *p);
897 l3dss1_get_cause(struct l3_process *pc, struct sk_buff *skb) {
904 if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
915 if (l && !(pc->para.loc & 0x80)) {
917 p++; /* skip recommendation */
920 pc->para.cause = *p++;
922 if (!(pc->para.cause & 0x80))
927 pc->para.diag[i++] = *p++;
936 l3dss1_msg_with_uus(struct l3_process *pc, u_char cmd)
943 MsgHead(p, pc->callref, cmd);
945 if (pc->prot.dss1.uus1_data[0])
946 { *p++ = IE_USER_USER; /* UUS info element */
947 *p++ = strlen(pc->prot.dss1.uus1_data) + 1;
948 *p++ = 0x04; /* IA5 chars */
949 strcpy(p,pc->prot.dss1.uus1_data);
950 p += strlen(pc->prot.dss1.uus1_data);
951 pc->prot.dss1.uus1_data[0] = '\0';
955 if (!(skb = l3_alloc_skb(l)))
957 memcpy(skb_put(skb, l), tmp, l);
958 l3_msg(pc->st, DL_DATA | REQUEST, skb);
959 } /* l3dss1_msg_with_uus */
962 l3dss1_release_req(struct l3_process *pc, u_char pr, void *arg)
966 if (!pc->prot.dss1.uus1_data[0])
967 l3dss1_message(pc, MT_RELEASE);
969 l3dss1_msg_with_uus(pc, MT_RELEASE);
970 L3AddTimer(&pc->timer, T308, CC_T308_1);
974 l3dss1_release_cmpl(struct l3_process *pc, u_char pr, void *arg)
976 struct sk_buff *skb = arg;
979 if ((ret = l3dss1_get_cause(pc, skb))>0) {
980 if (pc->debug & L3_DEB_WARN)
981 l3_debug(pc->st, "RELCMPL get_cause ret(%d)",ret);
983 pc->para.cause = NO_CAUSE;
986 pc->st->l3.l3l4(pc->st, CC_RELEASE | CONFIRM, pc);
987 dss1_release_l3_process(pc);
993 EncodeASyncParams(u_char * p, u_char si2)
994 { // 7c 06 88 90 21 42 00 bb
997 p[1] = 0x40; // Intermediate rate: 16 kbit/s jj 2000.02.19
999 if (si2 & 32) // 7 data bits
1006 if (si2 & 16) // 2 stop bits
1013 if (si2 & 8) // even parity
1020 switch (si2 & 0x07) {
1022 p[0] = 66; // 1200 bit/s
1026 p[0] = 88; // 1200/75 bit/s
1030 p[0] = 87; // 75/1200 bit/s
1034 p[0] = 67; // 2400 bit/s
1038 p[0] = 69; // 4800 bit/s
1042 p[0] = 72; // 9600 bit/s
1046 p[0] = 73; // 14400 bit/s
1050 p[0] = 75; // 19200 bit/s
1058 EncodeSyncParams(u_char si2, u_char ai)
1063 return ai + 2; // 1200 bit/s
1066 return ai + 24; // 1200/75 bit/s
1069 return ai + 23; // 75/1200 bit/s
1072 return ai + 3; // 2400 bit/s
1075 return ai + 5; // 4800 bit/s
1078 return ai + 8; // 9600 bit/s
1081 return ai + 9; // 14400 bit/s
1084 return ai + 11; // 19200 bit/s
1087 return ai + 14; // 48000 bit/s
1090 return ai + 15; // 56000 bit/s
1093 return ai + 40; // negotiate bit/s
1103 DecodeASyncParams(u_char si2, u_char * p)
1108 case 66: // 1200 bit/s
1110 break; // si2 don't change
1112 case 88: // 1200/75 bit/s
1116 case 87: // 75/1200 bit/s
1120 case 67: // 2400 bit/s
1124 case 69: // 4800 bit/s
1128 case 72: // 9600 bit/s
1132 case 73: // 14400 bit/s
1136 case 75: // 19200 bit/s
1143 if ((info & 16) && (!(info & 8))) // 7 data bits
1145 si2 += 32; // else 8 data bits
1147 if ((info & 96) == 96) // 2 stop bits
1149 si2 += 16; // else 1 stop bit
1151 if ((info & 2) && (!(info & 1))) // even parity
1153 si2 += 8; // else no parity
1160 DecodeSyncParams(u_char si2, u_char info)
1164 case 40: // bit/s negotiation failed ai := 165 not 175!
1167 case 15: // 56000 bit/s failed, ai := 0 not 169 !
1170 case 14: // 48000 bit/s
1173 case 11: // 19200 bit/s
1176 case 9: // 14400 bit/s
1179 case 8: // 9600 bit/s
1182 case 5: // 4800 bit/s
1185 case 3: // 2400 bit/s
1188 case 23: // 75/1200 bit/s
1191 case 24: // 1200/75 bit/s
1194 default: // 1200 bit/s
1201 DecodeSI2(struct sk_buff *skb)
1203 u_char *p; //, *pend=skb->data + skb->len;
1205 if ((p = findie(skb->data, skb->len, 0x7c, 0))) {
1206 switch (p[4] & 0x0f) {
1208 if (p[1] == 0x04) // sync. Bitratenadaption
1210 return DecodeSyncParams(160, p[5]); // V.110/X.30
1212 else if (p[1] == 0x06) // async. Bitratenadaption
1214 return DecodeASyncParams(192, p); // V.110/X.30
1217 case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption
1219 return DecodeSyncParams(176, p[5]); // V.120
1230 l3dss1_setup_req(struct l3_process *pc, u_char pr,
1233 struct sk_buff *skb;
1239 u_char screen = 0x80;
1246 MsgHead(p, pc->callref, MT_SETUP);
1248 teln = pc->para.setup.phone;
1249 #ifndef CONFIG_HISAX_NO_KEYPAD
1250 send_keypad = (strchr(teln,'*') || strchr(teln,'#')) ? 1 : 0;
1254 #ifndef CONFIG_HISAX_NO_SENDCOMPLETE
1256 *p++ = 0xa1; /* complete indicator */
1259 * Set Bearer Capability, Map info from 1TR6-convention to EDSS1
1261 switch (pc->para.setup.si1) {
1262 case 1: /* Telephony */
1264 *p++ = 0x3; /* Length */
1265 *p++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1266 *p++ = 0x90; /* Circuit-Mode 64kbps */
1267 *p++ = 0xa3; /* A-Law Audio */
1269 case 5: /* Datatransmission 64k, BTX */
1270 case 7: /* Datatransmission 64k */
1273 *p++ = 0x2; /* Length */
1274 *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1275 *p++ = 0x90; /* Circuit-Mode 64kbps */
1281 *p++ = strlen(teln);
1283 *p++ = (*teln++) & 0x7F;
1287 * What about info2? Mapping to High-Layer-Compatibility?
1289 if ((*teln) && (!send_keypad)) {
1290 /* parse number for special things */
1291 if (!isdigit(*teln)) {
1292 switch (0x5f & *teln) {
1311 if (pc->debug & L3_DEB_WARN)
1312 l3_debug(pc->st, "Wrong MSN Code");
1319 *p++ = IE_CHANNEL_ID;
1323 msn = pc->para.setup.eazmsn;
1334 *p++ = IE_CALLING_PN;
1335 *p++ = strlen(msn) + (screen ? 2 : 1);
1336 /* Classify as AnyPref. */
1338 *p++ = 0x01; /* Ext = '0'B, Type = '000'B, Plan = '0001'B. */
1341 *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1343 *p++ = *msn++ & 0x7f;
1347 *p++ = IE_CALLING_SUB;
1348 *p++ = strlen(sub) + 2;
1349 *p++ = 0x80; /* NSAP coded */
1350 *p++ = 0x50; /* local IDI format */
1352 *p++ = *sub++ & 0x7f;
1365 *p++ = IE_CALLED_PN;
1366 *p++ = strlen(teln) + 1;
1367 /* Classify as AnyPref. */
1368 *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1370 *p++ = *teln++ & 0x7f;
1374 *p++ = IE_CALLED_SUB;
1375 *p++ = strlen(sub) + 2;
1376 *p++ = 0x80; /* NSAP coded */
1377 *p++ = 0x50; /* local IDI format */
1379 *p++ = *sub++ & 0x7f;
1383 if ((pc->para.setup.si2 >= 160) && (pc->para.setup.si2 <= 175)) { // sync. Bitratenadaption, V.110/X.30
1390 *p++ = EncodeSyncParams(pc->para.setup.si2 - 160, 0x80);
1391 } else if ((pc->para.setup.si2 >= 176) && (pc->para.setup.si2 <= 191)) { // sync. Bitratenadaption, V.120
1398 *p++ = EncodeSyncParams(pc->para.setup.si2 - 176, 0);
1400 } else if (pc->para.setup.si2 >= 192) { // async. Bitratenadaption, V.110/X.30
1407 p = EncodeASyncParams(p, pc->para.setup.si2 - 192);
1408 #ifndef CONFIG_HISAX_NO_LLC
1410 switch (pc->para.setup.si1) {
1411 case 1: /* Telephony */
1413 *p++ = 0x3; /* Length */
1414 *p++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1415 *p++ = 0x90; /* Circuit-Mode 64kbps */
1416 *p++ = 0xa3; /* A-Law Audio */
1418 case 5: /* Datatransmission 64k, BTX */
1419 case 7: /* Datatransmission 64k */
1422 *p++ = 0x2; /* Length */
1423 *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1424 *p++ = 0x90; /* Circuit-Mode 64kbps */
1431 if (!(skb = l3_alloc_skb(l)))
1433 memcpy(skb_put(skb, l), tmp, l);
1434 L3DelTimer(&pc->timer);
1435 L3AddTimer(&pc->timer, T303, CC_T303);
1437 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1441 l3dss1_call_proc(struct l3_process *pc, u_char pr, void *arg)
1443 struct sk_buff *skb = arg;
1446 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1447 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
1448 if (pc->debug & L3_DEB_WARN)
1449 l3_debug(pc->st, "setup answer with wrong chid %x", id);
1450 pc->para.cause = 100;
1451 l3dss1_status_send(pc, pr, NULL);
1454 pc->para.bchannel = id;
1455 } else if (1 == pc->state) {
1456 if (pc->debug & L3_DEB_WARN)
1457 l3_debug(pc->st, "setup answer wrong chid (ret %d)", id);
1459 pc->para.cause = 96;
1461 pc->para.cause = 100;
1462 l3dss1_status_send(pc, pr, NULL);
1465 /* Now we are on none mandatory IEs */
1466 ret = check_infoelements(pc, skb, ie_CALL_PROCEEDING);
1467 if (ERR_IE_COMPREHENSION == ret) {
1468 l3dss1_std_ie_err(pc, ret);
1471 L3DelTimer(&pc->timer);
1473 L3AddTimer(&pc->timer, T310, CC_T310);
1474 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
1475 l3dss1_std_ie_err(pc, ret);
1476 pc->st->l3.l3l4(pc->st, CC_PROCEEDING | INDICATION, pc);
1480 l3dss1_setup_ack(struct l3_process *pc, u_char pr, void *arg)
1482 struct sk_buff *skb = arg;
1485 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1486 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
1487 if (pc->debug & L3_DEB_WARN)
1488 l3_debug(pc->st, "setup answer with wrong chid %x", id);
1489 pc->para.cause = 100;
1490 l3dss1_status_send(pc, pr, NULL);
1493 pc->para.bchannel = id;
1495 if (pc->debug & L3_DEB_WARN)
1496 l3_debug(pc->st, "setup answer wrong chid (ret %d)", id);
1498 pc->para.cause = 96;
1500 pc->para.cause = 100;
1501 l3dss1_status_send(pc, pr, NULL);
1504 /* Now we are on none mandatory IEs */
1505 ret = check_infoelements(pc, skb, ie_SETUP_ACKNOWLEDGE);
1506 if (ERR_IE_COMPREHENSION == ret) {
1507 l3dss1_std_ie_err(pc, ret);
1510 L3DelTimer(&pc->timer);
1512 L3AddTimer(&pc->timer, T304, CC_T304);
1513 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
1514 l3dss1_std_ie_err(pc, ret);
1515 pc->st->l3.l3l4(pc->st, CC_MORE_INFO | INDICATION, pc);
1519 l3dss1_disconnect(struct l3_process *pc, u_char pr, void *arg)
1521 struct sk_buff *skb = arg;
1527 if ((ret = l3dss1_get_cause(pc, skb))) {
1528 if (pc->debug & L3_DEB_WARN)
1529 l3_debug(pc->st, "DISC get_cause ret(%d)", ret);
1535 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0)))
1536 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
1537 ret = check_infoelements(pc, skb, ie_DISCONNECT);
1538 if (ERR_IE_COMPREHENSION == ret)
1540 else if ((!cause) && (ERR_IE_UNRECOGNIZED == ret))
1547 pc->st->l3.l3l4(pc->st, CC_DISCONNECT | INDICATION, pc);
1549 l3dss1_release_req(pc, pr, NULL);
1551 l3dss1_message_cause(pc, MT_RELEASE, cause);
1552 L3AddTimer(&pc->timer, T308, CC_T308_1);
1557 l3dss1_connect(struct l3_process *pc, u_char pr, void *arg)
1559 struct sk_buff *skb = arg;
1562 ret = check_infoelements(pc, skb, ie_CONNECT);
1563 if (ERR_IE_COMPREHENSION == ret) {
1564 l3dss1_std_ie_err(pc, ret);
1567 L3DelTimer(&pc->timer); /* T310 */
1569 pc->para.chargeinfo = 0;
1570 /* here should inserted COLP handling KKe */
1572 l3dss1_std_ie_err(pc, ret);
1573 pc->st->l3.l3l4(pc->st, CC_SETUP | CONFIRM, pc);
1577 l3dss1_alerting(struct l3_process *pc, u_char pr, void *arg)
1579 struct sk_buff *skb = arg;
1582 ret = check_infoelements(pc, skb, ie_ALERTING);
1583 if (ERR_IE_COMPREHENSION == ret) {
1584 l3dss1_std_ie_err(pc, ret);
1587 L3DelTimer(&pc->timer); /* T304 */
1590 l3dss1_std_ie_err(pc, ret);
1591 pc->st->l3.l3l4(pc->st, CC_ALERTING | INDICATION, pc);
1595 l3dss1_setup(struct l3_process *pc, u_char pr, void *arg)
1600 struct sk_buff *skb = arg;
1605 * Bearer Capabilities
1608 /* only the first occurence 'll be detected ! */
1609 if ((p = findie(p, skb->len, 0x04, 0))) {
1610 if ((p[1] < 2) || (p[1] > 11))
1613 pc->para.setup.si2 = 0;
1614 switch (p[2] & 0x7f) {
1615 case 0x00: /* Speech */
1616 case 0x10: /* 3.1 Khz audio */
1617 pc->para.setup.si1 = 1;
1619 case 0x08: /* Unrestricted digital information */
1620 pc->para.setup.si1 = 7;
1621 /* JIM, 05.11.97 I wanna set service indicator 2 */
1623 pc->para.setup.si2 = DecodeSI2(skb);
1626 case 0x09: /* Restricted digital information */
1627 pc->para.setup.si1 = 2;
1630 /* Unrestr. digital information with
1631 * tones/announcements ( or 7 kHz audio
1633 pc->para.setup.si1 = 3;
1635 case 0x18: /* Video */
1636 pc->para.setup.si1 = 4;
1642 switch (p[3] & 0x7f) {
1643 case 0x40: /* packed mode */
1644 pc->para.setup.si1 = 8;
1646 case 0x10: /* 64 kbit */
1647 case 0x11: /* 2*64 kbit */
1648 case 0x13: /* 384 kbit */
1649 case 0x15: /* 1536 kbit */
1650 case 0x17: /* 1920 kbit */
1651 pc->para.moderate = p[3] & 0x7f;
1658 if (pc->debug & L3_DEB_SI)
1659 l3_debug(pc->st, "SI=%d, AI=%d",
1660 pc->para.setup.si1, pc->para.setup.si2);
1662 if (pc->debug & L3_DEB_WARN)
1663 l3_debug(pc->st, "setup with wrong bearer(l=%d:%x,%x)",
1665 pc->para.cause = 100;
1666 l3dss1_msg_without_setup(pc, pr, NULL);
1670 if (pc->debug & L3_DEB_WARN)
1671 l3_debug(pc->st, "setup without bearer capabilities");
1672 /* ETS 300-104 1.3.3 */
1673 pc->para.cause = 96;
1674 l3dss1_msg_without_setup(pc, pr, NULL);
1678 * Channel Identification
1680 if ((id = l3dss1_get_channel_id(pc, skb)) >= 0) {
1681 if ((pc->para.bchannel = id)) {
1682 if ((3 == id) && (0x10 == pc->para.moderate)) {
1683 if (pc->debug & L3_DEB_WARN)
1684 l3_debug(pc->st, "setup with wrong chid %x",
1686 pc->para.cause = 100;
1687 l3dss1_msg_without_setup(pc, pr, NULL);
1692 { if (pc->debug & L3_DEB_WARN)
1693 l3_debug(pc->st, "setup without bchannel, call waiting");
1697 if (pc->debug & L3_DEB_WARN)
1698 l3_debug(pc->st, "setup with wrong chid ret %d", id);
1700 pc->para.cause = 96;
1702 pc->para.cause = 100;
1703 l3dss1_msg_without_setup(pc, pr, NULL);
1706 /* Now we are on none mandatory IEs */
1707 err = check_infoelements(pc, skb, ie_SETUP);
1708 if (ERR_IE_COMPREHENSION == err) {
1709 pc->para.cause = 96;
1710 l3dss1_msg_without_setup(pc, pr, NULL);
1714 if ((p = findie(p, skb->len, 0x70, 0)))
1715 iecpy(pc->para.setup.eazmsn, p, 1);
1717 pc->para.setup.eazmsn[0] = 0;
1720 if ((p = findie(p, skb->len, 0x71, 0))) {
1721 /* Called party subaddress */
1722 if ((p[1] >= 2) && (p[2] == 0x80) && (p[3] == 0x50)) {
1724 iecpy(&tmp[1], p, 2);
1725 strcat(pc->para.setup.eazmsn, tmp);
1726 } else if (pc->debug & L3_DEB_WARN)
1727 l3_debug(pc->st, "wrong called subaddress");
1730 if ((p = findie(p, skb->len, 0x6c, 0))) {
1731 pc->para.setup.plan = p[2];
1733 iecpy(pc->para.setup.phone, p, 1);
1734 pc->para.setup.screen = 0;
1736 iecpy(pc->para.setup.phone, p, 2);
1737 pc->para.setup.screen = p[3];
1740 pc->para.setup.phone[0] = 0;
1741 pc->para.setup.plan = 0;
1742 pc->para.setup.screen = 0;
1745 if ((p = findie(p, skb->len, 0x6d, 0))) {
1746 /* Calling party subaddress */
1747 if ((p[1] >= 2) && (p[2] == 0x80) && (p[3] == 0x50)) {
1749 iecpy(&tmp[1], p, 2);
1750 strcat(pc->para.setup.phone, tmp);
1751 } else if (pc->debug & L3_DEB_WARN)
1752 l3_debug(pc->st, "wrong calling subaddress");
1755 if (err) /* STATUS for none mandatory IE errors after actions are taken */
1756 l3dss1_std_ie_err(pc, err);
1757 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
1761 l3dss1_reset(struct l3_process *pc, u_char pr, void *arg)
1763 dss1_release_l3_process(pc);
1767 l3dss1_disconnect_req(struct l3_process *pc, u_char pr, void *arg)
1769 struct sk_buff *skb;
1775 if (pc->para.cause != NO_CAUSE)
1776 cause = pc->para.cause;
1780 MsgHead(p, pc->callref, MT_DISCONNECT);
1785 *p++ = cause | 0x80;
1787 if (pc->prot.dss1.uus1_data[0])
1788 { *p++ = IE_USER_USER; /* UUS info element */
1789 *p++ = strlen(pc->prot.dss1.uus1_data) + 1;
1790 *p++ = 0x04; /* IA5 chars */
1791 strcpy(p,pc->prot.dss1.uus1_data);
1792 p += strlen(pc->prot.dss1.uus1_data);
1793 pc->prot.dss1.uus1_data[0] = '\0';
1797 if (!(skb = l3_alloc_skb(l)))
1799 memcpy(skb_put(skb, l), tmp, l);
1801 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1802 L3AddTimer(&pc->timer, T305, CC_T305);
1806 l3dss1_setup_rsp(struct l3_process *pc, u_char pr,
1809 if (!pc->para.bchannel)
1810 { if (pc->debug & L3_DEB_WARN)
1811 l3_debug(pc->st, "D-chan connect for waiting call");
1812 l3dss1_disconnect_req(pc, pr, arg);
1816 l3dss1_message(pc, MT_CONNECT);
1817 L3DelTimer(&pc->timer);
1818 L3AddTimer(&pc->timer, T313, CC_T313);
1822 l3dss1_connect_ack(struct l3_process *pc, u_char pr, void *arg)
1824 struct sk_buff *skb = arg;
1827 ret = check_infoelements(pc, skb, ie_CONNECT_ACKNOWLEDGE);
1828 if (ERR_IE_COMPREHENSION == ret) {
1829 l3dss1_std_ie_err(pc, ret);
1833 L3DelTimer(&pc->timer);
1835 l3dss1_std_ie_err(pc, ret);
1836 pc->st->l3.l3l4(pc->st, CC_SETUP_COMPL | INDICATION, pc);
1840 l3dss1_reject_req(struct l3_process *pc, u_char pr, void *arg)
1842 struct sk_buff *skb;
1848 if (pc->para.cause != NO_CAUSE)
1849 cause = pc->para.cause;
1851 MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
1856 *p++ = cause | 0x80;
1859 if (!(skb = l3_alloc_skb(l)))
1861 memcpy(skb_put(skb, l), tmp, l);
1862 l3_msg(pc->st, DL_DATA | REQUEST, skb);
1863 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
1865 dss1_release_l3_process(pc);
1869 l3dss1_release(struct l3_process *pc, u_char pr, void *arg)
1871 struct sk_buff *skb = arg;
1876 if ((ret = l3dss1_get_cause(pc, skb))>0) {
1877 if (pc->debug & L3_DEB_WARN)
1878 l3_debug(pc->st, "REL get_cause ret(%d)", ret);
1880 pc->para.cause = NO_CAUSE;
1881 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) {
1882 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
1884 if ((ret<0) && (pc->state != 11))
1888 ret = check_infoelements(pc, skb, ie_RELEASE);
1889 if (ERR_IE_COMPREHENSION == ret)
1891 else if ((ERR_IE_UNRECOGNIZED == ret) && (!cause))
1894 l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, cause);
1896 l3dss1_message(pc, MT_RELEASE_COMPLETE);
1897 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
1899 dss1_release_l3_process(pc);
1903 l3dss1_alert_req(struct l3_process *pc, u_char pr,
1907 if (!pc->prot.dss1.uus1_data[0])
1908 l3dss1_message(pc, MT_ALERTING);
1910 l3dss1_msg_with_uus(pc, MT_ALERTING);
1914 l3dss1_proceed_req(struct l3_process *pc, u_char pr,
1918 l3dss1_message(pc, MT_CALL_PROCEEDING);
1919 pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc);
1923 l3dss1_setup_ack_req(struct l3_process *pc, u_char pr,
1927 L3DelTimer(&pc->timer);
1928 L3AddTimer(&pc->timer, T302, CC_T302);
1929 l3dss1_message(pc, MT_SETUP_ACKNOWLEDGE);
1932 /********************************************/
1933 /* deliver a incoming display message to HL */
1934 /********************************************/
1936 l3dss1_deliver_display(struct l3_process *pc, int pr, u_char *infp)
1939 struct IsdnCardState *cs;
1942 if (*infp++ != IE_DISPLAY) return;
1943 if ((len = *infp++) > 80) return; /* total length <= 82 */
1944 if (!pc->chan) return;
1946 p = ic.parm.display;
1950 ic.command = ISDN_STAT_DISPLAY;
1951 cs = pc->st->l1.hardware;
1952 ic.driver = cs->myid;
1953 ic.arg = pc->chan->chan;
1954 cs->iif.statcallb(&ic);
1955 } /* l3dss1_deliver_display */
1959 l3dss1_progress(struct l3_process *pc, u_char pr, void *arg)
1961 struct sk_buff *skb = arg;
1965 if ((p = findie(skb->data, skb->len, IE_PROGRESS, 0))) {
1968 pc->para.cause = 100;
1969 } else if (!(p[2] & 0x70)) {
1987 pc->para.cause = 100;
1993 pc->para.cause = 100;
1998 pc->para.cause = 96;
2002 if (pc->debug & L3_DEB_WARN)
2003 l3_debug(pc->st, "progress error %d", err);
2004 l3dss1_status_send(pc, pr, NULL);
2007 /* Now we are on none mandatory IEs */
2008 err = check_infoelements(pc, skb, ie_PROGRESS);
2010 l3dss1_std_ie_err(pc, err);
2011 if (ERR_IE_COMPREHENSION != err)
2012 pc->st->l3.l3l4(pc->st, CC_PROGRESS | INDICATION, pc);
2016 l3dss1_notify(struct l3_process *pc, u_char pr, void *arg)
2018 struct sk_buff *skb = arg;
2022 if ((p = findie(skb->data, skb->len, IE_NOTIFY, 0))) {
2025 pc->para.cause = 100;
2033 pc->para.cause = 100;
2039 pc->para.cause = 96;
2043 if (pc->debug & L3_DEB_WARN)
2044 l3_debug(pc->st, "notify error %d", err);
2045 l3dss1_status_send(pc, pr, NULL);
2048 /* Now we are on none mandatory IEs */
2049 err = check_infoelements(pc, skb, ie_NOTIFY);
2051 l3dss1_std_ie_err(pc, err);
2052 if (ERR_IE_COMPREHENSION != err)
2053 pc->st->l3.l3l4(pc->st, CC_NOTIFY | INDICATION, pc);
2057 l3dss1_status_enq(struct l3_process *pc, u_char pr, void *arg)
2060 struct sk_buff *skb = arg;
2062 ret = check_infoelements(pc, skb, ie_STATUS_ENQUIRY);
2063 l3dss1_std_ie_err(pc, ret);
2064 pc->para.cause = 30; /* response to STATUS_ENQUIRY */
2065 l3dss1_status_send(pc, pr, NULL);
2069 l3dss1_information(struct l3_process *pc, u_char pr, void *arg)
2072 struct sk_buff *skb = arg;
2076 ret = check_infoelements(pc, skb, ie_INFORMATION);
2078 l3dss1_std_ie_err(pc, ret);
2079 if (pc->state == 25) { /* overlap receiving */
2080 L3DelTimer(&pc->timer);
2082 if ((p = findie(p, skb->len, 0x70, 0))) {
2084 strcat(pc->para.setup.eazmsn, tmp);
2085 pc->st->l3.l3l4(pc->st, CC_MORE_INFO | INDICATION, pc);
2087 L3AddTimer(&pc->timer, T302, CC_T302);
2091 /******************************/
2092 /* handle deflection requests */
2093 /******************************/
2094 static void l3dss1_redir_req(struct l3_process *pc, u_char pr, void *arg)
2096 struct sk_buff *skb;
2100 u_char len_phone = 0;
2105 strcpy(pc->prot.dss1.uus1_data,pc->chan->setup.eazmsn); /* copy uus element if available */
2106 if (!pc->chan->setup.phone[0])
2107 { pc->para.cause = -1;
2108 l3dss1_disconnect_req(pc,pr,arg); /* disconnect immediately */
2112 if (pc->prot.dss1.invoke_id)
2113 free_invoke_id(pc->st,pc->prot.dss1.invoke_id);
2115 if (!(pc->prot.dss1.invoke_id = new_invoke_id(pc->st)))
2118 MsgHead(p, pc->callref, MT_FACILITY);
2120 for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */
2121 if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */
2123 *p++ = 0x1c; /* Facility info element */
2124 *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */
2125 *p++ = 0x91; /* remote operations protocol */
2126 *p++ = 0xa1; /* invoke component */
2128 *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */
2129 *p++ = 0x02; /* invoke id tag, integer */
2130 *p++ = 0x01; /* length */
2131 *p++ = pc->prot.dss1.invoke_id; /* invoke id */
2132 *p++ = 0x02; /* operation value tag, integer */
2133 *p++ = 0x01; /* length */
2134 *p++ = 0x0D; /* Call Deflect */
2136 *p++ = 0x30; /* sequence phone number */
2137 *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */
2139 *p++ = 0x30; /* Deflected to UserNumber */
2140 *p++ = len_phone+2+len_sub; /* length */
2141 *p++ = 0x80; /* NumberDigits */
2142 *p++ = len_phone; /* length */
2143 for (l = 0; l < len_phone; l++)
2144 *p++ = pc->chan->setup.phone[l];
2147 { *p++ = 0x04; /* called party subaddress */
2149 while (*subp) *p++ = *subp++;
2152 *p++ = 0x01; /* screening identifier */
2154 *p++ = pc->chan->setup.screen;
2157 if (!(skb = l3_alloc_skb(l))) return;
2158 memcpy(skb_put(skb, l), tmp, l);
2160 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2161 } /* l3dss1_redir_req */
2163 /********************************************/
2164 /* handle deflection request in early state */
2165 /********************************************/
2166 static void l3dss1_redir_req_early(struct l3_process *pc, u_char pr, void *arg)
2168 l3dss1_proceed_req(pc,pr,arg);
2169 l3dss1_redir_req(pc,pr,arg);
2170 } /* l3dss1_redir_req_early */
2172 /***********************************************/
2173 /* handle special commands for this protocol. */
2174 /* Examples are call independant services like */
2175 /* remote operations with dummy callref. */
2176 /***********************************************/
2177 static int l3dss1_cmd_global(struct PStack *st, isdn_ctrl *ic)
2182 struct sk_buff *skb;
2183 struct l3_process *pc = NULL;
2186 { case DSS1_CMD_INVOKE:
2187 if (ic->parm.dss1_io.datalen < 0) return(-2); /* invalid parameter */
2189 for (proc_len = 1, i = ic->parm.dss1_io.proc >> 8; i; i++)
2190 i = i >> 8; /* add one byte */
2191 l = ic->parm.dss1_io.datalen + proc_len + 8; /* length excluding ie header */
2193 return(-2); /* too long */
2195 if (!(id = new_invoke_id(st)))
2196 return(0); /* first get a invoke id -> return if no available */
2199 MsgHead(p, i, MT_FACILITY); /* build message head */
2200 *p++ = 0x1C; /* Facility IE */
2201 *p++ = l; /* length of ie */
2202 *p++ = 0x91; /* remote operations */
2203 *p++ = 0xA1; /* invoke */
2204 *p++ = l - 3; /* length of invoke */
2205 *p++ = 0x02; /* invoke id tag */
2206 *p++ = 0x01; /* length is 1 */
2207 *p++ = id; /* invoke id */
2208 *p++ = 0x02; /* operation */
2209 *p++ = proc_len; /* length of operation */
2211 for (i = proc_len; i; i--)
2212 *p++ = (ic->parm.dss1_io.proc >> (i-1)) & 0xFF;
2213 memcpy(p, ic->parm.dss1_io.data, ic->parm.dss1_io.datalen); /* copy data */
2214 l = (p - temp) + ic->parm.dss1_io.datalen; /* total length */
2216 if (ic->parm.dss1_io.timeout > 0)
2217 if (!(pc = dss1_new_l3_process(st, -1)))
2218 { free_invoke_id(st, id);
2221 pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */
2222 pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */
2224 if (!(skb = l3_alloc_skb(l)))
2225 { free_invoke_id(st, id);
2226 if (pc) dss1_release_l3_process(pc);
2229 memcpy(skb_put(skb, l), temp, l);
2232 { pc->prot.dss1.invoke_id = id; /* remember id */
2233 L3AddTimer(&pc->timer, ic->parm.dss1_io.timeout, CC_TDSS1_IO | REQUEST);
2236 l3_msg(st, DL_DATA | REQUEST, skb);
2237 ic->parm.dss1_io.hl_id = id; /* return id */
2240 case DSS1_CMD_INVOKE_ABORT:
2241 if ((pc = l3dss1_search_dummy_proc(st, ic->parm.dss1_io.hl_id)))
2242 { L3DelTimer(&pc->timer); /* remove timer */
2243 dss1_release_l3_process(pc);
2247 { l3_debug(st, "l3dss1_cmd_global abort unknown id");
2253 l3_debug(st, "l3dss1_cmd_global unknown cmd 0x%lx", ic->arg);
2255 } /* switch ic-> arg */
2257 } /* l3dss1_cmd_global */
2260 l3dss1_io_timer(struct l3_process *pc)
2262 struct IsdnCardState *cs = pc->st->l1.hardware;
2264 L3DelTimer(&pc->timer); /* remove timer */
2266 ic.driver = cs->myid;
2267 ic.command = ISDN_STAT_PROT;
2268 ic.arg = DSS1_STAT_INVOKE_ERR;
2269 ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id;
2270 ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id;
2271 ic.parm.dss1_io.proc = pc->prot.dss1.proc;
2272 ic.parm.dss1_io.timeout= -1;
2273 ic.parm.dss1_io.datalen = 0;
2274 ic.parm.dss1_io.data = NULL;
2275 free_invoke_id(pc->st, pc->prot.dss1.invoke_id);
2276 pc->prot.dss1.invoke_id = 0; /* reset id */
2278 cs->iif.statcallb(&ic);
2280 dss1_release_l3_process(pc);
2281 } /* l3dss1_io_timer */
2284 l3dss1_release_ind(struct l3_process *pc, u_char pr, void *arg)
2287 struct sk_buff *skb = arg;
2291 if ((p = findie(p, skb->len, IE_CALL_STATE, 0))) {
2296 if (callState == 0) {
2297 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1... and 16.1
2298 * set down layer 3 without sending any message
2300 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2302 dss1_release_l3_process(pc);
2304 pc->st->l3.l3l4(pc->st, CC_IGNORE | INDICATION, pc);
2309 l3dss1_dummy(struct l3_process *pc, u_char pr, void *arg)
2314 l3dss1_t302(struct l3_process *pc, u_char pr, void *arg)
2316 L3DelTimer(&pc->timer);
2318 pc->para.cause = 28; /* invalid number */
2319 l3dss1_disconnect_req(pc, pr, NULL);
2320 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2324 l3dss1_t303(struct l3_process *pc, u_char pr, void *arg)
2328 L3DelTimer(&pc->timer);
2329 l3dss1_setup_req(pc, pr, arg);
2331 L3DelTimer(&pc->timer);
2332 l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, 102);
2333 pc->st->l3.l3l4(pc->st, CC_NOSETUP_RSP, pc);
2334 dss1_release_l3_process(pc);
2339 l3dss1_t304(struct l3_process *pc, u_char pr, void *arg)
2341 L3DelTimer(&pc->timer);
2343 pc->para.cause = 102;
2344 l3dss1_disconnect_req(pc, pr, NULL);
2345 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2350 l3dss1_t305(struct l3_process *pc, u_char pr, void *arg)
2355 struct sk_buff *skb;
2358 L3DelTimer(&pc->timer);
2359 if (pc->para.cause != NO_CAUSE)
2360 cause = pc->para.cause;
2362 MsgHead(p, pc->callref, MT_RELEASE);
2367 *p++ = cause | 0x80;
2370 if (!(skb = l3_alloc_skb(l)))
2372 memcpy(skb_put(skb, l), tmp, l);
2374 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2375 L3AddTimer(&pc->timer, T308, CC_T308_1);
2379 l3dss1_t310(struct l3_process *pc, u_char pr, void *arg)
2381 L3DelTimer(&pc->timer);
2383 pc->para.cause = 102;
2384 l3dss1_disconnect_req(pc, pr, NULL);
2385 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2389 l3dss1_t313(struct l3_process *pc, u_char pr, void *arg)
2391 L3DelTimer(&pc->timer);
2393 pc->para.cause = 102;
2394 l3dss1_disconnect_req(pc, pr, NULL);
2395 pc->st->l3.l3l4(pc->st, CC_CONNECT_ERR, pc);
2399 l3dss1_t308_1(struct l3_process *pc, u_char pr, void *arg)
2402 L3DelTimer(&pc->timer);
2403 l3dss1_message(pc, MT_RELEASE);
2404 L3AddTimer(&pc->timer, T308, CC_T308_2);
2408 l3dss1_t308_2(struct l3_process *pc, u_char pr, void *arg)
2410 L3DelTimer(&pc->timer);
2411 pc->st->l3.l3l4(pc->st, CC_RELEASE_ERR, pc);
2412 dss1_release_l3_process(pc);
2416 l3dss1_t318(struct l3_process *pc, u_char pr, void *arg)
2418 L3DelTimer(&pc->timer);
2419 pc->para.cause = 102; /* Timer expiry */
2420 pc->para.loc = 0; /* local */
2421 pc->st->l3.l3l4(pc->st, CC_RESUME_ERR, pc);
2423 l3dss1_message(pc, MT_RELEASE);
2424 L3AddTimer(&pc->timer, T308, CC_T308_1);
2428 l3dss1_t319(struct l3_process *pc, u_char pr, void *arg)
2430 L3DelTimer(&pc->timer);
2431 pc->para.cause = 102; /* Timer expiry */
2432 pc->para.loc = 0; /* local */
2433 pc->st->l3.l3l4(pc->st, CC_SUSPEND_ERR, pc);
2438 l3dss1_restart(struct l3_process *pc, u_char pr, void *arg)
2440 L3DelTimer(&pc->timer);
2441 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2442 dss1_release_l3_process(pc);
2446 l3dss1_status(struct l3_process *pc, u_char pr, void *arg)
2449 struct sk_buff *skb = arg;
2451 u_char cause = 0, callState = 0;
2453 if ((ret = l3dss1_get_cause(pc, skb))) {
2454 if (pc->debug & L3_DEB_WARN)
2455 l3_debug(pc->st, "STATUS get_cause ret(%d)",ret);
2461 if ((p = findie(skb->data, skb->len, IE_CALL_STATE, 0))) {
2465 if (!ie_in_set(pc, *p, l3_valid_states))
2471 if (!cause) { /* no error before */
2472 ret = check_infoelements(pc, skb, ie_STATUS);
2473 if (ERR_IE_COMPREHENSION == ret)
2475 else if (ERR_IE_UNRECOGNIZED == ret)
2481 if (pc->debug & L3_DEB_WARN)
2482 l3_debug(pc->st, "STATUS error(%d/%d)",ret,cause);
2483 tmp = pc->para.cause;
2484 pc->para.cause = cause;
2485 l3dss1_status_send(pc, 0, NULL);
2487 pc->para.cause = tmp;
2491 cause = pc->para.cause;
2492 if (((cause & 0x7f) == 111) && (callState == 0)) {
2493 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1...
2494 * if received MT_STATUS with cause == 111 and call
2495 * state == 0, then we must set down layer 3
2497 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2499 dss1_release_l3_process(pc);
2504 l3dss1_facility(struct l3_process *pc, u_char pr, void *arg)
2506 struct sk_buff *skb = arg;
2509 ret = check_infoelements(pc, skb, ie_FACILITY);
2510 l3dss1_std_ie_err(pc, ret);
2513 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0)))
2514 l3dss1_parse_facility(pc->st, pc, pc->callref, p);
2519 l3dss1_suspend_req(struct l3_process *pc, u_char pr, void *arg)
2521 struct sk_buff *skb;
2525 u_char *msg = pc->chan->setup.phone;
2527 MsgHead(p, pc->callref, MT_SUSPEND);
2529 if (l && (l <= 10)) { /* Max length 10 octets */
2532 for (i = 0; i < l; i++)
2535 l3_debug(pc->st, "SUS wrong CALL_ID len %d", l);
2539 if (!(skb = l3_alloc_skb(l)))
2541 memcpy(skb_put(skb, l), tmp, l);
2542 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2544 L3AddTimer(&pc->timer, T319, CC_T319);
2548 l3dss1_suspend_ack(struct l3_process *pc, u_char pr, void *arg)
2550 struct sk_buff *skb = arg;
2553 L3DelTimer(&pc->timer);
2555 pc->para.cause = NO_CAUSE;
2556 pc->st->l3.l3l4(pc->st, CC_SUSPEND | CONFIRM, pc);
2557 /* We don't handle suspend_ack for IE errors now */
2558 if ((ret = check_infoelements(pc, skb, ie_SUSPEND_ACKNOWLEDGE)))
2559 if (pc->debug & L3_DEB_WARN)
2560 l3_debug(pc->st, "SUSPACK check ie(%d)",ret);
2561 dss1_release_l3_process(pc);
2565 l3dss1_suspend_rej(struct l3_process *pc, u_char pr, void *arg)
2567 struct sk_buff *skb = arg;
2570 if ((ret = l3dss1_get_cause(pc, skb))) {
2571 if (pc->debug & L3_DEB_WARN)
2572 l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)",ret);
2574 pc->para.cause = 96;
2576 pc->para.cause = 100;
2577 l3dss1_status_send(pc, pr, NULL);
2580 ret = check_infoelements(pc, skb, ie_SUSPEND_REJECT);
2581 if (ERR_IE_COMPREHENSION == ret) {
2582 l3dss1_std_ie_err(pc, ret);
2585 L3DelTimer(&pc->timer);
2586 pc->st->l3.l3l4(pc->st, CC_SUSPEND_ERR, pc);
2588 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2589 l3dss1_std_ie_err(pc, ret);
2593 l3dss1_resume_req(struct l3_process *pc, u_char pr, void *arg)
2595 struct sk_buff *skb;
2599 u_char *msg = pc->para.setup.phone;
2601 MsgHead(p, pc->callref, MT_RESUME);
2604 if (l && (l <= 10)) { /* Max length 10 octets */
2607 for (i = 0; i < l; i++)
2610 l3_debug(pc->st, "RES wrong CALL_ID len %d", l);
2614 if (!(skb = l3_alloc_skb(l)))
2616 memcpy(skb_put(skb, l), tmp, l);
2617 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2619 L3AddTimer(&pc->timer, T318, CC_T318);
2623 l3dss1_resume_ack(struct l3_process *pc, u_char pr, void *arg)
2625 struct sk_buff *skb = arg;
2628 if ((id = l3dss1_get_channel_id(pc, skb)) > 0) {
2629 if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
2630 if (pc->debug & L3_DEB_WARN)
2631 l3_debug(pc->st, "resume ack with wrong chid %x", id);
2632 pc->para.cause = 100;
2633 l3dss1_status_send(pc, pr, NULL);
2636 pc->para.bchannel = id;
2637 } else if (1 == pc->state) {
2638 if (pc->debug & L3_DEB_WARN)
2639 l3_debug(pc->st, "resume ack without chid (ret %d)", id);
2640 pc->para.cause = 96;
2641 l3dss1_status_send(pc, pr, NULL);
2644 ret = check_infoelements(pc, skb, ie_RESUME_ACKNOWLEDGE);
2645 if (ERR_IE_COMPREHENSION == ret) {
2646 l3dss1_std_ie_err(pc, ret);
2649 L3DelTimer(&pc->timer);
2650 pc->st->l3.l3l4(pc->st, CC_RESUME | CONFIRM, pc);
2652 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2653 l3dss1_std_ie_err(pc, ret);
2657 l3dss1_resume_rej(struct l3_process *pc, u_char pr, void *arg)
2659 struct sk_buff *skb = arg;
2662 if ((ret = l3dss1_get_cause(pc, skb))) {
2663 if (pc->debug & L3_DEB_WARN)
2664 l3_debug(pc->st, "RES_REJ get_cause ret(%d)",ret);
2666 pc->para.cause = 96;
2668 pc->para.cause = 100;
2669 l3dss1_status_send(pc, pr, NULL);
2672 ret = check_infoelements(pc, skb, ie_RESUME_REJECT);
2673 if (ERR_IE_COMPREHENSION == ret) {
2674 l3dss1_std_ie_err(pc, ret);
2677 L3DelTimer(&pc->timer);
2678 pc->st->l3.l3l4(pc->st, CC_RESUME_ERR, pc);
2680 if (ret) /* STATUS for none mandatory IE errors after actions are taken */
2681 l3dss1_std_ie_err(pc, ret);
2682 dss1_release_l3_process(pc);
2686 l3dss1_global_restart(struct l3_process *pc, u_char pr, void *arg)
2690 u_char ri, ch = 0, chan = 0;
2692 struct sk_buff *skb = arg;
2693 struct l3_process *up;
2696 L3DelTimer(&pc->timer);
2698 if ((p = findie(p, skb->len, IE_RESTART_IND, 0))) {
2700 l3_debug(pc->st, "Restart %x", ri);
2702 l3_debug(pc->st, "Restart without restart IE");
2706 if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
2709 if (pc->st->l3.debug)
2710 l3_debug(pc->st, "Restart for channel %d", chan);
2713 up = pc->st->l3.proc;
2716 up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up);
2717 else if (up->para.bchannel == chan)
2718 up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up);
2722 MsgHead(p, pc->callref, MT_RESTART_ACKNOWLEDGE);
2724 *p++ = IE_CHANNEL_ID;
2728 *p++ = 0x79; /* RESTART Ind */
2732 if (!(skb = l3_alloc_skb(l)))
2734 memcpy(skb_put(skb, l), tmp, l);
2736 l3_msg(pc->st, DL_DATA | REQUEST, skb);
2740 l3dss1_dl_reset(struct l3_process *pc, u_char pr, void *arg)
2742 pc->para.cause = 0x29; /* Temporary failure */
2744 l3dss1_disconnect_req(pc, pr, NULL);
2745 pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc);
2749 l3dss1_dl_release(struct l3_process *pc, u_char pr, void *arg)
2752 pc->para.cause = 0x1b; /* Destination out of order */
2754 pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc);
2755 release_l3_process(pc);
2759 l3dss1_dl_reestablish(struct l3_process *pc, u_char pr, void *arg)
2761 L3DelTimer(&pc->timer);
2762 L3AddTimer(&pc->timer, T309, CC_T309);
2763 l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL);
2767 l3dss1_dl_reest_status(struct l3_process *pc, u_char pr, void *arg)
2769 L3DelTimer(&pc->timer);
2771 pc->para.cause = 0x1F; /* normal, unspecified */
2772 l3dss1_status_send(pc, 0, NULL);
2776 static struct stateentry downstatelist[] =
2779 CC_SETUP | REQUEST, l3dss1_setup_req},
2781 CC_RESUME | REQUEST, l3dss1_resume_req},
2782 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(25),
2783 CC_DISCONNECT | REQUEST, l3dss1_disconnect_req},
2785 CC_RELEASE | REQUEST, l3dss1_release_req},
2787 CC_RESTART | REQUEST, l3dss1_restart},
2788 {SBIT(6) | SBIT(25),
2789 CC_IGNORE | REQUEST, l3dss1_reset},
2790 {SBIT(6) | SBIT(25),
2791 CC_REJECT | REQUEST, l3dss1_reject_req},
2792 {SBIT(6) | SBIT(25),
2793 CC_PROCEED_SEND | REQUEST, l3dss1_proceed_req},
2795 CC_MORE_INFO | REQUEST, l3dss1_setup_ack_req},
2797 CC_MORE_INFO | REQUEST, l3dss1_dummy},
2798 {SBIT(6) | SBIT(9) | SBIT(25),
2799 CC_ALERTING | REQUEST, l3dss1_alert_req},
2800 {SBIT(6) | SBIT(7) | SBIT(9) | SBIT(25),
2801 CC_SETUP | RESPONSE, l3dss1_setup_rsp},
2803 CC_SUSPEND | REQUEST, l3dss1_suspend_req},
2804 {SBIT(7) | SBIT(9) | SBIT(25),
2805 CC_REDIR | REQUEST, l3dss1_redir_req},
2807 CC_REDIR | REQUEST, l3dss1_redir_req_early},
2808 {SBIT(9) | SBIT(25),
2809 CC_DISCONNECT | REQUEST, l3dss1_disconnect_req},
2811 CC_T302, l3dss1_t302},
2813 CC_T303, l3dss1_t303},
2815 CC_T304, l3dss1_t304},
2817 CC_T310, l3dss1_t310},
2819 CC_T313, l3dss1_t313},
2821 CC_T305, l3dss1_t305},
2823 CC_T319, l3dss1_t319},
2825 CC_T318, l3dss1_t318},
2827 CC_T308_1, l3dss1_t308_1},
2829 CC_T308_2, l3dss1_t308_2},
2831 CC_T309, l3dss1_dl_release},
2835 (sizeof(downstatelist) / sizeof(struct stateentry))
2837 static struct stateentry datastatelist[] =
2840 MT_STATUS_ENQUIRY, l3dss1_status_enq},
2842 MT_FACILITY, l3dss1_facility},
2844 MT_STATUS, l3dss1_release_ind},
2846 MT_STATUS, l3dss1_status},
2848 MT_SETUP, l3dss1_setup},
2849 {SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(12) |
2850 SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2851 MT_SETUP, l3dss1_dummy},
2853 MT_CALL_PROCEEDING, l3dss1_call_proc},
2855 MT_SETUP_ACKNOWLEDGE, l3dss1_setup_ack},
2857 MT_ALERTING, l3dss1_alerting},
2859 MT_PROGRESS, l3dss1_progress},
2860 {SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) |
2861 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2862 MT_INFORMATION, l3dss1_information},
2863 {SBIT(10) | SBIT(11) | SBIT(15),
2864 MT_NOTIFY, l3dss1_notify},
2865 {SBIT(0) | SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
2866 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2867 MT_RELEASE_COMPLETE, l3dss1_release_cmpl},
2868 {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),
2869 MT_RELEASE, l3dss1_release},
2870 {SBIT(19), MT_RELEASE, l3dss1_release_ind},
2871 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(15) | SBIT(17) | SBIT(25),
2872 MT_DISCONNECT, l3dss1_disconnect},
2874 MT_DISCONNECT, l3dss1_dummy},
2875 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4),
2876 MT_CONNECT, l3dss1_connect},
2878 MT_CONNECT_ACKNOWLEDGE, l3dss1_connect_ack},
2880 MT_SUSPEND_ACKNOWLEDGE, l3dss1_suspend_ack},
2882 MT_SUSPEND_REJECT, l3dss1_suspend_rej},
2884 MT_RESUME_ACKNOWLEDGE, l3dss1_resume_ack},
2886 MT_RESUME_REJECT, l3dss1_resume_rej},
2890 (sizeof(datastatelist) / sizeof(struct stateentry))
2892 static struct stateentry globalmes_list[] =
2895 MT_STATUS, l3dss1_status},
2897 MT_RESTART, l3dss1_global_restart},
2899 MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack},
2902 #define GLOBALM_LEN \
2903 (sizeof(globalmes_list) / sizeof(struct stateentry))
2905 static struct stateentry manstatelist[] =
2908 DL_ESTABLISH | INDICATION, l3dss1_dl_reset},
2910 DL_ESTABLISH | CONFIRM, l3dss1_dl_reest_status},
2912 DL_RELEASE | INDICATION, l3dss1_dl_reestablish},
2914 DL_RELEASE | INDICATION, l3dss1_dl_release},
2918 (sizeof(manstatelist) / sizeof(struct stateentry))
2923 global_handler(struct PStack *st, int mt, struct sk_buff *skb)
2929 struct l3_process *proc = st->l3.global;
2931 proc->callref = skb->data[2]; /* cr flag */
2932 for (i = 0; i < GLOBALM_LEN; i++)
2933 if ((mt == globalmes_list[i].primitive) &&
2934 ((1 << proc->state) & globalmes_list[i].state))
2936 if (i == GLOBALM_LEN) {
2937 if (st->l3.debug & L3_DEB_STATE) {
2938 l3_debug(st, "dss1 global state %d mt %x unhandled",
2941 MsgHead(p, proc->callref, MT_STATUS);
2945 *p++ = 81 |0x80; /* invalid cr */
2946 *p++ = 0x14; /* CallState */
2948 *p++ = proc->state & 0x3f;
2950 if (!(skb = l3_alloc_skb(l)))
2952 memcpy(skb_put(skb, l), tmp, l);
2953 l3_msg(proc->st, DL_DATA | REQUEST, skb);
2955 if (st->l3.debug & L3_DEB_STATE) {
2956 l3_debug(st, "dss1 global %d mt %x",
2959 globalmes_list[i].rout(proc, mt, skb);
2964 dss1up(struct PStack *st, int pr, void *arg)
2966 int i, mt, cr, cause, callState;
2969 struct sk_buff *skb = arg;
2970 struct l3_process *proc;
2973 case (DL_DATA | INDICATION):
2974 case (DL_UNIT_DATA | INDICATION):
2976 case (DL_ESTABLISH | CONFIRM):
2977 case (DL_ESTABLISH | INDICATION):
2978 case (DL_RELEASE | INDICATION):
2979 case (DL_RELEASE | CONFIRM):
2980 l3_msg(st, pr, arg);
2984 printk(KERN_ERR "HiSax dss1up unknown pr=%04x\n", pr);
2988 l3_debug(st, "dss1up frame too short(%d)", skb->len);
2993 if (skb->data[0] != PROTO_DIS_EURO) {
2994 if (st->l3.debug & L3_DEB_PROTERR) {
2995 l3_debug(st, "dss1up%sunexpected discriminator %x message len %d",
2996 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
2997 skb->data[0], skb->len);
3002 cr = getcallref(skb->data);
3003 if (skb->len < ((skb->data[1] & 0x0f) + 3)) {
3004 l3_debug(st, "dss1up frame too short(%d)", skb->len);
3008 mt = skb->data[skb->data[1] + 2];
3009 if (st->l3.debug & L3_DEB_STATE)
3010 l3_debug(st, "dss1up cr %d", cr);
3011 if (cr == -2) { /* wrong Callref */
3012 if (st->l3.debug & L3_DEB_WARN)
3013 l3_debug(st, "dss1up wrong Callref");
3016 } else if (cr == -1) { /* Dummy Callref */
3017 if (mt == MT_FACILITY)
3018 if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) {
3019 l3dss1_parse_facility(st, NULL,
3020 (pr == (DL_DATA | INDICATION)) ? -1 : -2, p);
3024 if (st->l3.debug & L3_DEB_WARN)
3025 l3_debug(st, "dss1up dummy Callref (no facility msg or ie)");
3028 } else if ((((skb->data[1] & 0x0f) == 1) && (0==(cr & 0x7f))) ||
3029 (((skb->data[1] & 0x0f) == 2) && (0==(cr & 0x7fff)))) { /* Global CallRef */
3030 if (st->l3.debug & L3_DEB_STATE)
3031 l3_debug(st, "dss1up Global CallRef");
3032 global_handler(st, mt, skb);
3035 } else if (!(proc = getl3proc(st, cr))) {
3036 /* No transaction process exist, that means no call with
3037 * this callreference is active
3039 if (mt == MT_SETUP) {
3040 /* Setup creates a new transaction process */
3041 if (skb->data[2] & 0x80) {
3042 /* Setup with wrong CREF flag */
3043 if (st->l3.debug & L3_DEB_STATE)
3044 l3_debug(st, "dss1up wrong CRef flag");
3048 if (!(proc = dss1_new_l3_process(st, cr))) {
3049 /* May be to answer with RELEASE_COMPLETE and
3050 * CAUSE 0x2f "Resource unavailable", but this
3051 * need a new_l3_process too ... arghh
3056 } else if (mt == MT_STATUS) {
3058 if ((ptr = findie(skb->data, skb->len, IE_CAUSE, 0)) != NULL) {
3062 cause = *ptr & 0x7f;
3065 if ((ptr = findie(skb->data, skb->len, IE_CALL_STATE, 0)) != NULL) {
3071 /* ETS 300-104 part 2.4.1
3072 * if setup has not been made and a message type
3073 * MT_STATUS is received with call state == 0,
3074 * we must send nothing
3076 if (callState != 0) {
3077 /* ETS 300-104 part 2.4.2
3078 * if setup has not been made and a message type
3079 * MT_STATUS is received with call state != 0,
3080 * we must send MT_RELEASE_COMPLETE cause 101
3082 if ((proc = dss1_new_l3_process(st, cr))) {
3083 proc->para.cause = 101;
3084 l3dss1_msg_without_setup(proc, 0, NULL);
3089 } else if (mt == MT_RELEASE_COMPLETE) {
3093 /* ETS 300-104 part 2
3094 * if setup has not been made and a message type
3095 * (except MT_SETUP and RELEASE_COMPLETE) is received,
3096 * we must send MT_RELEASE_COMPLETE cause 81 */
3098 if ((proc = dss1_new_l3_process(st, cr))) {
3099 proc->para.cause = 81;
3100 l3dss1_msg_without_setup(proc, 0, NULL);
3105 if (l3dss1_check_messagetype_validity(proc, mt, skb)) {
3109 if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL)
3110 l3dss1_deliver_display(proc, pr, p); /* Display IE included */
3111 for (i = 0; i < DATASLLEN; i++)
3112 if ((mt == datastatelist[i].primitive) &&
3113 ((1 << proc->state) & datastatelist[i].state))
3115 if (i == DATASLLEN) {
3116 if (st->l3.debug & L3_DEB_STATE) {
3117 l3_debug(st, "dss1up%sstate %d mt %#x unhandled",
3118 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
3121 if ((MT_RELEASE_COMPLETE != mt) && (MT_RELEASE != mt)) {
3122 proc->para.cause = 101;
3123 l3dss1_status_send(proc, pr, skb);
3126 if (st->l3.debug & L3_DEB_STATE) {
3127 l3_debug(st, "dss1up%sstate %d mt %x",
3128 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
3131 datastatelist[i].rout(proc, pr, skb);
3138 dss1down(struct PStack *st, int pr, void *arg)
3141 struct l3_process *proc;
3142 struct Channel *chan;
3144 if ((DL_ESTABLISH | REQUEST) == pr) {
3145 l3_msg(st, pr, NULL);
3147 } else if (((CC_SETUP | REQUEST) == pr) || ((CC_RESUME | REQUEST) == pr)) {
3151 if ((proc = dss1_new_l3_process(st, cr))) {
3154 memcpy(&proc->para.setup, &chan->setup, sizeof(setup_parm));
3161 printk(KERN_ERR "HiSax dss1down without proc pr=%04x\n", pr);
3165 if ( pr == (CC_TDSS1_IO | REQUEST)) {
3166 l3dss1_io_timer(proc); /* timer expires */
3170 for (i = 0; i < DOWNSLLEN; i++)
3171 if ((pr == downstatelist[i].primitive) &&
3172 ((1 << proc->state) & downstatelist[i].state))
3174 if (i == DOWNSLLEN) {
3175 if (st->l3.debug & L3_DEB_STATE) {
3176 l3_debug(st, "dss1down state %d prim %#x unhandled",
3180 if (st->l3.debug & L3_DEB_STATE) {
3181 l3_debug(st, "dss1down state %d prim %#x",
3184 downstatelist[i].rout(proc, pr, arg);
3189 dss1man(struct PStack *st, int pr, void *arg)
3192 struct l3_process *proc = arg;
3195 printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr);
3198 for (i = 0; i < MANSLLEN; i++)
3199 if ((pr == manstatelist[i].primitive) &&
3200 ((1 << proc->state) & manstatelist[i].state))
3202 if (i == MANSLLEN) {
3203 if (st->l3.debug & L3_DEB_STATE) {
3204 l3_debug(st, "cr %d dss1man state %d prim %#x unhandled",
3205 proc->callref & 0x7f, proc->state, pr);
3208 if (st->l3.debug & L3_DEB_STATE) {
3209 l3_debug(st, "cr %d dss1man state %d prim %#x",
3210 proc->callref & 0x7f, proc->state, pr);
3212 manstatelist[i].rout(proc, pr, arg);
3217 setstack_dss1(struct PStack *st)
3222 st->lli.l4l3 = dss1down;
3223 st->lli.l4l3_proto = l3dss1_cmd_global;
3224 st->l2.l2l3 = dss1up;
3225 st->l3.l3ml3 = dss1man;
3227 st->prot.dss1.last_invoke_id = 0;
3228 st->prot.dss1.invoke_used[0] = 1; /* Bit 0 must always be set to 1 */
3231 st->prot.dss1.invoke_used[i++] = 0;
3233 if (!(st->l3.global = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) {
3234 printk(KERN_ERR "HiSax can't get memory for dss1 global CR\n");
3236 st->l3.global->state = 0;
3237 st->l3.global->callref = 0;
3238 st->l3.global->next = NULL;
3239 st->l3.global->debug = L3_DEB_WARN;
3240 st->l3.global->st = st;
3241 st->l3.global->N303 = 1;
3242 st->l3.global->prot.dss1.invoke_id = 0;
3244 L3InitTimer(st->l3.global, &st->l3.global->timer);
3246 strcpy(tmp, dss1_revision);
3247 printk(KERN_INFO "HiSax: DSS1 Rev. %s\n", HiSax_getrev(tmp));