Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTE message parsing #6

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions diag_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,7 @@ struct radio_message * handle_4G(struct diag_packet *dp, unsigned len)
return 0;
}

payload_len = dp->len - 16;

if (payload_len > len - 16) {
return 0;
}

if (payload_len > sizeof(m->bb.data)) {
return 0;
}

payload_len = len - 7;
data = &dp->data[1];

m = (struct radio_message *) malloc(sizeof(struct radio_message));
Expand All @@ -216,13 +207,6 @@ struct radio_message * handle_4G(struct diag_packet *dp, unsigned len)
case 0xb0c0: // LTE RRC
m->flags = MSG_BCCH; // it's not really BCCH, just indicates RRC
m->bb.arfcn[0] = ((uint16_t) dp->data[4]) << 8 | dp->data[3];
if (dp->data[0]) {
// Uplink
m->bb.arfcn[0] |= ARFCN_UPLINK;
} else {
// Downlink
}

/* Qualcomm to wireshark conversion */
switch (dp->data[7]) {
case 2: // BCCH-DL-SCH
Expand All @@ -242,30 +226,27 @@ struct radio_message * handle_4G(struct diag_packet *dp, unsigned len)
break;
case 7: // UL-CCCH
m->chan_nr = 2;
m->bb.arfcn[0] |= ARFCN_UPLINK;
break;
case 8: // UL-DCCH
m->chan_nr = 3;
m->bb.arfcn[0] |= ARFCN_UPLINK;
break;
default:
// Unhandled
return NULL;
}
// verify len
payload_len = ((uint16_t)dp->data[9]) << 8 | dp->data[8];
if (payload_len > len - 15) {
return 0;
}
if (payload_len > sizeof(m->bb.data)) {
return 0;
}
data = &dp->data[10];
/* payload_len = dp->data[12]-1; */
payload_len=len-14;
data = &dp->data[14];
break;
case 0xb0e0: // LTE NAS ESM DL (protected)
case 0xb0ea: // LTE NAS EMM DL (protected)
m->flags = MSG_SDCCH | MSG_CIPHERED;
m->bb.arfcn[0] = 0;
break;
case 0xb0e1: // LTE NAS ESM DL (protected)
case 0xb0e1: // LTE NAS ESM UL (protected)
case 0xb0eb: // LTE NAS EMM UL (protected)
m->flags = MSG_SDCCH | MSG_CIPHERED;
m->bb.arfcn[0] = ARFCN_UPLINK;
Expand Down Expand Up @@ -686,7 +667,6 @@ void handle_diag(uint8_t *msg, unsigned len)
m->bb.arfcn[i] = last_burst.arfcn[i];
}
}

handle_radio_msg(_s, m);
}
}
2 changes: 1 addition & 1 deletion output.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void net_send_msg(struct radio_message *m)
msgb = gsmtap_makemsg_ex(0x0e, m->bb.arfcn[0], 0,
0, 0, 0, 0, 0, m->bb.data, m->msg_len);
} else if (m->flags & MSG_BCCH) {
msgb = gsmtap_makemsg_ex(0x0d, m->bb.arfcn[0], 0,
msgb = gsmtap_makemsg_ex(GSMTAP_TYPE_LTE_RRC, m->bb.arfcn[0], 0,
m->chan_nr, 0, 0, 0, 0, m->bb.data, m->msg_len);
} else {
/* no other types defined */
Expand Down