Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
9a6d30d7
Commit
9a6d30d7
authored
Oct 23, 2018
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
T: macpdu2wireshark: cleanup
- factorize - harmonize - simplify
parent
35a7e3a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
144 deletions
+61
-144
common/utils/T/tracer/macpdu2wireshark.c
common/utils/T/tracer/macpdu2wireshark.c
+61
-144
No files found.
common/utils/T/tracer/macpdu2wireshark.c
View file @
9a6d30d7
...
@@ -14,7 +14,10 @@
...
@@ -14,7 +14,10 @@
#define DEFAULT_IP "127.0.0.1"
#define DEFAULT_IP "127.0.0.1"
#define DEFAULT_PORT 9999
#define DEFAULT_PORT 9999
#define NO_PREAMBLE -1
int
no_sib
=
0
;
int
no_sib
=
0
;
int
no_mib
=
0
;
typedef
struct
{
typedef
struct
{
int
socket
;
int
socket
;
...
@@ -45,9 +48,9 @@ typedef struct {
...
@@ -45,9 +48,9 @@ typedef struct {
int
rar_data
;
int
rar_data
;
}
ev_data
;
}
ev_data
;
void
ul
(
void
*
_d
,
event
e
)
void
trace
(
ev_data
*
d
,
int
direction
,
int
rnti_type
,
int
rnti
,
int
frame
,
int
subframe
,
void
*
buf
,
int
bufsize
,
int
preamble
)
{
{
ev_data
*
d
=
_d
;
ssize_t
ret
;
ssize_t
ret
;
int
fsf
;
int
fsf
;
int
i
;
int
i
;
...
@@ -56,171 +59,88 @@ void ul(void *_d, event e)
...
@@ -56,171 +59,88 @@ void ul(void *_d, event e)
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
PUTC
(
&
d
->
buf
,
DIRECTION_UPLINK
);
PUTC
(
&
d
->
buf
,
direction
);
PUTC
(
&
d
->
buf
,
C_RNTI
);
PUTC
(
&
d
->
buf
,
rnti_type
);
PUTC
(
&
d
->
buf
,
MAC_LTE_RNTI_TAG
);
if
(
rnti_type
==
C_RNTI
||
rnti_type
==
RA_RNTI
)
{
PUTC
(
&
d
->
buf
,
(
e
.
e
[
d
->
ul_rnti
].
i
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
MAC_LTE_RNTI_TAG
);
PUTC
(
&
d
->
buf
,
e
.
e
[
d
->
ul_rnti
].
i
&
255
);
PUTC
(
&
d
->
buf
,
(
rnti
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
rnti
&
255
);
}
/* for newer version of wireshark? */
/* for newer version of wireshark? */
fsf
=
(
e
.
e
[
d
->
ul_frame
].
i
<<
4
)
+
e
.
e
[
d
->
ul_subframe
].
i
;
fsf
=
(
frame
<<
4
)
+
subframe
;
/* for older version? */
/* for older version? */
fsf
=
e
.
e
[
d
->
ul_subframe
].
i
;
//fsf = subframe
;
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
if
(
preamble
!=
NO_PREAMBLE
)
{
PUTC
(
&
d
->
buf
,
MAC_LTE_SEND_PREAMBLE_TAG
);
PUTC
(
&
d
->
buf
,
preamble
);
PUTC
(
&
d
->
buf
,
0
);
/* rach attempt - always 0 for us (not sure of this) */
}
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
for
(
i
=
0
;
i
<
e
.
e
[
d
->
ul_data
].
b
size
;
i
++
)
for
(
i
=
0
;
i
<
buf
size
;
i
++
)
PUTC
(
&
d
->
buf
,
((
char
*
)
e
.
e
[
d
->
ul_data
].
b
)[
i
]);
PUTC
(
&
d
->
buf
,
((
char
*
)
buf
)[
i
]);
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
}
}
void
ul
(
void
*
_d
,
event
e
)
{
ev_data
*
d
=
_d
;
trace
(
d
,
DIRECTION_UPLINK
,
C_RNTI
,
e
.
e
[
d
->
ul_rnti
].
i
,
e
.
e
[
d
->
ul_frame
].
i
,
e
.
e
[
d
->
ul_subframe
].
i
,
e
.
e
[
d
->
ul_data
].
b
,
e
.
e
[
d
->
ul_data
].
bsize
,
NO_PREAMBLE
);
}
void
dl
(
void
*
_d
,
event
e
)
void
dl
(
void
*
_d
,
event
e
)
{
{
ev_data
*
d
=
_d
;
ev_data
*
d
=
_d
;
ssize_t
ret
;
int
fsf
;
int
i
;
if
(
e
.
e
[
d
->
dl_rnti
].
i
==
0xffff
&&
no_sib
)
return
;
if
(
e
.
e
[
d
->
dl_rnti
].
i
==
0xffff
&&
no_sib
)
return
;
d
->
buf
.
osize
=
0
;
trace
(
d
,
DIRECTION_DOWNLINK
,
e
.
e
[
d
->
dl_rnti
].
i
!=
0xffff
?
C_RNTI
:
SI_RNTI
,
e
.
e
[
d
->
dl_rnti
].
i
,
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
e
.
e
[
d
->
dl_frame
].
i
,
e
.
e
[
d
->
dl_subframe
].
i
,
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
e
.
e
[
d
->
dl_data
].
b
,
e
.
e
[
d
->
dl_data
].
bsize
,
PUTC
(
&
d
->
buf
,
DIRECTION_DOWNLINK
);
NO_PREAMBLE
);
if
(
e
.
e
[
d
->
dl_rnti
].
i
!=
0xffff
)
{
PUTC
(
&
d
->
buf
,
C_RNTI
);
PUTC
(
&
d
->
buf
,
MAC_LTE_RNTI_TAG
);
PUTC
(
&
d
->
buf
,
(
e
.
e
[
d
->
dl_rnti
].
i
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
e
.
e
[
d
->
dl_rnti
].
i
&
255
);
}
else
{
PUTC
(
&
d
->
buf
,
SI_RNTI
);
}
/* for newer version of wireshark? */
fsf
=
(
e
.
e
[
d
->
dl_frame
].
i
<<
4
)
+
e
.
e
[
d
->
dl_subframe
].
i
;
/* for older version? */
//fsf = e.e[d->dl_subframe].i;
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
for
(
i
=
0
;
i
<
e
.
e
[
d
->
dl_data
].
bsize
;
i
++
)
PUTC
(
&
d
->
buf
,
((
char
*
)
e
.
e
[
d
->
dl_data
].
b
)[
i
]);
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
}
}
void
mib
(
void
*
_d
,
event
e
)
void
mib
(
void
*
_d
,
event
e
)
{
{
ev_data
*
d
=
_d
;
ev_data
*
d
=
_d
;
ssize_t
ret
;
int
fsf
;
int
i
;
d
->
buf
.
osize
=
0
;
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
PUTC
(
&
d
->
buf
,
DIRECTION_DOWNLINK
);
PUTC
(
&
d
->
buf
,
NO_RNTI
);
/* for newer version of wireshark? */
fsf
=
(
e
.
e
[
d
->
mib_frame
].
i
<<
4
)
+
e
.
e
[
d
->
mib_subframe
].
i
;
/* for older version? */
//fsf = e.e[d->mib_subframe].i;
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
if
(
no_mib
)
return
;
for
(
i
=
0
;
i
<
e
.
e
[
d
->
mib_data
].
bsize
;
i
++
)
PUTC
(
&
d
->
buf
,
((
char
*
)
e
.
e
[
d
->
mib_data
].
b
)[
i
]);
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
trace
(
d
,
DIRECTION_DOWNLINK
,
NO_RNTI
,
0
,
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
e
.
e
[
d
->
mib_frame
].
i
,
e
.
e
[
d
->
mib_subframe
].
i
,
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
e
.
e
[
d
->
mib_data
].
b
,
e
.
e
[
d
->
mib_data
].
bsize
,
NO_PREAMBLE
);
}
}
void
preamble
(
void
*
_d
,
event
e
)
void
preamble
(
void
*
_d
,
event
e
)
{
{
ev_data
*
d
=
_d
;
ev_data
*
d
=
_d
;
ssize_t
ret
;
trace
(
d
,
DIRECTION_UPLINK
,
NO_RNTI
,
0
,
int
fsf
;
e
.
e
[
d
->
preamble_frame
].
i
,
e
.
e
[
d
->
preamble_subframe
].
i
,
NULL
,
0
,
d
->
buf
.
osize
=
0
;
e
.
e
[
d
->
preamble_preamble
].
i
);
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
PUTC
(
&
d
->
buf
,
DIRECTION_UPLINK
);
PUTC
(
&
d
->
buf
,
NO_RNTI
);
/* for newer version of wireshark? */
fsf
=
(
e
.
e
[
d
->
preamble_frame
].
i
<<
4
)
+
e
.
e
[
d
->
preamble_subframe
].
i
;
/* for older version? */
//fsf = e.e[d->preamble_subframe].i;
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
PUTC
(
&
d
->
buf
,
MAC_LTE_SEND_PREAMBLE_TAG
);
PUTC
(
&
d
->
buf
,
e
.
e
[
d
->
preamble_preamble
].
i
);
PUTC
(
&
d
->
buf
,
0
);
/* rach attempt - always 0 for us (not sure of this) */
/* if we don't put this (even with no data) wireshark (2.4.5) is not happy */
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
}
}
void
rar
(
void
*
_d
,
event
e
)
void
rar
(
void
*
_d
,
event
e
)
{
{
ev_data
*
d
=
_d
;
ev_data
*
d
=
_d
;
ssize_t
ret
;
trace
(
d
,
DIRECTION_DOWNLINK
,
RA_RNTI
,
e
.
e
[
d
->
rar_rnti
].
i
,
int
fsf
;
e
.
e
[
d
->
rar_frame
].
i
,
e
.
e
[
d
->
rar_subframe
].
i
,
int
i
;
e
.
e
[
d
->
rar_data
].
b
,
e
.
e
[
d
->
rar_data
].
bsize
,
NO_PREAMBLE
);
if
(
e
.
e
[
d
->
rar_rnti
].
i
==
0xffff
&&
no_sib
)
return
;
d
->
buf
.
osize
=
0
;
PUTS
(
&
d
->
buf
,
MAC_LTE_START_STRING
);
PUTC
(
&
d
->
buf
,
FDD_RADIO
);
PUTC
(
&
d
->
buf
,
DIRECTION_DOWNLINK
);
PUTC
(
&
d
->
buf
,
RA_RNTI
);
PUTC
(
&
d
->
buf
,
MAC_LTE_RNTI_TAG
);
PUTC
(
&
d
->
buf
,
(
e
.
e
[
d
->
rar_rnti
].
i
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
e
.
e
[
d
->
rar_rnti
].
i
&
255
);
/* for newer version of wireshark? */
fsf
=
(
e
.
e
[
d
->
rar_frame
].
i
<<
4
)
+
e
.
e
[
d
->
rar_subframe
].
i
;
/* for older version? */
//fsf = e.e[d->rar_subframe].i;
PUTC
(
&
d
->
buf
,
MAC_LTE_FRAME_SUBFRAME_TAG
);
PUTC
(
&
d
->
buf
,
(
fsf
>>
8
)
&
255
);
PUTC
(
&
d
->
buf
,
fsf
&
255
);
PUTC
(
&
d
->
buf
,
MAC_LTE_PAYLOAD_TAG
);
for
(
i
=
0
;
i
<
e
.
e
[
d
->
rar_data
].
bsize
;
i
++
)
PUTC
(
&
d
->
buf
,
((
char
*
)
e
.
e
[
d
->
rar_data
].
b
)[
i
]);
ret
=
sendto
(
d
->
socket
,
d
->
buf
.
obuf
,
d
->
buf
.
osize
,
0
,
(
struct
sockaddr
*
)
&
d
->
to
,
sizeof
(
struct
sockaddr_in
));
if
(
ret
!=
d
->
buf
.
osize
)
abort
();
}
}
void
setup_data
(
ev_data
*
d
,
void
*
database
,
int
ul_id
,
int
dl_id
,
int
mib_id
,
void
setup_data
(
ev_data
*
d
,
void
*
database
,
int
ul_id
,
int
dl_id
,
int
mib_id
,
...
@@ -281,17 +201,15 @@ void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
...
@@ -281,17 +201,15 @@ void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
if
(
d
->
dl_rnti
==
-
1
||
d
->
dl_frame
==
-
1
||
d
->
dl_subframe
==
-
1
||
if
(
d
->
dl_rnti
==
-
1
||
d
->
dl_frame
==
-
1
||
d
->
dl_subframe
==
-
1
||
d
->
dl_data
==
-
1
)
goto
error
;
d
->
dl_data
==
-
1
)
goto
error
;
if
(
mib_id
!=
-
1
)
{
/* MIB: frame, subframe, data */
/* MIB: frame, subframe, data */
f
=
get_format
(
database
,
mib_id
);
f
=
get_format
(
database
,
mib_id
);
for
(
i
=
0
;
i
<
f
.
count
;
i
++
)
{
for
(
i
=
0
;
i
<
f
.
count
;
i
++
)
{
G
(
"frame"
,
"int"
,
d
->
mib_frame
);
G
(
"frame"
,
"int"
,
d
->
mib_frame
);
G
(
"subframe"
,
"int"
,
d
->
mib_subframe
);
G
(
"subframe"
,
"int"
,
d
->
mib_subframe
);
G
(
"data"
,
"buffer"
,
d
->
mib_data
);
G
(
"data"
,
"buffer"
,
d
->
mib_data
);
}
if
(
d
->
mib_frame
==
-
1
||
d
->
mib_subframe
==
-
1
||
d
->
mib_data
==
-
1
)
goto
error
;
}
}
if
(
d
->
mib_frame
==
-
1
||
d
->
mib_subframe
==
-
1
||
d
->
mib_data
==
-
1
)
goto
error
;
/* preamble: frame, subframe, preamble */
/* preamble: frame, subframe, preamble */
f
=
get_format
(
database
,
preamble_id
);
f
=
get_format
(
database
,
preamble_id
);
...
@@ -370,7 +288,6 @@ int main(int n, char **v)
...
@@ -370,7 +288,6 @@ int main(int n, char **v)
ev_data
d
;
ev_data
d
;
char
*
ip
=
DEFAULT_IP
;
char
*
ip
=
DEFAULT_IP
;
int
port
=
DEFAULT_PORT
;
int
port
=
DEFAULT_PORT
;
int
do_mib
=
1
;
memset
(
&
d
,
0
,
sizeof
(
ev_data
));
memset
(
&
d
,
0
,
sizeof
(
ev_data
));
...
@@ -382,7 +299,7 @@ int main(int n, char **v)
...
@@ -382,7 +299,7 @@ int main(int n, char **v)
{
if
(
i
>
n
-
2
)
usage
();
input_filename
=
v
[
++
i
];
continue
;
}
{
if
(
i
>
n
-
2
)
usage
();
input_filename
=
v
[
++
i
];
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-ip"
))
{
if
(
i
>
n
-
2
)
usage
();
ip
=
v
[
++
i
];
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-ip"
))
{
if
(
i
>
n
-
2
)
usage
();
ip
=
v
[
++
i
];
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-p"
))
{
if
(
i
>
n
-
2
)
usage
();
port
=
atoi
(
v
[
++
i
]);
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-p"
))
{
if
(
i
>
n
-
2
)
usage
();
port
=
atoi
(
v
[
++
i
]);
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-no-mib"
))
{
do_mib
=
0
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-no-mib"
))
{
no_mib
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-no-sib"
))
{
no_sib
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-no-sib"
))
{
no_sib
=
1
;
continue
;
}
usage
();
usage
();
}
}
...
@@ -407,14 +324,14 @@ int main(int n, char **v)
...
@@ -407,14 +324,14 @@ int main(int n, char **v)
ul_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_UL_PDU_WITH_DATA"
);
ul_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_UL_PDU_WITH_DATA"
);
dl_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_DL_PDU_WITH_DATA"
);
dl_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_DL_PDU_WITH_DATA"
);
if
(
do_mib
)
mib_id
=
event_id_from_name
(
database
,
"ENB_PHY_MIB"
);
mib_id
=
event_id_from_name
(
database
,
"ENB_PHY_MIB"
);
preamble_id
=
event_id_from_name
(
database
,
"ENB_PHY_INITIATE_RA_PROCEDURE"
);
preamble_id
=
event_id_from_name
(
database
,
"ENB_PHY_INITIATE_RA_PROCEDURE"
);
rar_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_DL_RAR_PDU_WITH_DATA"
);
rar_id
=
event_id_from_name
(
database
,
"ENB_MAC_UE_DL_RAR_PDU_WITH_DATA"
);
setup_data
(
&
d
,
database
,
ul_id
,
dl_id
,
mib_id
,
preamble_id
,
rar_id
);
setup_data
(
&
d
,
database
,
ul_id
,
dl_id
,
mib_id
,
preamble_id
,
rar_id
);
register_handler_function
(
h
,
ul_id
,
ul
,
&
d
);
register_handler_function
(
h
,
ul_id
,
ul
,
&
d
);
register_handler_function
(
h
,
dl_id
,
dl
,
&
d
);
register_handler_function
(
h
,
dl_id
,
dl
,
&
d
);
if
(
do_mib
)
register_handler_function
(
h
,
mib_id
,
mib
,
&
d
);
register_handler_function
(
h
,
mib_id
,
mib
,
&
d
);
register_handler_function
(
h
,
preamble_id
,
preamble
,
&
d
);
register_handler_function
(
h
,
preamble_id
,
preamble
,
&
d
);
register_handler_function
(
h
,
rar_id
,
rar
,
&
d
);
register_handler_function
(
h
,
rar_id
,
rar
,
&
d
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment