Commit 7654f8a2 authored by Cedric Roux's avatar Cedric Roux

Merge remote-tracking branch 'origin/issue_344_segv_trace_wireshark' into...

Merge remote-tracking branch 'origin/issue_344_segv_trace_wireshark' into develop_integration_2018_w35
parents 3f08e450 d5f28018
...@@ -2617,7 +2617,7 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin ...@@ -2617,7 +2617,7 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin
dummy[0] = ue->pbch_vars[eNB_id]->decoded_output[2]; dummy[0] = ue->pbch_vars[eNB_id]->decoded_output[2];
dummy[1] = ue->pbch_vars[eNB_id]->decoded_output[1]; dummy[1] = ue->pbch_vars[eNB_id]->decoded_output[1];
dummy[2] = ue->pbch_vars[eNB_id]->decoded_output[0]; dummy[2] = ue->pbch_vars[eNB_id]->decoded_output[0];
trace_pdu(1, dummy, 3, ue->Mod_id, 0, 0, trace_pdu( DIRECTION_DOWNLINK, dummy, WS_C_RNTI, ue->Mod_id, 0, 0,
frame_rx, subframe_rx, 0, 0); frame_rx, subframe_rx, 0, 0);
LOG_D(OPT,"[UE %d][PBCH] Frame %d trace pdu for PBCH\n", LOG_D(OPT,"[UE %d][PBCH] Frame %d trace pdu for PBCH\n",
ue->Mod_id, subframe_rx); ue->Mod_id, subframe_rx);
......
...@@ -988,9 +988,10 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, ...@@ -988,9 +988,10 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
payload[0], ra->msg4_TBsize)); payload[0], ra->msg4_TBsize));
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
(uint8_t *) mac-> (uint8_t *) mac->
UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], rrc_sdu_length, UE_id, 3, UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0],
rrc_sdu_length, UE_id, WS_C_RNTI,
UE_RNTI(module_idP, UE_id), mac->frame, UE_RNTI(module_idP, UE_id), mac->frame,
mac->subframe, 0, 0); mac->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
...@@ -1193,9 +1194,10 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, ...@@ -1193,9 +1194,10 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
payload[0], ra->msg4_TBsize)); payload[0], ra->msg4_TBsize));
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
(uint8_t *) mac-> (uint8_t *) mac->
UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], rrc_sdu_length, UE_id, 3, UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0],
rrc_sdu_length, UE_id, WS_C_RNTI,
UE_RNTI(module_idP, UE_id), mac->frame, UE_RNTI(module_idP, UE_id), mac->frame,
mac->subframe, 0, 0); mac->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
......
...@@ -281,10 +281,10 @@ schedule_SIB1_BR(module_id_t module_idP, ...@@ -281,10 +281,10 @@ schedule_SIB1_BR(module_id_t module_idP,
eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
&cc->BCCH_BR_pdu[0].payload[0], &cc->BCCH_BR_pdu[0].payload[0],
bcch_sdu_length, bcch_sdu_length,
0xffff, 4, 0xffff, eNB->frame, eNB->subframe, 0, 0); 0xffff, WS_SI_RNTI, 0xffff, eNB->frame, eNB->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
module_idP, frameP, CC_id, 0xffff, bcch_sdu_length); module_idP, frameP, CC_id, 0xffff, bcch_sdu_length);
...@@ -472,11 +472,11 @@ schedule_SI_BR(module_id_t module_idP, frame_t frameP, ...@@ -472,11 +472,11 @@ schedule_SI_BR(module_id_t module_idP, frame_t frameP,
eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
&cc->BCCH_BR_pdu[i + 1].payload[0], &cc->BCCH_BR_pdu[i + 1].payload[0],
bcch_sdu_length, bcch_sdu_length,
0xffff, 0xffff,
4, WS_SI_RNTI,
0xffff, eNB->frame, eNB->subframe, 0, 0xffff, eNB->frame, eNB->subframe, 0,
0); 0);
LOG_D(OPT, LOG_D(OPT,
...@@ -759,11 +759,11 @@ schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) ...@@ -759,11 +759,11 @@ schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
} }
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
&cc->BCCH_pdu.payload[0], &cc->BCCH_pdu.payload[0],
bcch_sdu_length, bcch_sdu_length,
0xffff, 0xffff,
4, 0xffff, eNB->frame, eNB->subframe, 0, 0); WS_SI_RNTI, 0xffff, eNB->frame, eNB->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
module_idP, frameP, CC_id, 0xffff, module_idP, frameP, CC_id, 0xffff,
......
...@@ -1359,9 +1359,9 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, ...@@ -1359,9 +1359,9 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP,
} }
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, (uint8_t *) trace_pdu(DIRECTION_DOWNLINK,
UE_list->DLSCH_pdu[CC_id][0][UE_id]. (uint8_t *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
payload[0], TBS, module_idP, 3, TBS, module_idP, WS_C_RNTI,
UE_RNTI(module_idP, UE_id), eNB->frame, UE_RNTI(module_idP, UE_id), eNB->frame,
eNB->subframe, 0, 0); eNB->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
...@@ -2085,7 +2085,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) ...@@ -2085,7 +2085,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP)
} }
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, trace_pdu(DIRECTION_DOWNLINK,
&eNB->common_channels[CC_id].PCCH_pdu.payload[0], &eNB->common_channels[CC_id].PCCH_pdu.payload[0],
pcch_sdu_length, pcch_sdu_length,
0xffff, 0xffff,
......
...@@ -1655,8 +1655,8 @@ schedule_ue_spec_fairRR(module_id_t module_idP, ...@@ -1655,8 +1655,8 @@ schedule_ue_spec_fairRR(module_id_t module_idP,
} }
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], trace_pdu(DIRECTION_DOWNLINK, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
TBS, module_idP, 3, UE_RNTI(module_idP,UE_id), TBS, module_idP, WS_RA_RNTI, UE_RNTI(module_idP,UE_id),
eNB->frame, eNB->subframe,0,0); eNB->frame, eNB->subframe,0,0);
LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n",
module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS); module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS);
......
...@@ -767,7 +767,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, ...@@ -767,7 +767,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
/* Tracing of PDU is done on UE side */ /* Tracing of PDU is done on UE side */
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(1, (uint8_t *) cc->MCH_pdu.payload, TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark trace_pdu(DIRECTION_DOWNLINK, (uint8_t *) cc->MCH_pdu.payload, TBS, module_idP, WS_M_RNTI , 0xffff, // M_RNTI = 6 in wirehsark
RC.mac[module_idP]->frame, RC.mac[module_idP]->frame,
RC.mac[module_idP]->subframe, 0, 0); RC.mac[module_idP]->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
......
...@@ -150,7 +150,7 @@ rx_sdu(const module_id_t enb_mod_idP, ...@@ -150,7 +150,7 @@ rx_sdu(const module_id_t enb_mod_idP,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1);
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(0, sduP, sdu_lenP, 0, 3, current_rnti, frameP, subframeP, trace_pdu(DIRECTION_UPLINK, sduP, sdu_lenP, 0, WS_C_RNTI, current_rnti, frameP, subframeP,
0, 0); 0, 0);
LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n",
enb_mod_idP, frameP, current_rnti, sdu_lenP); enb_mod_idP, frameP, current_rnti, sdu_lenP);
......
...@@ -248,7 +248,7 @@ Msg1_transmitted(module_id_t module_idP, uint8_t CC_id, ...@@ -248,7 +248,7 @@ Msg1_transmitted(module_id_t module_idP, uint8_t CC_id,
UE_mac_inst[module_idP].RA_attempt_number++; UE_mac_inst[module_idP].RA_attempt_number++;
if (opt_enabled) { if (opt_enabled) {
trace_pdu(0, NULL, 0, module_idP, 0, trace_pdu(DIRECTION_UPLINK, NULL, 0, module_idP, WS_NO_RNTI,
UE_mac_inst[module_idP].RA_prach_resources. UE_mac_inst[module_idP].RA_prach_resources.
ra_PreambleIndex, UE_mac_inst[module_idP].txFrame, ra_PreambleIndex, UE_mac_inst[module_idP].txFrame,
UE_mac_inst[module_idP].txSubframe, 0, UE_mac_inst[module_idP].txSubframe, 0,
...@@ -277,8 +277,8 @@ Msg3_transmitted(module_id_t module_idP, uint8_t CC_id, ...@@ -277,8 +277,8 @@ Msg3_transmitted(module_id_t module_idP, uint8_t CC_id,
UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
if (opt_enabled) { // msg3 if (opt_enabled) { // msg3
trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], trace_pdu(DIRECTION_UPLINK , &UE_mac_inst[module_idP].CCCH_pdu.payload[0],
UE_mac_inst[module_idP].RA_Msg3_size, module_idP, 3, UE_mac_inst[module_idP].RA_Msg3_size, module_idP, WS_C_RNTI,
UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].crnti,
UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txFrame,
UE_mac_inst[module_idP].txSubframe, 0, 0); UE_mac_inst[module_idP].txSubframe, 0, 0);
......
...@@ -96,7 +96,7 @@ fill_rar(const module_id_t module_idP, ...@@ -96,7 +96,7 @@ fill_rar(const module_id_t module_idP,
((ra->msg3_ULdelay & 1) << 1) | (ra->msg3_cqireq & 1); ((ra->msg3_ULdelay & 1) << 1) | (ra->msg3_cqireq & 1);
if (opt_enabled) { if (opt_enabled) {
trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, trace_pdu(DIRECTION_DOWNLINK , dlsch_buffer, input_buffer_length, module_idP, WS_RA_RNTI , 1,
RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe, RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe,
0, 0); 0, 0);
LOG_D(OPT, LOG_D(OPT,
...@@ -181,7 +181,7 @@ fill_rar_br(eNB_MAC_INST * eNB, ...@@ -181,7 +181,7 @@ fill_rar_br(eNB_MAC_INST * eNB,
ra->preamble_index, ra->timing_offset); ra->preamble_index, ra->timing_offset);
if (opt_enabled) { if (opt_enabled) {
trace_pdu(1, dlsch_buffer, input_buffer_length, eNB->Mod_id, 2, 1, trace_pdu(DIRECTION_DOWNLINK , dlsch_buffer, input_buffer_length, eNB->Mod_id, WS_RA_RNTI , 1,
eNB->frame, eNB->subframe, 0, 0); eNB->frame, eNB->subframe, 0, 0);
LOG_D(OPT, LOG_D(OPT,
"[RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", "[RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n",
......
...@@ -119,8 +119,8 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra ...@@ -119,8 +119,8 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
LOG_D(OPT, LOG_D(OPT,
"[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n", "[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n",
module_idP, CC_id, frameP, ra_rnti); module_idP, CC_id, frameP, ra_rnti);
trace_pdu(1, (uint8_t *) dlsch_buffer, n_rarh + n_rarpy * 6, trace_pdu(DIRECTION_DOWNLINK, (uint8_t *) dlsch_buffer, n_rarh + n_rarpy * 6,
module_idP, 2, ra_rnti, UE_mac_inst[module_idP].rxFrame, module_idP, WS_RA_RNTI, ra_rnti, UE_mac_inst[module_idP].rxFrame,
UE_mac_inst[module_idP].rxSubframe, 0, 0); UE_mac_inst[module_idP].rxSubframe, 0, 0);
} }
......
...@@ -420,7 +420,7 @@ ue_send_sdu(module_id_t module_idP, ...@@ -420,7 +420,7 @@ ue_send_sdu(module_id_t module_idP,
//LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
if (opt_enabled) { if (opt_enabled) {
trace_pdu(1, sdu, sdu_len, module_idP, 3, trace_pdu(DIRECTION_DOWNLINK, sdu, sdu_len, module_idP, WS_C_RNTI,
UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0); UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0);
LOG_D(OPT, LOG_D(OPT,
"[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
...@@ -637,11 +637,11 @@ ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP, ...@@ -637,11 +637,11 @@ ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP,
stop_meas(&UE_mac_inst[module_idP].rx_si); stop_meas(&UE_mac_inst[module_idP].rx_si);
#endif #endif
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(0, trace_pdu(DIRECTION_UPLINK,
(uint8_t *) pdu, (uint8_t *) pdu,
len, len,
module_idP, module_idP,
4, WS_SI_RNTI,
0xffff, 0xffff,
UE_mac_inst[module_idP].rxFrame, UE_mac_inst[module_idP].rxFrame,
UE_mac_inst[module_idP].rxSubframe, 0, 0); UE_mac_inst[module_idP].rxSubframe, 0, 0);
...@@ -675,11 +675,11 @@ ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP, ...@@ -675,11 +675,11 @@ ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP,
stop_meas(&UE_mac_inst[module_idP].rx_p); stop_meas(&UE_mac_inst[module_idP].rx_p);
#endif #endif
if (opt_enabled == 1) { if (opt_enabled == 1) {
trace_pdu(0, trace_pdu(DIRECTION_UPLINK ,
(uint8_t *) pdu, (uint8_t *) pdu,
len, len,
module_idP, module_idP,
4, WS_SI_RNTI,
P_RNTI, P_RNTI,
UE_mac_inst[module_idP].rxFrame, UE_mac_inst[module_idP].rxFrame,
UE_mac_inst[module_idP].rxSubframe, 0, 0); UE_mac_inst[module_idP].rxSubframe, 0, 0);
...@@ -2469,7 +2469,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, ...@@ -2469,7 +2469,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
#endif #endif
if (opt_enabled) { if (opt_enabled) {
trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, trace_pdu(DIRECTION_UPLINK, ulsch_buffer, buflen, module_idP, WS_C_RNTI,
UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].crnti,
UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txFrame,
UE_mac_inst[module_idP].txSubframe, 0, 0); UE_mac_inst[module_idP].txSubframe, 0, 0);
......
2012 07 10 - Working version
How to configure wireshark for dissecting LTE protocols: How to configure wireshark for dissecting LTE protocols:
- start the wireshark as a sudoers - start the wireshark as a sudoers
- goto analyze->enabled prototols
=> enable mac_lte_udp and rlc_lte_udp
- goto edit/preferences and expand Protocols - goto edit/preferences and expand Protocols
- select UDP and check "try heuristic sub-dissectors first" - select UDP and check "try heuristic sub-dissectors first"
- select MAC-LTE, and check all the options (checkboxes), and set the "which layer info to show in info column" to "MAC info" - select MAC-LTE, and check all the options (checkboxes), and set the "which layer info to show in info column" to "MAC info"
- select RLC-LTE, and check all the options except the "May see RLC headers only", and set the "call PDCP dissector for DRB PDUs" to "12-bit SN". Optionally you may select the sequence analysis for RLC AM/UM. - select RLC-LTE, and check all the options except the "May see RLC headers only", and set the "call PDCP dissector for DRB PDUs" to "12-bit SN". Optionally you may select the sequence analysis for RLC AM/UM.
How to use
- start eNB or UE with option -W (or -P if you want to make a pcap file)
- capture on local interface "lo" - capture on local interface "lo"
- filter out the ICMP/DNS/TCP messages (e.g. "!icmp && !dns && !tcp") - filter out the ICMP/DNS/TCP messages (e.g. "!icmp && !dns && !tcp")
...@@ -42,11 +42,4 @@ typedef struct MAC_Context_Info_t { ...@@ -42,11 +42,4 @@ typedef struct MAC_Context_Info_t {
unsigned int subframesSinceCaptureStart; unsigned int subframesSinceCaptureStart;
} MAC_Context_Info_t; } MAC_Context_Info_t;
pcap_hdr_t file_header = {
0xa1b2c3d4, /* magic number */
2, 4, /* version number is 2.4 */
0, /* timezone */
0, /* sigfigs - apparently all tools do this */
65535, /* snaplen - this should be long enough */
MAC_LTE_DLT /* Data Link Type (DLT). Set as unused value 147 for now */
};
...@@ -55,6 +55,16 @@ This header file must be included */ ...@@ -55,6 +55,16 @@ This header file must be included */
#include "PHY/impl_defs_lte.h" #include "PHY/impl_defs_lte.h"
#endif #endif
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
typedef uint8_t guint8;
typedef uint16_t guint16;
typedef uint32_t guint32;
typedef guint8 gboolean;
#include "packet-mac-lte.h"
#include "mac_pcap.h"
#ifdef OCP_FRAMEWORK #ifdef OCP_FRAMEWORK
#include <enums.h> #include <enums.h>
#else #else
...@@ -74,7 +84,7 @@ typedef enum radio_type_e { ...@@ -74,7 +84,7 @@ typedef enum radio_type_e {
extern trace_mode_t opt_type; extern trace_mode_t opt_type;
extern char in_ip[40]; extern char in_ip[40];
extern char in_path[100]; extern char in_path[FILENAME_MAX];
/** /**
* function def * function def
...@@ -84,7 +94,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, ...@@ -84,7 +94,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe,
int oob_event, int oob_event_value); int oob_event, int oob_event_value);
int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p); int init_opt(char *path, char *ip);
void terminate_opt(void); void terminate_opt(void);
......
/* packet-mac-lte.h /* packet-mac-lte.h
* *
* Martin Mathieson * Martin Mathieson
* $Id: packet-mac-lte.h 42240 2012-04-25 20:02:12Z pascal $
* *
* Wireshark - Network traffic analyzer * Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org> * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs * Copyright 1998 Gerald Combs
* *
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This header file may also be distributed under * This header file may also be distributed under
* the terms of the BSD Licence as follows: * the terms of the BSD Licence as follows:
* *
* Copyright (C) 2009 Martin Mathieson. All rights reserved. * Copyright (C) 2009 Martin Mathieson. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-2-Clause
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE
*/ */
/*
this is wireshark, commit: commit eda834b6e29c36e05a63a6056afa98390ff79357
Date: Wed Aug 22 14:36:20 2018 +0200
modified to be used in OpenAir to create the LTE MAC/RLC encapsulated in UDP as per Wireshark feature
*/
#include "ws_symbol_export.h"
/** data structure to hold time values with nanosecond resolution*/
typedef struct {
time_t secs;
int nsecs;
} nstime_t;
#ifndef PACKET_MAC_LTE_H_
#define PACKET_MAC_LTE_H_
/* radioType */ /* radioType */
#define FDD_RADIO 1 #define FDD_RADIO 1
...@@ -45,105 +40,190 @@ ...@@ -45,105 +40,190 @@
#define DIRECTION_UPLINK 0 #define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1 #define DIRECTION_DOWNLINK 1
/* SR: no need to declare following part: */ /* rntiType */
#define WS_NO_RNTI 0
#define WS_P_RNTI 1
#define WS_RA_RNTI 2
#define WS_C_RNTI 3
#define WS_SI_RNTI 4
#define WS_SPS_RNTI 5
#define WS_M_RNTI 6
#define WS_SL_BCH_RNTI 7
#define WS_SL_RNTI 8
#define WS_SC_RNTI 9
#define WS_G_RNTI 10
typedef enum mac_lte_oob_event { typedef enum mac_lte_oob_event {
ltemac_send_preamble, ltemac_send_preamble,
ltemac_send_sr, ltemac_send_sr,
ltemac_sr_failure ltemac_sr_failure
} mac_lte_oob_event; } mac_lte_oob_event;
typedef enum mac_lte_dl_retx { typedef enum mac_lte_dl_retx {
dl_retx_no, dl_retx_no,
dl_retx_yes, dl_retx_yes,
dl_retx_unknown dl_retx_unknown
} mac_lte_dl_retx; } mac_lte_dl_retx;
typedef enum mac_lte_crc_status { typedef enum mac_lte_crc_status {
crc_fail = 0, crc_fail = 0,
crc_success = 1, crc_success = 1,
crc_high_code_rate = 2, crc_high_code_rate = 2,
crc_pdsch_lost = 3, crc_pdsch_lost = 3,
crc_duplicate_nonzero_rv = 4 crc_duplicate_nonzero_rv = 4,
crc_false_dci = 5
} mac_lte_crc_status; } mac_lte_crc_status;
/* N.B. for SCellIndex-r13 extends to 31 */
typedef enum mac_lte_carrier_id {
carrier_id_primary,
carrier_id_secondary_1,
carrier_id_secondary_2,
carrier_id_secondary_3,
carrier_id_secondary_4,
carrier_id_secondary_5,
carrier_id_secondary_6,
carrier_id_secondary_7
} mac_lte_carrier_id;
typedef enum mac_lte_ce_mode {
no_ce_mode = 0,
ce_mode_a = 1,
ce_mode_b = 2
} mac_lte_ce_mode;
typedef enum mac_lte_nb_mode {
no_nb_mode = 0,
nb_mode = 1
} mac_lte_nb_mode;
/* Context info attached to each LTE MAC frame */ /* Context info attached to each LTE MAC frame */
typedef struct mac_lte_info { typedef struct mac_lte_info
/* Needed for decode */ {
guint8 radioType; /* Needed for decode */
guint8 direction; guint8 radioType;
guint8 rntiType; guint8 direction;
guint8 rntiType;
/* Extra info to display */
guint16 rnti; /* Extra info to display */
guint16 ueid; guint16 rnti;
guint16 ueid;
/* Timing info */
guint16 sysframeNumber; /* Timing info */
guint16 subframeNumber; guint16 sysframeNumber;
guint16 subframeNumber;
/* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */
gboolean subframeNumberOfGrantPresent; /* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */
guint16 subframeNumberOfGrant; gboolean subframeNumberOfGrantPresent;
guint16 subframeNumberOfGrant;
/* Flag set only if doing PHY-level data test - i.e. there may not be a
well-formed MAC PDU so just show as raw data */ /* Flag set only if doing PHY-level data test - i.e. there may not be a
gboolean isPredefinedData; well-formed MAC PDU so just show as raw data */
gboolean isPredefinedData;
/* Length of DL PDU or UL grant size in bytes */
guint16 length; /* Length of DL PDU or UL grant size in bytes */
guint16 length;
/* UL only. 0=newTx, 1=first-retx, etc */
guint8 reTxCount; /* 0=newTx, 1=first-retx, etc */
guint8 isPHICHNACK; /* FALSE=PDCCH retx grant, TRUE=PHICH NACK */ guint8 reTxCount;
guint8 isPHICHNACK; /* FALSE=PDCCH retx grant, TRUE=PHICH NACK */
/* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set */
gboolean isExtendedBSRSizes; /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set */
gboolean isExtendedBSRSizes;
/* DL only. Status of CRC check */
mac_lte_crc_status crcStatusValid; /* UL only. Indicates if the R10 simultaneousPUCCH-PUSCH parameter is set for PCell */
gboolean isSimultPUCCHPUSCHPCell;
/* DL only. Is this known to be a retransmission? */
mac_lte_dl_retx dl_retx; /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set for PSCell */
gboolean isSimultPUCCHPUSCHPSCell;
/* More Physical layer info (see direction above for which side of union to use) */
union { /* Status of CRC check. For UE it is DL only. For eNodeB it is UL
struct mac_lte_ul_phy_info { only. For an analyzer, it is present for both DL and UL. */
guint8 present; /* Remaining UL fields are present and should be displayed */ gboolean crcStatusValid;
guint8 modulation_type; mac_lte_crc_status crcStatus;
guint8 tbs_index;
guint8 resource_block_length; /* Carrier ID */
guint8 resource_block_start; mac_lte_carrier_id carrierId;
guint8 harq_id;
gboolean ndi; /* DL only. Is this known to be a retransmission? */
} ul_info; mac_lte_dl_retx dl_retx;
struct mac_lte_dl_phy_info {
guint8 present; /* Remaining UL fields are present and should be displayed */ /* DL only. CE mode to be used for RAR decoding */
guint8 dci_format; mac_lte_ce_mode ceMode;
guint8 resource_allocation_type;
guint8 aggregation_level; /* DL and UL. NB-IoT mode of the UE */
guint8 mcs_index; mac_lte_nb_mode nbMode;
guint8 redundancy_version_index;
guint8 resource_block_length; /* UL only, for now used for CE mode A RAR decoding */
mac_lte_crc_status crc_status; guint8 nUlRb;
guint8 harq_id;
gboolean ndi; /* More Physical layer info (see direction above for which side of union to use) */
guint8 transport_block; /* 1..2 */ union {
} dl_info; struct mac_lte_ul_phy_info
} detailed_phy_info; {
guint8 present; /* Remaining UL fields are present and should be displayed */
/* Relating to out-of-band events */ guint8 modulation_type;
/* N.B. dissector will only look to these fields if length is 0... */ guint8 tbs_index;
mac_lte_oob_event oob_event; guint8 resource_block_length;
guint8 rapid; guint8 resource_block_start;
guint8 rach_attempt_number; guint8 harq_id;
#define MAX_SRs 20 gboolean ndi;
guint16 number_of_srs; } ul_info;
guint16 oob_ueid[MAX_SRs]; struct mac_lte_dl_phy_info
guint16 oob_rnti[MAX_SRs]; {
guint8 present; /* Remaining DL fields are present and should be displayed */
guint8 dci_format;
guint8 resource_allocation_type;
guint8 aggregation_level;
guint8 mcs_index;
guint8 redundancy_version_index;
guint8 resource_block_length;
guint8 harq_id;
gboolean ndi;
guint8 transport_block; /* 0..1 */
} dl_info;
} detailed_phy_info;
/* Relating to out-of-band events */
/* N.B. dissector will only look to these fields if length is 0... */
mac_lte_oob_event oob_event;
guint8 rapid;
guint8 rach_attempt_number;
#define MAX_SRs 20
guint16 number_of_srs;
guint16 oob_ueid[MAX_SRs];
guint16 oob_rnti[MAX_SRs];
} mac_lte_info; } mac_lte_info;
/* Accessor function to check if a frame was considered to be ReTx */
//int is_mac_lte_frame_retx(packet_info *pinfo, guint8 direction); typedef struct mac_lte_tap_info {
/* Info from context */
guint16 rnti;
guint16 ueid;
guint8 rntiType;
guint8 isPredefinedData;
gboolean crcStatusValid;
mac_lte_crc_status crcStatus;
guint8 direction;
guint8 isPHYRetx;
guint16 ueInTTI;
nstime_t mac_lte_time;
/* Number of bytes (which part is used depends upon context settings) */
guint32 single_number_of_bytes;
guint32 bytes_for_lcid[11];
guint32 sdus_for_lcid[11];
guint8 number_of_rars;
guint8 number_of_paging_ids;
/* Number of padding bytes includes padding subheaders and trailing padding */
guint16 padding_bytes;
guint16 raw_length;
} mac_lte_tap_info;
/*****************************************************************/ /*****************************************************************/
/* UDP framing format */ /* UDP framing format */
...@@ -153,12 +233,10 @@ typedef struct mac_lte_info { ...@@ -153,12 +233,10 @@ typedef struct mac_lte_info {
/* and implemented by this dissector, using the definitions */ /* and implemented by this dissector, using the definitions */
/* below. A link to an example program showing you how to encode */ /* below. A link to an example program showing you how to encode */
/* these headers and send LTE MAC PDUs on a UDP socket is */ /* these headers and send LTE MAC PDUs on a UDP socket is */
/* provided at http://wiki.wireshark.org/MAC-LTE */ /* provided at https://wiki.wireshark.org/MAC-LTE */
/* */ /* */
/* A heuristic dissecter (enabled by a preference) will */ /* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames . */ /* recognise a signature at the beginning of these frames. */
/* Until someone is using this format, suggestions for changes */
/* are welcome. */
/*****************************************************************/ /*****************************************************************/
...@@ -177,7 +255,7 @@ typedef struct mac_lte_info { ...@@ -177,7 +255,7 @@ typedef struct mac_lte_info {
to show you display/filter/plot/add-custom-columns on these fields, so should to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available. be added if available.
The format is to have the tag, followed by the value (there is no length field, The format is to have the tag, followed by the value (there is no length field,
its implicit from the tag) */ it's implicit from the tag) */
#define MAC_LTE_RNTI_TAG 0x02 #define MAC_LTE_RNTI_TAG 0x02
/* 2 bytes, network order */ /* 2 bytes, network order */
...@@ -185,8 +263,8 @@ typedef struct mac_lte_info { ...@@ -185,8 +263,8 @@ typedef struct mac_lte_info {
#define MAC_LTE_UEID_TAG 0x03 #define MAC_LTE_UEID_TAG 0x03
/* 2 bytes, network order */ /* 2 bytes, network order */
#define MAC_LTE_SUBFRAME_TAG 0x04 #define MAC_LTE_FRAME_SUBFRAME_TAG 0x04
/* 2 bytes, network order */ /* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */
#define MAC_LTE_PREDEFINED_DATA_TAG 0x05 #define MAC_LTE_PREDEFINED_DATA_TAG 0x05
/* 1 byte */ /* 1 byte */
...@@ -200,29 +278,101 @@ typedef struct mac_lte_info { ...@@ -200,29 +278,101 @@ typedef struct mac_lte_info {
#define MAC_LTE_EXT_BSR_SIZES_TAG 0x08 #define MAC_LTE_EXT_BSR_SIZES_TAG 0x08
/* 0 byte */ /* 0 byte */
#define MAC_LTE_OOB_EVENT_TAG 0x09 #define MAC_LTE_SEND_PREAMBLE_TAG 0x09
/* 3 byte */ /* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */
#define MAC_LTE_CARRIER_ID_TAG 0x0A
/* 1 byte */
#define MAC_LTE_PHY_TAG 0x0B
/* variable length, length (1 byte) then depending on direction
in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte),
RB start (1 byte), HARQ id (1 byte), NDI (1 byte)
in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte),
MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte),
HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG 0x0C
/* 0 byte */
#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D
/* 0 byte */
#define MAC_LTE_CE_MODE_TAG 0x0E
/* 1 byte containing mac_lte_ce_mode enum value */
#define MAC_LTE_NB_MODE_TAG 0x0F
/* 1 byte containing mac_lte_nb_mode enum value */
#define MAC_LTE_N_UL_RB_TAG 0x10
/* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */
#define MAC_LTE_SR_TAG 0x11
/* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */
/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU /* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
continues until the end of the frame) */ continues until the end of the frame) */
#define MAC_LTE_PAYLOAD_TAG 0x01 #define MAC_LTE_PAYLOAD_TAG 0x01
/* Set details of an LCID -> drb channel mapping. To be called from /* Type to store parameters for configuring LCID->RLC channel settings for DRB */
configuration protocol (e.g. RRC) */ /* Some are optional, and may not be seen (e.g. on reestablishment) */
/*void set_mac_lte_channel_mapping(guint16 ueid, guint8 lcid, typedef struct drb_mapping_t
guint8 srbid, guint8 drbid, {
guint8 rlcMode, guint8 um_sn_length, guint16 ueid; /* Mandatory */
guint8 ul_priority); guint8 drbid; /* Mandatory */
*/ gboolean lcid_present;
/* Functions to be called from outside this module (e.g. in a plugin, where mac_lte_info guint8 lcid; /* Part of LogicalChannelConfig - optional */
isn't available) to get/set per-packet data */ gboolean rlcMode_present;
//mac_lte_info *get_mac_lte_proto_data(packet_info *pinfo); guint8 rlcMode; /* Part of RLC config - optional */
//void set_mac_lte_proto_data(packet_info *pinfo, mac_lte_info *p_mac_lte_info); gboolean rlc_ul_ext_li_field; /* Part of RLC config - optional */
gboolean rlc_dl_ext_li_field; /* Part of RLC config - optional */
/* Function to attempt to populate p_mac_lte_info using framing definition above */ gboolean rlc_ul_ext_am_sn; /* Part of RLC config - optional */
/*gboolean dissect_mac_lte_context_fields(struct mac_lte_info *p_mac_lte_info, tvbuff_t *tvb, gboolean rlc_dl_ext_am_sn; /* Part of RLC config - optional */
gint *p_offset); gboolean um_sn_length_present;
*/ guint8 um_sn_length; /* Part of RLC config - optional */
gboolean ul_priority_present;
#endif /* PACKET_MAC_LTE_H_ */ guint8 ul_priority; /* Part of LogicalChannelConfig - optional */
gboolean pdcp_sn_size_present;
guint8 pdcp_sn_size; /* Part of pdcp-Config - optional */
} drb_mapping_t;
/* Dedicated DRX config. Used to verify that a sensible config is given.
Also, beginning to configure MAC with this config and (optionally) show
DRX config and state (cycles/timers) attached to each UL/DL PDU! */
typedef struct drx_config_t {
gboolean configured;
guint32 frameNum;
guint32 previousFrameNum;
guint32 onDurationTimer;
guint32 inactivityTimer;
guint32 retransmissionTimer;
guint32 longCycle;
guint32 cycleOffset;
/* Optional Short cycle */
gboolean shortCycleConfigured;
guint32 shortCycle;
guint32 shortCycleTimer;
} drx_config_t;
/* RRC can indicate whether simultaneous PUCCH/PUSCH is used */
typedef enum {
SIMULT_PUCCH_PUSCH_PCELL = 0,
SIMULT_PUCCH_PUSCH_PSCELL
} simult_pucch_pusch_cell_type;
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
...@@ -95,26 +95,22 @@ what about the implementation ...@@ -95,26 +95,22 @@ what about the implementation
int opt_enabled=0; int opt_enabled=0;
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
typedef uint8_t guint8;
typedef uint16_t guint16;
typedef uint32_t guint32;
typedef guint8 gboolean;
#include "packet-mac-lte.h"
#include "mac_pcap.h"
//static unsigned char g_PDUBuffer[1600]; //static unsigned char g_PDUBuffer[1600];
//static unsigned int g_PDUOffset; //static unsigned int g_PDUOffset;
char in_ip[40]; char in_ip[40];
char in_path[100]; char in_path[FILENAME_MAX];
FILE *file_fd = NULL; FILE *file_fd = NULL;
pcap_hdr_t file_header = {
0xa1b2c3d4, /* magic number */
2, 4, /* version number is 2.4 */
0, /* timezone */
0, /* sigfigs - apparently all tools do this */
65535, /* snaplen - this should be long enough */
MAC_LTE_DLT /* Data Link Type (DLT). Set as unused value 147 for now */
};
trace_mode_t opt_type = OPT_NONE; trace_mode_t opt_type = OPT_NONE;
static radio_type_t radio_type;
static unsigned int subframesSinceCaptureStart; static unsigned int subframesSinceCaptureStart;
static int g_socksd = -1;/* UDP socket used for sending frames */ static int g_socksd = -1;/* UDP socket used for sending frames */
...@@ -237,22 +233,13 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, ...@@ -237,22 +233,13 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
guint8 oob_event, guint8 oob_event_value, guint8 oob_event, guint8 oob_event_value,
uint8_t *pdu_buffer, unsigned int pdu_buffer_size) uint8_t *pdu_buffer, unsigned int pdu_buffer_size)
{ {
#ifdef JUMBO_FRAME unsigned char frameBuffer[9000];
static unsigned char frameBuffer[9000]; unsigned int frameOffset;
#else
static unsigned char frameBuffer[1600];
#endif
static unsigned int frameOffset;
ssize_t bytesSent; ssize_t bytesSent;
frameOffset = 0; frameOffset = 0;
uint16_t tmp16; uint16_t tmp16;
/********************************************************************/
/* Fixed start to each frame (allowing heuristic dissector to work) */
/* Not NULL terminated */
memset(frameBuffer+frameOffset, 0, sizeof(mac_lte_info)+pdu_buffer_size + 8);
memcpy(frameBuffer+frameOffset, MAC_LTE_START_STRING, memcpy(frameBuffer+frameOffset, MAC_LTE_START_STRING,
strlen(MAC_LTE_START_STRING)); strlen(MAC_LTE_START_STRING));
frameOffset += strlen(MAC_LTE_START_STRING); frameOffset += strlen(MAC_LTE_START_STRING);
...@@ -279,7 +266,7 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, ...@@ -279,7 +266,7 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
frameOffset += 2; frameOffset += 2;
/* Subframe number */ /* Subframe number */
frameBuffer[frameOffset++] = MAC_LTE_SUBFRAME_TAG; frameBuffer[frameOffset++] = MAC_LTE_FRAME_SUBFRAME_TAG;
tmp16 = htons(sfnSf); // frame counter : this will give an expert info as wireshark expects SF and not F tmp16 = htons(sfnSf); // frame counter : this will give an expert info as wireshark expects SF and not F
memcpy(frameBuffer+frameOffset, &tmp16, 2); memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2; frameOffset += 2;
...@@ -313,26 +300,29 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType, ...@@ -313,26 +300,29 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
if (pdu_buffer_size==0) { if (pdu_buffer_size==0) {
switch (oob_event) { switch (oob_event) {
case ltemac_send_preamble : case ltemac_send_preamble :
LOG_D(OPT,"oob ltemac_send_preamble event %02x." LOG_D(OPT,"ltemac_send_preamble event %02x."
//"%02x." //"%02x."
"%02x.%02x\n", "%02x.%02x\n",
MAC_LTE_OOB_EVENT_TAG, MAC_LTE_SEND_PREAMBLE_TAG,
//ltemac_send_preamble, //ltemac_send_preamble,
rnti, rnti,
oob_event_value); oob_event_value);
//frameBuffer[frameOffset++]=0; //frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0; //frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0; //frameBuffer[frameOffset++]=0;
frameBuffer[frameOffset++] = MAC_LTE_OOB_EVENT_TAG; frameBuffer[frameOffset++] = MAC_LTE_SEND_PREAMBLE_TAG;
//frameBuffer[frameOffset++]=ltemac_send_preamble; //frameBuffer[frameOffset++]=ltemac_send_preamble;
frameBuffer[frameOffset++]=rnti; // is the preamble frameBuffer[frameOffset++]=rnti; // is the preamble
frameBuffer[frameOffset++]=oob_event_value; frameBuffer[frameOffset++]=oob_event_value;
break; break;
case ltemac_send_sr: case ltemac_send_sr:
frameBuffer[frameOffset++]=ltemac_send_sr; frameBuffer[frameOffset++]=MAC_LTE_SR_TAG ;
frameOffset+=2; frameOffset+=2;
frameBuffer[frameOffset++]=rnti;
frameOffset++;
frameBuffer[frameOffset++]=oob_event_value; frameBuffer[frameOffset++]=oob_event_value;
frameOffset++;
break; break;
case ltemac_sr_failure: case ltemac_sr_failure:
...@@ -394,7 +384,7 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, ...@@ -394,7 +384,7 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context,
offset += 2; offset += 2;
/* Subframe number */ /* Subframe number */
context_header[offset++] = MAC_LTE_SUBFRAME_TAG; context_header[offset++] = MAC_LTE_FRAME_SUBFRAME_TAG;
tmp16 = htons(context->subFrameNumber); tmp16 = htons(context->subFrameNumber);
memcpy(context_header+offset, &tmp16, 2); memcpy(context_header+offset, &tmp16, 2);
offset += 2; offset += 2;
...@@ -423,21 +413,27 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, ...@@ -423,21 +413,27 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context,
return 1; return 1;
} }
#include <common/ran_context.h>
extern RAN_CONTEXT_t RC;
#include <openair1/PHY/phy_extern_ue.h>
/* Remote serveraddress (where Wireshark is running) */ /* Remote serveraddress (where Wireshark is running) */
void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event, int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event,
int oob_event_value) int oob_event_value)
{ {
MAC_Context_Info_t pdu_context; MAC_Context_Info_t pdu_context;
int radioType=FDD_RADIO;
if (RC.eNB[0][0]!=NULL)
radioType=RC.eNB[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
if (PHY_vars_UE_g[0][0] != NULL)
radioType=PHY_vars_UE_g[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
switch (opt_type) { switch (opt_type) {
case OPT_WIRESHARK : case OPT_WIRESHARK :
if (g_socksd == -1) { if (g_socksd == -1) {
return; return;
} }
SendFrame(radio_type, SendFrame( radioType,
(direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK, (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK,
rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber, rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber,
1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus 1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus
...@@ -450,7 +446,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, ...@@ -450,7 +446,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
return; return;
} }
pdu_context.radioType = radio_type; pdu_context.radioType = radioType;
pdu_context.direction = (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK pdu_context.direction = (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK
: DIRECTION_UPLINK; : DIRECTION_UPLINK;
pdu_context.rntiType = rntiType; pdu_context.rntiType = rntiType;
...@@ -470,7 +466,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, ...@@ -470,7 +466,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
} }
} }
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p) int init_opt(char *path, char *ip)
{ {
uint16_t in_port; uint16_t in_port;
subframesSinceCaptureStart = 0; subframesSinceCaptureStart = 0;
...@@ -489,13 +485,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p) ...@@ -489,13 +485,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p)
strcpy( in_ip, "127.0.0.1" ); strcpy( in_ip, "127.0.0.1" );
} }
if (port != NULL) { in_port = PACKET_MAC_LTE_DEFAULT_UDP_PORT;
in_port = atoi(port);
} else {
in_port = PACKET_MAC_LTE_DEFAULT_UDP_PORT;
}
radio_type = radio_type_p;
// trace_mode // trace_mode
switch (opt_type) { switch (opt_type) {
......
/* ws_compiler_tests.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __WS_COMPILER_TESTS_H__
#define __WS_COMPILER_TESTS_H__
/*
* This was introduced by Clang:
*
* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
*
* in some version (which version?); it has been picked up by GCC 5.0.
*/
#ifndef __has_attribute
/*
* It's a macro, so you can check whether it's defined to check
* whether it's supported.
*
* If it's not, define it to always return 0, so that we move on to
* the fallback checks.
*/
#define __has_attribute(x) 0
#endif
/*
* Note that the C90 spec's "6.8.1 Conditional inclusion" and the
* C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
*
* Prior to evaluation, macro invocations in the list of preprocessing
* tokens that will become the controlling constant expression are
* replaced (except for those macro names modified by the defined unary
* operator), just as in normal text. If the token "defined" is
* generated as a result of this replacement process or use of the
* "defined" unary operator does not match one of the two specified
* forms prior to macro replacement, the behavior is undefined.
*
* so you shouldn't use defined() in a #define that's used in #if or
* #elif. Some versions of Clang, for example, will warn about this.
*
* Instead, we check whether the pre-defined macros for particular
* compilers are defined and, if not, define the "is this version XXX
* or a later version of this compiler" macros as 0.
*/
/*
* Check whether this is GCC major.minor or a later release, or some
* compiler that claims to be "just like GCC" of that version or a
* later release.
*/
#if !defined(__GNUC__)
#define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
#else
#define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) \
(__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#endif
/*
* Check whether this is Clang major.minor or a later release.
*/
#if !defined(__clang__)
#define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
#else
#define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) \
(__clang_major__ > (major) || \
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
#endif
/*
* Check whether this is Sun C/SunPro C/Oracle Studio major.minor
* or a later release.
*
* The version number in __SUNPRO_C is encoded in hex BCD, with the
* uppermost hex digit being the major version number, the next
* one or two hex digits being the minor version number, and
* the last digit being the patch version.
*
* It represents the *compiler* version, not the product version;
* see
*
* https://sourceforge.net/p/predef/wiki/Compilers/
*
* for a partial mapping, which we assume continues for later
* 12.x product releases.
*/
#if !defined(__SUNPRO_C)
#define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) 0
#else
#define WS_SUNPRO_VERSION_TO_BCD(major, minor) \
(((minor) >= 10) ? \
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
(((major) << 8) | ((minor) << 4)))
#define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) \
(__SUNPRO_C >= WS_SUNPRO_VERSION_TO_BCD((major), (minor)))
#endif
/*
* Check whether this is IBM XL C major.minor or a later release.
*
* The version number in __xlC__ has the major version in the
* upper 8 bits and the minor version in the lower 8 bits.
*/
#if !defined(__xlC__)
#define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) 0
#else
#define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__xlC__ >= (((major) << 8) | (minor)))
#endif
/*
* Check whether this is HP aC++/HP C major.minor or a later release.
*
* The version number in __HP_aCC is encoded in zero-padded decimal BCD,
* with the "A." stripped off, the uppermost two decimal digits being
* the major version number, the next two decimal digits being the minor
* version number, and the last two decimal digits being the patch version.
* (Strip off the A., remove the . between the major and minor version
* number, and add two digits of patch.)
*/
#if !defined(__HP_aCC)
#define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) 0
#else
#define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) \
(__HP_aCC >= ((major)*10000 + (minor)*100))
#endif
#endif /* __WS_COMPILER_TESTS_H__ */
/*
* Cross platform defines for exporting symbols from shared libraries
*
* Wireshark - Network traffic analyzer
* By Balint Reczey <balint@balintreczey.hu>
* Copyright 2013 Balint Reczey
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "ws_compiler_tests.h"
/** Reset symbol export behavior.
* If you {un}define WS_BUILD_DLL on the fly you'll have to define this
* as well.
*/
#ifdef RESET_SYMBOL_EXPORT
#ifdef SYMBOL_EXPORT_H
#undef SYMBOL_EXPORT_H
#endif
#ifdef WS_DLL_PUBLIC
#undef WS_DLL_PUBLIC
#endif
#ifdef WS_DLL_PUBLIC_DEF
#undef WS_DLL_PUBLIC_DEF
#endif
#ifdef WS_DLL_LOCAL
#undef WS_DLL_LOCAL
#endif
#endif /* RESET_SYMBOL_EXPORT */
#ifndef SYMBOL_EXPORT_H
#define SYMBOL_EXPORT_H
/*
* NOTE: G_HAVE_GNUC_VISIBILITY is defined only if all of
*
* __attribute__ ((visibility ("hidden")))
*
* __attribute__ ((visibility ("internal")))
*
* __attribute__ ((visibility ("protected")))
*
* __attribute__ ((visibility ("default")))
*
* are supported, and at least some versions of GCC from Apple support
* "default" and "hidden" but not "internal" or "protected", so it
* shouldn't be used to determine whether "hidden" or "default" is
* supported.
*
* This also means that we shouldn't use G_GNUC_INTERNAL instead of
* WS_DLL_LOCAL, as GLib uses G_HAVE_GNUC_VISIBILITY to determine
* whether to use __attribute__ ((visibility ("hidden"))) for
* G_GNUC_INTERNAL, and that will not use it even with compilers
* that support it.
*/
/* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
#if defined _WIN32 || defined __CYGWIN__
/* Compiling for Windows, so we use the Windows DLL declarations. */
#ifdef WS_BUILD_DLL
/*
* Building a DLL; for all definitions, we want dllexport, and
* (presumably so source from DLL and source from a program using the
* DLL can both include a header that declares APIs and exported data
* for the DLL), for declarations, either dllexport or dllimport will
* work (they mean the same thing for a declaration when building a DLL).
*/
#ifdef __GNUC__
/* GCC */
#define WS_DLL_PUBLIC_DEF __attribute__ ((dllexport))
#else /* ! __GNUC__ */
/*
* Presumably MSVC.
* Note: actually gcc seems to also support this syntax.
*/
#define WS_DLL_PUBLIC_DEF __declspec(dllexport)
#endif /* __GNUC__ */
#else /* WS_BUILD_DLL */
/*
* Building a program; we should only see declarations, not definitions,
* with WS_DLL_PUBLIC, and they all represent APIs or data imported
* from a DLL, so use dllimport.
*
* For functions, export shouldn't be necessary; for data, it might
* be necessary, e.g. if what's declared is an array whose size is
* not given in the declaration.
*/
#ifdef __GNUC__
/* GCC */
#define WS_DLL_PUBLIC_DEF __attribute__ ((dllimport))
#elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
/*
* Presumably MSVC, and we're not building all-static.
* Note: actually gcc seems to also support this syntax.
*/
#define WS_DLL_PUBLIC_DEF __declspec(dllimport)
#else /* ! __GNUC__ && ENABLE_STATIC */
/*
* Presumably MSVC, and we're building all-static, so we're
* not building any DLLs.
*/
#define WS_DLL_PUBLIC_DEF
#endif /* __GNUC__ */
#endif /* WS_BUILD_DLL */
/*
* Symbols in a DLL are *not* exported unless they're specifically
* flagged as exported, so, for a non-static but non-exported
* symbol, we don't have to do anything.
*/
#define WS_DLL_LOCAL
#else /* defined _WIN32 || defined __CYGWIN__ */
/*
* Compiling for UN*X, where the dllimport and dllexport stuff
* is neither necessary nor supported; just specify the
* visibility if we have a compiler that supports doing so.
*/
#if WS_IS_AT_LEAST_GNUC_VERSION(3,4) \
|| WS_IS_AT_LEAST_XL_C_VERSION(12,0)
/*
* GCC 3.4 or later, or some compiler asserting compatibility with
* GCC 3.4 or later, or XL C 13.0 or later, so we have
* __attribute__((visibility()).
*/
/*
* Symbols exported from libraries.
*/
#define WS_DLL_PUBLIC_DEF __attribute__ ((visibility ("default")))
/*
* Non-static symbols *not* exported from libraries.
*/
#define WS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
#elif WS_IS_AT_LEAST_SUNC_VERSION(5,5)
/*
* Sun C 5.5 or later, so we have __global and __hidden.
* (Sun C 5.9 and later also have __attribute__((visibility()),
* but there's no reason to prefer it with Sun C.)
*/
/*
* Symbols exported from libraries.
*/
#define WS_DLL_PUBLIC_DEF __global
/*
* Non-static symbols *not* exported from libraries.
*/
#define WS_DLL_LOCAL __hidden
#else
/*
* We have neither a way to make stuff not explicitly marked as
* visible invisible outside a library nor a way to make stuff
* explicitly marked as local invisible outside the library.
*/
/*
* Symbols exported from libraries.
*/
#define WS_DLL_PUBLIC_DEF
/*
* Non-static symbols *not* exported from libraries.
*/
#define WS_DLL_LOCAL
#endif
#endif
/*
* You *must* use this for exported data *declarations*; if you use
* WS_DLL_PUBLIC_DEF, some compilers, such as MSVC++, will complain
* about array definitions with no size.
*
* You must *not* use this for exported data *definitions*, as that
* will, for some compilers, cause warnings about items being initialized
* and declared extern.
*
* Either can be used for exported *function* declarations and definitions.
*/
#define WS_DLL_PUBLIC WS_DLL_PUBLIC_DEF extern
#endif /* SYMBOL_EXPORT_H */
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
...@@ -975,14 +975,7 @@ int main( int argc, char **argv ) ...@@ -975,14 +975,7 @@ int main( int argc, char **argv )
#endif #endif
if (opt_type != OPT_NONE) { if (opt_type != OPT_NONE) {
radio_type_t radio_type; if (init_opt(in_path, in_ip) == -1)
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
LOG_E(OPT,"failed to run OPT \n"); LOG_E(OPT,"failed to run OPT \n");
} }
......
...@@ -862,14 +862,7 @@ int main( int argc, char **argv ) ...@@ -862,14 +862,7 @@ int main( int argc, char **argv )
#endif #endif
if (opt_type != OPT_NONE) { if (opt_type != OPT_NONE) {
radio_type_t radio_type; if (init_opt(in_path, in_ip) == -1)
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
LOG_E(OPT,"failed to run OPT \n"); LOG_E(OPT,"failed to run OPT \n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment