aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-11 19:17:07 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-11 20:00:22 +0800
commit7407aec9218f0f8555889663524289e5ba4c1961 (patch)
treefcba97fd5eeed496c8b7df9b05c2474f188adb08
parente575ce69ce3f973e0dd0157acc8853e5ccbe9330 (diff)
bsc_msc_ip: Move the MSC connection into the structure
-rw-r--r--openbsc/include/openbsc/gsm_data.h3
-rw-r--r--openbsc/src/bsc_msc_ip.c33
2 files changed, 19 insertions, 17 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 20ea235e..65b5a3c3 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -3,6 +3,8 @@
#include <sys/types.h>
+struct bsc_msc_connection;
+
enum gsm_phys_chan_config {
GSM_PCHAN_NONE,
GSM_PCHAN_CCCH,
@@ -673,6 +675,7 @@ struct gsm_network {
char *bsc_token;
char *msc_ip;
int msc_port;
+ struct bsc_msc_connection *msc_con;
int ping_timeout;
int pong_timeout;
};
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c
index 8dfbab7d..ece817f1 100644
--- a/openbsc/src/bsc_msc_ip.c
+++ b/openbsc/src/bsc_msc_ip.c
@@ -69,7 +69,6 @@ static int testmode = 0;
extern int ipacc_rtp_direct;
/* msc handling */
-static struct bsc_msc_connection *msc_con;
static struct timer_list msc_ping_timeout;
static struct timer_list msc_pong_timeout;
@@ -271,7 +270,7 @@ static int open_sccp_connection(struct msgb *layer3)
struct msgb *data;
/* When not connected to a MSC. We will simply close things down. */
- if (!msc_con->is_authenticated) {
+ if (!bsc_gsmnet->msc_con->is_authenticated) {
LOGP(DMSC, LOGL_ERROR, "Not connected to a MSC. Not forwarding data.\n");
use_subscr_con(&layer3->lchan->conn);
put_subscr_con(&layer3->lchan->conn, 0);
@@ -637,7 +636,7 @@ static void print_usage()
static int msc_queue_write(struct msgb *msg, int proto)
{
ipaccess_prepend_header(msg, proto);
- if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
+ if (write_queue_enqueue(&bsc_gsmnet->msc_con->write_queue, msg) != 0) {
LOGP(DMSC, LOGL_FATAL, "Failed to queue IPA/%d\n", proto);
msgb_free(msg);
return -1;
@@ -653,7 +652,7 @@ static int msc_sccp_do_write(struct bsc_fd *fd, struct msgb *msg)
LOGP(DMSC, LOGL_DEBUG, "Sending SCCP to MSC: %u\n", msgb_l2len(msg));
LOGP(DMI, LOGL_DEBUG, "MSC TX %s\n", hexdump(msg->l2h, msgb_l2len(msg)));
- ret = write(msc_con->write_queue.bfd.fd, msg->data, msg->len);
+ ret = write(bsc_gsmnet->msc_con->write_queue.bfd.fd, msg->data, msg->len);
if (ret < msg->len)
perror("MSC: Failed to send SCCP");
@@ -825,7 +824,7 @@ static void initialize_if_needed(void)
struct msgb *msg;
- if (!msc_con->is_authenticated) {
+ if (!bsc_gsmnet->msc_con->is_authenticated) {
/* send a gsm 08.08 reset message from here */
msg = bssmap_create_reset();
if (!msg) {
@@ -835,7 +834,7 @@ static void initialize_if_needed(void)
sccp_write(msg, &sccp_ssn_bssap, &sccp_ssn_bssap, 0);
msgb_free(msg);
- msc_con->is_authenticated = 1;
+ bsc_gsmnet->msc_con->is_authenticated = 1;
}
}
@@ -910,7 +909,7 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc)
static void msc_pong_timeout_cb(void *data)
{
LOGP(DMSC, LOGL_ERROR, "MSC didn't answer PING. Closing connection.\n");
- bsc_msc_lost(msc_con);
+ bsc_msc_lost(bsc_gsmnet->msc_con);
}
static void send_ping(void)
@@ -966,7 +965,7 @@ static int ipaccess_a_fd_cb(struct bsc_fd *bfd)
if (!msg) {
if (error == 0) {
LOGP(DMSC, LOGL_ERROR, "The connection to the MSC was lost.\n");
- bsc_msc_lost(msc_con);
+ bsc_msc_lost(bsc_gsmnet->msc_con);
return -1;
}
@@ -1099,9 +1098,9 @@ static void signal_handler(int signal)
talloc_report_full(tall_bsc_ctx, stderr);
break;
case SIGUSR2:
- if (!msc_con || !msc_con->is_connected)
+ if (!bsc_gsmnet->msc_con || !bsc_gsmnet->msc_con->is_connected)
return;
- bsc_msc_lost(msc_con);
+ bsc_msc_lost(bsc_gsmnet->msc_con);
break;
default:
break;
@@ -1216,8 +1215,8 @@ int main(int argc, char **argv)
if (msc_address)
msc = msc_address;
- msc_con = bsc_msc_create(msc, bsc_gsmnet->msc_port);
- if (!msc_con) {
+ bsc_gsmnet->msc_con = bsc_msc_create(msc, bsc_gsmnet->msc_port);
+ if (!bsc_gsmnet->msc_con) {
fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
exit(1);
}
@@ -1225,11 +1224,11 @@ int main(int argc, char **argv)
msc_ping_timeout.cb = msc_ping_timeout_cb;
msc_pong_timeout.cb = msc_pong_timeout_cb;
- msc_con->connection_loss = msc_connection_was_lost;
- msc_con->connected = msc_connection_connected;
- msc_con->write_queue.read_cb = ipaccess_a_fd_cb;
- msc_con->write_queue.write_cb = msc_sccp_do_write;
- bsc_msc_connect(msc_con);
+ bsc_gsmnet->msc_con->connection_loss = msc_connection_was_lost;
+ bsc_gsmnet->msc_con->connected = msc_connection_connected;
+ bsc_gsmnet->msc_con->write_queue.read_cb = ipaccess_a_fd_cb;
+ bsc_gsmnet->msc_con->write_queue.write_cb = msc_sccp_do_write;
+ bsc_msc_connect(bsc_gsmnet->msc_con);