blob: 0561df1f47dd864a19f7a4f7dff06970c52b056b [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
Holger Hans Peter Freyther1b9902c2013-09-03 14:35:33 +020044 /* original value */
45 struct sccp_source_reference original_dest_ref;
46
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080047 /* called ssn number */
48 int called_ssn;
49
50 /* calling ssn number */
51 int calling_ssn;
52
53 /* sccp message type */
54 int sccp_type;
55
56 /* bssap type, e.g. 0 for BSS Management */
57 int bssap;
58
59 /* the gsm0808 message type */
60 int gsm_type;
61};
62
63/*
64 * Per SCCP source local reference patch table. It needs to
65 * be updated on new SCCP connections, connection confirm and reject,
66 * and on the loss of the BSC connection.
67 */
Holger Hans Peter Freytherc279e392013-04-16 09:53:13 +020068struct nat_sccp_connection {
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080069 struct llist_head list_entry;
70
71 struct bsc_connection *bsc;
72 struct bsc_msc_connection *msc_con;
73
74 struct sccp_source_reference real_ref;
75 struct sccp_source_reference patched_ref;
76 struct sccp_source_reference remote_ref;
77 int has_remote_ref;
78
79 /* status */
80 int con_type;
81 int con_local;
Holger Hans Peter Freytheref38e852011-04-06 11:27:52 +020082 int authorized;
Holger Hans Peter Freyther909e61f2010-09-15 00:41:19 +080083 int imsi_checked;
Holger Hans Peter Freyther8c78b482010-09-29 01:00:46 +080084 char *imsi;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080085
Holger Hans Peter Freytherb2b291d2013-04-16 13:23:43 +020086 uint16_t lac;
87 uint16_t ci;
88
Holger Hans Peter Freyther123bc322011-04-16 14:06:18 +020089 /* remember which Transactions we run over the bypass */
90 char ussd_ti[8];
91
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080092 /*
93 * audio handling. Remember if we have ever send a CRCX,
94 * remember the endpoint used by the MSC and BSC.
95 */
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080096 int msc_endp;
97 int bsc_endp;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080098
99 /* timeout handling */
100 struct timespec creation_time;
101};
102
103
104#endif