bsc: Allow the NAT to query the list of LACs

Right now the code assumes that any request coming
from the NAT is a query and the code responds to with
a list of configured LACs.
This commit is contained in:
Holger Hans Peter Freyther 2011-04-23 16:37:58 +02:00
parent a78b6026c9
commit 2a9eeaa588
2 changed files with 39 additions and 4 deletions

View File

@ -69,7 +69,7 @@ struct ipac_msgt_sccp_state {
} __attribute__((packed));
/*
* @add_remove 0 for remove, 1 for add
* @add_remove 0 for remove, 1 for add, 3 to asK
* @nr_lacs Number of extra lacs inside this package
* @lac One lac entry
*/

View File

@ -1,8 +1,8 @@
/*
* Handle the connection to the MSC. This include ping/timeout/reconnect
* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
* (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2010 by On-Waves
* (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2011 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@ -37,6 +37,7 @@
static void initialize_if_needed(struct bsc_msc_connection *conn);
static void send_lacs(struct gsm_network *net, struct bsc_msc_connection *conn);
static void send_id_get_response(struct osmo_msc_data *data, int fd);
static void send_ping(struct osmo_msc_data *data);
@ -203,7 +204,8 @@ static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg)
msg->l2h = hh_ext->data;
if (hh_ext->proto == IPAC_PROTO_EXT_MGCP)
mgcp_forward(msc, msg);
else if (hh_ext->proto == IPAC_PROTO_EXT_LAC)
send_lacs(msc->network, msc->msc_con);
}
static int ipaccess_a_fd_cb(struct bsc_fd *bfd)
@ -329,6 +331,39 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc)
bsc_msc_schedule_connect(msc);
}
static void send_lacs(struct gsm_network *net, struct bsc_msc_connection *conn)
{
struct ipac_ext_lac_cmd *lac;
struct gsm_bts *bts;
struct msgb *msg;
int lacs = 0;
if (llist_empty(&net->bts_list)) {
LOGP(DMSC, LOGL_ERROR, "No BTSs configured. Not sending LACs.\n");
return;
}
msg = msgb_alloc_headroom(4096, 128, "LAC Command");
if (!msg) {
LOGP(DMSC, LOGL_ERROR, "Failed to create the LAC command.\n");
return;
}
lac = (struct ipac_ext_lac_cmd *) msgb_put(msg, sizeof(*lac));
lac->add_remove = 1;
llist_for_each_entry(bts, &net->bts_list, list) {
if (lacs++ == 0)
lac->lac = htons(bts->location_area_code);
else
msgb_put_u16(msg, htons(bts->location_area_code));
}
lac->nr_extra_lacs = lacs - 1;
ipaccess_prepend_header_ext(msg, IPAC_PROTO_EXT_LAC);
msc_queue_write(conn, msg, IPAC_PROTO_OSMO);
}
static void initialize_if_needed(struct bsc_msc_connection *conn)
{
struct msgb *msg;