|
|
|
|
@ -12,7 +12,7 @@
|
|
|
|
|
+include ../../Makefile.modules
|
|
|
|
|
--- /dev/null
|
|
|
|
|
+++ b/modules/tcap/tcap_mod.c
|
|
|
|
|
@@ -0,0 +1,342 @@
|
|
|
|
|
@@ -0,0 +1,329 @@
|
|
|
|
|
+#include <stdio.h>
|
|
|
|
|
+#include <stdlib.h>
|
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
@ -38,6 +38,7 @@
|
|
|
|
|
+static int inap_extract_f(sip_msg_t *msg, char *su, char *sq);
|
|
|
|
|
+static int inap_extract_var_f(sip_msg_t *msg, char *o, char *f, char *d);
|
|
|
|
|
+static int isup_decode_number_f(sip_msg_t *msg, char *su, char *sq);
|
|
|
|
|
+static int isup_decode_number_hex_f(sip_msg_t *msg, char *su, char *sq);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
@ -50,6 +51,8 @@
|
|
|
|
|
+ fixup_pvar_pvar_pvar, fixup_free_pvar_pvar_pvar, ANY_ROUTE},
|
|
|
|
|
+ {"isup_decode_number", (cmd_function)isup_decode_number_f, 2,
|
|
|
|
|
+ fixup_spve_str, 0, ANY_ROUTE},
|
|
|
|
|
+ {"isup_decode_number_hex", (cmd_function)isup_decode_number_hex_f, 2,
|
|
|
|
|
+ fixup_spve_str, 0, ANY_ROUTE},
|
|
|
|
|
+ {0,}
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
@ -289,7 +292,7 @@
|
|
|
|
|
+
|
|
|
|
|
+ OUTPUT_BUFFER_INIT(&out, buf);
|
|
|
|
|
+ LM_DBG("tcap:[%.*s][%d] bin:[%.*s] field:[%s]\n", tcap.rs.len, tcap.rs.s,
|
|
|
|
|
+ bin, tcap.rs.len, bin, cfield);
|
|
|
|
|
+ tcap.rs.len, bin_len, bin, cfield);
|
|
|
|
|
+
|
|
|
|
|
+ err = "Error parsing TCAP body";
|
|
|
|
|
+ if (inap_extract(bin, bin_len, cfield, &out)<0)
|
|
|
|
|
@ -309,32 +312,9 @@
|
|
|
|
|
+ return -1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static inline char phone_digit(unsigned char d) {
|
|
|
|
|
+ switch (d) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ case 6:
|
|
|
|
|
+ case 7:
|
|
|
|
|
+ case 8:
|
|
|
|
|
+ case 9:
|
|
|
|
|
+ return '0' + d;
|
|
|
|
|
+ case 11:
|
|
|
|
|
+ return '*';
|
|
|
|
|
+ case 12:
|
|
|
|
|
+ return '#';
|
|
|
|
|
+ case 15:
|
|
|
|
|
+ return 'F';
|
|
|
|
|
+ default:
|
|
|
|
|
+ return '?';
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+static int isup_decode_number_f(sip_msg_t *msg, char *su, char *sq) {
|
|
|
|
|
+static int isup_decode_number_common_f(sip_msg_t *msg, char *su, char *sq,
|
|
|
|
|
+ int (*func)(const char *, int, char *))
|
|
|
|
|
+{
|
|
|
|
|
+ const char *err;
|
|
|
|
|
+ str inp;
|
|
|
|
|
+ char num[64];
|
|
|
|
|
@ -343,7 +323,7 @@
|
|
|
|
|
+ if (fixup_get_svalue(msg, (gparam_p) su, &inp))
|
|
|
|
|
+ goto error;
|
|
|
|
|
+ err = "Invalid encoded number";
|
|
|
|
|
+ if (isup_convert_number(inp.s, inp.len, num))
|
|
|
|
|
+ if (func(inp.s, inp.len, num))
|
|
|
|
|
+ goto error;
|
|
|
|
|
+
|
|
|
|
|
+ if (copy_output(msg, sq, num, strlen(num)))
|
|
|
|
|
@ -355,6 +335,13 @@
|
|
|
|
|
+ LM_ERR("%s\n", err);
|
|
|
|
|
+ return -1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int isup_decode_number_f(sip_msg_t *msg, char *su, char *sq) {
|
|
|
|
|
+ return isup_decode_number_common_f(msg, su, sq, isup_convert_number);
|
|
|
|
|
+}
|
|
|
|
|
+static int isup_decode_number_hex_f(sip_msg_t *msg, char *su, char *sq) {
|
|
|
|
|
+ return isup_decode_number_common_f(msg, su, sq, isup_convert_number_hex);
|
|
|
|
|
+}
|
|
|
|
|
--- a/Makefile.groups
|
|
|
|
|
+++ b/Makefile.groups
|
|
|
|
|
@@ -187,6 +187,9 @@
|
|
|
|
|
|