aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-05 19:48:47 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-15 20:06:48 +0100
commit9b17c769b9b9d9c52405a2fded1431de1e34591e (patch)
tree999129385c1d1c12f1e6da6ebf82a5e4dc78af5f /openbsc/src/bsc
parent2a8675e49a5fac26778f6397696bd98981422f21 (diff)
bsc: Work a bit on opening the SCCP connection to the MSC.
Most of the code is still stubs but the structure is a lot cleaner than the one in the on-waves/bsc-master branch.
Diffstat (limited to 'openbsc/src/bsc')
-rw-r--r--openbsc/src/bsc/osmo_bsc_api.c46
-rw-r--r--openbsc/src/bsc/osmo_bsc_sccp.c20
2 files changed, 60 insertions, 6 deletions
diff --git a/openbsc/src/bsc/osmo_bsc_api.c b/openbsc/src/bsc/osmo_bsc_api.c
index 84c2d6ec0..b8423b27b 100644
--- a/openbsc/src/bsc/osmo_bsc_api.c
+++ b/openbsc/src/bsc/osmo_bsc_api.c
@@ -19,6 +19,7 @@
*/
#include <openbsc/osmo_bsc.h>
+#include <openbsc/osmo_msc_data.h>
#include <openbsc/debug.h>
#include <osmocore/protocol/gsm_08_08.h>
@@ -43,6 +44,20 @@
} \
bsc_queue_for_msc(conn, resp);
+static uint16_t get_network_code_for_msc(struct gsm_network *net)
+{
+ if (net->msc_data->core_ncc != -1)
+ return net->msc_data->core_ncc;
+ return net->network_code;
+}
+
+static uint16_t get_country_code_for_msc(struct gsm_network *net)
+{
+ if (net->msc_data->core_mcc != -1)
+ return net->msc_data->core_mcc;
+ return net->country_code;
+}
+
static void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci)
{
struct msgb *resp;
@@ -63,15 +78,38 @@ static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
queue_msg_or_return(resp);
}
+/*
+ * Instruct to reserve data for a new connectiom, create the complete
+ * layer three message, send it to open the connection.
+ */
static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
uint16_t chosen_channel)
{
- if (bsc_create_new_connection(conn, msg, chosen_channel) == 0) {
- bsc_scan_bts_msg(conn, msg);
- return BSC_API_CONN_POL_ACCEPT;
+ struct msgb *resp;
+ uint16_t network_code = get_network_code_for_msc(conn->bts->network);
+ uint16_t country_code = get_country_code_for_msc(conn->bts->network);
+
+ /* allocate resource for a new connection */
+ if (bsc_create_new_connection(conn) != 0)
+ return BSC_API_CONN_POL_REJECT;
+
+ bsc_scan_bts_msg(conn, msg);
+ resp = gsm0808_create_layer3(msg, network_code, country_code,
+ conn->bts->location_area_code,
+ conn->bts->cell_identity);
+ if (!resp) {
+ LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n");
+ bsc_delete_connection(conn);
+ return BSC_API_CONN_POL_REJECT;
+ }
+
+ if (bsc_open_connection(conn, resp) != 0) {
+ bsc_delete_connection(conn);
+ msgb_free(resp);
+ return BSC_API_CONN_POL_REJECT;
}
- return BSC_API_CONN_POL_REJECT;
+ return BSC_API_CONN_POL_ACCEPT;
}
static void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg)
diff --git a/openbsc/src/bsc/osmo_bsc_sccp.c b/openbsc/src/bsc/osmo_bsc_sccp.c
index 694a30f20..d1fff9148 100644
--- a/openbsc/src/bsc/osmo_bsc_sccp.c
+++ b/openbsc/src/bsc/osmo_bsc_sccp.c
@@ -25,6 +25,7 @@
#include <openbsc/debug.h>
#include <osmocore/gsm0808.h>
+#include <osmocore/talloc.h>
#include <osmocore/protocol/gsm_08_08.h>
#include <osmocom/sccp/sccp.h>
@@ -75,13 +76,28 @@ int bsc_queue_for_msc(struct gsm_subscriber_connection *conn, struct msgb *msg)
return 0;
}
-int bsc_create_new_connection(struct gsm_subscriber_connection *conn,
- struct msgb *msg, uint16_t chosen_channel)
+int bsc_create_new_connection(struct gsm_subscriber_connection *conn)
{
LOGP(DMSC, LOGL_ERROR, "Not implemented yet.\n");
return -1;
}
+int bsc_open_connection(struct gsm_subscriber_connection *conn, struct msgb *msg)
+{
+ LOGP(DMSC, LOGL_ERROR, "Not implemented yet.\n");
+ return -1;
+}
+
+int bsc_delete_connection(struct gsm_subscriber_connection *conn)
+{
+ if (!conn->sccp_con)
+ return 0;
+
+ talloc_free(conn->sccp_con);
+ conn->sccp_con = NULL;
+ return 0;
+}
+
int osmo_bsc_sccp_init(struct gsm_network *gsmnet)
{
sccp_set_log_area(DSCCP);