Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
Holger Hans Peter Freyther | df6143a | 2010-06-15 18:46:56 +0800 | [diff] [blame] | 3 | * (C) 2010 by On-Waves |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef BSC_NAT_H |
| 23 | #define BSC_NAT_H |
| 24 | |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 25 | #include "mgcp.h" |
| 26 | |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 27 | #include <sys/types.h> |
Holger Hans Peter Freyther | 9f8f3d0 | 2010-02-07 13:08:09 +0100 | [diff] [blame] | 28 | |
Holger Hans Peter Freyther | 6c45f2e | 2010-06-15 19:06:18 +0800 | [diff] [blame] | 29 | #include <osmocore/select.h> |
| 30 | #include <osmocore/msgb.h> |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 31 | #include <osmocore/msgfile.h> |
Holger Hans Peter Freyther | 6c45f2e | 2010-06-15 19:06:18 +0800 | [diff] [blame] | 32 | #include <osmocore/timer.h> |
Holger Hans Peter Freyther | ed07a3f | 2010-06-15 18:47:10 +0800 | [diff] [blame] | 33 | #include <osmocore/write_queue.h> |
Holger Hans Peter Freyther | b2c38eb | 2010-06-17 18:16:00 +0800 | [diff] [blame] | 34 | #include <osmocore/rate_ctr.h> |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 35 | #include <osmocore/statistics.h> |
Holger Hans Peter Freyther | a396757 | 2010-09-29 02:30:50 +0800 | [diff] [blame] | 36 | #include <osmocore/protocol/gsm_04_08.h> |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 37 | |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 38 | #include <regex.h> |
| 39 | |
Holger Hans Peter Freyther | 1d6fb18 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 40 | #define DIR_BSC 1 |
| 41 | #define DIR_MSC 2 |
Holger Hans Peter Freyther | 0b8f69d | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 42 | |
Holger Hans Peter Freyther | 3d38742 | 2010-10-16 16:35:00 +0200 | [diff] [blame] | 43 | struct sccp_source_reference; |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 44 | struct sccp_connections; |
| 45 | struct bsc_nat_parsed; |
Holger Hans Peter Freyther | aa69824 | 2010-06-15 18:46:19 +0800 | [diff] [blame] | 46 | struct bsc_nat; |
Holger Hans Peter Freyther | c16c2dc | 2010-10-13 20:22:36 +0200 | [diff] [blame] | 47 | struct bsc_nat_ussd_con; |
Holger Hans Peter Freyther | aa69824 | 2010-06-15 18:46:19 +0800 | [diff] [blame] | 48 | |
Holger Hans Peter Freyther | 19c0a84 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 49 | enum { |
| 50 | NAT_CON_TYPE_NONE, |
| 51 | NAT_CON_TYPE_LU, |
| 52 | NAT_CON_TYPE_CM_SERV_REQ, |
| 53 | NAT_CON_TYPE_PAG_RESP, |
Holger Hans Peter Freyther | 74dc303 | 2010-09-29 02:47:29 +0800 | [diff] [blame] | 54 | NAT_CON_TYPE_SSA, |
Holger Hans Peter Freyther | b71c23b | 2010-05-16 20:43:52 +0800 | [diff] [blame] | 55 | NAT_CON_TYPE_LOCAL_REJECT, |
Holger Hans Peter Freyther | 19c0a84 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 56 | NAT_CON_TYPE_OTHER, |
| 57 | }; |
| 58 | |
Holger Hans Peter Freyther | 0b8f69d | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 59 | /* |
Holger Hans Peter Freyther | 9f8f3d0 | 2010-02-07 13:08:09 +0100 | [diff] [blame] | 60 | * Per BSC data structure |
| 61 | */ |
| 62 | struct bsc_connection { |
| 63 | struct llist_head list_entry; |
| 64 | |
| 65 | /* do we know anything about this BSC? */ |
| 66 | int authenticated; |
| 67 | |
| 68 | /* the fd we use to communicate */ |
Holger Hans Peter Freyther | ed07a3f | 2010-06-15 18:47:10 +0800 | [diff] [blame] | 69 | struct write_queue write_queue; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 70 | |
Holger Hans Peter Freyther | 47dd494 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 71 | /* the BSS associated */ |
| 72 | struct bsc_config *cfg; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 73 | |
| 74 | /* a timeout node */ |
| 75 | struct timer_list id_timeout; |
Holger Hans Peter Freyther | aa69824 | 2010-06-15 18:46:19 +0800 | [diff] [blame] | 76 | |
Holger Hans Peter Freyther | 906c15e | 2010-05-02 19:28:59 +0800 | [diff] [blame] | 77 | /* pong timeout */ |
| 78 | struct timer_list ping_timeout; |
| 79 | struct timer_list pong_timeout; |
| 80 | |
Holger Hans Peter Freyther | 45fd07d | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 81 | /* mgcp related code */ |
Holger Hans Peter Freyther | 85902a4 | 2010-09-01 09:31:46 +0800 | [diff] [blame] | 82 | int endpoint_status[32]; |
Holger Hans Peter Freyther | 45fd07d | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 83 | int last_endpoint; |
| 84 | |
Holger Hans Peter Freyther | aa69824 | 2010-06-15 18:46:19 +0800 | [diff] [blame] | 85 | /* a back pointer */ |
| 86 | struct bsc_nat *nat; |
Holger Hans Peter Freyther | 9f8f3d0 | 2010-02-07 13:08:09 +0100 | [diff] [blame] | 87 | }; |
| 88 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 89 | /** |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 90 | * Stats per BSC |
| 91 | */ |
| 92 | struct bsc_config_stats { |
Holger Hans Peter Freyther | b2c38eb | 2010-06-17 18:16:00 +0800 | [diff] [blame] | 93 | struct rate_ctr_group *ctrg; |
| 94 | }; |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 95 | |
Holger Hans Peter Freyther | b2c38eb | 2010-06-17 18:16:00 +0800 | [diff] [blame] | 96 | enum bsc_cfg_ctr { |
| 97 | BCFG_CTR_SCCP_CONN, |
| 98 | BCFG_CTR_SCCP_CALLS, |
| 99 | BCFG_CTR_NET_RECONN, |
Holger Hans Peter Freyther | 8330c1c | 2010-06-17 18:29:42 +0800 | [diff] [blame] | 100 | BCFG_CTR_DROPPED_SCCP, |
| 101 | BCFG_CTR_DROPPED_CALLS, |
Holger Hans Peter Freyther | ee88496 | 2010-09-25 17:58:22 +0800 | [diff] [blame] | 102 | BCFG_CTR_REJECTED_CR, |
| 103 | BCFG_CTR_REJECTED_MSG, |
| 104 | BCFG_CTR_ILL_PACKET, |
Holger Hans Peter Freyther | 463dc62 | 2010-10-03 19:41:42 +0800 | [diff] [blame] | 105 | BCFG_CTR_CON_TYPE_LU, |
| 106 | BCFG_CTR_CON_CMSERV_RQ, |
| 107 | BCFG_CTR_CON_PAG_RESP, |
Holger Hans Peter Freyther | 74dc303 | 2010-09-29 02:47:29 +0800 | [diff] [blame] | 108 | BCFG_CTR_CON_SSA, |
Holger Hans Peter Freyther | 463dc62 | 2010-10-03 19:41:42 +0800 | [diff] [blame] | 109 | BCFG_CTR_CON_OTHER, |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | /** |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 113 | * One BSC entry in the config |
| 114 | */ |
| 115 | struct bsc_config { |
| 116 | struct llist_head entry; |
| 117 | |
| 118 | char *token; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 119 | int nr; |
| 120 | |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 121 | char *description; |
| 122 | |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 123 | /* imsi white and blacklist */ |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 124 | char *acc_lst_name; |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 125 | |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 126 | int forbid_paging; |
| 127 | |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 128 | /* backpointer */ |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 129 | struct bsc_nat *nat; |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 130 | |
| 131 | struct bsc_config_stats stats; |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 132 | |
| 133 | struct llist_head lac_list; |
| 134 | }; |
| 135 | |
| 136 | struct bsc_lac_entry { |
| 137 | struct llist_head entry; |
| 138 | uint16_t lac; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | /** |
Holger Hans Peter Freyther | a0df82d | 2010-04-01 08:21:33 +0200 | [diff] [blame] | 142 | * BSCs point of view of endpoints |
| 143 | */ |
| 144 | struct bsc_endpoint { |
Holger Hans Peter Freyther | 5b2726e | 2010-08-06 09:05:05 +0800 | [diff] [blame] | 145 | /* the operation that is carried out */ |
| 146 | int transaction_state; |
Holger Hans Peter Freyther | a0df82d | 2010-04-01 08:21:33 +0200 | [diff] [blame] | 147 | /* the pending transaction id */ |
| 148 | char *transaction_id; |
| 149 | /* the bsc we are talking to */ |
| 150 | struct bsc_connection *bsc; |
| 151 | }; |
| 152 | |
| 153 | /** |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 154 | * Statistic for the nat. |
| 155 | */ |
| 156 | struct bsc_nat_statistics { |
| 157 | struct { |
| 158 | struct counter *conn; |
| 159 | struct counter *calls; |
| 160 | } sccp; |
| 161 | |
| 162 | struct { |
| 163 | struct counter *reconn; |
| 164 | struct counter *auth_fail; |
| 165 | } bsc; |
| 166 | |
| 167 | struct { |
| 168 | struct counter *reconn; |
| 169 | } msc; |
Holger Hans Peter Freyther | c16c2dc | 2010-10-13 20:22:36 +0200 | [diff] [blame] | 170 | |
| 171 | struct { |
| 172 | struct counter *reconn; |
| 173 | } ussd; |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
Holger Hans Peter Freyther | 2f1a984 | 2010-09-25 06:14:52 +0800 | [diff] [blame] | 176 | enum bsc_nat_acc_ctr { |
| 177 | ACC_LIST_BSC_FILTER, |
| 178 | ACC_LIST_NAT_FILTER, |
| 179 | }; |
| 180 | |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 181 | struct bsc_nat_acc_lst { |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 182 | struct llist_head list; |
| 183 | |
Holger Hans Peter Freyther | 2f1a984 | 2010-09-25 06:14:52 +0800 | [diff] [blame] | 184 | /* counter */ |
| 185 | struct rate_ctr_group *stats; |
| 186 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 187 | /* the name of the list */ |
| 188 | const char *name; |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 189 | struct llist_head fltr_list; |
| 190 | }; |
| 191 | |
| 192 | struct bsc_nat_acc_lst_entry { |
| 193 | struct llist_head list; |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 194 | |
| 195 | /* the filter */ |
| 196 | char *imsi_allow; |
| 197 | regex_t imsi_allow_re; |
| 198 | char *imsi_deny; |
| 199 | regex_t imsi_deny_re; |
| 200 | }; |
| 201 | |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 202 | /** |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 203 | * the structure of the "nat" network |
| 204 | */ |
| 205 | struct bsc_nat { |
| 206 | /* active SCCP connections that need patching */ |
| 207 | struct llist_head sccp_connections; |
| 208 | |
| 209 | /* active BSC connections that need patching */ |
| 210 | struct llist_head bsc_connections; |
| 211 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 212 | /* access lists */ |
| 213 | struct llist_head access_lists; |
| 214 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 215 | /* known BSC's */ |
| 216 | struct llist_head bsc_configs; |
| 217 | int num_bsc; |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 218 | int bsc_ip_dscp; |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 219 | |
| 220 | /* MGCP config */ |
| 221 | struct mgcp_config *mgcp_cfg; |
Holger Hans Peter Freyther | dbd16fe | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 222 | uint8_t mgcp_msg[4096]; |
Holger Hans Peter Freyther | 8d20065 | 2010-04-04 18:09:10 +0200 | [diff] [blame] | 223 | int mgcp_length; |
Holger Hans Peter Freyther | a0df82d | 2010-04-01 08:21:33 +0200 | [diff] [blame] | 224 | |
Holger Hans Peter Freyther | b752761 | 2010-04-07 11:20:36 +0200 | [diff] [blame] | 225 | /* msc things */ |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 226 | char *msc_ip; |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 227 | int msc_port; |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 228 | struct bsc_msc_connection *msc_con; |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 229 | char *token; |
Holger Hans Peter Freyther | b752761 | 2010-04-07 11:20:36 +0200 | [diff] [blame] | 230 | |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 231 | /* timeouts */ |
| 232 | int auth_timeout; |
| 233 | int ping_timeout; |
| 234 | int pong_timeout; |
| 235 | |
Holger Hans Peter Freyther | a0df82d | 2010-04-01 08:21:33 +0200 | [diff] [blame] | 236 | struct bsc_endpoint *bsc_endpoints; |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 237 | |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 238 | /* filter */ |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 239 | char *acc_lst_name; |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 240 | |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 241 | /* number rewriting */ |
| 242 | char *num_rewr_name; |
| 243 | struct msg_entries *num_rewr; |
| 244 | |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 245 | /* USSD messages we want to match */ |
| 246 | char *ussd_lst_name; |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 247 | char *ussd_query; |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 248 | char *ussd_token; |
| 249 | char *ussd_local; |
Holger Hans Peter Freyther | c16c2dc | 2010-10-13 20:22:36 +0200 | [diff] [blame] | 250 | struct bsc_fd ussd_listen; |
| 251 | struct bsc_nat_ussd_con *ussd_con; |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 252 | |
Holger Hans Peter Freyther | d470286 | 2010-04-12 12:17:09 +0200 | [diff] [blame] | 253 | /* statistics */ |
| 254 | struct bsc_nat_statistics stats; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 255 | }; |
| 256 | |
| 257 | /* create and init the structures */ |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 258 | struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 259 | struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num); |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 260 | void bsc_config_add_lac(struct bsc_config *cfg, int lac); |
| 261 | void bsc_config_del_lac(struct bsc_config *cfg, int lac); |
| 262 | int bsc_config_handles_lac(struct bsc_config *cfg, int lac); |
| 263 | |
Holger Hans Peter Freyther | dcf8a7d | 2010-06-15 18:48:01 +0800 | [diff] [blame] | 264 | struct bsc_nat *bsc_nat_alloc(void); |
| 265 | struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat); |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 266 | void bsc_nat_set_msc_ip(struct bsc_nat *bsc, const char *ip); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 267 | |
Holger Hans Peter Freyther | 23fe7be | 2010-03-30 10:45:48 +0200 | [diff] [blame] | 268 | void sccp_connection_destroy(struct sccp_connections *); |
Holger Hans Peter Freyther | 2f9dcf0 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 269 | void bsc_close_connection(struct bsc_connection *); |
Holger Hans Peter Freyther | 9f8f3d0 | 2010-02-07 13:08:09 +0100 | [diff] [blame] | 270 | |
Holger Hans Peter Freyther | 234d312 | 2010-05-16 02:06:11 +0800 | [diff] [blame] | 271 | const char *bsc_con_type_to_string(int type); |
| 272 | |
Holger Hans Peter Freyther | 0b8f69d | 2010-06-15 18:45:38 +0800 | [diff] [blame] | 273 | /** |
| 274 | * parse the given message into the above structure |
| 275 | */ |
| 276 | struct bsc_nat_parsed *bsc_nat_parse(struct msgb *msg); |
| 277 | |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 278 | /** |
| 279 | * filter based on IP Access header in both directions |
| 280 | */ |
Holger Hans Peter Freyther | 1d6fb18 | 2010-01-30 11:53:30 +0100 | [diff] [blame] | 281 | int bsc_nat_filter_ipa(int direction, struct msgb *msg, struct bsc_nat_parsed *parsed); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 282 | int bsc_nat_vty_init(struct bsc_nat *nat); |
Holger Hans Peter Freyther | 979a309 | 2010-04-17 08:07:19 +0200 | [diff] [blame] | 283 | struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg, int *_lac); |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 284 | |
Holger Hans Peter Freyther | 0ab6bab | 2010-06-15 18:47:49 +0800 | [diff] [blame] | 285 | /** |
Holger Hans Peter Freyther | b4af5c9 | 2010-05-14 03:39:56 +0800 | [diff] [blame] | 286 | * Content filtering. |
| 287 | */ |
Holger Hans Peter Freyther | 19c0a84 | 2010-05-16 02:00:40 +0800 | [diff] [blame] | 288 | int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, |
Holger Hans Peter Freyther | 749497e | 2010-09-29 01:19:42 +0800 | [diff] [blame] | 289 | struct bsc_nat_parsed *, int *con_type, char **imsi); |
Holger Hans Peter Freyther | 74e0a1b | 2010-09-15 01:11:08 +0800 | [diff] [blame] | 290 | int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg, |
| 291 | struct sccp_connections *con, struct bsc_nat_parsed *parsed); |
Holger Hans Peter Freyther | b4af5c9 | 2010-05-14 03:39:56 +0800 | [diff] [blame] | 292 | |
| 293 | /** |
Holger Hans Peter Freyther | 0ab6bab | 2010-06-15 18:47:49 +0800 | [diff] [blame] | 294 | * SCCP patching and handling |
| 295 | */ |
Holger Hans Peter Freyther | fa20c94 | 2010-05-16 16:51:31 +0800 | [diff] [blame] | 296 | struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed); |
Holger Hans Peter Freyther | 49c7fb5 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 297 | int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *parsed); |
Holger Hans Peter Freyther | 0ab6bab | 2010-06-15 18:47:49 +0800 | [diff] [blame] | 298 | void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed); |
Holger Hans Peter Freyther | 49c7fb5 | 2010-06-15 18:48:55 +0800 | [diff] [blame] | 299 | struct sccp_connections *patch_sccp_src_ref_to_bsc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *); |
Holger Hans Peter Freyther | b5513ca | 2010-04-21 18:56:12 +0800 | [diff] [blame] | 300 | struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat_parsed *, struct bsc_connection *); |
Holger Hans Peter Freyther | 3d38742 | 2010-10-16 16:35:00 +0200 | [diff] [blame] | 301 | struct sccp_connections *bsc_nat_find_con_by_bsc(struct bsc_nat *, struct sccp_source_reference *); |
Holger Hans Peter Freyther | 0ab6bab | 2010-06-15 18:47:49 +0800 | [diff] [blame] | 302 | |
Holger Hans Peter Freyther | 465313e | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 303 | /** |
| 304 | * MGCP/Audio handling |
| 305 | */ |
Holger Hans Peter Freyther | dbd16fe | 2010-07-23 19:08:55 +0800 | [diff] [blame] | 306 | int bsc_write_mgcp(struct bsc_connection *bsc, const uint8_t *data, unsigned int length); |
Holger Hans Peter Freyther | 45fd07d | 2010-08-28 18:22:14 +0800 | [diff] [blame] | 307 | int bsc_mgcp_assign_patch(struct sccp_connections *, struct msgb *msg); |
Holger Hans Peter Freyther | 7b7eef6 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 308 | void bsc_mgcp_init(struct sccp_connections *); |
| 309 | void bsc_mgcp_dlcx(struct sccp_connections *); |
Holger Hans Peter Freyther | 241e130 | 2010-03-31 09:16:56 +0200 | [diff] [blame] | 310 | void bsc_mgcp_free_endpoints(struct bsc_nat *nat); |
Holger Hans Peter Freyther | 7b7eef6 | 2010-04-22 12:08:17 +0800 | [diff] [blame] | 311 | int bsc_mgcp_nat_init(struct bsc_nat *nat); |
Holger Hans Peter Freyther | 465313e | 2010-06-15 18:49:53 +0800 | [diff] [blame] | 312 | |
Holger Hans Peter Freyther | 08a1b16 | 2010-04-18 02:26:16 +0800 | [diff] [blame] | 313 | struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number); |
Holger Hans Peter Freyther | f7c86c5 | 2010-08-30 13:44:32 +0800 | [diff] [blame] | 314 | struct msgb *bsc_mgcp_rewrite(char *input, int length, int endp, const char *ip, int port); |
Holger Hans Peter Freyther | 3c3bce1 | 2010-04-01 10:16:28 +0200 | [diff] [blame] | 315 | void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg); |
| 316 | |
Holger Hans Peter Freyther | 26a4389 | 2010-04-05 23:09:27 +0200 | [diff] [blame] | 317 | void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc); |
Holger Hans Peter Freyther | 3c3bce1 | 2010-04-01 10:16:28 +0200 | [diff] [blame] | 318 | int bsc_mgcp_parse_response(const char *str, int *code, char transaction[60]); |
Holger Hans Peter Freyther | 4634013 | 2010-08-06 08:26:54 +0800 | [diff] [blame] | 319 | uint32_t bsc_mgcp_extract_ci(const char *resp); |
Holger Hans Peter Freyther | fc9bd23 | 2010-04-01 03:55:27 +0200 | [diff] [blame] | 320 | |
Holger Hans Peter Freyther | 2896df7 | 2010-04-08 10:24:57 +0200 | [diff] [blame] | 321 | |
| 322 | int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id); |
Holger Hans Peter Freyther | 4d44fc5 | 2010-10-13 17:56:22 +0200 | [diff] [blame] | 323 | int bsc_do_write(struct write_queue *queue, struct msgb *msg, int id); |
Holger Hans Peter Freyther | 7e8da13 | 2010-10-16 17:33:46 +0200 | [diff] [blame] | 324 | int bsc_write_msg(struct write_queue *queue, struct msgb *msg); |
Holger Hans Peter Freyther | 69cfa17 | 2010-10-13 20:37:13 +0200 | [diff] [blame] | 325 | int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg); |
Holger Hans Peter Freyther | 2896df7 | 2010-04-08 10:24:57 +0200 | [diff] [blame] | 326 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 327 | /* IMSI allow/deny handling */ |
Holger Hans Peter Freyther | 12dc89a | 2010-05-14 18:38:29 +0800 | [diff] [blame] | 328 | void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv); |
Holger Hans Peter Freyther | 29c6703 | 2010-06-08 10:14:44 +0800 | [diff] [blame] | 329 | struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct bsc_nat *nat, const char *name); |
| 330 | struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(struct bsc_nat *nat, const char *name); |
| 331 | void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst); |
Holger Hans Peter Freyther | 12dc89a | 2010-05-14 18:38:29 +0800 | [diff] [blame] | 332 | |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 333 | struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *); |
Holger Hans Peter Freyther | c1cac1e | 2010-10-11 09:50:31 +0200 | [diff] [blame] | 334 | int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *imsi); |
Holger Hans Peter Freyther | d77c817 | 2010-06-08 10:53:39 +0800 | [diff] [blame] | 335 | |
Holger Hans Peter Freyther | 20ee312 | 2010-07-05 14:39:44 +0800 | [diff] [blame] | 336 | int bsc_nat_msc_is_connected(struct bsc_nat *nat); |
| 337 | |
Holger Hans Peter Freyther | 463dc62 | 2010-10-03 19:41:42 +0800 | [diff] [blame] | 338 | int bsc_conn_type_to_ctr(struct sccp_connections *conn); |
| 339 | |
Holger Hans Peter Freyther | a396757 | 2010-09-29 02:30:50 +0800 | [diff] [blame] | 340 | struct gsm48_hdr *bsc_unpack_dtap(struct bsc_nat_parsed *parsed, struct msgb *msg, uint32_t *len); |
| 341 | |
Holger Hans Peter Freyther | 17870cf | 2010-09-29 19:32:55 +0800 | [diff] [blame] | 342 | /** USSD filtering */ |
Holger Hans Peter Freyther | c16c2dc | 2010-10-13 20:22:36 +0200 | [diff] [blame] | 343 | int bsc_ussd_init(struct bsc_nat *nat); |
Holger Hans Peter Freyther | 17870cf | 2010-09-29 19:32:55 +0800 | [diff] [blame] | 344 | int bsc_check_ussd(struct sccp_connections *con, struct bsc_nat_parsed *parsed, struct msgb *msg); |
| 345 | |
Holger Hans Peter Freyther | a914daf | 2010-10-21 12:12:57 +0200 | [diff] [blame^] | 346 | struct msgb *bsc_nat_rewrite_setup(struct bsc_nat *nat, struct msgb *msg, struct bsc_nat_parsed *); |
| 347 | |
Holger Hans Peter Freyther | 6a97b8d | 2010-06-15 18:45:26 +0800 | [diff] [blame] | 348 | #endif |