From 2a9eeaa588a2a3b63fadd94d6760879b44b14af5 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 23 Apr 2011 16:37:58 +0200 Subject: 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. --- openbsc/include/openbsc/ipaccess.h | 2 +- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 41 ++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h index dc5172cc9..388ad643a 100644 --- a/openbsc/include/openbsc/ipaccess.h +++ b/openbsc/include/openbsc/ipaccess.h @@ -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 */ diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 91d9f7322..e42d8b490 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -1,8 +1,8 @@ /* * Handle the connection to the MSC. This include ping/timeout/reconnect * (C) 2008-2009 by Harald Welte - * (C) 2009-2010 by Holger Hans Peter Freyther - * (C) 2009-2010 by On-Waves + * (C) 2009-2011 by Holger Hans Peter Freyther + * (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; -- cgit v1.2.3