FreeCalypso > hg > themwi-system-sw
annotate mncc/call_setup.c @ 16:4c2000b3aed7
top Makefile: add mncc
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 26 Jun 2022 16:33:30 -0800 |
parents | ccc5ab6d8388 |
children | c6572f4c31d2 |
rev | line source |
---|---|
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement setup of new calls: either new MO calls |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * coming from GSM or new MT calls coming from a ThemWi call socket. |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <syslog.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../include/mncc.h" |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../include/gsm48_const.h" |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "struct.h" |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "gsm_call.h" |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 preen_msc_provided_number(nums) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 struct gsm_mncc_number *nums; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int len; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 len = grok_number_string(nums->number, 0); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 switch (len) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 case 4: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 nums->type = GSM48_TON_NET_SPEC; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 nums->plan = GSM48_NPI_PRIVATE; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 case 11: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (nums->number[0] != '1') |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return(0); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 nums->type = GSM48_TON_INTERNATIONAL; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 nums->plan = GSM48_NPI_ISDN_E164; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 default: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return(0); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 nums->screen = GSM48_SCRN_NETWORK; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 return(1); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 void |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 reject_mo_call(callref, cause_loc, cause_val) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 uint32_t callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 struct gsm_mncc msg; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 bzero(&msg, sizeof(struct gsm_mncc)); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 msg.msg_type = MNCC_REJ_REQ; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 msg.callref = callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 mncc_set_cause(&msg, cause_loc, cause_val); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc)); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 void |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 process_mo_call_setup(msg) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 struct gsm_mncc *msg; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 struct gsm_call *call; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 char nanp[11]; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 int res, is_nanp, is_itn, is_local; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 if (preen_msc_provided_number(&msg->calling)) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 msg->fields |= MNCC_F_CALLING; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 else |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 msg->fields &= ~MNCC_F_CALLING; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (!(msg->fields & MNCC_F_CALLED)) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 GSM48_CC_CAUSE_INVAL_MAND_INF); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 call = create_gsm_call(msg->callref); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 if (!call) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 GSM48_CC_CAUSE_RESOURCE_UNAVAIL); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 /* route based on destination address */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 refresh_number_db(); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 is_nanp = is_itn = 0; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 switch (grok_number_string(msg->called.number, 0)) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 case 4: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (msg->called.type != GSM48_TON_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 msg->called.type != GSM48_TON_NET_SPEC && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 msg->called.type != GSM48_TON_SHORT_CODE) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (msg->called.plan != GSM48_NPI_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 msg->called.plan != GSM48_NPI_ISDN_E164 && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 msg->called.plan != GSM48_NPI_PRIVATE) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 res = lookup_short_dial_number(msg->called.number, nanp); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 if (!res) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 GSM48_CC_CAUSE_UNASSIGNED_NR); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 call->gc_flag = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if (nanp[0]) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 is_nanp = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 msg->called.type = GSM48_TON_INTERNATIONAL; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 msg->called.plan = GSM48_NPI_ISDN_E164; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 msg->called.number[0] = '1'; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 strcpy(msg->called.number+1, nanp); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } else { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 is_itn = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 msg->called.type = GSM48_TON_NET_SPEC; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 msg->called.plan = GSM48_NPI_PRIVATE; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 case 10: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (msg->called.type != GSM48_TON_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 msg->called.type != GSM48_TON_NATIONAL) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (msg->called.plan != GSM48_NPI_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 msg->called.plan != GSM48_NPI_ISDN_E164 && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 msg->called.plan != GSM48_NPI_NATIONAL) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if (!is_nanp_valid_prefix(msg->called.number)) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 GSM48_CC_CAUSE_INV_NR_FORMAT); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 call->gc_flag = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 is_nanp = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 /* canonicalize to international format */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 bcopy(msg->called.number, msg->called.number+1, 11); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 msg->called.number[0] = '1'; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 msg->called.type = GSM48_TON_INTERNATIONAL; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 msg->called.plan = GSM48_NPI_ISDN_E164; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 case 11: |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (msg->called.type != GSM48_TON_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 msg->called.type != GSM48_TON_INTERNATIONAL) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (msg->called.plan != GSM48_NPI_UNKNOWN && |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 msg->called.plan != GSM48_NPI_ISDN_E164) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (msg->called.number[0] != '1') |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 if (!is_nanp_valid_prefix(msg->called.number+1)) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 GSM48_CC_CAUSE_INV_NR_FORMAT); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 call->gc_flag = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 is_nanp = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 /* canonicalize to international format */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 msg->called.type = GSM48_TON_INTERNATIONAL; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 msg->called.plan = GSM48_NPI_ISDN_E164; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 break; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 is_local = is_itn; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 if (is_nanp && is_nanp_locally_owned(msg->called.number+1)) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 is_local = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 /* weed out attempts to call yourself */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if (is_local && !strcmp(msg->calling.number, msg->called.number)) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 GSM48_CC_CAUSE_INCOMPAT_DEST); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 call->gc_flag = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 /* actually route the call */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 if (is_local) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 internal_switch_mo_setup(call, msg); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 /* outbound calls remain to be implemented */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 GSM48_CC_CAUSE_NO_ROUTE); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 call->gc_flag = 1; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 static void |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 reject_mt_call(conn, callref, cause_loc, cause_val) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 struct socket_conn *conn; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 uint32_t callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 struct gsm_mncc msg; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 bzero(&msg, sizeof(struct gsm_mncc)); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 msg.msg_type = MNCC_REJ_REQ; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 msg.callref = callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 mncc_set_cause(&msg, cause_loc, cause_val); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 mncc_signal_to_socket_nocall(conn, &msg); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 void |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 process_ext_mtcall_setup(conn, msg) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 struct socket_conn *conn; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 struct gsm_mncc *msg; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 struct gsm_call *call; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 if (!(msg->fields & MNCC_F_CALLED) && !msg->imsi[0]) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 reject_mt_call(conn, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 GSM48_CC_CAUSE_INVAL_MAND_INF); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 call = create_new_mt_call(); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 if (!call) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 reject_mt_call(conn, msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 GSM48_CC_CAUSE_RESOURCE_UNAVAIL); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 call->socket = conn; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 call->socket_ref = msg->callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 /* forward to GSM MNCC interface */ |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 msg->callref = call->callref; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc)); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 preen_connected_number(msg) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 struct gsm_mncc *msg; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 if (preen_msc_provided_number(&msg->connected)) |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 msg->fields |= MNCC_F_CONNECTED; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 else |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 msg->fields &= ~MNCC_F_CONNECTED; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 } |