aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 11:20:36 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 11:20:36 +0200
commitb76cd5ed7eda93e4dcb9b0f82f6082116c7d305a (patch)
tree211aceaa597a164ec669524ea3a26afbff04bd77
parent1592550d9898394f6ca4aef98676545f8eec2e63 (diff)
nat: Send the reset after we have received the init ack
Sending the reset right away will upset the MSC and we need to wait for the first contact.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h3
-rw-r--r--openbsc/src/nat/bsc_nat.c12
2 files changed, 10 insertions, 5 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index ff0f907c5..d3cd4626c 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -158,6 +158,9 @@ struct bsc_nat {
u_int8_t mgcp_msg[4096];
int mgcp_length;
+ /* msc things */
+ int first_contact;
+
struct bsc_endpoint *bsc_endpoints;
};
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 75c8935d8..2e2235d21 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -60,6 +60,7 @@ static struct bsc_fd bsc_listen;
static struct bsc_nat *nat;
static void bsc_write(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length);
static void remove_bsc_connection(struct bsc_connection *connection);
+static void msc_send_reset(struct bsc_msc_connection *con);
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num)
{
@@ -169,10 +170,11 @@ static void send_mgcp_reset(struct bsc_connection *bsc)
*/
static void initialize_msc_if_needed()
{
- static int init = 0;
- init = 1;
+ if (nat->first_contact)
+ return;
- /* do we need to send a GSM 08.08 message here? */
+ nat->first_contact = 1;
+ msc_send_reset(msc_con);
}
/*
@@ -303,11 +305,12 @@ static void msc_connection_was_lost(struct bsc_msc_connection *con)
llist_for_each_entry_safe(bsc, tmp, &nat->bsc_connections, list_entry)
remove_bsc_connection(bsc);
+ nat->first_contact = 0;
bsc_mgcp_free_endpoints(nat);
bsc_msc_schedule_connect(con);
}
-static void msc_connected(struct bsc_msc_connection *con)
+static void msc_send_reset(struct bsc_msc_connection *con)
{
static const u_int8_t reset[] = {
0x00, 0x12, 0xfd,
@@ -810,7 +813,6 @@ int main(int argc, char** argv)
}
msc_con->connection_loss = msc_connection_was_lost;
- msc_con->connected = msc_connected;
msc_con->write_queue.read_cb = ipaccess_msc_read_cb;
msc_con->write_queue.write_cb = ipaccess_msc_write_cb;;
bsc_msc_connect(msc_con);