2010-06-15 10:45:26 +00:00
|
|
|
/*
|
2012-12-03 14:32:54 +00:00
|
|
|
* (C) 2010-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2010-2012 by On-Waves
|
2010-06-15 10:45:26 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-06-15 10:45:26 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2010-06-15 10:45:26 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-06-15 10:45:26 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BSC_NAT_H
|
|
|
|
#define BSC_NAT_H
|
|
|
|
|
2010-06-15 10:50:26 +00:00
|
|
|
#include "mgcp.h"
|
|
|
|
|
2010-02-07 12:08:09 +00:00
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/select.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/core/msgfile.h>
|
|
|
|
#include <osmocom/core/timer.h>
|
|
|
|
#include <osmocom/core/write_queue.h>
|
|
|
|
#include <osmocom/core/rate_ctr.h>
|
|
|
|
#include <osmocom/core/statistics.h>
|
|
|
|
#include <osmocom/gsm/protocol/gsm_04_08.h>
|
2010-06-15 10:45:26 +00:00
|
|
|
|
2010-04-13 07:24:37 +00:00
|
|
|
#include <regex.h>
|
|
|
|
|
2010-01-30 10:53:30 +00:00
|
|
|
#define DIR_BSC 1
|
|
|
|
#define DIR_MSC 2
|
2010-06-15 10:45:38 +00:00
|
|
|
|
2011-05-02 14:50:36 +00:00
|
|
|
#define PAGIN_GROUP_UNASSIGNED -1
|
|
|
|
|
2010-10-16 14:35:00 +00:00
|
|
|
struct sccp_source_reference;
|
2013-04-16 07:53:13 +00:00
|
|
|
struct nat_sccp_connection;
|
2010-07-30 21:17:17 +00:00
|
|
|
struct bsc_nat_parsed;
|
2010-06-15 10:46:19 +00:00
|
|
|
struct bsc_nat;
|
2010-10-13 18:22:36 +00:00
|
|
|
struct bsc_nat_ussd_con;
|
2013-06-25 09:44:01 +00:00
|
|
|
struct nat_rewrite_rule;
|
2010-06-15 10:46:19 +00:00
|
|
|
|
2010-05-15 18:00:40 +00:00
|
|
|
enum {
|
|
|
|
NAT_CON_TYPE_NONE,
|
|
|
|
NAT_CON_TYPE_LU,
|
|
|
|
NAT_CON_TYPE_CM_SERV_REQ,
|
|
|
|
NAT_CON_TYPE_PAG_RESP,
|
2010-09-28 18:47:29 +00:00
|
|
|
NAT_CON_TYPE_SSA,
|
2010-05-16 12:43:52 +00:00
|
|
|
NAT_CON_TYPE_LOCAL_REJECT,
|
2010-05-15 18:00:40 +00:00
|
|
|
NAT_CON_TYPE_OTHER,
|
|
|
|
};
|
|
|
|
|
2011-04-16 14:02:59 +00:00
|
|
|
/*
|
|
|
|
* Is this terminated to the MSC, to the local machine (release
|
|
|
|
* handling for IMSI filtering) or to a USSD provider?
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
NAT_CON_END_MSC,
|
|
|
|
NAT_CON_END_LOCAL,
|
|
|
|
NAT_CON_END_USSD,
|
|
|
|
};
|
|
|
|
|
2011-02-18 13:32:56 +00:00
|
|
|
/*
|
|
|
|
* Pending command entry
|
|
|
|
*/
|
|
|
|
struct bsc_cmd_list {
|
|
|
|
struct llist_head list_entry;
|
|
|
|
|
|
|
|
struct osmo_timer_list timeout;
|
|
|
|
|
|
|
|
/* The NATed ID used on the bsc_con*/
|
|
|
|
int nat_id;
|
|
|
|
|
|
|
|
/* The control connection from which the command originated */
|
|
|
|
struct ctrl_connection *ccon;
|
|
|
|
|
|
|
|
/* The command from the control connection */
|
|
|
|
struct ctrl_cmd *cmd;
|
|
|
|
};
|
|
|
|
|
2010-02-07 12:08:09 +00:00
|
|
|
/*
|
|
|
|
* Per BSC data structure
|
|
|
|
*/
|
|
|
|
struct bsc_connection {
|
|
|
|
struct llist_head list_entry;
|
|
|
|
|
|
|
|
/* do we know anything about this BSC? */
|
|
|
|
int authenticated;
|
|
|
|
|
|
|
|
/* the fd we use to communicate */
|
2011-05-06 10:09:47 +00:00
|
|
|
struct osmo_wqueue write_queue;
|
2010-06-15 10:46:11 +00:00
|
|
|
|
2010-04-06 13:11:34 +00:00
|
|
|
/* the BSS associated */
|
|
|
|
struct bsc_config *cfg;
|
2010-06-15 10:46:11 +00:00
|
|
|
|
|
|
|
/* a timeout node */
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list id_timeout;
|
2010-06-15 10:46:19 +00:00
|
|
|
|
2010-05-02 11:28:59 +00:00
|
|
|
/* pong timeout */
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list ping_timeout;
|
|
|
|
struct osmo_timer_list pong_timeout;
|
2010-05-02 11:28:59 +00:00
|
|
|
|
2010-08-28 10:22:14 +00:00
|
|
|
/* mgcp related code */
|
2011-02-25 16:09:07 +00:00
|
|
|
char *_endpoint_status;
|
2011-02-26 10:38:00 +00:00
|
|
|
int number_multiplexes;
|
2011-02-27 10:04:27 +00:00
|
|
|
int max_endpoints;
|
2010-08-28 10:22:14 +00:00
|
|
|
int last_endpoint;
|
2012-10-24 19:53:40 +00:00
|
|
|
int next_transaction;
|
|
|
|
uint32_t pending_dlcx_count;
|
|
|
|
struct llist_head pending_dlcx;
|
2010-08-28 10:22:14 +00:00
|
|
|
|
2011-02-18 13:32:56 +00:00
|
|
|
/* track the pending commands for this BSC */
|
|
|
|
struct llist_head cmd_pending;
|
|
|
|
int last_id;
|
|
|
|
|
2010-06-15 10:46:19 +00:00
|
|
|
/* a back pointer */
|
|
|
|
struct bsc_nat *nat;
|
2010-02-07 12:08:09 +00:00
|
|
|
};
|
|
|
|
|
2010-04-12 10:17:09 +00:00
|
|
|
/**
|
|
|
|
* Stats per BSC
|
|
|
|
*/
|
|
|
|
struct bsc_config_stats {
|
2010-06-17 10:16:00 +00:00
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
};
|
2010-04-12 10:17:09 +00:00
|
|
|
|
2010-06-17 10:16:00 +00:00
|
|
|
enum bsc_cfg_ctr {
|
|
|
|
BCFG_CTR_SCCP_CONN,
|
|
|
|
BCFG_CTR_SCCP_CALLS,
|
|
|
|
BCFG_CTR_NET_RECONN,
|
2010-06-17 10:29:42 +00:00
|
|
|
BCFG_CTR_DROPPED_SCCP,
|
|
|
|
BCFG_CTR_DROPPED_CALLS,
|
2010-09-25 09:58:22 +00:00
|
|
|
BCFG_CTR_REJECTED_CR,
|
|
|
|
BCFG_CTR_REJECTED_MSG,
|
|
|
|
BCFG_CTR_ILL_PACKET,
|
2010-10-03 11:41:42 +00:00
|
|
|
BCFG_CTR_CON_TYPE_LU,
|
|
|
|
BCFG_CTR_CON_CMSERV_RQ,
|
|
|
|
BCFG_CTR_CON_PAG_RESP,
|
2010-09-28 18:47:29 +00:00
|
|
|
BCFG_CTR_CON_SSA,
|
2010-10-03 11:41:42 +00:00
|
|
|
BCFG_CTR_CON_OTHER,
|
2010-04-12 10:17:09 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 10:46:11 +00:00
|
|
|
/**
|
|
|
|
* One BSC entry in the config
|
|
|
|
*/
|
|
|
|
struct bsc_config {
|
|
|
|
struct llist_head entry;
|
|
|
|
|
|
|
|
char *token;
|
|
|
|
int nr;
|
|
|
|
|
2010-05-14 14:06:28 +00:00
|
|
|
char *description;
|
|
|
|
|
2010-04-13 07:24:37 +00:00
|
|
|
/* imsi white and blacklist */
|
2010-05-31 17:03:13 +00:00
|
|
|
char *acc_lst_name;
|
2010-04-13 07:24:37 +00:00
|
|
|
|
2010-04-21 11:05:14 +00:00
|
|
|
int forbid_paging;
|
2011-05-02 14:50:36 +00:00
|
|
|
int paging_group;
|
2010-04-21 11:05:14 +00:00
|
|
|
|
2011-02-25 16:09:07 +00:00
|
|
|
/* audio handling */
|
2011-02-27 10:04:27 +00:00
|
|
|
int max_endpoints;
|
2011-02-25 16:09:07 +00:00
|
|
|
|
2010-04-13 07:24:37 +00:00
|
|
|
/* backpointer */
|
2010-06-15 10:46:11 +00:00
|
|
|
struct bsc_nat *nat;
|
2010-04-12 10:17:09 +00:00
|
|
|
|
|
|
|
struct bsc_config_stats stats;
|
2010-10-08 14:08:29 +00:00
|
|
|
|
|
|
|
struct llist_head lac_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bsc_lac_entry {
|
|
|
|
struct llist_head entry;
|
|
|
|
uint16_t lac;
|
2010-06-15 10:46:11 +00:00
|
|
|
};
|
|
|
|
|
2011-05-02 14:50:36 +00:00
|
|
|
struct bsc_nat_paging_group {
|
|
|
|
struct llist_head entry;
|
|
|
|
|
|
|
|
/* list of lac entries */
|
|
|
|
struct llist_head lists;
|
|
|
|
int nr;
|
|
|
|
};
|
|
|
|
|
2010-04-01 06:21:33 +00:00
|
|
|
/**
|
|
|
|
* BSCs point of view of endpoints
|
|
|
|
*/
|
|
|
|
struct bsc_endpoint {
|
2010-08-06 01:05:05 +00:00
|
|
|
/* the operation that is carried out */
|
|
|
|
int transaction_state;
|
2010-04-01 06:21:33 +00:00
|
|
|
/* the pending transaction id */
|
|
|
|
char *transaction_id;
|
|
|
|
/* the bsc we are talking to */
|
|
|
|
struct bsc_connection *bsc;
|
|
|
|
};
|
|
|
|
|
2010-04-12 10:17:09 +00:00
|
|
|
/**
|
|
|
|
* Statistic for the nat.
|
|
|
|
*/
|
|
|
|
struct bsc_nat_statistics {
|
|
|
|
struct {
|
2011-05-06 10:13:10 +00:00
|
|
|
struct osmo_counter *conn;
|
|
|
|
struct osmo_counter *calls;
|
2010-04-12 10:17:09 +00:00
|
|
|
} sccp;
|
|
|
|
|
|
|
|
struct {
|
2011-05-06 10:13:10 +00:00
|
|
|
struct osmo_counter *reconn;
|
|
|
|
struct osmo_counter *auth_fail;
|
2010-04-12 10:17:09 +00:00
|
|
|
} bsc;
|
|
|
|
|
|
|
|
struct {
|
2011-05-06 10:13:10 +00:00
|
|
|
struct osmo_counter *reconn;
|
2010-04-12 10:17:09 +00:00
|
|
|
} msc;
|
2010-10-13 18:22:36 +00:00
|
|
|
|
|
|
|
struct {
|
2011-05-06 10:13:10 +00:00
|
|
|
struct osmo_counter *reconn;
|
2010-10-13 18:22:36 +00:00
|
|
|
} ussd;
|
2010-04-12 10:17:09 +00:00
|
|
|
};
|
|
|
|
|
2010-09-24 22:14:52 +00:00
|
|
|
enum bsc_nat_acc_ctr {
|
|
|
|
ACC_LIST_BSC_FILTER,
|
|
|
|
ACC_LIST_NAT_FILTER,
|
|
|
|
};
|
|
|
|
|
2010-06-08 02:14:44 +00:00
|
|
|
struct bsc_nat_acc_lst {
|
2010-05-31 17:03:13 +00:00
|
|
|
struct llist_head list;
|
|
|
|
|
2010-09-24 22:14:52 +00:00
|
|
|
/* counter */
|
|
|
|
struct rate_ctr_group *stats;
|
|
|
|
|
2010-05-31 17:03:13 +00:00
|
|
|
/* the name of the list */
|
|
|
|
const char *name;
|
2010-06-08 02:53:39 +00:00
|
|
|
struct llist_head fltr_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bsc_nat_acc_lst_entry {
|
|
|
|
struct llist_head list;
|
2010-05-31 17:03:13 +00:00
|
|
|
|
|
|
|
/* the filter */
|
|
|
|
char *imsi_allow;
|
|
|
|
regex_t imsi_allow_re;
|
|
|
|
char *imsi_deny;
|
|
|
|
regex_t imsi_deny_re;
|
2014-01-20 08:55:46 +00:00
|
|
|
|
|
|
|
/* reject reasons for the access lists */
|
|
|
|
int cm_reject_cause;
|
|
|
|
int lu_reject_cause;
|
2010-05-31 17:03:13 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 10:46:11 +00:00
|
|
|
/**
|
|
|
|
* the structure of the "nat" network
|
|
|
|
*/
|
|
|
|
struct bsc_nat {
|
|
|
|
/* active SCCP connections that need patching */
|
|
|
|
struct llist_head sccp_connections;
|
|
|
|
|
|
|
|
/* active BSC connections that need patching */
|
|
|
|
struct llist_head bsc_connections;
|
|
|
|
|
2010-05-31 17:03:13 +00:00
|
|
|
/* access lists */
|
|
|
|
struct llist_head access_lists;
|
|
|
|
|
2011-05-02 14:50:36 +00:00
|
|
|
/* paging groups */
|
|
|
|
struct llist_head paging_groups;
|
|
|
|
|
2010-06-15 10:46:11 +00:00
|
|
|
/* known BSC's */
|
|
|
|
struct llist_head bsc_configs;
|
|
|
|
int num_bsc;
|
2010-07-27 11:21:53 +00:00
|
|
|
int bsc_ip_dscp;
|
2010-06-15 10:50:26 +00:00
|
|
|
|
|
|
|
/* MGCP config */
|
|
|
|
struct mgcp_config *mgcp_cfg;
|
2010-07-23 11:08:55 +00:00
|
|
|
uint8_t mgcp_msg[4096];
|
2010-04-04 16:09:10 +00:00
|
|
|
int mgcp_length;
|
2012-11-05 13:54:56 +00:00
|
|
|
int mgcp_ipa;
|
2010-04-01 06:21:33 +00:00
|
|
|
|
2010-04-07 09:20:36 +00:00
|
|
|
/* msc things */
|
2011-04-23 21:31:31 +00:00
|
|
|
struct llist_head dests;
|
|
|
|
struct bsc_msc_dest *main_dest;
|
2010-05-11 11:07:39 +00:00
|
|
|
struct bsc_msc_connection *msc_con;
|
2010-05-14 16:14:58 +00:00
|
|
|
char *token;
|
2010-04-07 09:20:36 +00:00
|
|
|
|
2010-05-05 08:57:38 +00:00
|
|
|
/* timeouts */
|
|
|
|
int auth_timeout;
|
|
|
|
int ping_timeout;
|
|
|
|
int pong_timeout;
|
|
|
|
|
2010-04-01 06:21:33 +00:00
|
|
|
struct bsc_endpoint *bsc_endpoints;
|
2010-04-12 10:17:09 +00:00
|
|
|
|
2010-04-13 07:24:37 +00:00
|
|
|
/* filter */
|
2010-05-31 17:03:13 +00:00
|
|
|
char *acc_lst_name;
|
2010-04-13 07:24:37 +00:00
|
|
|
|
2013-01-01 10:25:09 +00:00
|
|
|
/* Barring of subscribers with a rb tree */
|
|
|
|
struct rb_root imsi_black_list;
|
|
|
|
char *imsi_black_list_fn;
|
|
|
|
|
2010-10-21 08:59:54 +00:00
|
|
|
/* number rewriting */
|
|
|
|
char *num_rewr_name;
|
2011-05-27 10:38:58 +00:00
|
|
|
struct llist_head num_rewr;
|
2013-06-25 13:38:31 +00:00
|
|
|
char *num_rewr_post_name;
|
|
|
|
struct llist_head num_rewr_post;
|
2010-10-21 08:59:54 +00:00
|
|
|
|
2011-05-27 15:14:15 +00:00
|
|
|
char *smsc_rewr_name;
|
|
|
|
struct llist_head smsc_rewr;
|
2011-05-27 17:21:24 +00:00
|
|
|
char *tpdest_match_name;
|
|
|
|
struct llist_head tpdest_match;
|
2012-01-10 21:39:07 +00:00
|
|
|
char *sms_clear_tp_srr_name;
|
|
|
|
struct llist_head sms_clear_tp_srr;
|
2012-01-18 19:00:28 +00:00
|
|
|
char *sms_num_rewr_name;
|
|
|
|
struct llist_head sms_num_rewr;
|
2011-05-27 15:14:15 +00:00
|
|
|
|
2013-06-25 09:44:01 +00:00
|
|
|
/* more rewriting */
|
|
|
|
char *num_rewr_trie_name;
|
|
|
|
struct nat_rewrite *num_rewr_trie;
|
|
|
|
|
2010-10-10 15:29:20 +00:00
|
|
|
/* USSD messages we want to match */
|
|
|
|
char *ussd_lst_name;
|
2010-10-11 08:06:39 +00:00
|
|
|
char *ussd_query;
|
2011-04-01 15:32:21 +00:00
|
|
|
regex_t ussd_query_re;
|
2010-10-12 16:25:52 +00:00
|
|
|
char *ussd_token;
|
|
|
|
char *ussd_local;
|
2011-05-06 10:11:23 +00:00
|
|
|
struct osmo_fd ussd_listen;
|
2010-10-13 18:22:36 +00:00
|
|
|
struct bsc_nat_ussd_con *ussd_con;
|
2010-10-10 15:29:20 +00:00
|
|
|
|
2011-04-23 21:55:14 +00:00
|
|
|
/* for maintainenance */
|
|
|
|
int blocked;
|
|
|
|
|
2010-04-12 10:17:09 +00:00
|
|
|
/* statistics */
|
|
|
|
struct bsc_nat_statistics stats;
|
2011-07-22 15:55:42 +00:00
|
|
|
|
|
|
|
/* control interface */
|
|
|
|
struct ctrl_handle *ctrl;
|
2010-06-15 10:46:11 +00:00
|
|
|
};
|
|
|
|
|
2011-04-16 15:01:47 +00:00
|
|
|
struct bsc_nat_ussd_con {
|
2011-05-06 10:09:47 +00:00
|
|
|
struct osmo_wqueue queue;
|
2011-04-16 15:01:47 +00:00
|
|
|
struct bsc_nat *nat;
|
|
|
|
int authorized;
|
|
|
|
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list auth_timeout;
|
2011-04-16 15:01:47 +00:00
|
|
|
};
|
|
|
|
|
2012-12-17 13:35:03 +00:00
|
|
|
struct bsc_nat_reject_cause {
|
|
|
|
int lu_reject_cause;
|
|
|
|
int cm_reject_cause;
|
|
|
|
};
|
|
|
|
|
2010-06-15 10:46:11 +00:00
|
|
|
/* create and init the structures */
|
2010-10-08 14:08:29 +00:00
|
|
|
struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token);
|
2010-06-15 10:46:11 +00:00
|
|
|
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num);
|
2011-02-27 10:18:41 +00:00
|
|
|
void bsc_config_free(struct bsc_config *);
|
2010-10-08 14:08:29 +00:00
|
|
|
void bsc_config_add_lac(struct bsc_config *cfg, int lac);
|
|
|
|
void bsc_config_del_lac(struct bsc_config *cfg, int lac);
|
|
|
|
int bsc_config_handles_lac(struct bsc_config *cfg, int lac);
|
|
|
|
|
2010-06-15 10:48:01 +00:00
|
|
|
struct bsc_nat *bsc_nat_alloc(void);
|
|
|
|
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat);
|
2010-06-15 10:51:04 +00:00
|
|
|
void bsc_nat_set_msc_ip(struct bsc_nat *bsc, const char *ip);
|
2010-06-15 10:46:11 +00:00
|
|
|
|
2013-04-16 07:53:13 +00:00
|
|
|
void sccp_connection_destroy(struct nat_sccp_connection *);
|
2010-04-27 05:21:39 +00:00
|
|
|
void bsc_close_connection(struct bsc_connection *);
|
2010-02-07 12:08:09 +00:00
|
|
|
|
2010-05-15 18:06:11 +00:00
|
|
|
const char *bsc_con_type_to_string(int type);
|
|
|
|
|
2010-06-15 10:45:38 +00:00
|
|
|
/**
|
|
|
|
* parse the given message into the above structure
|
|
|
|
*/
|
|
|
|
struct bsc_nat_parsed *bsc_nat_parse(struct msgb *msg);
|
|
|
|
|
2010-06-15 10:45:26 +00:00
|
|
|
/**
|
|
|
|
* filter based on IP Access header in both directions
|
|
|
|
*/
|
2010-01-30 10:53:30 +00:00
|
|
|
int bsc_nat_filter_ipa(int direction, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
2010-06-15 10:46:11 +00:00
|
|
|
int bsc_nat_vty_init(struct bsc_nat *nat);
|
2011-05-02 14:20:32 +00:00
|
|
|
int bsc_nat_find_paging(struct msgb *msg, const uint8_t **,int *len);
|
2010-06-15 10:45:26 +00:00
|
|
|
|
2010-05-13 19:39:56 +00:00
|
|
|
/**
|
|
|
|
* Content filtering.
|
|
|
|
*/
|
2010-05-15 18:00:40 +00:00
|
|
|
int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
|
2012-12-17 13:35:03 +00:00
|
|
|
struct bsc_nat_parsed *, int *con_type, char **imsi,
|
|
|
|
struct bsc_nat_reject_cause *cause);
|
2010-09-14 17:11:08 +00:00
|
|
|
int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg,
|
2013-04-16 07:53:13 +00:00
|
|
|
struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed,
|
2012-12-17 13:35:03 +00:00
|
|
|
struct bsc_nat_reject_cause *cause);
|
2010-05-13 19:39:56 +00:00
|
|
|
|
2010-06-15 10:47:49 +00:00
|
|
|
/**
|
|
|
|
* SCCP patching and handling
|
|
|
|
*/
|
2013-04-16 07:53:13 +00:00
|
|
|
struct nat_sccp_connection *create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed);
|
|
|
|
int update_sccp_src_ref(struct nat_sccp_connection *sccp, struct bsc_nat_parsed *parsed);
|
2010-06-15 10:47:49 +00:00
|
|
|
void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
2013-04-16 07:53:13 +00:00
|
|
|
struct nat_sccp_connection *patch_sccp_src_ref_to_bsc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *);
|
|
|
|
struct nat_sccp_connection *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat_parsed *, struct bsc_connection *);
|
|
|
|
struct nat_sccp_connection *bsc_nat_find_con_by_bsc(struct bsc_nat *, struct sccp_source_reference *);
|
2010-06-15 10:47:49 +00:00
|
|
|
|
2010-06-15 10:49:53 +00:00
|
|
|
/**
|
|
|
|
* MGCP/Audio handling
|
|
|
|
*/
|
2011-02-27 10:04:27 +00:00
|
|
|
int bsc_mgcp_nr_multiplexes(int max_endpoints);
|
2010-07-23 11:08:55 +00:00
|
|
|
int bsc_write_mgcp(struct bsc_connection *bsc, const uint8_t *data, unsigned int length);
|
2013-04-16 07:53:13 +00:00
|
|
|
int bsc_mgcp_assign_patch(struct nat_sccp_connection *, struct msgb *msg);
|
|
|
|
void bsc_mgcp_init(struct nat_sccp_connection *);
|
|
|
|
void bsc_mgcp_dlcx(struct nat_sccp_connection *);
|
2010-03-31 07:16:56 +00:00
|
|
|
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
|
2010-04-22 04:08:17 +00:00
|
|
|
int bsc_mgcp_nat_init(struct bsc_nat *nat);
|
2010-06-15 10:49:53 +00:00
|
|
|
|
2013-04-16 07:53:13 +00:00
|
|
|
struct nat_sccp_connection *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
2013-11-29 12:43:48 +00:00
|
|
|
struct msgb *bsc_mgcp_rewrite(char *input, int length, int endp, const char *ip,
|
|
|
|
int port, int *payload_type);
|
2010-04-01 08:16:28 +00:00
|
|
|
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
|
|
|
|
|
2010-04-05 21:09:27 +00:00
|
|
|
void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc);
|
2010-04-01 08:16:28 +00:00
|
|
|
int bsc_mgcp_parse_response(const char *str, int *code, char transaction[60]);
|
2010-08-06 00:26:54 +00:00
|
|
|
uint32_t bsc_mgcp_extract_ci(const char *resp);
|
2010-04-01 01:55:27 +00:00
|
|
|
|
2010-04-08 08:24:57 +00:00
|
|
|
|
|
|
|
int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id);
|
2011-05-06 10:09:47 +00:00
|
|
|
int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int id);
|
|
|
|
int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg);
|
2011-05-06 10:11:23 +00:00
|
|
|
int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg);
|
2010-04-08 08:24:57 +00:00
|
|
|
|
2010-05-31 17:03:13 +00:00
|
|
|
/* IMSI allow/deny handling */
|
2010-06-08 02:14:44 +00:00
|
|
|
struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct bsc_nat *nat, const char *name);
|
|
|
|
struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(struct bsc_nat *nat, const char *name);
|
|
|
|
void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst);
|
2010-05-14 10:38:29 +00:00
|
|
|
|
2010-06-08 02:53:39 +00:00
|
|
|
struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *);
|
2010-10-11 07:50:31 +00:00
|
|
|
int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *imsi);
|
2010-06-08 02:53:39 +00:00
|
|
|
|
2010-07-05 06:39:44 +00:00
|
|
|
int bsc_nat_msc_is_connected(struct bsc_nat *nat);
|
|
|
|
|
2013-04-16 07:53:13 +00:00
|
|
|
int bsc_conn_type_to_ctr(struct nat_sccp_connection *conn);
|
2010-10-03 11:41:42 +00:00
|
|
|
|
2010-09-28 18:30:50 +00:00
|
|
|
struct gsm48_hdr *bsc_unpack_dtap(struct bsc_nat_parsed *parsed, struct msgb *msg, uint32_t *len);
|
|
|
|
|
2010-09-29 11:32:55 +00:00
|
|
|
/** USSD filtering */
|
2010-10-13 18:22:36 +00:00
|
|
|
int bsc_ussd_init(struct bsc_nat *nat);
|
2013-08-26 12:04:43 +00:00
|
|
|
int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed, struct msgb *msg);
|
|
|
|
int bsc_ussd_close_connections(struct bsc_nat *nat);
|
2010-09-29 11:32:55 +00:00
|
|
|
|
2011-05-27 12:09:55 +00:00
|
|
|
struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct bsc_nat_parsed *, const char *imsi);
|
2010-10-21 10:12:57 +00:00
|
|
|
|
2011-05-02 17:16:13 +00:00
|
|
|
/** paging group handling */
|
|
|
|
struct bsc_nat_paging_group *bsc_nat_paging_group_num(struct bsc_nat *nat, int group);
|
|
|
|
struct bsc_nat_paging_group *bsc_nat_paging_group_create(struct bsc_nat *nat, int group);
|
|
|
|
void bsc_nat_paging_group_delete(struct bsc_nat_paging_group *);
|
|
|
|
void bsc_nat_paging_group_add_lac(struct bsc_nat_paging_group *grp, int lac);
|
|
|
|
void bsc_nat_paging_group_del_lac(struct bsc_nat_paging_group *grp, int lac);
|
|
|
|
|
2011-05-27 10:38:58 +00:00
|
|
|
/**
|
|
|
|
* Number rewriting support below
|
|
|
|
*/
|
|
|
|
struct bsc_nat_num_rewr_entry {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
regex_t msisdn_reg;
|
|
|
|
regex_t num_reg;
|
|
|
|
|
|
|
|
char *replace;
|
2013-06-25 09:44:01 +00:00
|
|
|
uint8_t is_prefix_lookup;
|
2011-05-27 10:38:58 +00:00
|
|
|
};
|
|
|
|
|
2011-05-27 15:14:15 +00:00
|
|
|
void bsc_nat_num_rewr_entry_adapt(void *ctx, struct llist_head *head, const struct osmo_config_list *);
|
2011-05-27 10:38:58 +00:00
|
|
|
|
2013-01-01 10:25:09 +00:00
|
|
|
struct bsc_nat_barr_entry {
|
|
|
|
struct rb_node node;
|
|
|
|
|
|
|
|
char *imsi;
|
|
|
|
int cm_reject_cause;
|
|
|
|
int lu_reject_cause;
|
|
|
|
};
|
|
|
|
|
|
|
|
int bsc_nat_barr_adapt(void *ctx, struct rb_root *rbtree, const struct osmo_config_list *);
|
|
|
|
int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu);
|
|
|
|
|
2012-11-05 13:54:56 +00:00
|
|
|
void bsc_nat_send_mgcp_to_msc(struct bsc_nat *bsc_nat, struct msgb *msg);
|
|
|
|
void bsc_nat_handle_mgcp(struct bsc_nat *bsc, struct msgb *msg);
|
|
|
|
|
2012-11-05 15:04:10 +00:00
|
|
|
struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, int port);
|
|
|
|
void bsc_nat_ctrl_del_pending(struct bsc_cmd_list *pending);
|
|
|
|
int bsc_nat_handle_ctrlif_msg(struct bsc_connection *bsc, struct msgb *msg);
|
|
|
|
|
2013-04-16 11:23:43 +00:00
|
|
|
int bsc_nat_extract_lac(struct bsc_connection *bsc, struct nat_sccp_connection *con,
|
|
|
|
struct bsc_nat_parsed *parsed, struct msgb *msg);
|
|
|
|
|
2010-06-15 10:45:26 +00:00
|
|
|
#endif
|