From 86f42eb6a5091805e5569edeed1f32b97124f720 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 6 Apr 2010 15:11:34 +0200 Subject: nat: Store the config in the connection instead of the lac This allows that we can print the Nr. next to the lac and it allows us to change the lac at runtime without reconnecting the BSC. --- openbsc/include/openbsc/bsc_nat.h | 4 ++-- openbsc/src/nat/bsc_nat.c | 4 ++-- openbsc/src/nat/bsc_nat_utils.c | 4 +++- openbsc/src/nat/bsc_nat_vty.c | 11 +++++++---- openbsc/tests/bsc-nat/bsc_nat_test.c | 6 ++++-- 5 files changed, 18 insertions(+), 11 deletions(-) (limited to 'openbsc') diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 6cf20f2d0..ff0f907c5 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -84,8 +84,8 @@ struct bsc_connection { /* the fd we use to communicate */ struct write_queue write_queue; - /* the LAC assigned to this connection */ - unsigned int lac; + /* the BSS associated */ + struct bsc_config *cfg; /* a timeout node */ struct timer_list id_timeout; diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index 82f0fec8b..561be8af6 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -377,9 +377,9 @@ static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc llist_for_each_entry(conf, &bsc->nat->bsc_configs, entry) { if (strcmp(conf->token, token) == 0) { bsc->authenticated = 1; - bsc->lac = conf->lac; + bsc->cfg = conf; bsc_del_timer(&bsc->id_timeout); - LOGP(DNAT, LOGL_NOTICE, "Authenticated bsc %d\n", bsc->lac); + LOGP(DNAT, LOGL_NOTICE, "Authenticated bsc nr: %d lac: %d\n", conf->nr, conf->lac); break; } } diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c index 8c6de31fe..24b4e1f00 100644 --- a/openbsc/src/nat/bsc_nat_utils.c +++ b/openbsc/src/nat/bsc_nat_utils.c @@ -115,7 +115,9 @@ struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg) for (i = 1; i < data_length - 1; i += 2) { unsigned int _lac = ntohs(*(unsigned int *) &data[i]); llist_for_each_entry(bsc, &nat->bsc_connections, list_entry) { - if (!bsc->authenticated || _lac != bsc->lac) + if (!bsc->cfg) + continue; + if (!bsc->authenticated || _lac != bsc->cfg->lac) continue; return bsc; diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index d5f83ebdd..4c60a19f7 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -76,8 +76,9 @@ DEFUN(show_sccp, show_sccp_cmd, "show connections sccp", { struct sccp_connections *con; llist_for_each_entry(con, &_nat->sccp_connections, list_entry) { - vty_out(vty, "SCCP for BSC: %d BSC ref: 0x%x Local ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s", - con->bsc->lac, + vty_out(vty, "SCCP for BSC: Nr: %d lac: %d BSC ref: 0x%x Local ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s", + con->bsc->cfg ? con->bsc->cfg->nr : -1, + con->bsc->cfg ? con->bsc->cfg->lac : -1, sccp_src_ref_to_int(&con->real_ref), sccp_src_ref_to_int(&con->patched_ref), con->msc_timeslot, con->bsc_timeslot, @@ -92,8 +93,10 @@ DEFUN(show_bsc, show_bsc_cmd, "show connections bsc", { struct bsc_connection *con; llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { - vty_out(vty, "BSC lac: %d auth: %d fd: %d%s", - con->lac, con->authenticated, con->write_queue.bfd.fd, VTY_NEWLINE); + vty_out(vty, "BSC lac: %d, %d auth: %d fd: %d%s", + con->cfg ? con->cfg->nr : -1, + con->cfg ? con->cfg->lac : -1, + con->authenticated, con->write_queue.bfd.fd, VTY_NEWLINE); } return CMD_SUCCESS; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index 593963291..40e2475ba 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -332,13 +332,15 @@ static void test_paging(void) struct bsc_nat *nat; struct bsc_connection *con; struct bsc_nat_parsed *parsed; + struct bsc_config cfg; struct msgb *msg; fprintf(stderr, "Testing paging by lac.\n"); nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - con->lac = 23; + con->cfg = &cfg; + cfg.lac = 23; con->authenticated = 1; llist_add(&con->list_entry, &nat->bsc_connections); msg = msgb_alloc(4096, "test"); @@ -360,7 +362,7 @@ static void test_paging(void) talloc_free(parsed); /* Test by finding it */ - con->lac = 8213; + cfg.lac = 8213; copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd)); parsed = bsc_nat_parse(msg); if (bsc_nat_find_bsc(nat, msg) != con) { -- cgit v1.2.3