aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-12-14 16:15:20 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2018-01-30 18:59:28 +0100
commit8aef4862af7787ec363c348be28437c8dbf25c71 (patch)
tree6d59f37b6d32e1edc4c8a88ad01165e96db2b736 /openbsc/src
parent038a666af04beb2fc1f94276345cc30ed52847fd (diff)
osmo-bsc_nat: Change nat_sccp_conection ref names
For the multi-msc support we also need to NAT the SCCP refs from the MSC so clarify which real/patched ref belongs to which side of the connection. Change-Id: Idb964542b2172f0f293fa1b7e334d016e9e09461
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c36
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c4
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c8
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_sccp.c38
4 files changed, 43 insertions, 43 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 1f56535d1..8bce839be 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -250,8 +250,8 @@ static struct msgb *nat_create_rlsd(struct nat_sccp_connection *conn)
rel = (struct sccp_connection_released *) msg->l2h;
rel->type = SCCP_MSG_TYPE_RLSD;
rel->release_cause = SCCP_RELEASE_CAUSE_SCCP_FAILURE;
- rel->destination_local_reference = conn->remote_ref;
- rel->source_local_reference = conn->patched_ref;
+ rel->destination_local_reference = conn->msc_real_ref;
+ rel->source_local_reference = conn->bsc_patched_ref;
return msg;
}
@@ -297,8 +297,8 @@ static void nat_send_rlsd_bsc(struct nat_sccp_connection *conn)
rel = (struct sccp_connection_released *) msg->l2h;
rel->type = SCCP_MSG_TYPE_RLSD;
rel->release_cause = SCCP_RELEASE_CAUSE_SCCP_FAILURE;
- rel->destination_local_reference = conn->real_ref;
- rel->source_local_reference = conn->remote_ref;
+ rel->destination_local_reference = conn->bsc_real_ref;
+ rel->source_local_reference = conn->msc_real_ref;
bsc_write(conn->bsc, msg, IPAC_PROTO_SCCP);
}
@@ -314,7 +314,7 @@ static struct msgb *nat_creat_clrc(struct nat_sccp_connection *conn, uint8_t cau
return NULL;
}
- sccp = sccp_create_dt1(&conn->real_ref, msg->data, msg->len);
+ sccp = sccp_create_dt1(&conn->bsc_real_ref, msg->data, msg->len);
if (!sccp) {
LOGP(DNAT, LOGL_ERROR, "Failed to allocate SCCP msg.\n");
msgb_free(msg);
@@ -470,7 +470,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
{
struct msgb *rlsd;
/* 1. release the network */
- rlsd = sccp_create_rlsd(&con->patched_ref, &con->remote_ref,
+ rlsd = sccp_create_rlsd(&con->bsc_patched_ref, &con->msc_real_ref,
SCCP_RELEASE_CAUSE_END_USER_ORIGINATED);
if (!rlsd)
LOGP(DNAT, LOGL_ERROR, "Failed to create RLSD message.\n");
@@ -488,7 +488,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
if (payload) {
gsm0808_prepend_dtap_header(payload, 0);
- udt = sccp_create_dt1(&con->real_ref, payload->data, payload->len);
+ udt = sccp_create_dt1(&con->bsc_real_ref, payload->data, payload->len);
if (udt)
bsc_write(bsc, udt, IPAC_PROTO_SCCP);
else
@@ -502,7 +502,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
nat_send_clrc_bsc(con);
- rlsd = sccp_create_rlsd(&con->remote_ref, &con->real_ref,
+ rlsd = sccp_create_rlsd(&con->msc_real_ref, &con->bsc_real_ref,
SCCP_RELEASE_CAUSE_END_USER_ORIGINATED);
if (!rlsd) {
LOGP(DNAT, LOGL_ERROR, "Failed to allocate RLSD for the BSC.\n");
@@ -543,20 +543,20 @@ static void bsc_send_con_refuse(struct bsc_connection *bsc,
if (!con)
goto send_refuse;
- /* declare it local and assign a unique remote_ref */
+ /* declare it local and assign a unique msc_real_ref */
con->filter_state.con_type = FLT_CON_TYPE_LOCAL_REJECT;
con->con_local = NAT_CON_END_LOCAL;
- con->has_remote_ref = 1;
- con->remote_ref = con->patched_ref;
+ con->has_msc_ref = 1;
+ con->msc_real_ref = con->bsc_patched_ref;
/* 1. create a confirmation */
- cc = sccp_create_cc(&con->remote_ref, &con->real_ref);
+ cc = sccp_create_cc(&con->msc_real_ref, &con->bsc_real_ref);
if (!cc)
goto send_refuse;
/* 2. create the DT1 */
gsm0808_prepend_dtap_header(payload, 0);
- udt = sccp_create_dt1(&con->real_ref, payload->data, payload->len);
+ udt = sccp_create_dt1(&con->bsc_real_ref, payload->data, payload->len);
if (!udt) {
msgb_free(cc);
goto send_refuse;
@@ -571,7 +571,7 @@ static void bsc_send_con_refuse(struct bsc_connection *bsc,
}
/* 4. send a RLSD */
- rlsd = sccp_create_rlsd(&con->remote_ref, &con->real_ref,
+ rlsd = sccp_create_rlsd(&con->msc_real_ref, &con->bsc_real_ref,
SCCP_RELEASE_CAUSE_END_USER_ORIGINATED);
if (!rlsd) {
msgb_free(cc);
@@ -930,7 +930,7 @@ void bsc_close_connection(struct bsc_connection *connection)
if (ctr)
rate_ctr_inc(ctr);
- if (sccp_patch->has_remote_ref) {
+ if (sccp_patch->has_msc_ref) {
if (sccp_patch->con_local == NAT_CON_END_MSC)
nat_send_rlsd_msc(sccp_patch);
else if (sccp_patch->con_local == NAT_CON_END_USSD)
@@ -1560,7 +1560,7 @@ static void sccp_close_unconfirmed(void *_data)
clock_gettime(CLOCK_MONOTONIC, &now);
llist_for_each_entry_safe(conn, tmp1, &nat->sccp_connections, list_entry) {
- if (conn->has_remote_ref)
+ if (conn->has_msc_ref)
continue;
int diff = (now.tv_sec - conn->creation_time.tv_sec) / 60;
@@ -1569,8 +1569,8 @@ static void sccp_close_unconfirmed(void *_data)
LOGP(DNAT, LOGL_ERROR,
"SCCP connection 0x%x/0x%x was never confirmed on bsc nr. %d\n",
- sccp_src_ref_to_int(&conn->real_ref),
- sccp_src_ref_to_int(&conn->patched_ref),
+ sccp_src_ref_to_int(&conn->bsc_real_ref),
+ sccp_src_ref_to_int(&conn->bsc_patched_ref),
conn->bsc->cfg->nr);
sccp_connection_destroy(conn);
destroyed = 1;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 5ab5fb38b..6d46e4f3f 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -402,8 +402,8 @@ int bsc_config_handles_lac(struct bsc_config *cfg, int lac_nr)
void sccp_connection_destroy(struct nat_sccp_connection *conn)
{
LOGP(DNAT, LOGL_DEBUG, "Destroy 0x%x <-> 0x%x mapping for con %p\n",
- sccp_src_ref_to_int(&conn->real_ref),
- sccp_src_ref_to_int(&conn->patched_ref), conn->bsc);
+ sccp_src_ref_to_int(&conn->bsc_real_ref),
+ sccp_src_ref_to_int(&conn->bsc_patched_ref), conn->bsc);
bsc_mgcp_dlcx(conn);
llist_del(&conn->list_entry);
talloc_free(conn);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index b68a91a43..20cacdb77 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -223,10 +223,10 @@ DEFUN(show_sccp, show_sccp_cmd, "show sccp connections",
llist_for_each_entry(con, &_nat->sccp_connections, list_entry) {
vty_out(vty, "For BSC Nr: %d BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x type: %s%s",
con->bsc->cfg ? con->bsc->cfg->nr : -1,
- sccp_src_ref_to_int(&con->real_ref),
- sccp_src_ref_to_int(&con->patched_ref),
- con->has_remote_ref,
- sccp_src_ref_to_int(&con->remote_ref),
+ sccp_src_ref_to_int(&con->bsc_real_ref),
+ sccp_src_ref_to_int(&con->bsc_patched_ref),
+ con->has_msc_ref,
+ sccp_src_ref_to_int(&con->msc_real_ref),
con->msc_endp, con->bsc_endp,
bsc_con_type_to_string(con->filter_state.con_type),
VTY_NEWLINE);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_sccp.c b/openbsc/src/osmo-bsc_nat/bsc_sccp.c
index c6c265f7a..b5da6e353 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_sccp.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_sccp.c
@@ -45,7 +45,7 @@ static int sccp_ref_is_free(struct sccp_source_reference *ref, struct bsc_nat *n
struct nat_sccp_connection *conn;
llist_for_each_entry(conn, &nat->sccp_connections, list_entry) {
- if (equal(ref, &conn->patched_ref))
+ if (equal(ref, &conn->bsc_patched_ref))
return -1;
}
@@ -91,12 +91,12 @@ struct nat_sccp_connection *create_sccp_src_ref(struct bsc_connection *bsc,
llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
if (conn->bsc != bsc)
continue;
- if (!equal(parsed->src_local_ref, &conn->real_ref))
+ if (!equal(parsed->src_local_ref, &conn->bsc_real_ref))
continue;
/* the BSC has reassigned the SRC ref and we failed to keep track */
- memset(&conn->remote_ref, 0, sizeof(conn->remote_ref));
- if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
+ memset(&conn->msc_real_ref, 0, sizeof(conn->msc_real_ref));
+ if (assign_src_local_reference(&conn->bsc_patched_ref, bsc->nat) != 0) {
LOGP(DNAT, LOGL_ERROR, "BSC %d reused src ref: %d and we failed to generate a new id.\n",
bsc->cfg->nr, sccp_src_ref_to_int(parsed->src_local_ref));
bsc_mgcp_dlcx(conn);
@@ -119,8 +119,8 @@ struct nat_sccp_connection *create_sccp_src_ref(struct bsc_connection *bsc,
conn->bsc = bsc;
clock_gettime(CLOCK_MONOTONIC, &conn->creation_time);
- conn->real_ref = *parsed->src_local_ref;
- if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
+ conn->bsc_real_ref = *parsed->src_local_ref;
+ if (assign_src_local_reference(&conn->bsc_patched_ref, bsc->nat) != 0) {
LOGP(DNAT, LOGL_ERROR, "Failed to assign a ref.\n");
talloc_free(conn);
return NULL;
@@ -132,8 +132,8 @@ struct nat_sccp_connection *create_sccp_src_ref(struct bsc_connection *bsc,
osmo_counter_inc(bsc->cfg->nat->stats.sccp.conn);
LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con %p\n",
- sccp_src_ref_to_int(&conn->real_ref),
- sccp_src_ref_to_int(&conn->patched_ref), bsc);
+ sccp_src_ref_to_int(&conn->bsc_real_ref),
+ sccp_src_ref_to_int(&conn->bsc_patched_ref), bsc);
return conn;
}
@@ -145,11 +145,11 @@ int update_sccp_src_ref(struct nat_sccp_connection *sccp, struct bsc_nat_parsed
return -1;
}
- sccp->remote_ref = *parsed->src_local_ref;
- sccp->has_remote_ref = 1;
+ sccp->msc_real_ref = *parsed->src_local_ref;
+ sccp->has_msc_ref = 1;
LOGP(DNAT, LOGL_DEBUG, "Updating 0x%x to remote 0x%x on %p\n",
- sccp_src_ref_to_int(&sccp->patched_ref),
- sccp_src_ref_to_int(&sccp->remote_ref), sccp->bsc);
+ sccp_src_ref_to_int(&sccp->bsc_patched_ref),
+ sccp_src_ref_to_int(&sccp->msc_real_ref), sccp->bsc);
return 0;
}
@@ -159,7 +159,7 @@ void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bs
struct nat_sccp_connection *conn;
llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
- if (equal(parsed->src_local_ref, &conn->patched_ref)) {
+ if (equal(parsed->src_local_ref, &conn->bsc_patched_ref)) {
sccp_connection_destroy(conn);
return;
}
@@ -187,11 +187,11 @@ struct nat_sccp_connection *patch_sccp_src_ref_to_bsc(struct msgb *msg,
llist_for_each_entry(conn, &nat->sccp_connections, list_entry) {
- if (!equal(parsed->dest_local_ref, &conn->patched_ref))
+ if (!equal(parsed->dest_local_ref, &conn->bsc_patched_ref))
continue;
/* Change the dest address to the real one */
- *parsed->dest_local_ref = conn->real_ref;
+ *parsed->dest_local_ref = conn->bsc_real_ref;
return conn;
}
@@ -217,12 +217,12 @@ struct nat_sccp_connection *patch_sccp_src_ref_to_msc(struct msgb *msg,
continue;
if (parsed->src_local_ref) {
- if (equal(parsed->src_local_ref, &conn->real_ref)) {
- *parsed->src_local_ref = conn->patched_ref;
+ if (equal(parsed->src_local_ref, &conn->bsc_real_ref)) {
+ *parsed->src_local_ref = conn->bsc_patched_ref;
return conn;
}
} else if (parsed->dest_local_ref) {
- if (equal(parsed->dest_local_ref, &conn->remote_ref))
+ if (equal(parsed->dest_local_ref, &conn->msc_real_ref))
return conn;
} else {
LOGP(DNAT, LOGL_ERROR, "Header has neither loc/dst ref.\n");
@@ -239,7 +239,7 @@ struct nat_sccp_connection *bsc_nat_find_con_by_bsc(struct bsc_nat *nat,
struct nat_sccp_connection *conn;
llist_for_each_entry(conn, &nat->sccp_connections, list_entry) {
- if (equal(ref, &conn->real_ref))
+ if (equal(ref, &conn->bsc_real_ref))
return conn;
}