-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisup.c
5560 lines (4806 loc) · 141 KB
/
isup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* libss7: An implementation of Signalling System 7
*
* Written by Matthew Fredrickson <[email protected]>
*
* scheduling routines taken from libpri by Mark Spencer <[email protected]>
*
* Copyright (C) 2006-2008, Digium, Inc
* All Rights Reserved.
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*
* In addition, when this program is distributed with Asterisk in
* any form that would qualify as a 'combined work' or as a
* 'derivative work' (but not mere aggregation), you can redistribute
* and/or modify the combination under the terms of the license
* provided with that copy of Asterisk, instead of the license
* terms granted here.
*/
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include "libss7.h"
#include "isup.h"
#include "ss7_internal.h"
#include "mtp3.h"
#define FUNC_DUMP(name) int ((name))(struct ss7 *ss7, int messagetype, unsigned char *parm, int len)
/* Length here is paramter length */
#define FUNC_RECV(name) int ((name))(struct ss7 *ss7, struct isup_call *c, int messagetype, unsigned char *parm, int len)
/* Length here is maximum length */
#define FUNC_SEND(name) int ((name))(struct ss7 *ss7, struct isup_call *c, int messagetype, unsigned char *parm, int len)
#define PARM_TYPE_FIXED 0x01
#define PARM_TYPE_VARIABLE 0x02
#define PARM_TYPE_OPTIONAL 0x03
#define CODE_CCITT 0x0
struct parm_func {
int parm;
char *name;
FUNC_DUMP(*dump);
FUNC_RECV(*receive);
FUNC_SEND(*transmit);
};
struct isup_timer_param {
struct ss7 *ss7;
struct isup_call *c;
int timer;
};
static int iam_params[] = {ISUP_PARM_NATURE_OF_CONNECTION_IND, ISUP_PARM_FORWARD_CALL_IND, ISUP_PARM_CALLING_PARTY_CAT,
ISUP_PARM_TRANSMISSION_MEDIUM_REQS, ISUP_PARM_CALLED_PARTY_NUM, ISUP_PARM_CALLING_PARTY_NUM, ISUP_PARM_REDIRECTING_NUMBER,
ISUP_PARM_REDIRECTION_INFO, ISUP_PARM_REDIRECT_COUNTER, ISUP_PARM_ORIGINAL_CALLED_NUM, ISUP_PARM_OPT_FORWARD_CALL_INDICATOR,
ISUP_PARM_CUG_INTERLOCK_CODE, -1};
static int ansi_iam_params[] = {ISUP_PARM_NATURE_OF_CONNECTION_IND, ISUP_PARM_FORWARD_CALL_IND, ISUP_PARM_CALLING_PARTY_CAT,
ISUP_PARM_USER_SERVICE_INFO, ISUP_PARM_CALLED_PARTY_NUM, ISUP_PARM_CALLING_PARTY_NUM, ISUP_PARM_CHARGE_NUMBER,
ISUP_PARM_ORIG_LINE_INFO, ISUP_PARM_GENERIC_ADDR, ISUP_PARM_GENERIC_DIGITS, ISUP_PARM_GENERIC_NAME, ISUP_PARM_JIP,
ISUP_PARM_LOCAL_SERVICE_PROVIDER_IDENTIFICATION, ISUP_PARM_REDIRECTION_INFO, ISUP_PARM_REDIRECTING_NUMBER, ISUP_PARM_REDIRECT_COUNTER,
ISUP_PARM_ORIGINAL_CALLED_NUM, ISUP_PARM_OPT_FORWARD_CALL_INDICATOR, ISUP_PARM_CUG_INTERLOCK_CODE, -1};
static int acm_params[] = {ISUP_PARM_BACKWARD_CALL_IND, -1};
static int frj_params[] = {ISUP_PARM_FACILITY_IND, ISUP_PARM_CALL_REF, -1};
static int faa_params[] = {ISUP_PARM_FACILITY_IND, ISUP_PARM_CALL_REF, -1};
static int far_params[] = {ISUP_PARM_FACILITY_IND, ISUP_PARM_CALL_REF, -1};
static int anm_params[] = { ISUP_CONNECTED_NUMBER, -1};
static int con_params[] = { ISUP_PARM_BACKWARD_CALL_IND, ISUP_CONNECTED_NUMBER, -1};
static int rel_params[] = { ISUP_PARM_CAUSE, -1};
static int greset_params[] = { ISUP_PARM_RANGE_AND_STATUS, -1};
static int cot_params[] = { ISUP_PARM_CONTINUITY_IND, -1};
static int cpg_params[] = { ISUP_PARM_EVENT_INFO, ISUP_CONNECTED_NUMBER, -1};
static int cicgroup_params[] = { ISUP_PARM_CIRCUIT_GROUP_SUPERVISION_IND, ISUP_PARM_RANGE_AND_STATUS, -1};
static int cqr_params[] = { ISUP_PARM_RANGE_AND_STATUS, ISUP_PARM_CIRCUIT_STATE_IND, -1};
static int sus_res_params[] = { ISUP_PARM_SUSPEND_RESUME_IND, ISUP_PARM_CALL_REF, -1};
static int inr_params[] = { ISUP_PARM_INR_IND, -1};
static int inf_params[] = { ISUP_PARM_INF_IND, ISUP_PARM_CALLING_PARTY_NUM, ISUP_PARM_CALLING_PARTY_CAT, -1};
static int sam_params[] = { ISUP_PARM_SUBSEQUENT_NUMBER, -1};
static int empty_params[] = { -1};
static struct message_data {
int messagetype;
int mand_fixed_params;
int mand_var_params;
int opt_params;
int ansi_priority;
int *param_list;
} messages[] = {
{ISUP_IAM, 4, 1, 1, 0, iam_params},
{ISUP_ACM, 1, 0, 1, 1, acm_params},
{ISUP_ANM, 0, 0, 1, 2, anm_params},
{ISUP_CON, 1, 0, 1, -1, con_params},
{ISUP_REL, 0, 1, 1, 1, rel_params},
{ISUP_RLC, 0, 0, 1, 2, empty_params},
{ISUP_GRS, 0, 1, 0, 0, greset_params},
{ISUP_GRA, 0, 1, 0, 0, greset_params},
{ISUP_CGB, 1, 1, 0, 0, cicgroup_params},
{ISUP_CGU, 1, 1, 0, 0, cicgroup_params},
{ISUP_CGBA, 1, 1, 0, 0, cicgroup_params},
{ISUP_CGUA, 1, 1, 0, 0, cicgroup_params},
{ISUP_COT, 1, 0, 0, 1, cot_params},
{ISUP_CCR, 0, 0, 0, 1, empty_params},
{ISUP_BLO, 0, 0, 0, 0, empty_params},
{ISUP_LPA, 0, 0, 0, 1, empty_params},
{ISUP_UBL, 0, 0, 0, 0, empty_params},
{ISUP_BLA, 0, 0, 0, 0, empty_params},
{ISUP_UBA, 0, 0, 0, 0, empty_params},
{ISUP_RSC, 0, 0, 0, 0, empty_params},
{ISUP_CVR, 0, 0, 0, 0, empty_params},
{ISUP_CVT, 0, 0, 0, 0, empty_params},
{ISUP_CPG, 1, 0, 1, 1, cpg_params},
{ISUP_UCIC, 0, 0, 0, 1, empty_params},
{ISUP_CQM, 0, 1, 0, 0, greset_params},
{ISUP_CQR, 0, 2, 0, 0, cqr_params},
{ISUP_FRJ, 1, 0, 1, -1, frj_params},
{ISUP_FAA, 1, 0, 1, -1, faa_params},
{ISUP_FAR, 1, 0, 1, -1, far_params},
{ISUP_CFN, 0, 1, 1, 0, rel_params},
{ISUP_SUS, 1, 0, 1, 1, sus_res_params},
{ISUP_RES, 1, 0, 1, 1, sus_res_params},
{ISUP_INR, 1, 0, 0, 1, inr_params},
{ISUP_INF, 1, 0, 2, 1, inf_params},
{ISUP_SAM, 0, 1, 1, -1, sam_params}
};
static int isup_send_message(struct ss7 *ss7, struct isup_call *c, int messagetype, int parms[]);
static int isup_start_timer(struct ss7 *ss7, struct isup_call *c, int timer);
static void isup_stop_all_timers(struct ss7 *ss7, struct isup_call *c);
static void isup_stop_timer(struct ss7 *ss7, struct isup_call *c, int timer);
static char * message2str(unsigned char message)
{
switch (message) {
case ISUP_IAM:
return "IAM";
case ISUP_ACM:
return "ACM";
case ISUP_ANM:
return "ANM";
case ISUP_CON:
return "CON";
case ISUP_REL:
return "REL";
case ISUP_RLC:
return "RLC";
case ISUP_GRS:
return "GRS";
case ISUP_GRA:
return "GRA";
case ISUP_COT:
return "COT";
case ISUP_CCR:
return "CCR";
case ISUP_BLO:
return "BLO";
case ISUP_UBL:
return "UBL";
case ISUP_BLA:
return "BLA";
case ISUP_UBA:
return "UBA";
case ISUP_CGB:
return "CGB";
case ISUP_CGU:
return "CGU";
case ISUP_CGBA:
return "CGBA";
case ISUP_CGUA:
return "CGUA";
case ISUP_RSC:
return "RSC";
case ISUP_CPG:
return "CPG";
case ISUP_UCIC:
return "UCIC";
case ISUP_LPA:
return "LPA";
case ISUP_FAA:
return "FAA";
case ISUP_FAR:
return "FAR";
case ISUP_FRJ:
return "FRJ";
case ISUP_CVT:
return "CVT";
case ISUP_CVR:
return "CVR";
case ISUP_CFN:
return "CFN";
case ISUP_SUS:
return "SUS";
case ISUP_RES:
return "RES";
case ISUP_INR:
return "INR";
case ISUP_INF:
return "INF";
case ISUP_SAM:
return "SAM";
default:
return "Unknown";
}
}
static char * isup_timer2str(int timer)
{
switch (timer) {
case ISUP_TIMER_T1:
return "t1";
case ISUP_TIMER_T2:
return "t2";
case ISUP_TIMER_T5:
return "t5";
case ISUP_TIMER_T6:
return "t6";
case ISUP_TIMER_T7:
return "t7";
case ISUP_TIMER_T8:
return "t8";
case ISUP_TIMER_T10:
return "t10";
case ISUP_TIMER_T12:
return "t12";
case ISUP_TIMER_T13:
return "t13";
case ISUP_TIMER_T14:
return "t14";
case ISUP_TIMER_T15:
return "t15";
case ISUP_TIMER_T16:
return "t16";
case ISUP_TIMER_T17:
return "t17";
case ISUP_TIMER_T18:
return "t18";
case ISUP_TIMER_T19:
return "t19";
case ISUP_TIMER_T20:
return "t20";
case ISUP_TIMER_T21:
return "t21";
case ISUP_TIMER_T22:
return "t22";
case ISUP_TIMER_T23:
return "t23";
case ISUP_TIMER_T27:
return "t27";
case ISUP_TIMER_T33:
return "t33";
case ISUP_TIMER_T35:
return "t35";
default:
return "unknown";
}
}
static char char2digit(char localchar)
{
switch (localchar) {
case '0':
return 0x0;
case '1':
return 0x1;
case '2':
return 0x2;
case '3':
return 0x3;
case '4':
return 0x4;
case '5':
return 0x5;
case '6':
return 0x6;
case '7':
return 0x7;
case '8':
return 0x8;
case '9':
return 0x9;
case 'a':
case 'A':
return 0xa;
case 'b':
case 'B':
return 0xb;
case 'c':
case 'C':
return 0xc;
case 'd':
case 'D':
return 0xd;
case 'e':
case 'E':
case '*':
return 0xe;
case 'f':
case 'F':
case '#':
return 0xf;
default:
return 0x0;
}
}
static char digit2char(unsigned char digit)
{
switch (digit & 0xf) {
case 0x0:
return '0';
case 0x1:
return '1';
case 0x2:
return '2';
case 0x3:
return '3';
case 0x4:
return '4';
case 0x5:
return '5';
case 0x6:
return '6';
case 0x7:
return '7';
case 0x8:
return '8';
case 0x9:
return '9';
case 0xa:
return 'A';
case 0xb:
return 'B';
case 0xc:
return 'C';
case 0xd:
return 'D';
case 0xe:
return '*';
case 0xf:
return '#';
default:
return 0;
}
}
static void isup_dump_buffer(struct ss7 *ss7, unsigned char *data, int len)
{
int i;
ss7_message(ss7, "[");
for (i = 0; i < len; i++) {
ss7_message(ss7, "0x%x ", data[i]);
}
ss7_message(ss7, "]\n");
}
static void isup_get_number(char *dest, unsigned char *src, int srclen, int oddeven)
{
int i;
if (oddeven < 2) {
/* BCD odd or even */
for (i = 0; i < ((srclen * 2) - oddeven); i++)
dest[i] = digit2char(src[i/2] >> ((i % 2) ? 4 : 0));
} else {
/* oddeven = 2 for IA5 characters */
for (i = 0; i < srclen; i++)
dest[i] = src[i];
}
dest[i] = '\0';
}
static void isup_put_generic(unsigned char *dest, char *src, int *len)
{
int i = 0;
int numlen = strlen(src);
*len = numlen;
while (i < numlen) {
dest[i] = (src[i]);
i++;
}
}
static void isup_put_number(unsigned char *dest, char *src, int *len, int *oddeven)
{
int i = 0;
int numlen = strlen(src);
if (numlen % 2) {
*oddeven = 1;
*len = numlen/2 + 1;
} else {
*oddeven = 0;
*len = numlen/2;
}
while (i < numlen) {
if (!(i % 2)) {
dest[i/2] |= char2digit(src[i]) & 0xf;
} else {
dest[i/2] |= (char2digit(src[i]) << 4) & 0xf0;
}
i++;
}
}
static FUNC_SEND(nature_of_connection_ind_transmit)
{
parm[0] = 0x00;
if (c->cot_check_required) {
parm[0] |= 0x04;
}
if (c->cot_performed_on_previous_cic) {
parm[0] |= 0x08;
}
if (c->local_echocontrol_ind) {
parm[0] |= 0x10;
}
return 1; /* Length plus size of type header */
}
static FUNC_RECV(nature_of_connection_ind_receive)
{
unsigned char cci = (parm[0] >> 2) & 0x3;
if (cci & 0x1) {
c->cot_check_required = 1;
} else {
c->cot_check_required = 0;
}
if (cci & 0x2) {
c->cot_performed_on_previous_cic = 1;
} else {
c->cot_performed_on_previous_cic = 0;
}
if (parm[0] & 0x10) {
c->echocontrol_ind = 1;
} else {
c->echocontrol_ind = 0;
}
return 1;
}
static FUNC_DUMP(nature_of_connection_ind_dump)
{
unsigned char con = parm[0];
char *continuity = "";
ss7_message(ss7, "\t\t\tSatellites in connection: %d\n", con&0x03);
con>>=2;
switch (con & 0x03) {
case 0:
continuity = "Check not required";
break;
case 1:
continuity = "Check required on this circuit";
break;
case 2:
continuity = "Check performed on a previous circuit";
break;
case 3:
continuity = "spare";
break;
}
ss7_message(ss7, "\t\t\tContinuity Check: %s (%d)\n", continuity, con & 0x3);
con>>=2;
con &= 0x01;
ss7_message(ss7, "\t\t\tOutgoing half echo control device: %s (%d)\n", con ? "included" : "not included", con);
return 1;
}
static FUNC_SEND(forward_call_ind_transmit)
{
parm[0] = 0x60;
parm[1] = 0x0;
if (ss7->flags & SS7_ISDN_ACCESS_INDICATOR) {
parm [1] |= 0x01;
}
if (c->interworking_indicator) {
parm[0] |= (1 << 3);
}
if (c->forward_indicator_pmbits) {
parm[1] |= (c->forward_indicator_pmbits & 0xf0);
}
return 2;
}
static FUNC_RECV(forward_call_ind_receive)
{
return 2;
}
static FUNC_DUMP(forward_call_ind_dump)
{
char *cb_str, *hg_str, *kj_str;
cb_str = hg_str = kj_str = "";
switch ((parm[0] >> 1) & 3) {
case 0:
cb_str = "no end-to-end";
break;
case 1:
cb_str = "pass-along";
break;
case 2:
cb_str = "SCCP";
break;
case 3:
cb_str = "pass-along and SCCP";
break;
}
switch ((parm[0] >> 6) & 3) {
case 0:
hg_str = "ISDN user part preferred all the way";
break;
case 1:
hg_str = "ISDN user part not preferred all the way";
break;
case 2:
hg_str = "ISDN user part required all the way";
break;
case 3:
hg_str = "spare";
break;
}
switch ((parm[1] >> 1) & 3) {
case 0:
kj_str = "no indication";
break;
case 1:
kj_str = "connectionless method available";
break;
case 2:
kj_str = "connection oriented method available";
break;
case 3:
kj_str = "connectionless and connection oriented method available";
break;
}
ss7_message(ss7, "\t\t\tNat/Intl Call Ind: call to be treated as a %s call (%d)\n", (parm[0] & 1) ? "international" : "national", parm[0] & 1);
ss7_message(ss7, "\t\t\tEnd to End Method Ind: %s method(s) available (%d)\n", cb_str, (parm[0] >> 1) & 3);
ss7_message(ss7, "\t\t\tInterworking Ind: %sinterworking encountered (%d)\n", ((parm[0] >> 3) & 1) ? "" : "no ", (parm[0] >> 3) & 1);
ss7_message(ss7, "\t\t\tEnd to End Info Ind: %send-to-end information available (%d)\n", ((parm[0]>>4)&1) ? "" : "no ", (parm[0] >> 4) & 1);
ss7_message(ss7, "\t\t\tISDN User Part Ind: ISDN user part %sused all the way (%d)\n", ((parm[0]>>5)&1) ? "" : "not ", (parm[0] >> 5) & 1);
ss7_message(ss7, "\t\t\tISDN User Part Pref Ind: %s (%d)\n", hg_str, (parm[0] >> 6) & 3);
ss7_message(ss7, "\t\t\tISDN Access Ind: originating access %s (%d)\n", (parm[1] & 1) ? "ISDN" : "non-ISDN", parm[1] & 1);
ss7_message(ss7, "\t\t\tSCCP Method Ind: %s (%d)\n", kj_str, (parm[1] >> 1) & 3);
ss7_message(ss7, "\t\t\tP-M bits(%d) P: %d O: %d N: %d M: %d\n", (parm[1] & 0xf0),
((parm[1] >> 7) & 0x1), ((parm[1] >> 6) & 0x1), ((parm[1] >> 5) & 0x1), ((parm[1] >> 4) & 0x1));
return 2;
}
static FUNC_RECV(calling_party_cat_receive)
{
c->calling_party_cat = parm[0];
return 1;
}
static FUNC_SEND(calling_party_cat_transmit)
{
parm[0] = c->calling_party_cat;
return 1;
}
static FUNC_DUMP(calling_party_cat_dump)
{
char *cattype;
switch (parm[0]) {
case 1:
cattype = "Operator, French";
break;
case 2:
cattype = "Operator, English";
break;
case 3:
cattype = "Operator, German";
break;
case 4:
cattype = "Operator, Russian";
break;
case 5:
cattype = "Operator, Spanish";
break;
case 9:
cattype = "Reserved";
break;
case 10:
cattype = "Ordinary calling subscriber";
break;
case 11:
cattype = "Calling subscriber with priority";
break;
case 12:
cattype = "Data Call (voice band data)";
break;
case 13:
cattype = "Test Call";
break;
case 15:
cattype = "Payphone";
break;
default:
cattype = "Unknown";
break;
}
ss7_message(ss7, "\t\t\tCategory: %s (%d)\n", cattype, parm[0]);
return 1;
}
static FUNC_RECV(user_service_info_receive)
{
/* NoOp it for now */
return len;
}
static FUNC_SEND(user_service_info_transmit)
{
/* Default to Coding standard CCITT / 3.1 khz Audio */
parm[0] = 0x90;
/* Default to Circuit mode / 64kbps */
parm[1] = 0x90;
/* User Layer 1 set to ulaw */
parm[2] = 0xa2;
return 3;
}
static FUNC_SEND(transmission_medium_reqs_transmit)
{
if (ss7->switchtype != SS7_ITU) {
return 0;
}
parm[0] = c->transcap;
return 1;
}
static FUNC_RECV(transmission_medium_reqs_receive)
{
c->transcap = parm[0] & 0x7f;
return 1;
}
static FUNC_DUMP(transmission_medium_reqs_dump)
{
char *type;
switch (parm[0]) {
case 0:
type = "Speech";
break;
case 1:
case 6:
type = "Spare";
break;
case 2:
type = "64 kbit/s unrestricted";
break;
case 3:
type = "3.1 khz audio";
break;
default:
type = "N x 64kbit/s unrestricted or possibly spare";
break;
}
ss7_message(ss7, "\t\t\t%s (%d)\n", type, parm[0]);
return 1;
}
static FUNC_DUMP(called_party_num_dump)
{
int oddeven = (parm[0] >> 7) & 0x1;
char numbuf[64] = "";
ss7_message(ss7, "\t\t\tNature of address: %x\n", parm[0] & 0x7f);
ss7_message(ss7, "\t\t\tNI: %x\n", (parm[1] >> 7) & 0x1);
ss7_message(ss7, "\t\t\tNumbering plan: %x\n", (parm[1] >> 4) & 0x7);
isup_get_number(numbuf, &parm[2], len - 2, oddeven);
ss7_message(ss7, "\t\t\tAddress signals: %s\n", numbuf);
return len;
}
/* For variable length parameters we pass in the length of the parameter */
static FUNC_RECV(called_party_num_receive)
{
int odd = 0;
if (parm[0] & 0x80) {
odd = 1;
}
isup_get_number(c->called_party_num, &parm[2], len - 2, odd);
c->called_nai = parm[0] & 0x7f; /* Nature of Address Indicator */
return len;
}
static FUNC_SEND(called_party_num_transmit)
{
int numlen, oddeven;
isup_put_number(&parm[2], c->called_party_num, &numlen, &oddeven);
parm[0] = c->called_nai & 0x7f; /* Nature of Address Indicator */
if (oddeven) {
parm[0] |= 0x80; /* Odd number of digits */
}
parm[1] = 0x1 << 4; /* Assume E.164 ISDN numbering plan, called number complete */
return numlen + 2;
}
static FUNC_RECV(backward_call_ind_receive)
{
c->called_party_status_ind = (parm[0] >> 2) & 0x3;
c->echocontrol_ind = (parm[1] >> 5) & 0x1;
return 2;
}
static FUNC_SEND(backward_call_ind_transmit)
{
parm[0] = 0x40;
parm[1] = 0x04;
if (c->local_echocontrol_ind) {
parm[1] |= 0x20;
}
if (ss7->flags | SS7_ISDN_ACCESS_INDICATOR) {
parm[1] |= 0x10;
}
return 2;
}
static FUNC_DUMP(backward_call_ind_dump)
{
unsigned char ba = parm[0] & 0x3;
unsigned char dc = (parm[0] >> 2) & 0x3;
unsigned char fe = (parm[0] >> 4) & 0x3;
unsigned char hg = (parm[0] >> 6) & 0x3;
unsigned char i = parm[1] & 0x1;
unsigned char j = (parm[1] >> 1) & 0x1;
unsigned char k = (parm[1] >> 2) & 0x1;
unsigned char l = (parm[1] >> 3) & 0x1;
unsigned char m = (parm[1] >> 4) & 0x1;
unsigned char n = (parm[1] >> 5) & 0x1;
unsigned char pq = (parm[1] >> 7) & 0x3;
ss7_message(ss7, "\t\t\tCharge indicator: %d\n", ba);
ss7_message(ss7, "\t\t\tCalled party's status indicator: %d\n", dc);
ss7_message(ss7, "\t\t\tCalled party's category indicator: %d\n", fe);
ss7_message(ss7, "\t\t\tEnd to End method indicator: %d\n", hg);
ss7_message(ss7, "\t\t\tInterworking indicator: %d\n", i);
ss7_message(ss7, "\t\t\tEnd to End information indicator: %d\n", j);
ss7_message(ss7, "\t\t\tISDN user part indicator: %d\n", k);
ss7_message(ss7, "\t\t\tHolding indicator: %d\n", l);
ss7_message(ss7, "\t\t\tISDN access indicator: %d\n", m);
ss7_message(ss7, "\t\t\tEcho control device indicator: %d\n", n);
ss7_message(ss7, "\t\t\tSCCP method indicator: %d\n", pq);
return 2;
}
static FUNC_RECV(opt_backward_call_ind_receive)
{
return 1;
}
static FUNC_DUMP(opt_backward_call_ind_dump)
{
unsigned char a, b, c, d;
a = parm[0] & 1;
b = (parm[0] >> 1) & 1;
c = (parm[0] >> 2) & 1;
d = (parm[0] >> 3) & 1;
ss7_message(ss7, "\t\t\tIn-band information indicator: %d\n", a);
ss7_message(ss7, "\t\t\tCall diversion may occur indicator: %d\n", b);
ss7_message(ss7, "\t\t\tSimple segmentation indicator: %d\n", c);
ss7_message(ss7, "\t\t\tMLPP user indicator: %d\n", d);
return 1;
}
static FUNC_DUMP(opt_forward_call_ind_dump)
{
char *desc;
switch (parm[0] & 0x03) {
case ISUP_CUG_NON:
desc = "non-CUG call";
break;
case ISUP_CUG_OUTGOING_ALLOWED:
desc = "closed user group call, outgoing access allowed";
break;
case ISUP_CUG_OUTGOING_NOT_ALLOWED:
desc = "closed user group call, outgoing access not allowed";
break;
default:
desc = "spare";
}
ss7_message(ss7, "\t\t\tClosed user group call indicator: %s\n", desc);
ss7_message(ss7, "\t\t\tSimple segmentation indicator: %s\n", (parm[0] & (1 << 2)) ?
"additional information will be sent in segmentation message" :
"no additional message will be sent");
ss7_message(ss7, "\t\t\tConnected line identify request indicator %s\n", (parm[0] & (1 << 7)) ?
"requested": "not requested");
return 1;
}
static FUNC_SEND(opt_forward_call_ind_transmit)
{
if (c->col_req || c->cug_indicator) {
parm[0] = (c->cug_indicator & 0x03) | (c->col_req << 7);
return 1;
} else {
return 0;
}
}
static FUNC_RECV(opt_forward_call_ind_receive)
{
c->cug_indicator = parm[0] & 0x03;
c->col_req = parm[0] >> 7;
return 1;
}
static FUNC_RECV(cause_receive)
{
c->causeloc = parm[0] & 0xf;
c->causecode = (parm[0] & 0x60) >> 5;
c->cause = (parm[1] & 0x7f);
return len;
}
static FUNC_SEND(cause_transmit)
{
parm[0] = 0x80 | (c->causecode << 5) | c->causeloc;
parm[1] = 0x80 | c->cause;
return 2;
}
static FUNC_DUMP(cause_dump) /* ITU-T Q.850 */
{
char *cause;
switch (parm[1] & 0x7f) {
case 1:
cause = "Unallocated (unassigned) number";
break;
case 2:
cause = "No route to specified transit network";
break;
case 3:
cause = "No route to destination";
break;
case 4:
cause = "Send special information tone";
break;
case 5:
cause = "Misdialled trunk prefix";
break;
case 6:
cause = "Channel unacceptable";
break;
case 7:
cause = "Call awarded and being delivered in an established channel";
break;
case 8:
cause = "Preemption";
break;
case 9:
cause = "Preemption - circuit reserved for reuse";
break;
case 16:
cause = "Normal call clearing";
break;
case 17:
cause = "User busy";
break;
case 18:
cause = "No user responding";
break;
case 19:
cause = "No answer from user (user alerted)";
break;
case 20:
cause = "Subscriber absent";
break;
case 21:
cause = "Call rejected";
break;
case 22:
cause = "Number changed";
break;
case 23:
cause = "Redirection to new destination";
break;
case 25:
cause = "Exchange routing error";
break;
case 26:
cause = "Non-selected user clearing";
break;
case 27:
cause = "Destination out of order";
break;
case 28:
cause = "Invalid number format (address incomplete)";
break;
case 29:
cause = "Facility rejected";
break;
case 30:
cause = "Response to STATUS ENQUIRY";
break;
case 31:
cause = "Normal, unspecified";
break;
case 34:
cause = "No circuit/channel available";
break;
case 38:
cause = "Network out of order";
break;
case 39:
cause = "Permanent frame mode connection out of service";
break;
case 40:
cause = "Permanent frame mode connection operational";
break;
case 41:
cause = "Temporary failure";
break;
case 42:
cause = "Switching equipment congestion";
break;
case 43: