blob: 082466408886aa763d711de7cd1f886677291759 [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
Holger Hans Peter Freytherc09f8a32015-04-05 19:13:27 +020025#include "bsc_msg_filter.h"
26
Harald Welted5db12c2010-08-03 15:11:51 +020027#include <osmocom/sccp/sccp_types.h>
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080028
29/*
30 * For the NAT we will need to analyze and later patch
31 * the received message. This would require us to parse
32 * the IPA and SCCP header twice. Instead of doing this
33 * we will have one analyze structure and have the patching
34 * and filter operate on the same structure.
35 */
36struct bsc_nat_parsed {
37 /* ip access prototype */
38 int ipa_proto;
39
40 /* source local reference */
41 struct sccp_source_reference *src_local_ref;
42
43 /* destination local reference */
44 struct sccp_source_reference *dest_local_ref;
45
Holger Hans Peter Freyther1b9902c2013-09-03 14:35:33 +020046 /* original value */
47 struct sccp_source_reference original_dest_ref;
48
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080049 /* called ssn number */
50 int called_ssn;
51
52 /* calling ssn number */
53 int calling_ssn;
54
55 /* sccp message type */
56 int sccp_type;
57
58 /* bssap type, e.g. 0 for BSS Management */
59 int bssap;
60
61 /* the gsm0808 message type */
62 int gsm_type;
63};
64
65/*
66 * Per SCCP source local reference patch table. It needs to
67 * be updated on new SCCP connections, connection confirm and reject,
68 * and on the loss of the BSC connection.
69 */
Holger Hans Peter Freytherc279e392013-04-16 09:53:13 +020070struct nat_sccp_connection {
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080071 struct llist_head list_entry;
72
73 struct bsc_connection *bsc;
74 struct bsc_msc_connection *msc_con;
75
76 struct sccp_source_reference real_ref;
77 struct sccp_source_reference patched_ref;
78 struct sccp_source_reference remote_ref;
79 int has_remote_ref;
80
81 /* status */
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080082 int con_local;
Holger Hans Peter Freytheref38e852011-04-06 11:27:52 +020083 int authorized;
Holger Hans Peter Freytherc09f8a32015-04-05 19:13:27 +020084
85 struct bsc_filter_state filter_state;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080086
Holger Hans Peter Freytherb2b291d2013-04-16 13:23:43 +020087 uint16_t lac;
88 uint16_t ci;
89
Holger Hans Peter Freyther123bc322011-04-16 14:06:18 +020090 /* remember which Transactions we run over the bypass */
91 char ussd_ti[8];
92
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080093 /*
94 * audio handling. Remember if we have ever send a CRCX,
95 * remember the endpoint used by the MSC and BSC.
96 */
Holger Hans Peter Freytherf4b34392010-08-28 16:08:39 +080097 int msc_endp;
98 int bsc_endp;
Holger Hans Peter Freytherc2b31ed2010-07-31 05:17:17 +080099
100 /* timeout handling */
101 struct timespec creation_time;
102};
103
104
105#endif