Browse code

Merge 2332da7ea522dcdc5637019f1b91135d4c529ce7 into 608118deffa70cf12f4c3de29e18a0cfb1ff934c

MikhailKalashnikov authored on 09/09/2021 20:58:41 • GitHub committed on 09/09/2021 20:58:41
Showing 4 changed files
... ...
@@ -106,6 +106,24 @@ sipt_set_calling($fU, 4, 0, 3);
106 106
 # update the forwarding number to the value in the from header
107 107
 sipt_forwarfing($avp(s:forwarding_number), 3);
108 108
 ...
109
+</programlisting>
110
+		</example>
111
+	</section>
112
+	<section id="sipt.f.sipt_has_isup_body">
113
+		<title><function moreinfo="none">sipt_has_isup_body()</function></title>
114
+		<para>
115
+			The function returns <emphasis>true</emphasis> if the SIP message
116
+			has a ISUP body attached.
117
+		</para>
118
+		<example>
119
+			<title><function moreinfo="none">sipt_has_isup_body()</function> usage</title>
120
+			<programlisting format="linespecific">
121
+...
122
+if(sipt_has_isup_body())
123
+{
124
+    # do interesting stuff here
125
+}
126
+...
109 127
 </programlisting>
110 128
 		</example>
111 129
 	</section>
... ...
@@ -253,6 +271,14 @@ if($sipt(calling_party_number.nai) == 3)
253 271
 </programlisting>
254 272
 		</example>
255 273
 	</section>
274
+	<section id="sipt.v.sipt_calling_party_number">
275
+		<title><varname>$sipt(calling_party_number)</varname></title>
276
+		<para>
277
+			Returns the value (Address signal) of the Calling Party for the IAM message.
278
+			Returns -1 if there is a parsing error or if
279
+			the Calling Party Number is not present.
280
+		</para>
281
+	</section>
256 282
 	<section id="sipt.v.sipt_called_party_nai">
257 283
 		<title><varname>$sipt(called_party_number.nature_of_address) / $sipt(called_party_number.nai) / $sipt_called_party_nai</varname></title>
258 284
 		<para>
... ...
@@ -286,6 +312,14 @@ if($sipt(called_party_number.nai) == 3)
286 312
 ...
287 313
 </programlisting>
288 314
 		</example>
315
+	</section>
316
+		<section id="sipt.v.sipt_called_party_number">
317
+		<title><varname>$sipt(called_party_number)</varname></title>
318
+		<para>
319
+			Returns the value (Address signal) of the Called Party for the IAM message.
320
+			Returns -1 if there is a parsing error or if
321
+			the Called Party Number is not present.
322
+		</para>
289 323
 	</section>
290 324
 	<section id="sipt.v.sipt_event_info">
291 325
 		<title><varname>$sipt(event_info)</varname></title>
... ...
@@ -332,8 +366,8 @@ if($sipt(called_party_number.nai) == 3)
332 366
 	<section id="sipt.v.sipt_redirection_info">
333 367
 		<title><varname>$sipt(redirection_info) / $sipt_redirection_info</varname></title>
334 368
 		<para>
335
-			Returns redirection info header from ISUP
336
-			Returns "Redirecting reason" or -1 if no redirection info found.
369
+			Returns call diversion information header from ISUP
370
+			Returns "Redirecting reason" or -1 if no call diversion information found.
337 371
 		</para>
338 372
 		<table>
339 373
 			<title>Redirecting reason Values</title>
... ...
@@ -386,6 +420,63 @@ $avp(s:redir_num) = $sipt(redirection_number);
386 420
 			</tgroup>
387 421
 		</table>
388 422
 	</section>
423
+
424
+	<section id="sipt.v.sipt_redirection_information_reason">
425
+		<title><varname>$sipt(redirection_information.reason)</varname></title>
426
+		<para>
427
+			Returns redirection reason from Redirection information from ISUP or -1 if no Redirection information found.
428
+		</para>
429
+	</section>
430
+
431
+	<section id="sipt.v.sipt_redirection_information_original_reason">
432
+		<title><varname>$sipt(redirection_information.original_reason)</varname></title>
433
+		<para>
434
+			Returns original redirection reason from Redirection information from ISUP or -1 if no Redirection information found.
435
+		</para>
436
+	</section>
437
+
438
+	<section id="sipt.v.sipt_redirecting_number_nai">
439
+		<title><varname>$sipt(redirecting_number.nai)</varname></title>
440
+		<para>
441
+			Returns NAI for redirecting number from ISUP or -1 if no redirecting number found.
442
+		</para>
443
+	</section>
444
+
445
+	<section id="sipt.v.sipt_redirecting_number">
446
+		<title><varname>$sipt(redirecting_number)</varname></title>
447
+		<para>
448
+			Returns redirecting number from ISUP or -1 if no redirecting number found.
449
+		</para>
450
+	</section>
451
+
452
+	<section id="sipt.v.sipt_original_called_number_nai">
453
+		<title><varname>$sipt(original_called_number.nai)</varname></title>
454
+		<para>
455
+			Returns NAI for original called number from ISUP or -1 if no original called number found.
456
+		</para>
457
+	</section>
458
+
459
+	<section id="sipt.v.sipt_original_called_number">
460
+		<title><varname>$sipt(original_called_number)</varname></title>
461
+		<para>
462
+			Returns original called number from ISUP or -1 if no original called number found.
463
+		</para>
464
+	</section>
465
+	
466
+	<section id="sipt.v.sipt_generic_number_nai">
467
+		<title><varname>$sipt(generic_number.nai)</varname></title>
468
+		<para>
469
+			Returns NAI for generic number from ISUP or -1 if no generic number found.
470
+		</para>
471
+	</section>
472
+
473
+	<section id="sipt.v.sipt_generic_number">
474
+		<title><varname>$sipt(generic_number)</varname></title>
475
+		<para>
476
+			Returns generic number from ISUP or -1 if no generic number found.
477
+		</para>
478
+	</section>
479
+
389 480
 </section>
390 481
 </chapter>
391 482
 
... ...
@@ -47,15 +47,28 @@ static int sipt_get_hop_counter(struct sip_msg *msg, pv_param_t *param, pv_value
47 47
 static int sipt_get_event_info(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
48 48
 static int sipt_get_cpc(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
49 49
 static int sipt_get_calling_party_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
50
+static int sipt_get_calling_party(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
50 51
 static int sipt_get_presentation(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
51 52
 static int sipt_get_screening(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
52 53
 static int sipt_get_called_party_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
54
+static int sipt_get_called_party(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
53 55
 static int sipt_get_charge_indicator(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
54 56
 
55 57
 static int sipt_get_redirection_info(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
56 58
 static int sipt_get_redirection_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
57 59
 static int sipt_get_redirection_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
58 60
 
61
+static int sipt_get_redirection_reason(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
62
+static int sipt_get_original_redirection_reason(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
63
+static int sipt_get_redirecting_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
64
+static int sipt_get_redirecting_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
65
+static int sipt_get_original_called_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
66
+static int sipt_get_original_called_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
67
+static int sipt_get_generic_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
68
+static int sipt_get_generic_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
69
+
70
+static int sipt_has_isup_body(struct sip_msg *msg, char *type, char *str2 );
71
+
59 72
 /* New API */
60 73
 int sipt_parse_pv_name(pv_spec_p sp, str *in);
61 74
 static int sipt_get_pv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
... ...
@@ -102,10 +115,30 @@ static sipt_header_map_t sipt_header_mapping[] =
102 115
 		{{"CHARGE_INDICATOR", 1}, 
103 116
 			{NULL, 0}
104 117
 		}},
105
-        {"REDIRECTION_INFO", ISUP_PARM_REDIRECTION_INFO, 
106
-                {{NULL, 0}}  },
107
-        {"REDIRECTION_NUMBER", ISUP_PARM_REDIRECTION_NUMBER, 
108
-            		{{"NATURE_OF_ADDRESS", 1}, 
118
+	{"REDIRECTION_INFO", ISUP_PARM_DIVERSION_INFORMATION,
119
+		{{NULL, 0}}  },
120
+	{"REDIRECTION_NUMBER", ISUP_PARM_REDIRECTION_NUMBER,
121
+		{{"NATURE_OF_ADDRESS", 1},
122
+			{"NAI", 1},
123
+			{NULL, 0}
124
+		}},
125
+	{"REDIRECTION_INFORMATION", ISUP_PARM_REDIRECTION_INFO,
126
+		{{"REASON", 1},
127
+			{"ORIGINAL_REASON", 2},
128
+			{NULL, 0}
129
+		}},
130
+	{"REDIRECTING_NUMBER", ISUP_PARM_REDIRECTING_NUMBER,
131
+		{{"NATURE_OF_ADDRESS", 1},
132
+			{"NAI", 1},
133
+			{NULL, 0}
134
+		}},
135
+	{"ORIGINAL_CALLED_NUMBER", ISUP_PARM_ORIGINAL_CALLED_NUM,
136
+		{{"NATURE_OF_ADDRESS", 1},
137
+			{"NAI", 1},
138
+			{NULL, 0}
139
+		}},
140
+	{"GENERIC_NUMBER", ISUP_PARM_GENERIC_ADDR,
141
+		{{"NATURE_OF_ADDRESS", 1},
109 142
 			{"NAI", 1},
110 143
 			{NULL, 0}
111 144
 		}},
... ...
@@ -168,7 +201,13 @@ static cmd_export_t cmds[]={
168 201
 		4,          /* number of parameters */
169 202
 		fixup_str_str_str, fixup_free_str_str_str,         /* */
170 203
 		/* can be applied to original requests */
171
-		ONREPLY_ROUTE}, 
204
+		ONREPLY_ROUTE},
205
+	{"sipt_has_isup_body", /* action name as in scripts */
206
+		(cmd_function)sipt_has_isup_body,  /* C function name */
207
+		0,          /* number of parameters */
208
+		0, 0,
209
+		/* can be applied to original requests */
210
+		ANY_ROUTE},
172 211
 	{0, 0, 0, 0, 0, 0}
173 212
 };
174 213
 
... ...
@@ -291,6 +330,36 @@ static int sipt_get_calling_party_nai(struct sip_msg *msg, pv_param_t *param, pv
291 330
 	return 0;
292 331
 }
293 332
 
333
+static int sipt_get_calling_party(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
334
+{
335
+	static char sb_s_buf[26];
336
+	str body;
337
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
338
+
339
+	memset(sb_s_buf, 0, 26);
340
+	if(body.s == NULL)
341
+	{
342
+		LM_INFO("No ISUP Message Found");
343
+		return -1;
344
+	}
345
+
346
+	if((body.s[0] != ISUP_IAM))
347
+	{
348
+		LM_DBG("message not an IAM\n");
349
+		return -1;
350
+	}
351
+
352
+	isup_get_calling_party((unsigned char*)body.s, body.len, sb_s_buf);
353
+
354
+	if (strlen(sb_s_buf) > 0)
355
+	{
356
+		pv_get_strzval(msg, param, res, sb_s_buf);
357
+	} else {
358
+		pv_get_sintval(msg, param, res, -1);
359
+	}
360
+	return 0;
361
+}
362
+
294 363
 static int sipt_get_redirection_info(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
295 364
 {
296 365
 	str body;
... ...
@@ -363,6 +432,200 @@ static int sipt_get_redirection_number(struct sip_msg *msg, pv_param_t *param, p
363 432
 	return 0;
364 433
 }
365 434
 
435
+static int sipt_get_redirection_reason(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
436
+{
437
+	str body;
438
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
439
+
440
+	if(body.s == NULL)
441
+	{
442
+		LM_INFO("No ISUP Message Found");
443
+		return -1;
444
+	}
445
+
446
+	if((body.s[0] != ISUP_IAM))
447
+	{
448
+		LM_DBG("message not an IAM\n");
449
+		return -1;
450
+	}
451
+
452
+	pv_get_sintval(msg, param, res, isup_get_redirection_reason((unsigned char*)body.s, body.len));
453
+	return 0;
454
+}
455
+
456
+static int sipt_get_original_redirection_reason(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
457
+{
458
+	str body;
459
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
460
+
461
+	if(body.s == NULL)
462
+	{
463
+		LM_INFO("No ISUP Message Found");
464
+		return -1;
465
+	}
466
+
467
+	if((body.s[0] != ISUP_IAM))
468
+	{
469
+		LM_DBG("message not an IAM\n");
470
+		return -1;
471
+	}
472
+
473
+	pv_get_sintval(msg, param, res, isup_get_original_redirection_reason((unsigned char*)body.s, body.len));
474
+	return 0;
475
+}
476
+
477
+static int sipt_get_redirecting_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
478
+{
479
+	str body;
480
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
481
+
482
+	if(body.s == NULL)
483
+	{
484
+		LM_INFO("No ISUP Message Found");
485
+		return -1;
486
+	}
487
+
488
+	if((body.s[0] != ISUP_IAM))
489
+	{
490
+		LM_DBG("message not an IAM\n");
491
+		return -1;
492
+	}
493
+	
494
+	pv_get_sintval(msg, param, res, isup_get_redirecting_number_nai((unsigned char*)body.s, body.len));
495
+	return 0;
496
+}
497
+
498
+static int sipt_get_redirecting_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
499
+{
500
+	static char sb_s_buf[26];
501
+	str body;
502
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
503
+
504
+	memset(sb_s_buf, 0, 26);
505
+	if(body.s == NULL)
506
+	{
507
+		LM_INFO("No ISUP Message Found");
508
+		return -1;
509
+	}
510
+
511
+	if((body.s[0] != ISUP_IAM))
512
+	{
513
+		LM_DBG("message not an IAM\n");
514
+		return -1;
515
+	}
516
+
517
+	isup_get_redirecting_number((unsigned char*)body.s, body.len, sb_s_buf);
518
+
519
+	if (strlen(sb_s_buf) > 0)
520
+	{
521
+		pv_get_strzval(msg, param, res, sb_s_buf);
522
+	} else {
523
+		pv_get_sintval(msg, param, res, -1);
524
+	}
525
+	return 0;
526
+}
527
+
528
+static int sipt_get_original_called_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
529
+{
530
+	str body;
531
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
532
+
533
+	if(body.s == NULL)
534
+	{
535
+		LM_INFO("No ISUP Message Found");
536
+		return -1;
537
+	}
538
+
539
+	if((body.s[0] != ISUP_IAM))
540
+	{
541
+		LM_DBG("message not an IAM\n");
542
+		return -1;
543
+	}
544
+
545
+	pv_get_sintval(msg, param, res, isup_get_original_called_number_nai((unsigned char*)body.s, body.len));
546
+	return 0;
547
+}
548
+
549
+static int sipt_get_original_called_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
550
+{
551
+	static char sb_s_buf[26];
552
+	str body;
553
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
554
+
555
+	memset(sb_s_buf, 0, 26);
556
+	if(body.s == NULL)
557
+	{
558
+		LM_INFO("No ISUP Message Found");
559
+		return -1;
560
+	}
561
+
562
+	if((body.s[0] != ISUP_IAM))
563
+	{
564
+		LM_DBG("message not an IAM\n");
565
+		return -1;
566
+	}
567
+
568
+	isup_get_original_called_number((unsigned char*)body.s, body.len, sb_s_buf);
569
+
570
+	if (strlen(sb_s_buf) > 0)
571
+	{
572
+		pv_get_strzval(msg, param, res, sb_s_buf);
573
+	} else {
574
+		pv_get_sintval(msg, param, res, -1);
575
+	}
576
+	return 0;
577
+}
578
+
579
+static int sipt_get_generic_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
580
+{
581
+	str body;
582
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
583
+
584
+	if(body.s == NULL)
585
+	{
586
+		LM_INFO("No ISUP Message Found");
587
+		return -1;
588
+	}
589
+
590
+	if((body.s[0] != ISUP_IAM))
591
+	{
592
+		LM_DBG("message not an IAM\n");
593
+		return -1;
594
+	}
595
+
596
+	pv_get_sintval(msg, param, res, isup_get_generic_number_nai((unsigned char*)body.s, body.len));
597
+	return 0;
598
+}
599
+
600
+static int sipt_get_generic_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
601
+{
602
+	static char sb_s_buf[26];
603
+	str body;
604
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
605
+
606
+	memset(sb_s_buf, 0, 26);
607
+	if(body.s == NULL)
608
+	{
609
+		LM_INFO("No ISUP Message Found");
610
+		return -1;
611
+	}
612
+
613
+	if((body.s[0] != ISUP_IAM))
614
+	{
615
+		LM_DBG("message not an IAM\n");
616
+		return -1;
617
+	}
618
+
619
+	isup_get_generic_number((unsigned char*)body.s, body.len, sb_s_buf);
620
+
621
+	if (strlen(sb_s_buf) > 0)
622
+	{
623
+		pv_get_strzval(msg, param, res, sb_s_buf);
624
+	} else {
625
+		pv_get_sintval(msg, param, res, -1);
626
+	}
627
+	return 0;
628
+}
366 629
 
367 630
 static int sipt_get_presentation(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
368 631
 {
... ...
@@ -450,6 +713,43 @@ static int sipt_get_called_party_nai(struct sip_msg *msg, pv_param_t *param, pv_
450 713
 	return 0;
451 714
 }
452 715
 
716
+static int sipt_get_called_party(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
717
+{
718
+	static char sb_s_buf[26];
719
+	str body;
720
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
721
+
722
+	memset(sb_s_buf, 0, 26);
723
+	if(body.s == NULL)
724
+	{
725
+		LM_INFO("No ISUP Message Found");
726
+		return -1;
727
+	}
728
+
729
+	if((body.s[0] != ISUP_IAM))
730
+	{
731
+		LM_DBG("message not an IAM\n");
732
+		return -1;
733
+	}
734
+
735
+	isup_get_called_party((unsigned char*)body.s, body.len, sb_s_buf);
736
+
737
+	if (strlen(sb_s_buf) > 0)
738
+	{
739
+		pv_get_strzval(msg, param, res, sb_s_buf);
740
+	} else {
741
+		pv_get_sintval(msg, param, res, -1);
742
+	}
743
+	return 0;
744
+}
745
+
746
+static int sipt_has_isup_body(struct sip_msg *msg, char* foo, char* bar)
747
+{
748
+	str body;
749
+	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);
750
+	return (body.s == NULL)?-1:1;
751
+}
752
+
453 753
 int sipt_parse_pv_name(pv_spec_p sp, str *in)
454 754
 {
455 755
         sipt_pv_t *spv=NULL;
... ...
@@ -571,6 +871,8 @@ static int sipt_get_pv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
571 871
 		case ISUP_PARM_CALLING_PARTY_NUM:
572 872
 			switch(spv->sub_type)
573 873
 			{
874
+				case 0: /* NUMBER */
875
+					return sipt_get_calling_party(msg, param, res);
574 876
 				case 1: /* NAI */
575 877
 					return sipt_get_calling_party_nai(msg, param, res);
576 878
 				case 2: /* SCREENIG */
... ...
@@ -582,6 +884,8 @@ static int sipt_get_pv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
582 884
 		case ISUP_PARM_CALLED_PARTY_NUM:
583 885
 			switch(spv->sub_type)
584 886
 			{
887
+				case 0: /* NUMBER */
888
+					return sipt_get_called_party(msg, param, res);
585 889
 				case 1: /* NAI */
586 890
 					return sipt_get_called_party_nai(msg, param, res);
587 891
 			}
... ...
@@ -597,9 +901,9 @@ static int sipt_get_pv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
597 901
 				return sipt_get_charge_indicator(msg, param, res);
598 902
 			}
599 903
 			break;
600
-		case ISUP_PARM_REDIRECTION_INFO:
904
+		case ISUP_PARM_DIVERSION_INFORMATION:
601 905
 			return sipt_get_redirection_info(msg, param, res);
602
-                case ISUP_PARM_REDIRECTION_NUMBER:
906
+		case ISUP_PARM_REDIRECTION_NUMBER:
603 907
 			switch(spv->sub_type)
604 908
 			{
605 909
 				case 0: /* NUMBER */
... ...
@@ -608,6 +912,42 @@ static int sipt_get_pv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
608 912
 					return sipt_get_redirection_number_nai(msg, param, res);
609 913
 			}
610 914
 			break;
915
+		case ISUP_PARM_REDIRECTION_INFO:
916
+			switch(spv->sub_type)
917
+			{
918
+				case 1: /* REASON */
919
+					return sipt_get_redirection_reason(msg, param, res);
920
+				case 2: /* ORIGINAL_REASON */
921
+					return sipt_get_original_redirection_reason(msg, param, res);
922
+			}
923
+			break;
924
+		case ISUP_PARM_REDIRECTING_NUMBER:
925
+			switch(spv->sub_type)
926
+			{
927
+				case 0: /* NUMBER */
928
+					return sipt_get_redirecting_number(msg, param, res);
929
+				case 1: /* NAI */
930
+					return sipt_get_redirecting_number_nai(msg, param, res);
931
+			}
932
+			break;
933
+		case ISUP_PARM_GENERIC_ADDR:
934
+			switch(spv->sub_type)
935
+			{
936
+				case 0: /* NUMBER */
937
+					return sipt_get_generic_number(msg, param, res);
938
+				case 1: /* NAI */
939
+					return sipt_get_generic_number_nai(msg, param, res);
940
+			}
941
+			break;
942
+		case ISUP_PARM_ORIGINAL_CALLED_NUM:
943
+			switch(spv->sub_type)
944
+			{
945
+				case 0: /* NUMBER */
946
+					return sipt_get_original_called_number(msg, param, res);
947
+				case 1: /* NAI */
948
+					return sipt_get_original_called_number_nai(msg, param, res);
949
+			}
950
+			break;
611 951
 	}
612 952
 
613 953
 	return -1;
... ...
@@ -197,7 +197,9 @@ int isup_get_hop_counter(unsigned char *buf, int len);
197 197
 int isup_get_event_info(unsigned char *buf, int len);
198 198
 int isup_get_cpc(unsigned char *buf, int len);
199 199
 int isup_get_calling_party_nai(unsigned char *buf, int len);
200
+int isup_get_calling_party(unsigned char *buf, int len, char* sb_buf);
200 201
 int isup_get_called_party_nai(unsigned char *buf, int len);
202
+int isup_get_called_party(unsigned char *buf, int len, char* sb_buf);
201 203
 int isup_get_screening(unsigned char *buf, int len);
202 204
 int isup_get_presentation(unsigned char *buf, int len);
203 205
 int isup_get_charging_indicator(unsigned char *buf, int len);
... ...
@@ -210,4 +212,16 @@ int isup_get_redirection_info(unsigned char *buf, int len);
210 212
 int isup_get_redirection_number_nai(unsigned char *buf, int len);
211 213
 int isup_get_redirection_number(unsigned char *buf, int len, char* sb_buf);
212 214
 
215
+int isup_get_redirection_reason(unsigned char *buf, int len);
216
+int isup_get_original_redirection_reason(unsigned char *buf, int len);
217
+
218
+int isup_get_redirecting_number_nai(unsigned char *buf, int len);
219
+int isup_get_redirecting_number(unsigned char *buf, int len, char* sb_buf);
220
+
221
+int isup_get_generic_number_nai(unsigned char *buf, int len);
222
+int isup_get_generic_number(unsigned char *buf, int len, char* sb_buf);
223
+
224
+int isup_get_original_called_number_nai(unsigned char *buf, int len);
225
+int isup_get_original_called_number(unsigned char *buf, int len, char* sb_buf);
226
+
213 227
 #endif
... ...
@@ -278,6 +278,35 @@ int isup_get_calling_party_nai(unsigned char *buf, int len)
278 278
 	return -1;
279 279
 }
280 280
 
281
+int isup_get_calling_party(unsigned char *buf, int len, char* sb_buf)
282
+{
283
+	int sbparamlen;
284
+	int sb_i=0;
285
+	int sb_j=0;
286
+	int oddeven;
287
+	int offset = get_optional_header(ISUP_PARM_CALLING_PARTY_NUM, buf, len);
288
+
289
+	if(offset != -1 && len-offset-2 > 1)
290
+	{
291
+		sbparamlen = (buf[offset+1] & 0xFF) - 2;
292
+		oddeven = (buf[offset+2] >> 7) & 0x1;
293
+
294
+		while ((sbparamlen > 0) && (buf[offset] != 0)) {
295
+			sb_buf[sb_i]="0123456789ABCDEF"[(buf[offset+4+sb_j] & 0x0F)];
296
+			if(sbparamlen > 1 || oddeven == 0) 
297
+			{
298
+				sb_buf[sb_i+1]="0123456789ABCDEF"[(buf[offset+4+sb_j] >>4 & 0x0F)];
299
+			}
300
+			sb_i=sb_i+2;
301
+			sbparamlen--;
302
+			sb_j++;
303
+		}
304
+		sb_buf[sb_i] = '\x0';
305
+		return 1;
306
+	}
307
+	return -1;
308
+}
309
+
281 310
 int isup_get_screening(unsigned char *buf, int len)
282 311
 {
283 312
 	int  offset = get_optional_header(ISUP_PARM_CALLING_PARTY_NUM, buf, len);
... ...
@@ -318,6 +347,43 @@ int isup_get_called_party_nai(unsigned char *buf, int len)
318 347
 	return message->called_party_number[1]&0x7F;
319 348
 }
320 349
 
350
+int isup_get_called_party(unsigned char *buf, int len, char* sb_buf)
351
+{
352
+	struct isup_iam_fixed * message = (struct isup_iam_fixed*)buf;
353
+	int sbparamlen;
354
+	int oddeven;
355
+	int sb_i=0;
356
+	int sb_j=0;
357
+	int offset = 3;
358
+
359
+	// not an iam? do nothing
360
+	if(message->type != ISUP_IAM)
361
+	{
362
+		return -1;
363
+	}
364
+
365
+	/* Message Type = 1 */
366
+	len -= offsetof(struct isup_iam_fixed, called_party_number);
367
+
368
+	if (len < 1)
369
+		return -1;
370
+
371
+	sbparamlen = (message->called_party_number[0] & 0xFF) - 2;
372
+	oddeven = (message->called_party_number[1] >> 7) & 0x1;
373
+
374
+	while ((sbparamlen > 0) && (message->called_party_number[offset] != 0)) {
375
+		sb_buf[sb_i]="0123456789ABCDEF"[(message->called_party_number[offset+sb_j] & 0x0F)];
376
+		if(sbparamlen > 1 || oddeven == 0) 
377
+		{
378
+			sb_buf[sb_i+1]="0123456789ABCDEF"[(message->called_party_number[offset+sb_j] >>4 & 0x0F)];
379
+		}
380
+		sb_i=sb_i+2;
381
+		sbparamlen--;
382
+		sb_j++;
383
+	}
384
+	sb_buf[sb_i] = '\x0';
385
+	return 1;
386
+}
321 387
 
322 388
 int isup_get_charging_indicator(unsigned char *buf, int len) {
323 389
 	struct isup_acm_fixed * orig_message = (struct isup_acm_fixed*)buf;
... ...
@@ -396,6 +462,148 @@ int isup_get_redirection_number(unsigned char *buf, int len, char* sb_buf)
396 462
        return -1;
397 463
 }
398 464
 
465
+int isup_get_redirection_reason(unsigned char *buf, int len)
466
+{
467
+	int offset = get_optional_header(ISUP_PARM_REDIRECTION_INFO, buf, len);
468
+
469
+	if(offset != -1 && len-offset-2 > 1)
470
+	{
471
+		return (buf[offset+3]>>4 & 0x0F);
472
+	}
473
+	return -1;
474
+}
475
+
476
+int isup_get_original_redirection_reason(unsigned char *buf, int len)
477
+{
478
+	int offset = get_optional_header(ISUP_PARM_REDIRECTION_INFO, buf, len);
479
+
480
+	if(offset != -1 && len-offset-2 > 1)
481
+	{
482
+		return (buf[offset+2]>>4 & 0x0F);
483
+	}
484
+	return -1;
485
+}
486
+
487
+int isup_get_redirecting_number_nai(unsigned char *buf, int len)
488
+{
489
+	int offset = get_optional_header(ISUP_PARM_REDIRECTING_NUMBER, buf, len);
490
+
491
+	if(offset != -1 && len-offset-2 > 1)
492
+	{
493
+		return buf[offset+2] & 0x7F;
494
+	}
495
+	return -1;
496
+}
497
+
498
+int isup_get_redirecting_number(unsigned char *buf, int len, char* sb_buf)
499
+{
500
+	int sbparamlen;
501
+	int oddeven;
502
+	int sb_i=0;
503
+	int sb_j=0;
504
+	int offset = get_optional_header(ISUP_PARM_REDIRECTING_NUMBER, buf, len);
505
+
506
+	if(offset != -1 && len-offset-2 > 1)
507
+	{
508
+		sbparamlen = (buf[offset+1] & 0xFF) - 2;
509
+		oddeven = (buf[offset+2] >> 7) & 0x1;
510
+
511
+		while ((sbparamlen > 0) && (buf[offset] != 0)) {
512
+			sb_buf[sb_i]="0123456789ABCDEF"[(buf[offset+4+sb_j] & 0x0F)];
513
+			if(sbparamlen > 1 || oddeven == 0) 
514
+			{
515
+				sb_buf[sb_i+1]="0123456789ABCDEF"[(buf[offset+4+sb_j] >>4 & 0x0F)];
516
+			}
517
+			sb_i=sb_i+2;
518
+			sbparamlen--;
519
+			sb_j++;
520
+		}
521
+		sb_buf[sb_i] = '\x0';
522
+		return 1;
523
+	}
524
+	return -1;
525
+}
526
+
527
+int isup_get_original_called_number_nai(unsigned char *buf, int len)
528
+{
529
+	int offset = get_optional_header(ISUP_PARM_ORIGINAL_CALLED_NUM, buf, len);
530
+
531
+	if(offset != -1 && len-offset-2 > 1)
532
+	{
533
+		return buf[offset+2] & 0x7F;
534
+	}
535
+	return -1;
536
+}
537
+
538
+int isup_get_original_called_number(unsigned char *buf, int len, char* sb_buf)
539
+{
540
+	int sbparamlen;
541
+	int oddeven;
542
+	int sb_i=0;
543
+	int sb_j=0;
544
+	int offset = get_optional_header(ISUP_PARM_ORIGINAL_CALLED_NUM, buf, len);
545
+
546
+	if(offset != -1 && len-offset-2 > 1)
547
+	{
548
+		sbparamlen = (buf[offset+1] & 0xFF) - 2;
549
+		oddeven = (buf[offset+2] >> 7) & 0x1;
550
+
551
+		while ((sbparamlen > 0) && (buf[offset] != 0)) {
552
+			sb_buf[sb_i]="0123456789ABCDEF"[(buf[offset+4+sb_j] & 0x0F)];
553
+			if(sbparamlen > 1 || oddeven == 0) 
554
+			{
555
+				sb_buf[sb_i+1]="0123456789ABCDEF"[(buf[offset+4+sb_j] >>4 & 0x0F)];
556
+			}
557
+			sb_i=sb_i+2;
558
+			sbparamlen--;
559
+			sb_j++;
560
+		}
561
+		sb_buf[sb_i] = '\x0';
562
+		return 1;
563
+	}
564
+	return -1;
565
+}
566
+
567
+int isup_get_generic_number_nai(unsigned char *buf, int len)
568
+{
569
+	int offset = get_optional_header(ISUP_PARM_GENERIC_ADDR, buf, len);
570
+
571
+	if(offset != -1 && len-offset-2 > 1)
572
+	{
573
+		 return buf[offset+2] & 0x7F;
574
+	}
575
+	return -1;
576
+}
577
+
578
+int isup_get_generic_number(unsigned char *buf, int len, char* sb_buf)
579
+{
580
+	int sbparamlen;
581
+	int oddeven;
582
+	int sb_i=0;
583
+	int sb_j=0;
584
+	int offset = get_optional_header(ISUP_PARM_GENERIC_ADDR, buf, len);
585
+
586
+	if(offset != -1 && len-offset-2 > 1)
587
+	{
588
+		sbparamlen = (buf[offset+1] & 0xFF) - 2;
589
+		oddeven = (buf[offset+2] >> 7) & 0x1;
590
+
591
+		while ((sbparamlen > 0) && (buf[offset] != 0)) {
592
+			sb_buf[sb_i]="0123456789ABCDEF"[(buf[offset+4+sb_j] & 0x0F)];
593
+			if(sbparamlen > 1 || oddeven == 0) 
594
+			{
595
+				sb_buf[sb_i+1]="0123456789ABCDEF"[(buf[offset+4+sb_j] >>4 & 0x0F)];
596
+			}
597
+			sb_i=sb_i+2;
598
+			sbparamlen--;
599
+			sb_j++;
600
+		}
601
+		sb_buf[sb_i] = '\x0';
602
+		return 1;
603
+	}
604
+	return -1;
605
+}
606
+
399 607
 int isup_update_bci_1(struct sdp_mangler * mangle, int charge_indicator, int called_status, int called_category, int e2e_indicator, unsigned char *buf, int len)
400 608
 {
401 609
 	struct isup_acm_fixed * orig_message = (struct isup_acm_fixed*)buf;