aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-30 14:04:30 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-30 14:14:41 +0200
commit0e5d6442c6eb0c7fe091a312c418cf3f4db01317 (patch)
tree2569a51f04a0e281f0a30512fc750d10ce7dcf91
parentbb2bdfe1718295bcaf698fa80452bdeea4501721 (diff)
wip
-rw-r--r--src/hnbgw.c7
-rw-r--r--src/tests/hnb-test.c12
2 files changed, 13 insertions, 6 deletions
diff --git a/src/hnbgw.c b/src/hnbgw.c
index 3553f9e..13f2a9c 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -181,6 +181,9 @@ static int hnb_read_cb(struct osmo_stream_srv *conn)
msgb_put(msg, rc);
}
+ printf("Rx %s\n",
+ osmo_hexdump(msg->data, msg->len));
+
switch (msgb_sctp_ppid(msg)) {
case IUH_PPI_HNBAP:
hnb->hnbap_stream = msgb_sctp_stream(msg);
@@ -233,6 +236,8 @@ struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_
return NULL;
INIT_LLIST_HEAD(&ctx->map_list);
+ printf("hnb_context_alloc()\n");
+
ctx->gw = gw;
ctx->conn = osmo_stream_srv_create(tall_hnb_ctx, link, new_fd, hnb_read_cb, hnb_close_cb, ctx);
if (!ctx->conn) {
@@ -295,7 +300,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
static const struct log_info_cat log_cat[] = {
[DMAIN] = {
- .name = "DMAIN", .loglevel = LOGL_INFO, .enabled = 1,
+ .name = "DMAIN", .loglevel = LOGL_DEBUG, .enabled = 1,
.color = "",
.description = "Main program",
},
diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index 63fa636..18f4f32 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -213,7 +213,7 @@ static struct msgb *gen_nas_auth_resp()
{
uint8_t id_resp[] = {
GSM48_PDISC_MM,
- GSM48_MT_MM_AUTH_RESP,
+ 0x80 | GSM48_MT_MM_AUTH_RESP, /* simulate sequence nr 2 */
0x61, 0xb5, 0x69, 0xf5 /* hardcoded SRES */
};
@@ -251,9 +251,11 @@ static struct tlv_parsed *parse_mm(struct msgb *rxm)
gh = (struct gsm48_hdr *) msgb_l3(rxm);
length -= (const char *)&gh->data[0] - (const char *)gh;
+ OSMO_ASSERT(gsm48_hdr_pdisc(gh) == GSM48_PDISC_MM);
+
parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, &gh->data[0], length, 0, 0);
if (parse_res <= 0) {
- uint8_t msg_type = gh->msg_type & 0xbf;
+ uint8_t msg_type = gsm48_hdr_msg_type(gh);
printf("Error parsing MM message 0x%hhx: %d\n", msg_type, parse_res);
return NULL;
}
@@ -364,7 +366,7 @@ static int hnb_test_nas_rx_mm(struct hnb_test *hnb, struct msgb *rxm)
OSMO_ASSERT(!chan->is_ps);
struct gsm48_hdr *gh = msgb_l3(rxm);
- uint8_t msg_type = gh->msg_type & 0xbf;
+ uint8_t msg_type = gsm48_hdr_msg_type(gh);
int sent_tmsi;
switch (msg_type) {
@@ -407,7 +409,7 @@ static int hnb_test_nas_rx_dtap(struct hnb_test *hnb, struct msgb *msg)
// '05 04 0d' ==> LU reject
struct gsm48_hdr *gh = msgb_l3(msg);
- uint8_t pdisc = gh->proto_discr & 0x0f;
+ uint8_t pdisc = gsm48_hdr_pdisc(gh);
switch (pdisc) {
case GSM48_PDISC_MM:
@@ -797,7 +799,7 @@ static struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi)
/* len, IMSI/type, IMSI-------------------------------- */
0x08, 0x29, 0x26, 0x24, 0x10, 0x32, 0x54, 0x76, 0x98,
0x33, 0x03, 0x57, 0x18 , 0xb2 };
- uint8_t plmn_id[] = { 0x09, 0x01, 0x99 };
+ uint8_t plmn_id[] = { 0x09, 0xf1, 0x99 };
RANAP_GlobalRNC_ID_t rnc_id = {
.rNC_ID = 23,
.pLMNidentity.buf = plmn_id,