Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 1 | /* 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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 8 | * 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 Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 10 | * (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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 16 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * 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 Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef BSC_NAT_SCCP_H |
| 23 | #define BSC_NAT_SCCP_H |
| 24 | |
Holger Hans Peter Freyther | c09f8a3 | 2015-04-05 19:13:27 +0200 | [diff] [blame] | 25 | #include "bsc_msg_filter.h" |
| 26 | |
Harald Welte | d5db12c | 2010-08-03 15:11:51 +0200 | [diff] [blame] | 27 | #include <osmocom/sccp/sccp_types.h> |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 28 | |
| 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 | */ |
| 36 | struct 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 Freyther | 1b9902c | 2013-09-03 14:35:33 +0200 | [diff] [blame] | 46 | /* original value */ |
| 47 | struct sccp_source_reference original_dest_ref; |
| 48 | |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 49 | /* 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 Freyther | c279e39 | 2013-04-16 09:53:13 +0200 | [diff] [blame] | 70 | struct nat_sccp_connection { |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 71 | 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 Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 82 | int con_local; |
Holger Hans Peter Freyther | ef38e85 | 2011-04-06 11:27:52 +0200 | [diff] [blame] | 83 | int authorized; |
Holger Hans Peter Freyther | c09f8a3 | 2015-04-05 19:13:27 +0200 | [diff] [blame] | 84 | |
| 85 | struct bsc_filter_state filter_state; |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 86 | |
Holger Hans Peter Freyther | b2b291d | 2013-04-16 13:23:43 +0200 | [diff] [blame] | 87 | uint16_t lac; |
| 88 | uint16_t ci; |
| 89 | |
Holger Hans Peter Freyther | 123bc32 | 2011-04-16 14:06:18 +0200 | [diff] [blame] | 90 | /* remember which Transactions we run over the bypass */ |
| 91 | char ussd_ti[8]; |
| 92 | |
Holger Hans Peter Freyther | f4b3439 | 2010-08-28 16:08:39 +0800 | [diff] [blame] | 93 | /* |
| 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 Freyther | f4b3439 | 2010-08-28 16:08:39 +0800 | [diff] [blame] | 97 | int msc_endp; |
| 98 | int bsc_endp; |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 99 | |
| 100 | /* timeout handling */ |
| 101 | struct timespec creation_time; |
| 102 | }; |
| 103 | |
| 104 | |
| 105 | #endif |