summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-01-10 22:29:35 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-01-10 22:29:35 +0100
commit951f34b8857338b6cb9d09031a0ea3d2b157ab44 (patch)
treecce882498a7e10404ab792eb697352e78bae76c9
parentc2c0ea700bc5100645372c94d765ddb2b6f99285 (diff)
nat: Use the link_id from the original message in the new DTAP message
SMS went from SAPI=3 to SAPI=0 and nobody notices on the NAT->MSC direction.
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c4
-rw-r--r--openbsc/tests/bsc-nat/bsc_data.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 93fb5b564..1d67c350c 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -1124,6 +1124,7 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b
uint32_t len;
uint8_t msg_type, proto;
struct msgb *new_msg = NULL, *sccp;
+ uint8_t link_id;
if (!imsi || strlen(imsi) < 5)
return msg;
@@ -1138,6 +1139,7 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b
if (!hdr48)
return msg;
+ link_id = msg->l3h[1];
proto = hdr48->proto_discr & 0x0f;
msg_type = hdr48->msg_type & 0xbf;
@@ -1150,7 +1152,7 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b
return msg;
/* wrap with DTAP, SCCP, then IPA. TODO: Stop copying */
- gsm0808_prepend_dtap_header(new_msg, 0);
+ gsm0808_prepend_dtap_header(new_msg, link_id);
sccp = sccp_create_dt1(parsed->dest_local_ref, new_msg->data, new_msg->len);
talloc_free(new_msg);
diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c
index 8a06348fd..101c57614 100644
--- a/openbsc/tests/bsc-nat/bsc_data.c
+++ b/openbsc/tests/bsc-nat/bsc_data.c
@@ -109,7 +109,7 @@ static const uint8_t smsc_rewrite[] = {
static const uint8_t smsc_rewrite_patched[] = {
0x00, 0x31, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
-0x01, 0x2a, 0x01, 0x00, 0x27, 0x09, 0x01, 0x24,
+0x01, 0x2a, 0x01, 0x03, 0x27, 0x09, 0x01, 0x24,
0x00, 0x0c, 0x00, 0x08, 0x91, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0xf7, 0x17, 0x01, 0x0c, 0x0f,
0x81, 0x00, 0x94, 0x51, 0x87, 0x86, 0x78, 0x46,