1 /* $Id: l3dss1.c,v 2.29 2000/06/26 08:59:14 keil Exp $
3 * EURO/DSS1 D-channel protocol
5 * Author Karsten Keil (keil@isdn4linux.de)
6 * based on the teles driver from Jan den Ouden
8 * This file is (c) under GNU PUBLIC LICENSE
9 * For changes and modifications please read
10 * ../../../Documentation/isdn/HiSax.cert
12 * Thanks to Jan den Ouden
17 #define __NO_VERSION__
21 #include <linux/ctype.h>
22 #include <linux/config.h>
24 extern char *HiSax_getrev(const char *revision
);
25 const char *dss1_revision
= "$Revision: 2.29 $";
27 #define EXT_BEARER_CAPS 1
29 #define MsgHead(ptr, cref, mty) \
40 /**********************************************/
41 /* get a new invoke id for remote operations. */
42 /* Only a return value != 0 is valid */
43 /**********************************************/
44 static unsigned char new_invoke_id(struct PStack
*p
)
49 i
= 32; /* maximum search depth */
54 retval
= p
->prot
.dss1
.last_invoke_id
+ 1; /* try new id */
55 while ((i
) && (p
->prot
.dss1
.invoke_used
[retval
>> 3] == 0xFF)) {
56 p
->prot
.dss1
.last_invoke_id
= (retval
& 0xF8) + 8;
60 while (p
->prot
.dss1
.invoke_used
[retval
>> 3] & (1 << (retval
& 7)))
64 p
->prot
.dss1
.last_invoke_id
= retval
;
65 p
->prot
.dss1
.invoke_used
[retval
>> 3] |= (1 << (retval
& 7));
71 /*************************/
72 /* free a used invoke id */
73 /*************************/
74 static void free_invoke_id(struct PStack
*p
, unsigned char id
)
77 if (!id
) return; /* 0 = invalid value */
81 p
->prot
.dss1
.invoke_used
[id
>> 3] &= ~(1 << (id
& 7));
83 } /* free_invoke_id */
86 /**********************************************************/
87 /* create a new l3 process and fill in dss1 specific data */
88 /**********************************************************/
89 static struct l3_process
90 *dss1_new_l3_process(struct PStack
*st
, int cr
)
91 { struct l3_process
*proc
;
93 if (!(proc
= new_l3_process(st
, cr
)))
96 proc
->prot
.dss1
.invoke_id
= 0;
97 proc
->prot
.dss1
.remote_operation
= 0;
98 proc
->prot
.dss1
.uus1_data
[0] = '\0';
101 } /* dss1_new_l3_process */
103 /************************************************/
104 /* free a l3 process and all dss1 specific data */
105 /************************************************/
107 dss1_release_l3_process(struct l3_process
*p
)
109 free_invoke_id(p
->st
,p
->prot
.dss1
.invoke_id
);
110 release_l3_process(p
);
111 } /* dss1_release_l3_process */
113 /********************************************************/
114 /* search a process with invoke id id and dummy callref */
115 /********************************************************/
116 static struct l3_process
*
117 l3dss1_search_dummy_proc(struct PStack
*st
, int id
)
118 { struct l3_process
*pc
= st
->l3
.proc
; /* start of processes */
120 if (!id
) return(NULL
);
123 { if ((pc
->callref
== -1) && (pc
->prot
.dss1
.invoke_id
== id
))
128 } /* l3dss1_search_dummy_proc */
130 /*******************************************************************/
131 /* called when a facility message with a dummy callref is received */
132 /* and a return result is delivered. id specifies the invoke id. */
133 /*******************************************************************/
135 l3dss1_dummy_return_result(struct PStack
*st
, int id
, u_char
*p
, u_char nlen
)
137 struct IsdnCardState
*cs
;
138 struct l3_process
*pc
= NULL
;
140 if ((pc
= l3dss1_search_dummy_proc(st
, id
)))
141 { L3DelTimer(&pc
->timer
); /* remove timer */
143 cs
= pc
->st
->l1
.hardware
;
144 ic
.driver
= cs
->myid
;
145 ic
.command
= ISDN_STAT_PROT
;
146 ic
.arg
= DSS1_STAT_INVOKE_RES
;
147 ic
.parm
.dss1_io
.hl_id
= pc
->prot
.dss1
.invoke_id
;
148 ic
.parm
.dss1_io
.ll_id
= pc
->prot
.dss1
.ll_id
;
149 ic
.parm
.dss1_io
.proc
= pc
->prot
.dss1
.proc
;
150 ic
.parm
.dss1_io
.timeout
= 0;
151 ic
.parm
.dss1_io
.datalen
= nlen
;
152 ic
.parm
.dss1_io
.data
= p
;
153 free_invoke_id(pc
->st
, pc
->prot
.dss1
.invoke_id
);
154 pc
->prot
.dss1
.invoke_id
= 0; /* reset id */
156 cs
->iif
.statcallb(&ic
);
157 dss1_release_l3_process(pc
);
160 l3_debug(st
, "dummy return result id=0x%x result len=%d",id
,nlen
);
161 } /* l3dss1_dummy_return_result */
163 /*******************************************************************/
164 /* called when a facility message with a dummy callref is received */
165 /* and a return error is delivered. id specifies the invoke id. */
166 /*******************************************************************/
168 l3dss1_dummy_error_return(struct PStack
*st
, int id
, ulong error
)
170 struct IsdnCardState
*cs
;
171 struct l3_process
*pc
= NULL
;
173 if ((pc
= l3dss1_search_dummy_proc(st
, id
)))
174 { L3DelTimer(&pc
->timer
); /* remove timer */
176 cs
= pc
->st
->l1
.hardware
;
177 ic
.driver
= cs
->myid
;
178 ic
.command
= ISDN_STAT_PROT
;
179 ic
.arg
= DSS1_STAT_INVOKE_ERR
;
180 ic
.parm
.dss1_io
.hl_id
= pc
->prot
.dss1
.invoke_id
;
181 ic
.parm
.dss1_io
.ll_id
= pc
->prot
.dss1
.ll_id
;
182 ic
.parm
.dss1_io
.proc
= pc
->prot
.dss1
.proc
;
183 ic
.parm
.dss1_io
.timeout
= error
;
184 ic
.parm
.dss1_io
.datalen
= 0;
185 ic
.parm
.dss1_io
.data
= NULL
;
186 free_invoke_id(pc
->st
, pc
->prot
.dss1
.invoke_id
);
187 pc
->prot
.dss1
.invoke_id
= 0; /* reset id */
189 cs
->iif
.statcallb(&ic
);
190 dss1_release_l3_process(pc
);
193 l3_debug(st
, "dummy return error id=0x%x error=0x%lx",id
,error
);
194 } /* l3dss1_error_return */
196 /*******************************************************************/
197 /* called when a facility message with a dummy callref is received */
198 /* and a invoke is delivered. id specifies the invoke id. */
199 /*******************************************************************/
201 l3dss1_dummy_invoke(struct PStack
*st
, int cr
, int id
,
202 int ident
, u_char
*p
, u_char nlen
)
204 struct IsdnCardState
*cs
;
206 l3_debug(st
, "dummy invoke %s id=0x%x ident=0x%x datalen=%d",
207 (cr
== -1) ? "local" : "broadcast",id
,ident
,nlen
);
208 if (cr
>= -1) return; /* ignore local data */
210 cs
= st
->l1
.hardware
;
211 ic
.driver
= cs
->myid
;
212 ic
.command
= ISDN_STAT_PROT
;
213 ic
.arg
= DSS1_STAT_INVOKE_BRD
;
214 ic
.parm
.dss1_io
.hl_id
= id
;
215 ic
.parm
.dss1_io
.ll_id
= 0;
216 ic
.parm
.dss1_io
.proc
= ident
;
217 ic
.parm
.dss1_io
.timeout
= 0;
218 ic
.parm
.dss1_io
.datalen
= nlen
;
219 ic
.parm
.dss1_io
.data
= p
;
221 cs
->iif
.statcallb(&ic
);
222 } /* l3dss1_dummy_invoke */
225 l3dss1_parse_facility(struct PStack
*st
, struct l3_process
*pc
,
229 unsigned char nlen
= 0, ilen
, cp_tag
;
234 st
= pc
->st
; /* valid Stack */
236 if ((!st
) || (cr
>= 0)) return; /* neither pc nor st specified */
241 l3_debug(st
, "qd_len == 0");
244 if ((*p
& 0x1F) != 0x11) { /* Service discriminator, supplementary service */
245 l3_debug(st
, "supplementary service != 0x11");
248 while (qd_len
> 0 && !(*p
& 0x80)) { /* extension ? */
253 l3_debug(st
, "qd_len < 2");
258 if ((*p
& 0xE0) != 0xA0) { /* class and form */
259 l3_debug(st
, "class and form != 0xA0");
263 cp_tag
= *p
& 0x1F; /* remember tag value */
268 { l3_debug(st
, "qd_len < 1");
272 { /* length format indefinite or limited */
273 nlen
= *p
++ & 0x7F; /* number of len bytes or indefinite */
274 if ((qd_len
-- < ((!nlen
) ? 3 : (1 + nlen
))) ||
276 { l3_debug(st
, "length format error or not implemented");
280 { nlen
= *p
++; /* complete length */
284 { qd_len
-= 2; /* trailing null bytes */
285 if ((*(p
+qd_len
)) || (*(p
+qd_len
+1)))
286 { l3_debug(st
,"length format indefinite error");
297 { l3_debug(st
, "qd_len < nlen");
303 { l3_debug(st
, "nlen < 2");
307 { /* invoke identifier tag */
308 l3_debug(st
, "invoke identifier tag !=0x02");
314 { /* length format */
315 l3_debug(st
, "invoke id length format 2");
320 if (ilen
> nlen
|| ilen
== 0)
321 { l3_debug(st
, "ilen > nlen || ilen == 0");
327 { id
= (id
<< 8) | (*p
++ & 0xFF); /* invoke identifier */
331 switch (cp_tag
) { /* component tag */
334 l3_debug(st
, "nlen < 2 22");
337 if (*p
!= 0x02) { /* operation value */
338 l3_debug(st
, "operation value !=0x02");
345 if (ilen
> nlen
|| ilen
== 0) {
346 l3_debug(st
, "ilen > nlen || ilen == 0 22");
352 ident
= (ident
<< 8) | (*p
++ & 0xFF);
357 { l3dss1_dummy_invoke(st
, cr
, id
, ident
, p
, nlen
);
363 #define FOO1(s,a,b) \
366 if(nlen < ilen+2) { \
367 l3_debug(st, "FOO1 nlen < ilen+2"); \
371 if((*p & 0xFF) == (a)) { \
381 case 0x22: /* during */
382 FOO1("1A", 0x30, FOO1("1C", 0xA1, FOO1("1D", 0x30, FOO1("1E", 0x02, ( {
384 nlen
= (nlen
)?nlen
:0; /* Make gcc happy */
386 ident
= (ident
<< 8) | *p
++;
389 if (ident
> pc
->para
.chargeinfo
) {
390 pc
->para
.chargeinfo
= ident
;
391 st
->l3
.l3l4(st
, CC_CHARGE
| INDICATION
, pc
);
393 if (st
->l3
.debug
& L3_DEB_CHARGE
) {
395 l3_debug(st
, "charging info during %d", pc
->para
.chargeinfo
);
398 l3_debug(st
, "charging info final %d", pc
->para
.chargeinfo
);
404 case 0x24: /* final */
405 FOO1("2A", 0x30, FOO1("2B", 0x30, FOO1("2C", 0xA1, FOO1("2D", 0x30, FOO1("2E", 0x02, ( {
407 nlen
= (nlen
)?nlen
:0; /* Make gcc happy */
409 ident
= (ident
<< 8) | *p
++;
412 if (ident
> pc
->para
.chargeinfo
) {
413 pc
->para
.chargeinfo
= ident
;
414 st
->l3
.l3l4(st
, CC_CHARGE
| INDICATION
, pc
);
416 if (st
->l3
.debug
& L3_DEB_CHARGE
) {
417 l3_debug(st
, "charging info final %d", pc
->para
.chargeinfo
);
423 l3_debug(st
, "invoke break invalid ident %02x",ident
);
429 #else not HISAX_DE_AOC
430 l3_debug(st
, "invoke break");
431 #endif not HISAX_DE_AOC
433 case 2: /* return result */
434 /* if no process available handle separately */
437 l3dss1_dummy_return_result(st
, id
, p
, nlen
);
440 if ((pc
->prot
.dss1
.invoke_id
) && (pc
->prot
.dss1
.invoke_id
== id
))
441 { /* Diversion successfull */
442 free_invoke_id(st
,pc
->prot
.dss1
.invoke_id
);
443 pc
->prot
.dss1
.remote_result
= 0; /* success */
444 pc
->prot
.dss1
.invoke_id
= 0;
445 pc
->redir_result
= pc
->prot
.dss1
.remote_result
;
446 st
->l3
.l3l4(st
, CC_REDIR
| INDICATION
, pc
); } /* Diversion successfull */
448 l3_debug(st
,"return error unknown identifier");
450 case 3: /* return error */
453 { l3_debug(st
, "return error nlen < 2");
458 l3_debug(st
, "invoke error tag !=0x02");
464 { /* length format */
465 l3_debug(st
, "invoke return errlen > 4 ");
470 if (ilen
> nlen
|| ilen
== 0)
471 { l3_debug(st
, "error return ilen > nlen || ilen == 0");
476 { err_ret
= (err_ret
<< 8) | (*p
++ & 0xFF); /* error value */
479 /* if no process available handle separately */
482 l3dss1_dummy_error_return(st
, id
, err_ret
);
485 if ((pc
->prot
.dss1
.invoke_id
) && (pc
->prot
.dss1
.invoke_id
== id
))
486 { /* Deflection error */
487 free_invoke_id(st
,pc
->prot
.dss1
.invoke_id
);
488 pc
->prot
.dss1
.remote_result
= err_ret
; /* result */
489 pc
->prot
.dss1
.invoke_id
= 0;
490 pc
->redir_result
= pc
->prot
.dss1
.remote_result
;
491 st
->l3
.l3l4(st
, CC_REDIR
| INDICATION
, pc
);
492 } /* Deflection error */
494 l3_debug(st
,"return result unknown identifier");
497 l3_debug(st
, "facility default break tag=0x%02x",cp_tag
);
503 l3dss1_message(struct l3_process
*pc
, u_char mt
)
508 if (!(skb
= l3_alloc_skb(4)))
511 MsgHead(p
, pc
->callref
, mt
);
512 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
516 l3dss1_message_cause(struct l3_process
*pc
, u_char mt
, u_char cause
)
523 MsgHead(p
, pc
->callref
, mt
);
530 if (!(skb
= l3_alloc_skb(l
)))
532 memcpy(skb_put(skb
, l
), tmp
, l
);
533 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
537 l3dss1_status_send(struct l3_process
*pc
, u_char pr
, void *arg
)
544 MsgHead(p
, pc
->callref
, MT_STATUS
);
549 *p
++ = pc
->para
.cause
| 0x80;
551 *p
++ = IE_CALL_STATE
;
553 *p
++ = pc
->state
& 0x3f;
556 if (!(skb
= l3_alloc_skb(l
)))
558 memcpy(skb_put(skb
, l
), tmp
, l
);
559 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
563 l3dss1_msg_without_setup(struct l3_process
*pc
, u_char pr
, void *arg
)
565 /* This routine is called if here was no SETUP made (checks in dss1up and in
566 * l3dss1_setup) and a RELEASE_COMPLETE have to be sent with an error code
567 * MT_STATUS_ENQUIRE in the NULL state is handled too
574 switch (pc
->para
.cause
) {
575 case 81: /* invalid callreference */
576 case 88: /* incomp destination */
577 case 96: /* mandory IE missing */
578 case 100: /* invalid IE contents */
579 case 101: /* incompatible Callstate */
580 MsgHead(p
, pc
->callref
, MT_RELEASE_COMPLETE
);
584 *p
++ = pc
->para
.cause
| 0x80;
587 printk(KERN_ERR
"HiSax l3dss1_msg_without_setup wrong cause %d\n",
592 if (!(skb
= l3_alloc_skb(l
)))
594 memcpy(skb_put(skb
, l
), tmp
, l
);
595 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
596 dss1_release_l3_process(pc
);
599 static int ie_ALERTING
[] = {IE_BEARER
, IE_CHANNEL_ID
| IE_MANDATORY_1
,
600 IE_FACILITY
, IE_PROGRESS
, IE_DISPLAY
, IE_SIGNAL
, IE_HLC
,
602 static int ie_CALL_PROCEEDING
[] = {IE_BEARER
, IE_CHANNEL_ID
| IE_MANDATORY_1
,
603 IE_FACILITY
, IE_PROGRESS
, IE_DISPLAY
, IE_HLC
, -1};
604 static int ie_CONNECT
[] = {IE_BEARER
, IE_CHANNEL_ID
| IE_MANDATORY_1
,
605 IE_FACILITY
, IE_PROGRESS
, IE_DISPLAY
, IE_DATE
, IE_SIGNAL
,
606 IE_CONNECT_PN
, IE_CONNECT_SUB
, IE_LLC
, IE_HLC
, IE_USER_USER
, -1};
607 static int ie_CONNECT_ACKNOWLEDGE
[] = {IE_CHANNEL_ID
, IE_DISPLAY
, IE_SIGNAL
, -1};
608 static int ie_DISCONNECT
[] = {IE_CAUSE
| IE_MANDATORY
, IE_FACILITY
,
609 IE_PROGRESS
, IE_DISPLAY
, IE_SIGNAL
, IE_USER_USER
, -1};
610 static int ie_INFORMATION
[] = {IE_COMPLETE
, IE_DISPLAY
, IE_KEYPAD
, IE_SIGNAL
,
612 static int ie_NOTIFY
[] = {IE_BEARER
, IE_NOTIFY
| IE_MANDATORY
, IE_DISPLAY
, -1};
613 static int ie_PROGRESS
[] = {IE_BEARER
, IE_CAUSE
, IE_FACILITY
, IE_PROGRESS
|
614 IE_MANDATORY
, IE_DISPLAY
, IE_HLC
, IE_USER_USER
, -1};
615 static int ie_RELEASE
[] = {IE_CAUSE
| IE_MANDATORY_1
, IE_FACILITY
, IE_DISPLAY
,
616 IE_SIGNAL
, IE_USER_USER
, -1};
617 /* a RELEASE_COMPLETE with errors don't require special actions
618 static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1};
620 static int ie_RESUME_ACKNOWLEDGE
[] = {IE_CHANNEL_ID
| IE_MANDATORY
, IE_FACILITY
,
622 static int ie_RESUME_REJECT
[] = {IE_CAUSE
| IE_MANDATORY
, IE_DISPLAY
, -1};
623 static int ie_SETUP
[] = {IE_COMPLETE
, IE_BEARER
| IE_MANDATORY
,
624 IE_CHANNEL_ID
| IE_MANDATORY
, IE_FACILITY
, IE_PROGRESS
,
625 IE_NET_FAC
, IE_DISPLAY
, IE_KEYPAD
, IE_SIGNAL
, IE_CALLING_PN
,
626 IE_CALLING_SUB
, IE_CALLED_PN
, IE_CALLED_SUB
, IE_REDIR_NR
,
627 IE_LLC
, IE_HLC
, IE_USER_USER
, -1};
628 static int ie_SETUP_ACKNOWLEDGE
[] = {IE_CHANNEL_ID
| IE_MANDATORY
, IE_FACILITY
,
629 IE_PROGRESS
, IE_DISPLAY
, IE_SIGNAL
, -1};
630 static int ie_STATUS
[] = {IE_CAUSE
| IE_MANDATORY
, IE_CALL_STATE
|
631 IE_MANDATORY
, IE_DISPLAY
, -1};
632 static int ie_STATUS_ENQUIRY
[] = {IE_DISPLAY
, -1};
633 static int ie_SUSPEND_ACKNOWLEDGE
[] = {IE_DISPLAY
, IE_FACILITY
, -1};
634 static int ie_SUSPEND_REJECT
[] = {IE_CAUSE
| IE_MANDATORY
, IE_DISPLAY
, -1};
636 * static int ie_CONGESTION_CONTROL[] = {IE_CONGESTION | IE_MANDATORY,
637 * IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1};
638 * static int ie_USER_INFORMATION[] = {IE_MORE_DATA, IE_USER_USER | IE_MANDATORY, -1};
639 * static int ie_RESTART[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_RESTART_IND |
642 static int ie_FACILITY
[] = {IE_FACILITY
| IE_MANDATORY
, IE_DISPLAY
, -1};
643 static int comp_required
[] = {1,2,3,5,6,7,9,10,11,14,15,-1};
644 static int l3_valid_states
[] = {0,1,2,3,4,6,7,8,9,10,11,12,15,17,19,25,-1};
652 struct ie_len max_ie_len
[] = {
670 {IE_PACK_BINPARA
, 3},
671 {IE_PACK_WINSIZE
, 4},
676 {IE_CALLING_SUB
, 23},
689 getmax_ie_len(u_char ie
) {
691 while (max_ie_len
[i
].ie
!= -1) {
692 if (max_ie_len
[i
].ie
== ie
)
693 return(max_ie_len
[i
].len
);
700 ie_in_set(struct l3_process
*pc
, u_char ie
, int *checklist
) {
703 while (*checklist
!= -1) {
704 if ((*checklist
& 0xff) == ie
) {
717 check_infoelements(struct l3_process
*pc
, struct sk_buff
*skb
, int *checklist
)
722 int l
, newpos
, oldpos
;
723 int err_seq
= 0, err_len
= 0, err_compr
= 0, err_ureg
= 0;
732 /* shift codeset procedure not implemented in the moment */
733 while ((p
- skb
->data
) < skb
->len
) {
734 if ((newpos
= ie_in_set(pc
, *p
, cl
))) {
742 if (ie_in_set(pc
, *p
, comp_required
))
755 if (l
> getmax_ie_len(ie
))
758 if (err_compr
| err_ureg
| err_len
| err_seq
) {
759 if (pc
->debug
& L3_DEB_CHECK
)
760 l3_debug(pc
->st
, "check_infoelements mt %x %d/%d/%d/%d",
761 mt
, err_compr
, err_ureg
, err_len
, err_seq
);
763 return(ERR_IE_COMPREHENSION
);
765 return(ERR_IE_UNRECOGNIZED
);
767 return(ERR_IE_LENGTH
);
769 return(ERR_IE_SEQUENCE
);
774 /* verify if a message type exists and contain no IE error */
776 l3dss1_check_messagetype_validity(struct l3_process
*pc
, int mt
, void *arg
)
780 case MT_CALL_PROCEEDING
:
782 case MT_CONNECT_ACKNOWLEDGE
:
789 case MT_RELEASE_COMPLETE
:
791 case MT_SETUP_ACKNOWLEDGE
:
792 case MT_RESUME_ACKNOWLEDGE
:
793 case MT_RESUME_REJECT
:
794 case MT_SUSPEND_ACKNOWLEDGE
:
795 case MT_SUSPEND_REJECT
:
796 case MT_USER_INFORMATION
:
798 case MT_RESTART_ACKNOWLEDGE
:
799 case MT_CONGESTION_CONTROL
:
801 case MT_STATUS_ENQUIRY
:
802 if (pc
->debug
& L3_DEB_CHECK
)
803 l3_debug(pc
->st
, "l3dss1_check_messagetype_validity mt(%x) OK", mt
);
805 case MT_RESUME
: /* RESUME only in user->net */
806 case MT_SUSPEND
: /* SUSPEND only in user->net */
808 if (pc
->debug
& (L3_DEB_CHECK
| L3_DEB_WARN
))
809 l3_debug(pc
->st
, "l3dss1_check_messagetype_validity mt(%x) fail", mt
);
811 l3dss1_status_send(pc
, 0, NULL
);
818 l3dss1_std_ie_err(struct l3_process
*pc
, int ret
) {
820 if (pc
->debug
& L3_DEB_CHECK
)
821 l3_debug(pc
->st
, "check_infoelements ret %d", ret
);
825 case ERR_IE_COMPREHENSION
:
827 l3dss1_status_send(pc
, 0, NULL
);
829 case ERR_IE_UNRECOGNIZED
:
831 l3dss1_status_send(pc
, 0, NULL
);
834 pc
->para
.cause
= 100;
835 l3dss1_status_send(pc
, 0, NULL
);
837 case ERR_IE_SEQUENCE
:
844 l3dss1_get_channel_id(struct l3_process
*pc
, struct sk_buff
*skb
) {
848 if ((p
= findie(p
, skb
->len
, IE_CHANNEL_ID
, 0))) {
850 if (*p
!= 1) { /* len for BRI = 1 */
851 if (pc
->debug
& L3_DEB_WARN
)
852 l3_debug(pc
->st
, "wrong chid len %d", *p
);
856 if (*p
& 0x60) { /* only base rate interface */
857 if (pc
->debug
& L3_DEB_WARN
)
858 l3_debug(pc
->st
, "wrong chid %x", *p
);
867 l3dss1_get_cause(struct l3_process
*pc
, struct sk_buff
*skb
) {
874 if ((p
= findie(p
, skb
->len
, IE_CAUSE
, 0))) {
885 if (l
&& !(pc
->para
.loc
& 0x80)) {
887 p
++; /* skip recommendation */
890 pc
->para
.cause
= *p
++;
892 if (!(pc
->para
.cause
& 0x80))
897 pc
->para
.diag
[i
++] = *p
++;
906 l3dss1_msg_with_uus(struct l3_process
*pc
, u_char cmd
)
913 MsgHead(p
, pc
->callref
, cmd
);
915 if (pc
->prot
.dss1
.uus1_data
[0])
916 { *p
++ = IE_USER_USER
; /* UUS info element */
917 *p
++ = strlen(pc
->prot
.dss1
.uus1_data
) + 1;
918 *p
++ = 0x04; /* IA5 chars */
919 strcpy(p
,pc
->prot
.dss1
.uus1_data
);
920 p
+= strlen(pc
->prot
.dss1
.uus1_data
);
921 pc
->prot
.dss1
.uus1_data
[0] = '\0';
925 if (!(skb
= l3_alloc_skb(l
)))
927 memcpy(skb_put(skb
, l
), tmp
, l
);
928 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
929 } /* l3dss1_msg_with_uus */
932 l3dss1_release_req(struct l3_process
*pc
, u_char pr
, void *arg
)
936 if (!pc
->prot
.dss1
.uus1_data
[0])
937 l3dss1_message(pc
, MT_RELEASE
);
939 l3dss1_msg_with_uus(pc
, MT_RELEASE
);
940 L3AddTimer(&pc
->timer
, T308
, CC_T308_1
);
944 l3dss1_release_cmpl(struct l3_process
*pc
, u_char pr
, void *arg
)
946 struct sk_buff
*skb
= arg
;
949 if ((ret
= l3dss1_get_cause(pc
, skb
))>0) {
950 if (pc
->debug
& L3_DEB_WARN
)
951 l3_debug(pc
->st
, "RELCMPL get_cause ret(%d)",ret
);
953 pc
->para
.cause
= NO_CAUSE
;
956 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| CONFIRM
, pc
);
957 dss1_release_l3_process(pc
);
963 EncodeASyncParams(u_char
* p
, u_char si2
)
964 { // 7c 06 88 90 21 42 00 bb
967 p
[1] = 0x40; // Intermediate rate: 16 kbit/s jj 2000.02.19
969 if (si2
& 32) // 7 data bits
976 if (si2
& 16) // 2 stop bits
983 if (si2
& 8) // even parity
990 switch (si2
& 0x07) {
992 p
[0] = 66; // 1200 bit/s
996 p
[0] = 88; // 1200/75 bit/s
1000 p
[0] = 87; // 75/1200 bit/s
1004 p
[0] = 67; // 2400 bit/s
1008 p
[0] = 69; // 4800 bit/s
1012 p
[0] = 72; // 9600 bit/s
1016 p
[0] = 73; // 14400 bit/s
1020 p
[0] = 75; // 19200 bit/s
1028 EncodeSyncParams(u_char si2
, u_char ai
)
1033 return ai
+ 2; // 1200 bit/s
1036 return ai
+ 24; // 1200/75 bit/s
1039 return ai
+ 23; // 75/1200 bit/s
1042 return ai
+ 3; // 2400 bit/s
1045 return ai
+ 5; // 4800 bit/s
1048 return ai
+ 8; // 9600 bit/s
1051 return ai
+ 9; // 14400 bit/s
1054 return ai
+ 11; // 19200 bit/s
1057 return ai
+ 14; // 48000 bit/s
1060 return ai
+ 15; // 56000 bit/s
1063 return ai
+ 40; // negotiate bit/s
1073 DecodeASyncParams(u_char si2
, u_char
* p
)
1078 case 66: // 1200 bit/s
1080 break; // si2 don't change
1082 case 88: // 1200/75 bit/s
1086 case 87: // 75/1200 bit/s
1090 case 67: // 2400 bit/s
1094 case 69: // 4800 bit/s
1098 case 72: // 9600 bit/s
1102 case 73: // 14400 bit/s
1106 case 75: // 19200 bit/s
1113 if ((info
& 16) && (!(info
& 8))) // 7 data bits
1115 si2
+= 32; // else 8 data bits
1117 if ((info
& 96) == 96) // 2 stop bits
1119 si2
+= 16; // else 1 stop bit
1121 if ((info
& 2) && (!(info
& 1))) // even parity
1123 si2
+= 8; // else no parity
1130 DecodeSyncParams(u_char si2
, u_char info
)
1134 case 40: // bit/s negotiation failed ai := 165 not 175!
1137 case 15: // 56000 bit/s failed, ai := 0 not 169 !
1140 case 14: // 48000 bit/s
1143 case 11: // 19200 bit/s
1146 case 9: // 14400 bit/s
1149 case 8: // 9600 bit/s
1152 case 5: // 4800 bit/s
1155 case 3: // 2400 bit/s
1158 case 23: // 75/1200 bit/s
1161 case 24: // 1200/75 bit/s
1164 default: // 1200 bit/s
1171 DecodeSI2(struct sk_buff
*skb
)
1173 u_char
*p
; //, *pend=skb->data + skb->len;
1175 if ((p
= findie(skb
->data
, skb
->len
, 0x7c, 0))) {
1176 switch (p
[4] & 0x0f) {
1178 if (p
[1] == 0x04) // sync. Bitratenadaption
1180 return DecodeSyncParams(160, p
[5]); // V.110/X.30
1182 else if (p
[1] == 0x06) // async. Bitratenadaption
1184 return DecodeASyncParams(192, p
); // V.110/X.30
1187 case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption
1189 return DecodeSyncParams(176, p
[5]); // V.120
1200 l3dss1_setup_req(struct l3_process
*pc
, u_char pr
,
1203 struct sk_buff
*skb
;
1209 u_char screen
= 0x80;
1216 MsgHead(p
, pc
->callref
, MT_SETUP
);
1218 teln
= pc
->para
.setup
.phone
;
1219 #ifndef CONFIG_HISAX_NO_KEYPAD
1220 send_keypad
= (strchr(teln
,'*') || strchr(teln
,'#')) ? 1 : 0;
1224 #ifndef CONFIG_HISAX_NO_SENDCOMPLETE
1226 *p
++ = 0xa1; /* complete indicator */
1229 * Set Bearer Capability, Map info from 1TR6-convention to EDSS1
1231 switch (pc
->para
.setup
.si1
) {
1232 case 1: /* Telephony */
1234 *p
++ = 0x3; /* Length */
1235 *p
++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1236 *p
++ = 0x90; /* Circuit-Mode 64kbps */
1237 *p
++ = 0xa3; /* A-Law Audio */
1239 case 5: /* Datatransmission 64k, BTX */
1240 case 7: /* Datatransmission 64k */
1243 *p
++ = 0x2; /* Length */
1244 *p
++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1245 *p
++ = 0x90; /* Circuit-Mode 64kbps */
1251 *p
++ = strlen(teln
);
1253 *p
++ = (*teln
++) & 0x7F;
1257 * What about info2? Mapping to High-Layer-Compatibility?
1259 if ((*teln
) && (!send_keypad
)) {
1260 /* parse number for special things */
1261 if (!isdigit(*teln
)) {
1262 switch (0x5f & *teln
) {
1281 if (pc
->debug
& L3_DEB_WARN
)
1282 l3_debug(pc
->st
, "Wrong MSN Code");
1289 *p
++ = IE_CHANNEL_ID
;
1293 msn
= pc
->para
.setup
.eazmsn
;
1304 *p
++ = IE_CALLING_PN
;
1305 *p
++ = strlen(msn
) + (screen
? 2 : 1);
1306 /* Classify as AnyPref. */
1308 *p
++ = 0x01; /* Ext = '0'B, Type = '000'B, Plan = '0001'B. */
1311 *p
++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1313 *p
++ = *msn
++ & 0x7f;
1317 *p
++ = IE_CALLING_SUB
;
1318 *p
++ = strlen(sub
) + 2;
1319 *p
++ = 0x80; /* NSAP coded */
1320 *p
++ = 0x50; /* local IDI format */
1322 *p
++ = *sub
++ & 0x7f;
1335 *p
++ = IE_CALLED_PN
;
1336 *p
++ = strlen(teln
) + 1;
1337 /* Classify as AnyPref. */
1338 *p
++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
1340 *p
++ = *teln
++ & 0x7f;
1344 *p
++ = IE_CALLED_SUB
;
1345 *p
++ = strlen(sub
) + 2;
1346 *p
++ = 0x80; /* NSAP coded */
1347 *p
++ = 0x50; /* local IDI format */
1349 *p
++ = *sub
++ & 0x7f;
1353 if ((pc
->para
.setup
.si2
>= 160) && (pc
->para
.setup
.si2
<= 175)) { // sync. Bitratenadaption, V.110/X.30
1360 *p
++ = EncodeSyncParams(pc
->para
.setup
.si2
- 160, 0x80);
1361 } else if ((pc
->para
.setup
.si2
>= 176) && (pc
->para
.setup
.si2
<= 191)) { // sync. Bitratenadaption, V.120
1368 *p
++ = EncodeSyncParams(pc
->para
.setup
.si2
- 176, 0);
1370 } else if (pc
->para
.setup
.si2
>= 192) { // async. Bitratenadaption, V.110/X.30
1377 p
= EncodeASyncParams(p
, pc
->para
.setup
.si2
- 192);
1378 #ifndef CONFIG_HISAX_NO_LLC
1380 switch (pc
->para
.setup
.si1
) {
1381 case 1: /* Telephony */
1383 *p
++ = 0x3; /* Length */
1384 *p
++ = 0x90; /* Coding Std. CCITT, 3.1 kHz audio */
1385 *p
++ = 0x90; /* Circuit-Mode 64kbps */
1386 *p
++ = 0xa3; /* A-Law Audio */
1388 case 5: /* Datatransmission 64k, BTX */
1389 case 7: /* Datatransmission 64k */
1392 *p
++ = 0x2; /* Length */
1393 *p
++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */
1394 *p
++ = 0x90; /* Circuit-Mode 64kbps */
1401 if (!(skb
= l3_alloc_skb(l
)))
1403 memcpy(skb_put(skb
, l
), tmp
, l
);
1404 L3DelTimer(&pc
->timer
);
1405 L3AddTimer(&pc
->timer
, T303
, CC_T303
);
1407 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
1411 l3dss1_call_proc(struct l3_process
*pc
, u_char pr
, void *arg
)
1413 struct sk_buff
*skb
= arg
;
1416 if ((id
= l3dss1_get_channel_id(pc
, skb
)) >= 0) {
1417 if ((0 == id
) || ((3 == id
) && (0x10 == pc
->para
.moderate
))) {
1418 if (pc
->debug
& L3_DEB_WARN
)
1419 l3_debug(pc
->st
, "setup answer with wrong chid %x", id
);
1420 pc
->para
.cause
= 100;
1421 l3dss1_status_send(pc
, pr
, NULL
);
1424 pc
->para
.bchannel
= id
;
1425 } else if (1 == pc
->state
) {
1426 if (pc
->debug
& L3_DEB_WARN
)
1427 l3_debug(pc
->st
, "setup answer wrong chid (ret %d)", id
);
1429 pc
->para
.cause
= 96;
1431 pc
->para
.cause
= 100;
1432 l3dss1_status_send(pc
, pr
, NULL
);
1435 /* Now we are on none mandatory IEs */
1436 ret
= check_infoelements(pc
, skb
, ie_CALL_PROCEEDING
);
1437 if (ERR_IE_COMPREHENSION
== ret
) {
1438 l3dss1_std_ie_err(pc
, ret
);
1441 L3DelTimer(&pc
->timer
);
1443 L3AddTimer(&pc
->timer
, T310
, CC_T310
);
1444 if (ret
) /* STATUS for none mandatory IE errors after actions are taken */
1445 l3dss1_std_ie_err(pc
, ret
);
1446 pc
->st
->l3
.l3l4(pc
->st
, CC_PROCEEDING
| INDICATION
, pc
);
1450 l3dss1_setup_ack(struct l3_process
*pc
, u_char pr
, void *arg
)
1452 struct sk_buff
*skb
= arg
;
1455 if ((id
= l3dss1_get_channel_id(pc
, skb
)) >= 0) {
1456 if ((0 == id
) || ((3 == id
) && (0x10 == pc
->para
.moderate
))) {
1457 if (pc
->debug
& L3_DEB_WARN
)
1458 l3_debug(pc
->st
, "setup answer with wrong chid %x", id
);
1459 pc
->para
.cause
= 100;
1460 l3dss1_status_send(pc
, pr
, NULL
);
1463 pc
->para
.bchannel
= id
;
1465 if (pc
->debug
& L3_DEB_WARN
)
1466 l3_debug(pc
->st
, "setup answer wrong chid (ret %d)", id
);
1468 pc
->para
.cause
= 96;
1470 pc
->para
.cause
= 100;
1471 l3dss1_status_send(pc
, pr
, NULL
);
1474 /* Now we are on none mandatory IEs */
1475 ret
= check_infoelements(pc
, skb
, ie_SETUP_ACKNOWLEDGE
);
1476 if (ERR_IE_COMPREHENSION
== ret
) {
1477 l3dss1_std_ie_err(pc
, ret
);
1480 L3DelTimer(&pc
->timer
);
1482 L3AddTimer(&pc
->timer
, T304
, CC_T304
);
1483 if (ret
) /* STATUS for none mandatory IE errors after actions are taken */
1484 l3dss1_std_ie_err(pc
, ret
);
1485 pc
->st
->l3
.l3l4(pc
->st
, CC_MORE_INFO
| INDICATION
, pc
);
1489 l3dss1_disconnect(struct l3_process
*pc
, u_char pr
, void *arg
)
1491 struct sk_buff
*skb
= arg
;
1497 if ((ret
= l3dss1_get_cause(pc
, skb
))) {
1498 if (pc
->debug
& L3_DEB_WARN
)
1499 l3_debug(pc
->st
, "DISC get_cause ret(%d)", ret
);
1505 if ((p
= findie(skb
->data
, skb
->len
, IE_FACILITY
, 0)))
1506 l3dss1_parse_facility(pc
->st
, pc
, pc
->callref
, p
);
1507 ret
= check_infoelements(pc
, skb
, ie_DISCONNECT
);
1508 if (ERR_IE_COMPREHENSION
== ret
)
1510 else if ((!cause
) && (ERR_IE_UNRECOGNIZED
== ret
))
1517 pc
->st
->l3
.l3l4(pc
->st
, CC_DISCONNECT
| INDICATION
, pc
);
1519 l3dss1_release_req(pc
, pr
, NULL
);
1521 l3dss1_message_cause(pc
, MT_RELEASE
, cause
);
1522 L3AddTimer(&pc
->timer
, T308
, CC_T308_1
);
1527 l3dss1_connect(struct l3_process
*pc
, u_char pr
, void *arg
)
1529 struct sk_buff
*skb
= arg
;
1532 ret
= check_infoelements(pc
, skb
, ie_CONNECT
);
1533 if (ERR_IE_COMPREHENSION
== ret
) {
1534 l3dss1_std_ie_err(pc
, ret
);
1537 L3DelTimer(&pc
->timer
); /* T310 */
1539 pc
->para
.chargeinfo
= 0;
1540 /* here should inserted COLP handling KKe */
1542 l3dss1_std_ie_err(pc
, ret
);
1543 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP
| CONFIRM
, pc
);
1547 l3dss1_alerting(struct l3_process
*pc
, u_char pr
, void *arg
)
1549 struct sk_buff
*skb
= arg
;
1552 ret
= check_infoelements(pc
, skb
, ie_ALERTING
);
1553 if (ERR_IE_COMPREHENSION
== ret
) {
1554 l3dss1_std_ie_err(pc
, ret
);
1557 L3DelTimer(&pc
->timer
); /* T304 */
1560 l3dss1_std_ie_err(pc
, ret
);
1561 pc
->st
->l3
.l3l4(pc
->st
, CC_ALERTING
| INDICATION
, pc
);
1565 l3dss1_setup(struct l3_process
*pc
, u_char pr
, void *arg
)
1570 struct sk_buff
*skb
= arg
;
1575 * Bearer Capabilities
1578 /* only the first occurence 'll be detected ! */
1579 if ((p
= findie(p
, skb
->len
, 0x04, 0))) {
1580 if ((p
[1] < 2) || (p
[1] > 11))
1583 pc
->para
.setup
.si2
= 0;
1584 switch (p
[2] & 0x7f) {
1585 case 0x00: /* Speech */
1586 case 0x10: /* 3.1 Khz audio */
1587 pc
->para
.setup
.si1
= 1;
1589 case 0x08: /* Unrestricted digital information */
1590 pc
->para
.setup
.si1
= 7;
1591 /* JIM, 05.11.97 I wanna set service indicator 2 */
1593 pc
->para
.setup
.si2
= DecodeSI2(skb
);
1596 case 0x09: /* Restricted digital information */
1597 pc
->para
.setup
.si1
= 2;
1600 /* Unrestr. digital information with
1601 * tones/announcements ( or 7 kHz audio
1603 pc
->para
.setup
.si1
= 3;
1605 case 0x18: /* Video */
1606 pc
->para
.setup
.si1
= 4;
1612 switch (p
[3] & 0x7f) {
1613 case 0x40: /* packed mode */
1614 pc
->para
.setup
.si1
= 8;
1616 case 0x10: /* 64 kbit */
1617 case 0x11: /* 2*64 kbit */
1618 case 0x13: /* 384 kbit */
1619 case 0x15: /* 1536 kbit */
1620 case 0x17: /* 1920 kbit */
1621 pc
->para
.moderate
= p
[3] & 0x7f;
1628 if (pc
->debug
& L3_DEB_SI
)
1629 l3_debug(pc
->st
, "SI=%d, AI=%d",
1630 pc
->para
.setup
.si1
, pc
->para
.setup
.si2
);
1632 if (pc
->debug
& L3_DEB_WARN
)
1633 l3_debug(pc
->st
, "setup with wrong bearer(l=%d:%x,%x)",
1635 pc
->para
.cause
= 100;
1636 l3dss1_msg_without_setup(pc
, pr
, NULL
);
1640 if (pc
->debug
& L3_DEB_WARN
)
1641 l3_debug(pc
->st
, "setup without bearer capabilities");
1642 /* ETS 300-104 1.3.3 */
1643 pc
->para
.cause
= 96;
1644 l3dss1_msg_without_setup(pc
, pr
, NULL
);
1648 * Channel Identification
1650 if ((id
= l3dss1_get_channel_id(pc
, skb
)) >= 0) {
1651 if ((pc
->para
.bchannel
= id
)) {
1652 if ((3 == id
) && (0x10 == pc
->para
.moderate
)) {
1653 if (pc
->debug
& L3_DEB_WARN
)
1654 l3_debug(pc
->st
, "setup with wrong chid %x",
1656 pc
->para
.cause
= 100;
1657 l3dss1_msg_without_setup(pc
, pr
, NULL
);
1662 { if (pc
->debug
& L3_DEB_WARN
)
1663 l3_debug(pc
->st
, "setup without bchannel, call waiting");
1667 if (pc
->debug
& L3_DEB_WARN
)
1668 l3_debug(pc
->st
, "setup with wrong chid ret %d", id
);
1670 pc
->para
.cause
= 96;
1672 pc
->para
.cause
= 100;
1673 l3dss1_msg_without_setup(pc
, pr
, NULL
);
1676 /* Now we are on none mandatory IEs */
1677 err
= check_infoelements(pc
, skb
, ie_SETUP
);
1678 if (ERR_IE_COMPREHENSION
== err
) {
1679 pc
->para
.cause
= 96;
1680 l3dss1_msg_without_setup(pc
, pr
, NULL
);
1684 if ((p
= findie(p
, skb
->len
, 0x70, 0)))
1685 iecpy(pc
->para
.setup
.eazmsn
, p
, 1);
1687 pc
->para
.setup
.eazmsn
[0] = 0;
1690 if ((p
= findie(p
, skb
->len
, 0x71, 0))) {
1691 /* Called party subaddress */
1692 if ((p
[1] >= 2) && (p
[2] == 0x80) && (p
[3] == 0x50)) {
1694 iecpy(&tmp
[1], p
, 2);
1695 strcat(pc
->para
.setup
.eazmsn
, tmp
);
1696 } else if (pc
->debug
& L3_DEB_WARN
)
1697 l3_debug(pc
->st
, "wrong called subaddress");
1700 if ((p
= findie(p
, skb
->len
, 0x6c, 0))) {
1701 pc
->para
.setup
.plan
= p
[2];
1703 iecpy(pc
->para
.setup
.phone
, p
, 1);
1704 pc
->para
.setup
.screen
= 0;
1706 iecpy(pc
->para
.setup
.phone
, p
, 2);
1707 pc
->para
.setup
.screen
= p
[3];
1710 pc
->para
.setup
.phone
[0] = 0;
1711 pc
->para
.setup
.plan
= 0;
1712 pc
->para
.setup
.screen
= 0;
1715 if ((p
= findie(p
, skb
->len
, 0x6d, 0))) {
1716 /* Calling party subaddress */
1717 if ((p
[1] >= 2) && (p
[2] == 0x80) && (p
[3] == 0x50)) {
1719 iecpy(&tmp
[1], p
, 2);
1720 strcat(pc
->para
.setup
.phone
, tmp
);
1721 } else if (pc
->debug
& L3_DEB_WARN
)
1722 l3_debug(pc
->st
, "wrong calling subaddress");
1725 if (err
) /* STATUS for none mandatory IE errors after actions are taken */
1726 l3dss1_std_ie_err(pc
, err
);
1727 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP
| INDICATION
, pc
);
1731 l3dss1_reset(struct l3_process
*pc
, u_char pr
, void *arg
)
1733 dss1_release_l3_process(pc
);
1737 l3dss1_disconnect_req(struct l3_process
*pc
, u_char pr
, void *arg
)
1739 struct sk_buff
*skb
;
1745 if (pc
->para
.cause
!= NO_CAUSE
)
1746 cause
= pc
->para
.cause
;
1750 MsgHead(p
, pc
->callref
, MT_DISCONNECT
);
1755 *p
++ = cause
| 0x80;
1757 if (pc
->prot
.dss1
.uus1_data
[0])
1758 { *p
++ = IE_USER_USER
; /* UUS info element */
1759 *p
++ = strlen(pc
->prot
.dss1
.uus1_data
) + 1;
1760 *p
++ = 0x04; /* IA5 chars */
1761 strcpy(p
,pc
->prot
.dss1
.uus1_data
);
1762 p
+= strlen(pc
->prot
.dss1
.uus1_data
);
1763 pc
->prot
.dss1
.uus1_data
[0] = '\0';
1767 if (!(skb
= l3_alloc_skb(l
)))
1769 memcpy(skb_put(skb
, l
), tmp
, l
);
1771 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
1772 L3AddTimer(&pc
->timer
, T305
, CC_T305
);
1776 l3dss1_setup_rsp(struct l3_process
*pc
, u_char pr
,
1779 if (!pc
->para
.bchannel
)
1780 { if (pc
->debug
& L3_DEB_WARN
)
1781 l3_debug(pc
->st
, "D-chan connect for waiting call");
1782 l3dss1_disconnect_req(pc
, pr
, arg
);
1786 l3dss1_message(pc
, MT_CONNECT
);
1787 L3DelTimer(&pc
->timer
);
1788 L3AddTimer(&pc
->timer
, T313
, CC_T313
);
1792 l3dss1_connect_ack(struct l3_process
*pc
, u_char pr
, void *arg
)
1794 struct sk_buff
*skb
= arg
;
1797 ret
= check_infoelements(pc
, skb
, ie_CONNECT_ACKNOWLEDGE
);
1798 if (ERR_IE_COMPREHENSION
== ret
) {
1799 l3dss1_std_ie_err(pc
, ret
);
1803 L3DelTimer(&pc
->timer
);
1805 l3dss1_std_ie_err(pc
, ret
);
1806 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP_COMPL
| INDICATION
, pc
);
1810 l3dss1_reject_req(struct l3_process
*pc
, u_char pr
, void *arg
)
1812 struct sk_buff
*skb
;
1818 if (pc
->para
.cause
!= NO_CAUSE
)
1819 cause
= pc
->para
.cause
;
1821 MsgHead(p
, pc
->callref
, MT_RELEASE_COMPLETE
);
1826 *p
++ = cause
| 0x80;
1829 if (!(skb
= l3_alloc_skb(l
)))
1831 memcpy(skb_put(skb
, l
), tmp
, l
);
1832 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
1833 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
1835 dss1_release_l3_process(pc
);
1839 l3dss1_release(struct l3_process
*pc
, u_char pr
, void *arg
)
1841 struct sk_buff
*skb
= arg
;
1846 if ((ret
= l3dss1_get_cause(pc
, skb
))>0) {
1847 if (pc
->debug
& L3_DEB_WARN
)
1848 l3_debug(pc
->st
, "REL get_cause ret(%d)", ret
);
1850 pc
->para
.cause
= NO_CAUSE
;
1851 if ((p
= findie(skb
->data
, skb
->len
, IE_FACILITY
, 0))) {
1852 l3dss1_parse_facility(pc
->st
, pc
, pc
->callref
, p
);
1854 if ((ret
<0) && (pc
->state
!= 11))
1858 ret
= check_infoelements(pc
, skb
, ie_RELEASE
);
1859 if (ERR_IE_COMPREHENSION
== ret
)
1861 else if ((ERR_IE_UNRECOGNIZED
== ret
) && (!cause
))
1864 l3dss1_message_cause(pc
, MT_RELEASE_COMPLETE
, cause
);
1866 l3dss1_message(pc
, MT_RELEASE_COMPLETE
);
1867 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
1869 dss1_release_l3_process(pc
);
1873 l3dss1_alert_req(struct l3_process
*pc
, u_char pr
,
1877 if (!pc
->prot
.dss1
.uus1_data
[0])
1878 l3dss1_message(pc
, MT_ALERTING
);
1880 l3dss1_msg_with_uus(pc
, MT_ALERTING
);
1884 l3dss1_proceed_req(struct l3_process
*pc
, u_char pr
,
1888 l3dss1_message(pc
, MT_CALL_PROCEEDING
);
1889 pc
->st
->l3
.l3l4(pc
->st
, CC_PROCEED_SEND
| INDICATION
, pc
);
1892 /********************************************/
1893 /* deliver a incoming display message to HL */
1894 /********************************************/
1896 l3dss1_deliver_display(struct l3_process
*pc
, int pr
, u_char
*infp
)
1899 struct IsdnCardState
*cs
;
1902 if (*infp
++ != IE_DISPLAY
) return;
1903 if ((len
= *infp
++) > 80) return; /* total length <= 82 */
1904 if (!pc
->chan
) return;
1906 p
= ic
.parm
.display
;
1910 ic
.command
= ISDN_STAT_DISPLAY
;
1911 cs
= pc
->st
->l1
.hardware
;
1912 ic
.driver
= cs
->myid
;
1913 ic
.arg
= pc
->chan
->chan
;
1914 cs
->iif
.statcallb(&ic
);
1915 } /* l3dss1_deliver_display */
1919 l3dss1_progress(struct l3_process
*pc
, u_char pr
, void *arg
)
1921 struct sk_buff
*skb
= arg
;
1925 if ((p
= findie(skb
->data
, skb
->len
, IE_PROGRESS
, 0))) {
1928 pc
->para
.cause
= 100;
1929 } else if (p
[2] & 0x60) {
1947 pc
->para
.cause
= 100;
1953 pc
->para
.cause
= 100;
1958 pc
->para
.cause
= 96;
1962 if (pc
->debug
& L3_DEB_WARN
)
1963 l3_debug(pc
->st
, "progress error %d", err
);
1964 l3dss1_status_send(pc
, pr
, NULL
);
1967 /* Now we are on none mandatory IEs */
1968 err
= check_infoelements(pc
, skb
, ie_PROGRESS
);
1970 l3dss1_std_ie_err(pc
, err
);
1971 if (ERR_IE_COMPREHENSION
!= err
)
1972 pc
->st
->l3
.l3l4(pc
->st
, CC_PROGRESS
| INDICATION
, pc
);
1976 l3dss1_notify(struct l3_process
*pc
, u_char pr
, void *arg
)
1978 struct sk_buff
*skb
= arg
;
1982 if ((p
= findie(skb
->data
, skb
->len
, IE_NOTIFY
, 0))) {
1985 pc
->para
.cause
= 100;
1993 pc
->para
.cause
= 100;
1999 pc
->para
.cause
= 96;
2003 if (pc
->debug
& L3_DEB_WARN
)
2004 l3_debug(pc
->st
, "notify error %d", err
);
2005 l3dss1_status_send(pc
, pr
, NULL
);
2008 /* Now we are on none mandatory IEs */
2009 err
= check_infoelements(pc
, skb
, ie_NOTIFY
);
2011 l3dss1_std_ie_err(pc
, err
);
2012 if (ERR_IE_COMPREHENSION
!= err
)
2013 pc
->st
->l3
.l3l4(pc
->st
, CC_NOTIFY
| INDICATION
, pc
);
2017 l3dss1_status_enq(struct l3_process
*pc
, u_char pr
, void *arg
)
2020 struct sk_buff
*skb
= arg
;
2022 ret
= check_infoelements(pc
, skb
, ie_STATUS_ENQUIRY
);
2023 l3dss1_std_ie_err(pc
, ret
);
2024 pc
->para
.cause
= 30; /* response to STATUS_ENQUIRY */
2025 l3dss1_status_send(pc
, pr
, NULL
);
2029 l3dss1_information(struct l3_process
*pc
, u_char pr
, void *arg
)
2032 struct sk_buff
*skb
= arg
;
2034 ret
= check_infoelements(pc
, skb
, ie_INFORMATION
);
2035 l3dss1_std_ie_err(pc
, ret
);
2038 /******************************/
2039 /* handle deflection requests */
2040 /******************************/
2041 static void l3dss1_redir_req(struct l3_process
*pc
, u_char pr
, void *arg
)
2043 struct sk_buff
*skb
;
2047 u_char len_phone
= 0;
2052 strcpy(pc
->prot
.dss1
.uus1_data
,pc
->chan
->setup
.eazmsn
); /* copy uus element if available */
2053 if (!pc
->chan
->setup
.phone
[0])
2054 { pc
->para
.cause
= -1;
2055 l3dss1_disconnect_req(pc
,pr
,arg
); /* disconnect immediately */
2059 if (pc
->prot
.dss1
.invoke_id
)
2060 free_invoke_id(pc
->st
,pc
->prot
.dss1
.invoke_id
);
2062 if (!(pc
->prot
.dss1
.invoke_id
= new_invoke_id(pc
->st
)))
2065 MsgHead(p
, pc
->callref
, MT_FACILITY
);
2067 for (subp
= pc
->chan
->setup
.phone
; (*subp
) && (*subp
!= '.'); subp
++) len_phone
++; /* len of phone number */
2068 if (*subp
++ == '.') len_sub
= strlen(subp
) + 2; /* length including info subadress element */
2070 *p
++ = 0x1c; /* Facility info element */
2071 *p
++ = len_phone
+ len_sub
+ 2 + 2 + 8 + 3 + 3; /* length of element */
2072 *p
++ = 0x91; /* remote operations protocol */
2073 *p
++ = 0xa1; /* invoke component */
2075 *p
++ = len_phone
+ len_sub
+ 2 + 2 + 8 + 3; /* length of data */
2076 *p
++ = 0x02; /* invoke id tag, integer */
2077 *p
++ = 0x01; /* length */
2078 *p
++ = pc
->prot
.dss1
.invoke_id
; /* invoke id */
2079 *p
++ = 0x02; /* operation value tag, integer */
2080 *p
++ = 0x01; /* length */
2081 *p
++ = 0x0D; /* Call Deflect */
2083 *p
++ = 0x30; /* sequence phone number */
2084 *p
++ = len_phone
+ 2 + 2 + 3 + len_sub
; /* length */
2086 *p
++ = 0x30; /* Deflected to UserNumber */
2087 *p
++ = len_phone
+2+len_sub
; /* length */
2088 *p
++ = 0x80; /* NumberDigits */
2089 *p
++ = len_phone
; /* length */
2090 for (l
= 0; l
< len_phone
; l
++)
2091 *p
++ = pc
->chan
->setup
.phone
[l
];
2094 { *p
++ = 0x04; /* called party subadress */
2096 while (*subp
) *p
++ = *subp
++;
2099 *p
++ = 0x01; /* screening identifier */
2101 *p
++ = pc
->chan
->setup
.screen
;
2104 if (!(skb
= l3_alloc_skb(l
))) return;
2105 memcpy(skb_put(skb
, l
), tmp
, l
);
2107 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
2108 } /* l3dss1_redir_req */
2110 /********************************************/
2111 /* handle deflection request in early state */
2112 /********************************************/
2113 static void l3dss1_redir_req_early(struct l3_process
*pc
, u_char pr
, void *arg
)
2115 l3dss1_proceed_req(pc
,pr
,arg
);
2116 l3dss1_redir_req(pc
,pr
,arg
);
2117 } /* l3dss1_redir_req_early */
2119 /***********************************************/
2120 /* handle special commands for this protocol. */
2121 /* Examples are call independant services like */
2122 /* remote operations with dummy callref. */
2123 /***********************************************/
2124 static int l3dss1_cmd_global(struct PStack
*st
, isdn_ctrl
*ic
)
2129 struct sk_buff
*skb
;
2130 struct l3_process
*pc
= NULL
;
2133 { case DSS1_CMD_INVOKE
:
2134 if (ic
->parm
.dss1_io
.datalen
< 0) return(-2); /* invalid parameter */
2136 for (proc_len
= 1, i
= ic
->parm
.dss1_io
.proc
>> 8; i
; i
++)
2137 i
= i
>> 8; /* add one byte */
2138 l
= ic
->parm
.dss1_io
.datalen
+ proc_len
+ 8; /* length excluding ie header */
2140 return(-2); /* too long */
2142 if (!(id
= new_invoke_id(st
)))
2143 return(0); /* first get a invoke id -> return if no available */
2146 MsgHead(p
, i
, MT_FACILITY
); /* build message head */
2147 *p
++ = 0x1C; /* Facility IE */
2148 *p
++ = l
; /* length of ie */
2149 *p
++ = 0x91; /* remote operations */
2150 *p
++ = 0xA1; /* invoke */
2151 *p
++ = l
- 3; /* length of invoke */
2152 *p
++ = 0x02; /* invoke id tag */
2153 *p
++ = 0x01; /* length is 1 */
2154 *p
++ = id
; /* invoke id */
2155 *p
++ = 0x02; /* operation */
2156 *p
++ = proc_len
; /* length of operation */
2158 for (i
= proc_len
; i
; i
--)
2159 *p
++ = (ic
->parm
.dss1_io
.proc
>> (i
-1)) & 0xFF;
2160 memcpy(p
, ic
->parm
.dss1_io
.data
, ic
->parm
.dss1_io
.datalen
); /* copy data */
2161 l
= (p
- temp
) + ic
->parm
.dss1_io
.datalen
; /* total length */
2163 if (ic
->parm
.dss1_io
.timeout
> 0)
2164 if (!(pc
= dss1_new_l3_process(st
, -1)))
2165 { free_invoke_id(st
, id
);
2168 pc
->prot
.dss1
.ll_id
= ic
->parm
.dss1_io
.ll_id
; /* remember id */
2169 pc
->prot
.dss1
.proc
= ic
->parm
.dss1_io
.proc
; /* and procedure */
2171 if (!(skb
= l3_alloc_skb(l
)))
2172 { free_invoke_id(st
, id
);
2173 if (pc
) dss1_release_l3_process(pc
);
2176 memcpy(skb_put(skb
, l
), temp
, l
);
2179 { pc
->prot
.dss1
.invoke_id
= id
; /* remember id */
2180 L3AddTimer(&pc
->timer
, ic
->parm
.dss1_io
.timeout
, CC_TDSS1_IO
| REQUEST
);
2183 l3_msg(st
, DL_DATA
| REQUEST
, skb
);
2184 ic
->parm
.dss1_io
.hl_id
= id
; /* return id */
2187 case DSS1_CMD_INVOKE_ABORT
:
2188 if ((pc
= l3dss1_search_dummy_proc(st
, ic
->parm
.dss1_io
.hl_id
)))
2189 { L3DelTimer(&pc
->timer
); /* remove timer */
2190 dss1_release_l3_process(pc
);
2194 { l3_debug(st
, "l3dss1_cmd_global abort unknown id");
2200 l3_debug(st
, "l3dss1_cmd_global unknown cmd 0x%lx", ic
->arg
);
2202 } /* switch ic-> arg */
2204 } /* l3dss1_cmd_global */
2207 l3dss1_io_timer(struct l3_process
*pc
)
2209 struct IsdnCardState
*cs
= pc
->st
->l1
.hardware
;
2211 L3DelTimer(&pc
->timer
); /* remove timer */
2213 ic
.driver
= cs
->myid
;
2214 ic
.command
= ISDN_STAT_PROT
;
2215 ic
.arg
= DSS1_STAT_INVOKE_ERR
;
2216 ic
.parm
.dss1_io
.hl_id
= pc
->prot
.dss1
.invoke_id
;
2217 ic
.parm
.dss1_io
.ll_id
= pc
->prot
.dss1
.ll_id
;
2218 ic
.parm
.dss1_io
.proc
= pc
->prot
.dss1
.proc
;
2219 ic
.parm
.dss1_io
.timeout
= -1;
2220 ic
.parm
.dss1_io
.datalen
= 0;
2221 ic
.parm
.dss1_io
.data
= NULL
;
2222 free_invoke_id(pc
->st
, pc
->prot
.dss1
.invoke_id
);
2223 pc
->prot
.dss1
.invoke_id
= 0; /* reset id */
2225 cs
->iif
.statcallb(&ic
);
2227 dss1_release_l3_process(pc
);
2228 } /* l3dss1_io_timer */
2231 l3dss1_release_ind(struct l3_process
*pc
, u_char pr
, void *arg
)
2234 struct sk_buff
*skb
= arg
;
2238 if ((p
= findie(p
, skb
->len
, IE_CALL_STATE
, 0))) {
2243 if (callState
== 0) {
2244 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1... and 16.1
2245 * set down layer 3 without sending any message
2247 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
2249 dss1_release_l3_process(pc
);
2251 pc
->st
->l3
.l3l4(pc
->st
, CC_IGNORE
| INDICATION
, pc
);
2256 l3dss1_dummy(struct l3_process
*pc
, u_char pr
, void *arg
)
2261 l3dss1_t303(struct l3_process
*pc
, u_char pr
, void *arg
)
2265 L3DelTimer(&pc
->timer
);
2266 l3dss1_setup_req(pc
, pr
, arg
);
2268 L3DelTimer(&pc
->timer
);
2269 l3dss1_message_cause(pc
, MT_RELEASE_COMPLETE
, 102);
2270 pc
->st
->l3
.l3l4(pc
->st
, CC_NOSETUP_RSP
, pc
);
2271 dss1_release_l3_process(pc
);
2276 l3dss1_t304(struct l3_process
*pc
, u_char pr
, void *arg
)
2278 L3DelTimer(&pc
->timer
);
2279 pc
->para
.cause
= 102;
2280 l3dss1_disconnect_req(pc
, pr
, NULL
);
2281 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP_ERR
, pc
);
2286 l3dss1_t305(struct l3_process
*pc
, u_char pr
, void *arg
)
2291 struct sk_buff
*skb
;
2294 L3DelTimer(&pc
->timer
);
2295 if (pc
->para
.cause
!= NO_CAUSE
)
2296 cause
= pc
->para
.cause
;
2298 MsgHead(p
, pc
->callref
, MT_RELEASE
);
2303 *p
++ = cause
| 0x80;
2306 if (!(skb
= l3_alloc_skb(l
)))
2308 memcpy(skb_put(skb
, l
), tmp
, l
);
2310 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
2311 L3AddTimer(&pc
->timer
, T308
, CC_T308_1
);
2315 l3dss1_t310(struct l3_process
*pc
, u_char pr
, void *arg
)
2317 L3DelTimer(&pc
->timer
);
2318 pc
->para
.cause
= 102;
2319 l3dss1_disconnect_req(pc
, pr
, NULL
);
2320 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP_ERR
, pc
);
2324 l3dss1_t313(struct l3_process
*pc
, u_char pr
, void *arg
)
2326 L3DelTimer(&pc
->timer
);
2327 pc
->para
.cause
= 102;
2328 l3dss1_disconnect_req(pc
, pr
, NULL
);
2329 pc
->st
->l3
.l3l4(pc
->st
, CC_CONNECT_ERR
, pc
);
2333 l3dss1_t308_1(struct l3_process
*pc
, u_char pr
, void *arg
)
2336 L3DelTimer(&pc
->timer
);
2337 l3dss1_message(pc
, MT_RELEASE
);
2338 L3AddTimer(&pc
->timer
, T308
, CC_T308_2
);
2342 l3dss1_t308_2(struct l3_process
*pc
, u_char pr
, void *arg
)
2344 L3DelTimer(&pc
->timer
);
2345 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE_ERR
, pc
);
2346 dss1_release_l3_process(pc
);
2350 l3dss1_t318(struct l3_process
*pc
, u_char pr
, void *arg
)
2352 L3DelTimer(&pc
->timer
);
2353 pc
->para
.cause
= 102; /* Timer expiry */
2354 pc
->para
.loc
= 0; /* local */
2355 pc
->st
->l3
.l3l4(pc
->st
, CC_RESUME_ERR
, pc
);
2357 l3dss1_message(pc
, MT_RELEASE
);
2358 L3AddTimer(&pc
->timer
, T308
, CC_T308_1
);
2362 l3dss1_t319(struct l3_process
*pc
, u_char pr
, void *arg
)
2364 L3DelTimer(&pc
->timer
);
2365 pc
->para
.cause
= 102; /* Timer expiry */
2366 pc
->para
.loc
= 0; /* local */
2367 pc
->st
->l3
.l3l4(pc
->st
, CC_SUSPEND_ERR
, pc
);
2372 l3dss1_restart(struct l3_process
*pc
, u_char pr
, void *arg
)
2374 L3DelTimer(&pc
->timer
);
2375 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
2376 dss1_release_l3_process(pc
);
2380 l3dss1_status(struct l3_process
*pc
, u_char pr
, void *arg
)
2383 struct sk_buff
*skb
= arg
;
2385 u_char cause
= 0, callState
= 0;
2387 if ((ret
= l3dss1_get_cause(pc
, skb
))) {
2388 if (pc
->debug
& L3_DEB_WARN
)
2389 l3_debug(pc
->st
, "STATUS get_cause ret(%d)",ret
);
2395 if ((p
= findie(skb
->data
, skb
->len
, IE_CALL_STATE
, 0))) {
2399 if (!ie_in_set(pc
, *p
, l3_valid_states
))
2405 if (!cause
) { /* no error before */
2406 ret
= check_infoelements(pc
, skb
, ie_STATUS
);
2407 if (ERR_IE_COMPREHENSION
== ret
)
2409 else if (ERR_IE_UNRECOGNIZED
== ret
)
2415 if (pc
->debug
& L3_DEB_WARN
)
2416 l3_debug(pc
->st
, "STATUS error(%d/%d)",ret
,cause
);
2417 tmp
= pc
->para
.cause
;
2418 pc
->para
.cause
= cause
;
2419 l3dss1_status_send(pc
, 0, NULL
);
2421 pc
->para
.cause
= tmp
;
2425 cause
= pc
->para
.cause
;
2426 if (((cause
& 0x7f) == 111) && (callState
== 0)) {
2427 /* ETS 300-104 7.6.1, 8.6.1, 10.6.1...
2428 * if received MT_STATUS with cause == 111 and call
2429 * state == 0, then we must set down layer 3
2431 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
2433 dss1_release_l3_process(pc
);
2438 l3dss1_facility(struct l3_process
*pc
, u_char pr
, void *arg
)
2440 struct sk_buff
*skb
= arg
;
2443 ret
= check_infoelements(pc
, skb
, ie_FACILITY
);
2444 l3dss1_std_ie_err(pc
, ret
);
2447 if ((p
= findie(skb
->data
, skb
->len
, IE_FACILITY
, 0)))
2448 l3dss1_parse_facility(pc
->st
, pc
, pc
->callref
, p
);
2453 l3dss1_suspend_req(struct l3_process
*pc
, u_char pr
, void *arg
)
2455 struct sk_buff
*skb
;
2459 u_char
*msg
= pc
->chan
->setup
.phone
;
2461 MsgHead(p
, pc
->callref
, MT_SUSPEND
);
2463 if (l
&& (l
<= 10)) { /* Max length 10 octets */
2466 for (i
= 0; i
< l
; i
++)
2469 l3_debug(pc
->st
, "SUS wrong CALL_ID len %d", l
);
2473 if (!(skb
= l3_alloc_skb(l
)))
2475 memcpy(skb_put(skb
, l
), tmp
, l
);
2476 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
2478 L3AddTimer(&pc
->timer
, T319
, CC_T319
);
2482 l3dss1_suspend_ack(struct l3_process
*pc
, u_char pr
, void *arg
)
2484 struct sk_buff
*skb
= arg
;
2487 L3DelTimer(&pc
->timer
);
2489 pc
->para
.cause
= NO_CAUSE
;
2490 pc
->st
->l3
.l3l4(pc
->st
, CC_SUSPEND
| CONFIRM
, pc
);
2491 /* We don't handle suspend_ack for IE errors now */
2492 if ((ret
= check_infoelements(pc
, skb
, ie_SUSPEND_ACKNOWLEDGE
)))
2493 if (pc
->debug
& L3_DEB_WARN
)
2494 l3_debug(pc
->st
, "SUSPACK check ie(%d)",ret
);
2495 dss1_release_l3_process(pc
);
2499 l3dss1_suspend_rej(struct l3_process
*pc
, u_char pr
, void *arg
)
2501 struct sk_buff
*skb
= arg
;
2504 if ((ret
= l3dss1_get_cause(pc
, skb
))) {
2505 if (pc
->debug
& L3_DEB_WARN
)
2506 l3_debug(pc
->st
, "SUSP_REJ get_cause ret(%d)",ret
);
2508 pc
->para
.cause
= 96;
2510 pc
->para
.cause
= 100;
2511 l3dss1_status_send(pc
, pr
, NULL
);
2514 ret
= check_infoelements(pc
, skb
, ie_SUSPEND_REJECT
);
2515 if (ERR_IE_COMPREHENSION
== ret
) {
2516 l3dss1_std_ie_err(pc
, ret
);
2519 L3DelTimer(&pc
->timer
);
2520 pc
->st
->l3
.l3l4(pc
->st
, CC_SUSPEND_ERR
, pc
);
2522 if (ret
) /* STATUS for none mandatory IE errors after actions are taken */
2523 l3dss1_std_ie_err(pc
, ret
);
2527 l3dss1_resume_req(struct l3_process
*pc
, u_char pr
, void *arg
)
2529 struct sk_buff
*skb
;
2533 u_char
*msg
= pc
->para
.setup
.phone
;
2535 MsgHead(p
, pc
->callref
, MT_RESUME
);
2538 if (l
&& (l
<= 10)) { /* Max length 10 octets */
2541 for (i
= 0; i
< l
; i
++)
2544 l3_debug(pc
->st
, "RES wrong CALL_ID len %d", l
);
2548 if (!(skb
= l3_alloc_skb(l
)))
2550 memcpy(skb_put(skb
, l
), tmp
, l
);
2551 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
2553 L3AddTimer(&pc
->timer
, T318
, CC_T318
);
2557 l3dss1_resume_ack(struct l3_process
*pc
, u_char pr
, void *arg
)
2559 struct sk_buff
*skb
= arg
;
2562 if ((id
= l3dss1_get_channel_id(pc
, skb
)) > 0) {
2563 if ((0 == id
) || ((3 == id
) && (0x10 == pc
->para
.moderate
))) {
2564 if (pc
->debug
& L3_DEB_WARN
)
2565 l3_debug(pc
->st
, "resume ack with wrong chid %x", id
);
2566 pc
->para
.cause
= 100;
2567 l3dss1_status_send(pc
, pr
, NULL
);
2570 pc
->para
.bchannel
= id
;
2571 } else if (1 == pc
->state
) {
2572 if (pc
->debug
& L3_DEB_WARN
)
2573 l3_debug(pc
->st
, "resume ack without chid (ret %d)", id
);
2574 pc
->para
.cause
= 96;
2575 l3dss1_status_send(pc
, pr
, NULL
);
2578 ret
= check_infoelements(pc
, skb
, ie_RESUME_ACKNOWLEDGE
);
2579 if (ERR_IE_COMPREHENSION
== ret
) {
2580 l3dss1_std_ie_err(pc
, ret
);
2583 L3DelTimer(&pc
->timer
);
2584 pc
->st
->l3
.l3l4(pc
->st
, CC_RESUME
| CONFIRM
, pc
);
2586 if (ret
) /* STATUS for none mandatory IE errors after actions are taken */
2587 l3dss1_std_ie_err(pc
, ret
);
2591 l3dss1_resume_rej(struct l3_process
*pc
, u_char pr
, void *arg
)
2593 struct sk_buff
*skb
= arg
;
2596 if ((ret
= l3dss1_get_cause(pc
, skb
))) {
2597 if (pc
->debug
& L3_DEB_WARN
)
2598 l3_debug(pc
->st
, "RES_REJ get_cause ret(%d)",ret
);
2600 pc
->para
.cause
= 96;
2602 pc
->para
.cause
= 100;
2603 l3dss1_status_send(pc
, pr
, NULL
);
2606 ret
= check_infoelements(pc
, skb
, ie_RESUME_REJECT
);
2607 if (ERR_IE_COMPREHENSION
== ret
) {
2608 l3dss1_std_ie_err(pc
, ret
);
2611 L3DelTimer(&pc
->timer
);
2612 pc
->st
->l3
.l3l4(pc
->st
, CC_RESUME_ERR
, pc
);
2614 if (ret
) /* STATUS for none mandatory IE errors after actions are taken */
2615 l3dss1_std_ie_err(pc
, ret
);
2616 dss1_release_l3_process(pc
);
2620 l3dss1_global_restart(struct l3_process
*pc
, u_char pr
, void *arg
)
2624 u_char ri
, ch
= 0, chan
= 0;
2626 struct sk_buff
*skb
= arg
;
2627 struct l3_process
*up
;
2630 L3DelTimer(&pc
->timer
);
2632 if ((p
= findie(p
, skb
->len
, IE_RESTART_IND
, 0))) {
2634 l3_debug(pc
->st
, "Restart %x", ri
);
2636 l3_debug(pc
->st
, "Restart without restart IE");
2640 if ((p
= findie(p
, skb
->len
, IE_CHANNEL_ID
, 0))) {
2643 if (pc
->st
->l3
.debug
)
2644 l3_debug(pc
->st
, "Restart for channel %d", chan
);
2647 up
= pc
->st
->l3
.proc
;
2650 up
->st
->lli
.l4l3(up
->st
, CC_RESTART
| REQUEST
, up
);
2651 else if (up
->para
.bchannel
== chan
)
2652 up
->st
->lli
.l4l3(up
->st
, CC_RESTART
| REQUEST
, up
);
2656 MsgHead(p
, pc
->callref
, MT_RESTART_ACKNOWLEDGE
);
2658 *p
++ = IE_CHANNEL_ID
;
2662 *p
++ = 0x79; /* RESTART Ind */
2666 if (!(skb
= l3_alloc_skb(l
)))
2668 memcpy(skb_put(skb
, l
), tmp
, l
);
2670 l3_msg(pc
->st
, DL_DATA
| REQUEST
, skb
);
2674 l3dss1_dl_reset(struct l3_process
*pc
, u_char pr
, void *arg
)
2676 pc
->para
.cause
= 0x29; /* Temporary failure */
2678 l3dss1_disconnect_req(pc
, pr
, NULL
);
2679 pc
->st
->l3
.l3l4(pc
->st
, CC_SETUP_ERR
, pc
);
2683 l3dss1_dl_release(struct l3_process
*pc
, u_char pr
, void *arg
)
2686 pc
->para
.cause
= 0x1b; /* Destination out of order */
2688 pc
->st
->l3
.l3l4(pc
->st
, CC_RELEASE
| INDICATION
, pc
);
2689 release_l3_process(pc
);
2693 l3dss1_dl_reestablish(struct l3_process
*pc
, u_char pr
, void *arg
)
2695 L3DelTimer(&pc
->timer
);
2696 L3AddTimer(&pc
->timer
, T309
, CC_T309
);
2697 l3_msg(pc
->st
, DL_ESTABLISH
| REQUEST
, NULL
);
2701 l3dss1_dl_reest_status(struct l3_process
*pc
, u_char pr
, void *arg
)
2703 L3DelTimer(&pc
->timer
);
2705 pc
->para
.cause
= 0x1F; /* normal, unspecified */
2706 l3dss1_status_send(pc
, 0, NULL
);
2710 static struct stateentry downstatelist
[] =
2713 CC_SETUP
| REQUEST
, l3dss1_setup_req
},
2715 CC_RESUME
| REQUEST
, l3dss1_resume_req
},
2716 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10),
2717 CC_DISCONNECT
| REQUEST
, l3dss1_disconnect_req
},
2719 CC_RELEASE
| REQUEST
, l3dss1_release_req
},
2721 CC_RESTART
| REQUEST
, l3dss1_restart
},
2723 CC_IGNORE
| REQUEST
, l3dss1_reset
},
2725 CC_REJECT
| REQUEST
, l3dss1_reject_req
},
2727 CC_PROCEED_SEND
| REQUEST
, l3dss1_proceed_req
},
2729 CC_ALERTING
| REQUEST
, l3dss1_alert_req
},
2730 {SBIT(6) | SBIT(7) | SBIT(9),
2731 CC_SETUP
| RESPONSE
, l3dss1_setup_rsp
},
2733 CC_SUSPEND
| REQUEST
, l3dss1_suspend_req
},
2735 CC_PROCEED_SEND
| REQUEST
, l3dss1_proceed_req
},
2737 CC_REDIR
| REQUEST
, l3dss1_redir_req
},
2739 CC_REDIR
| REQUEST
, l3dss1_redir_req_early
},
2740 {SBIT(9) | SBIT(25),
2741 CC_DISCONNECT
| REQUEST
, l3dss1_disconnect_req
},
2743 CC_T303
, l3dss1_t303
},
2745 CC_T304
, l3dss1_t304
},
2747 CC_T310
, l3dss1_t310
},
2749 CC_T313
, l3dss1_t313
},
2751 CC_T305
, l3dss1_t305
},
2753 CC_T319
, l3dss1_t319
},
2755 CC_T318
, l3dss1_t318
},
2757 CC_T308_1
, l3dss1_t308_1
},
2759 CC_T308_2
, l3dss1_t308_2
},
2761 CC_T309
, l3dss1_dl_release
},
2765 (sizeof(downstatelist) / sizeof(struct stateentry))
2767 static struct stateentry datastatelist
[] =
2770 MT_STATUS_ENQUIRY
, l3dss1_status_enq
},
2772 MT_FACILITY
, l3dss1_facility
},
2774 MT_STATUS
, l3dss1_release_ind
},
2776 MT_STATUS
, l3dss1_status
},
2778 MT_SETUP
, l3dss1_setup
},
2779 {SBIT(6) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(12) |
2780 SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2781 MT_SETUP
, l3dss1_dummy
},
2783 MT_CALL_PROCEEDING
, l3dss1_call_proc
},
2785 MT_SETUP_ACKNOWLEDGE
, l3dss1_setup_ack
},
2787 MT_ALERTING
, l3dss1_alerting
},
2789 MT_PROGRESS
, l3dss1_progress
},
2790 {SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) |
2791 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2792 MT_INFORMATION
, l3dss1_information
},
2793 {SBIT(10) | SBIT(11) | SBIT(15),
2794 MT_NOTIFY
, l3dss1_notify
},
2795 {SBIT(0) | SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
2796 SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19) | SBIT(25),
2797 MT_RELEASE_COMPLETE
, l3dss1_release_cmpl
},
2798 {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),
2799 MT_RELEASE
, l3dss1_release
},
2800 {SBIT(19), MT_RELEASE
, l3dss1_release_ind
},
2801 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10) | SBIT(11) | SBIT(15) | SBIT(17) | SBIT(25),
2802 MT_DISCONNECT
, l3dss1_disconnect
},
2804 MT_DISCONNECT
, l3dss1_dummy
},
2805 {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4),
2806 MT_CONNECT
, l3dss1_connect
},
2808 MT_CONNECT_ACKNOWLEDGE
, l3dss1_connect_ack
},
2810 MT_SUSPEND_ACKNOWLEDGE
, l3dss1_suspend_ack
},
2812 MT_SUSPEND_REJECT
, l3dss1_suspend_rej
},
2814 MT_RESUME_ACKNOWLEDGE
, l3dss1_resume_ack
},
2816 MT_RESUME_REJECT
, l3dss1_resume_rej
},
2820 (sizeof(datastatelist) / sizeof(struct stateentry))
2822 static struct stateentry globalmes_list
[] =
2825 MT_STATUS
, l3dss1_status
},
2827 MT_RESTART
, l3dss1_global_restart
},
2829 MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack},
2832 #define GLOBALM_LEN \
2833 (sizeof(globalmes_list) / sizeof(struct stateentry))
2835 static struct stateentry manstatelist
[] =
2838 DL_ESTABLISH
| INDICATION
, l3dss1_dl_reset
},
2840 DL_ESTABLISH
| CONFIRM
, l3dss1_dl_reest_status
},
2842 DL_RELEASE
| INDICATION
, l3dss1_dl_reestablish
},
2844 DL_RELEASE
| INDICATION
, l3dss1_dl_release
},
2848 (sizeof(manstatelist) / sizeof(struct stateentry))
2853 global_handler(struct PStack
*st
, int mt
, struct sk_buff
*skb
)
2859 struct l3_process
*proc
= st
->l3
.global
;
2861 proc
->callref
= skb
->data
[2]; /* cr flag */
2862 for (i
= 0; i
< GLOBALM_LEN
; i
++)
2863 if ((mt
== globalmes_list
[i
].primitive
) &&
2864 ((1 << proc
->state
) & globalmes_list
[i
].state
))
2866 if (i
== GLOBALM_LEN
) {
2867 if (st
->l3
.debug
& L3_DEB_STATE
) {
2868 l3_debug(st
, "dss1 global state %d mt %x unhandled",
2871 MsgHead(p
, proc
->callref
, MT_STATUS
);
2875 *p
++ = 81 |0x80; /* invalid cr */
2876 *p
++ = 0x14; /* CallState */
2878 *p
++ = proc
->state
& 0x3f;
2880 if (!(skb
= l3_alloc_skb(l
)))
2882 memcpy(skb_put(skb
, l
), tmp
, l
);
2883 l3_msg(proc
->st
, DL_DATA
| REQUEST
, skb
);
2885 if (st
->l3
.debug
& L3_DEB_STATE
) {
2886 l3_debug(st
, "dss1 global %d mt %x",
2889 globalmes_list
[i
].rout(proc
, mt
, skb
);
2894 dss1up(struct PStack
*st
, int pr
, void *arg
)
2896 int i
, mt
, cr
, cause
, callState
;
2899 struct sk_buff
*skb
= arg
;
2900 struct l3_process
*proc
;
2903 case (DL_DATA
| INDICATION
):
2904 case (DL_UNIT_DATA
| INDICATION
):
2906 case (DL_ESTABLISH
| CONFIRM
):
2907 case (DL_ESTABLISH
| INDICATION
):
2908 case (DL_RELEASE
| INDICATION
):
2909 case (DL_RELEASE
| CONFIRM
):
2910 l3_msg(st
, pr
, arg
);
2914 printk(KERN_ERR
"HiSax dss1up unknown pr=%04x\n", pr
);
2918 l3_debug(st
, "dss1up frame too short(%d)", skb
->len
);
2923 if (skb
->data
[0] != PROTO_DIS_EURO
) {
2924 if (st
->l3
.debug
& L3_DEB_PROTERR
) {
2925 l3_debug(st
, "dss1up%sunexpected discriminator %x message len %d",
2926 (pr
== (DL_DATA
| INDICATION
)) ? " " : "(broadcast) ",
2927 skb
->data
[0], skb
->len
);
2932 cr
= getcallref(skb
->data
);
2933 if (skb
->len
< ((skb
->data
[1] & 0x0f) + 3)) {
2934 l3_debug(st
, "dss1up frame too short(%d)", skb
->len
);
2938 mt
= skb
->data
[skb
->data
[1] + 2];
2939 if (st
->l3
.debug
& L3_DEB_STATE
)
2940 l3_debug(st
, "dss1up cr %d", cr
);
2941 if (cr
== -2) { /* wrong Callref */
2942 if (st
->l3
.debug
& L3_DEB_WARN
)
2943 l3_debug(st
, "dss1up wrong Callref");
2946 } else if (cr
== -1) { /* Dummy Callref */
2947 if (mt
== MT_FACILITY
)
2948 if ((p
= findie(skb
->data
, skb
->len
, IE_FACILITY
, 0))) {
2949 l3dss1_parse_facility(st
, NULL
,
2950 (pr
== (DL_DATA
| INDICATION
)) ? -1 : -2, p
);
2954 if (st
->l3
.debug
& L3_DEB_WARN
)
2955 l3_debug(st
, "dss1up dummy Callref (no facility msg or ie)");
2958 } else if ((((skb
->data
[1] & 0x0f) == 1) && (0==(cr
& 0x7f))) ||
2959 (((skb
->data
[1] & 0x0f) == 2) && (0==(cr
& 0x7fff)))) { /* Global CallRef */
2960 if (st
->l3
.debug
& L3_DEB_STATE
)
2961 l3_debug(st
, "dss1up Global CallRef");
2962 global_handler(st
, mt
, skb
);
2965 } else if (!(proc
= getl3proc(st
, cr
))) {
2966 /* No transaction process exist, that means no call with
2967 * this callreference is active
2969 if (mt
== MT_SETUP
) {
2970 /* Setup creates a new transaction process */
2971 if (skb
->data
[2] & 0x80) {
2972 /* Setup with wrong CREF flag */
2973 if (st
->l3
.debug
& L3_DEB_STATE
)
2974 l3_debug(st
, "dss1up wrong CRef flag");
2978 if (!(proc
= dss1_new_l3_process(st
, cr
))) {
2979 /* May be to answer with RELEASE_COMPLETE and
2980 * CAUSE 0x2f "Resource unavailable", but this
2981 * need a new_l3_process too ... arghh
2986 } else if (mt
== MT_STATUS
) {
2988 if ((ptr
= findie(skb
->data
, skb
->len
, IE_CAUSE
, 0)) != NULL
) {
2992 cause
= *ptr
& 0x7f;
2995 if ((ptr
= findie(skb
->data
, skb
->len
, IE_CALL_STATE
, 0)) != NULL
) {
3001 /* ETS 300-104 part 2.4.1
3002 * if setup has not been made and a message type
3003 * MT_STATUS is received with call state == 0,
3004 * we must send nothing
3006 if (callState
!= 0) {
3007 /* ETS 300-104 part 2.4.2
3008 * if setup has not been made and a message type
3009 * MT_STATUS is received with call state != 0,
3010 * we must send MT_RELEASE_COMPLETE cause 101
3012 if ((proc
= dss1_new_l3_process(st
, cr
))) {
3013 proc
->para
.cause
= 101;
3014 l3dss1_msg_without_setup(proc
, 0, NULL
);
3019 } else if (mt
== MT_RELEASE_COMPLETE
) {
3023 /* ETS 300-104 part 2
3024 * if setup has not been made and a message type
3025 * (except MT_SETUP and RELEASE_COMPLETE) is received,
3026 * we must send MT_RELEASE_COMPLETE cause 81 */
3028 if ((proc
= dss1_new_l3_process(st
, cr
))) {
3029 proc
->para
.cause
= 81;
3030 l3dss1_msg_without_setup(proc
, 0, NULL
);
3035 if (l3dss1_check_messagetype_validity(proc
, mt
, skb
)) {
3039 if ((p
= findie(skb
->data
, skb
->len
, IE_DISPLAY
, 0)) != NULL
)
3040 l3dss1_deliver_display(proc
, pr
, p
); /* Display IE included */
3041 for (i
= 0; i
< DATASLLEN
; i
++)
3042 if ((mt
== datastatelist
[i
].primitive
) &&
3043 ((1 << proc
->state
) & datastatelist
[i
].state
))
3045 if (i
== DATASLLEN
) {
3046 if (st
->l3
.debug
& L3_DEB_STATE
) {
3047 l3_debug(st
, "dss1up%sstate %d mt %#x unhandled",
3048 (pr
== (DL_DATA
| INDICATION
)) ? " " : "(broadcast) ",
3051 if ((MT_RELEASE_COMPLETE
!= mt
) && (MT_RELEASE
!= mt
)) {
3052 proc
->para
.cause
= 101;
3053 l3dss1_status_send(proc
, pr
, skb
);
3056 if (st
->l3
.debug
& L3_DEB_STATE
) {
3057 l3_debug(st
, "dss1up%sstate %d mt %x",
3058 (pr
== (DL_DATA
| INDICATION
)) ? " " : "(broadcast) ",
3061 datastatelist
[i
].rout(proc
, pr
, skb
);
3068 dss1down(struct PStack
*st
, int pr
, void *arg
)
3071 struct l3_process
*proc
;
3072 struct Channel
*chan
;
3074 if ((DL_ESTABLISH
| REQUEST
) == pr
) {
3075 l3_msg(st
, pr
, NULL
);
3077 } else if (((CC_SETUP
| REQUEST
) == pr
) || ((CC_RESUME
| REQUEST
) == pr
)) {
3081 if ((proc
= dss1_new_l3_process(st
, cr
))) {
3084 memcpy (&proc
->para
.setup
, &chan
->setup
, sizeof (chan
->setup
));
3091 printk(KERN_ERR
"HiSax dss1down without proc pr=%04x\n", pr
);
3095 if ( pr
== (CC_TDSS1_IO
| REQUEST
)) {
3096 l3dss1_io_timer(proc
); /* timer expires */
3100 for (i
= 0; i
< DOWNSLLEN
; i
++)
3101 if ((pr
== downstatelist
[i
].primitive
) &&
3102 ((1 << proc
->state
) & downstatelist
[i
].state
))
3104 if (i
== DOWNSLLEN
) {
3105 if (st
->l3
.debug
& L3_DEB_STATE
) {
3106 l3_debug(st
, "dss1down state %d prim %#x unhandled",
3110 if (st
->l3
.debug
& L3_DEB_STATE
) {
3111 l3_debug(st
, "dss1down state %d prim %#x",
3114 downstatelist
[i
].rout(proc
, pr
, arg
);
3119 dss1man(struct PStack
*st
, int pr
, void *arg
)
3122 struct l3_process
*proc
= arg
;
3125 printk(KERN_ERR
"HiSax dss1man without proc pr=%04x\n", pr
);
3128 for (i
= 0; i
< MANSLLEN
; i
++)
3129 if ((pr
== manstatelist
[i
].primitive
) &&
3130 ((1 << proc
->state
) & manstatelist
[i
].state
))
3132 if (i
== MANSLLEN
) {
3133 if (st
->l3
.debug
& L3_DEB_STATE
) {
3134 l3_debug(st
, "cr %d dss1man state %d prim %#x unhandled",
3135 proc
->callref
& 0x7f, proc
->state
, pr
);
3138 if (st
->l3
.debug
& L3_DEB_STATE
) {
3139 l3_debug(st
, "cr %d dss1man state %d prim %#x",
3140 proc
->callref
& 0x7f, proc
->state
, pr
);
3142 manstatelist
[i
].rout(proc
, pr
, arg
);
3147 setstack_dss1(struct PStack
*st
)
3152 st
->lli
.l4l3
= dss1down
;
3153 st
->lli
.l4l3_proto
= l3dss1_cmd_global
;
3154 st
->l2
.l2l3
= dss1up
;
3155 st
->l3
.l3ml3
= dss1man
;
3157 st
->prot
.dss1
.last_invoke_id
= 0;
3158 st
->prot
.dss1
.invoke_used
[0] = 1; /* Bit 0 must always be set to 1 */
3161 st
->prot
.dss1
.invoke_used
[i
++] = 0;
3163 if (!(st
->l3
.global
= kmalloc(sizeof(struct l3_process
), GFP_ATOMIC
))) {
3164 printk(KERN_ERR
"HiSax can't get memory for dss1 global CR\n");
3166 st
->l3
.global
->state
= 0;
3167 st
->l3
.global
->callref
= 0;
3168 st
->l3
.global
->next
= NULL
;
3169 st
->l3
.global
->debug
= L3_DEB_WARN
;
3170 st
->l3
.global
->st
= st
;
3171 st
->l3
.global
->N303
= 1;
3172 st
->l3
.global
->prot
.dss1
.invoke_id
= 0;
3174 L3InitTimer(st
->l3
.global
, &st
->l3
.global
->timer
);
3176 strcpy(tmp
, dss1_revision
);
3177 printk(KERN_INFO
"HiSax: DSS1 Rev. %s\n", HiSax_getrev(tmp
));