blob: 34aa6320aa2b0dc348882cc1c6374a216460ecc9 [file] [log] [blame]
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +08001/* NAT utilities using SCCP types */
2/*
3 * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2010 by On-Waves
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01008 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080010 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080016 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080019 *
20 */
21
22#ifndef BSC_NAT_SCCP_H
23#define BSC_NAT_SCCP_H
24
Harald Welted5db12c2010-08-03 15:11:51 +020025#include <osmocom/sccp/sccp_types.h>
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080026
27/*
28 * For the NAT we will need to analyze and later patch
29 * the received message. This would require us to parse
30 * the IPA and SCCP header twice. Instead of doing this
31 * we will have one analyze structure and have the patching
32 * and filter operate on the same structure.
33 */
34struct bsc_nat_parsed {
35 /* ip access prototype */
36 int ipa_proto;
37
38 /* source local reference */
39 struct sccp_source_reference *src_local_ref;
40
41 /* destination local reference */
42 struct sccp_source_reference *dest_local_ref;
43
44 /* called ssn number */
45 int called_ssn;
46
47 /* calling ssn number */
48 int calling_ssn;
49
50 /* sccp message type */
51 int sccp_type;
52
53 /* bssap type, e.g. 0 for BSS Management */
54 int bssap;
55
56 /* the gsm0808 message type */
57 int gsm_type;
58};
59
60/*
61 * Per SCCP source local reference patch table. It needs to
62 * be updated on new SCCP connections, connection confirm and reject,
63 * and on the loss of the BSC connection.
64 */
Holger Hans Peter Freytherc279e392013-04-16 09:53:13 +020065struct nat_sccp_connection {
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080066 struct llist_head list_entry;
67
68 struct bsc_connection *bsc;
69 struct bsc_msc_connection *msc_con;
70
71 struct sccp_source_reference real_ref;
72 struct sccp_source_reference patched_ref;
73 struct sccp_source_reference remote_ref;
74 int has_remote_ref;
75
76 /* status */
77 int con_type;
78 int con_local;
Holger Hans Peter Freytheref38e852011-04-06 11:27:52 +020079 int authorized;
Holger Hans Peter Freyther909e61f2010-09-15 00:41:19 +080080 int imsi_checked;
Holger Hans Peter Freyther8c78b482010-09-29 01:00:46 +080081 char *imsi;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080082
Holger Hans Peter Freytherb2b291d2013-04-16 13:23:43 +020083 uint16_t lac;
84 uint16_t ci;
85
Holger Hans Peter Freyther123bc322011-04-16 14:06:18 +020086 /* remember which Transactions we run over the bypass */
87 char ussd_ti[8];
88
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080089 /*
90 * audio handling. Remember if we have ever send a CRCX,
91 * remember the endpoint used by the MSC and BSC.
92 */
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080093 int msc_endp;
94 int bsc_endp;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080095
96 /* timeout handling */
97 struct timespec creation_time;
98};
99
100
101#endif