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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
canghaiwuhen
OpenXG-RAN
Commits
d171e18c
Commit
d171e18c
authored
Jan 22, 2019
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some cppcheck errors and warnings in config module and T Tracer
parent
974167b5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
341 additions
and
159 deletions
+341
-159
common/config/config_cmdline.c
common/config/config_cmdline.c
+1
-1
common/config/config_load_configmodule.c
common/config/config_load_configmodule.c
+1
-1
common/utils/T/T.c
common/utils/T/T.c
+3
-3
common/utils/T/T.h
common/utils/T/T.h
+41
-40
common/utils/msc/msc.c
common/utils/msc/msc.c
+295
-114
No files found.
common/config/config_cmdline.c
View file @
d171e18c
...
@@ -171,7 +171,7 @@ int config_check_unknown_cmdlineopt(char *prefix) {
...
@@ -171,7 +171,7 @@ int config_check_unknown_cmdlineopt(char *prefix) {
if
(
strcmp
(
prefix
,
CONFIG_CHECKALLSECTIONS
)
==
0
)
if
(
strcmp
(
prefix
,
CONFIG_CHECKALLSECTIONS
)
==
0
)
finalcheck
=
1
;
finalcheck
=
1
;
else
if
(
strlen
(
prefix
)
>
0
)
{
else
if
(
strlen
(
prefix
)
>
0
)
{
sprintf
(
testprefix
,
"--%
s."
,
prefix
);
sprintf
(
testprefix
,
"--%
.*s."
,
CONFIG_MAXOPTLENGTH
-
1
,
prefix
);
}
}
}
}
...
...
common/config/config_load_configmodule.c
View file @
d171e18c
...
@@ -345,7 +345,7 @@ void free_configmodule(void) {
...
@@ -345,7 +345,7 @@ void free_configmodule(void) {
if
(
cfgptr
->
cfgmode
!=
NULL
)
free
(
cfgptr
->
cfgmode
);
if
(
cfgptr
->
cfgmode
!=
NULL
)
free
(
cfgptr
->
cfgmode
);
printf
(
"[CONFIG] free %
u
config parameter pointers
\n
"
,
cfgptr
->
num_cfgP
);
printf
(
"[CONFIG] free %
i
config parameter pointers
\n
"
,
cfgptr
->
num_cfgP
);
for
(
int
i
=
0
;
i
<
cfgptr
->
num_cfgP
;
i
++
)
{
for
(
int
i
=
0
;
i
<
cfgptr
->
num_cfgP
;
i
++
)
{
if
(
cfgptr
->
cfgP
[
i
]
!=
NULL
)
free
(
cfgptr
->
cfgP
[
i
]);
if
(
cfgptr
->
cfgP
[
i
]
!=
NULL
)
free
(
cfgptr
->
cfgP
[
i
]);
...
...
common/utils/T/T.c
View file @
d171e18c
...
@@ -202,9 +202,9 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) {
...
@@ -202,9 +202,9 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) {
}
}
void
T_Config_Init
(
void
)
{
void
T_Config_Init
(
void
)
{
int
T_port
;
/* by default we wait for the tracer */
int
T_port
=
TTRACER_DEFAULT_PORTNUM
;
/* by default we wait for the tracer */
int
T_nowait
;
/* default port to listen to to wait for the tracer */
int
T_nowait
=
0
;
/* default port to listen to to wait for the tracer */
int
T_dont_fork
;
/* default is to fork, see 'T_init' to understand */
int
T_dont_fork
=
0
;
/* default is to fork, see 'T_init' to understand */
paramdef_t
ttraceparams
[]
=
CMDLINE_TTRACEPARAMS_DESC
;
paramdef_t
ttraceparams
[]
=
CMDLINE_TTRACEPARAMS_DESC
;
/* for a cleaner config file, TTracer params should be defined in a
/* for a cleaner config file, TTracer params should be defined in a
* specific section...
* specific section...
...
...
common/utils/T/T.h
View file @
d171e18c
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include "T_defs.h"
#include "T_defs.h"
#ifdef T_SEND_TIME
#ifdef T_SEND_TIME
#include <time.h>
#include <time.h>
#endif
#endif
/* T message IDs */
/* T message IDs */
...
@@ -598,20 +598,21 @@ extern int *T_active;
...
@@ -598,20 +598,21 @@ extern int *T_active;
#define TTRACER_CONFIG_PREFIX "TTracer"
#define TTRACER_CONFIG_PREFIX "TTracer"
/*------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------
-------
*/
/* configuration parameters for TTRACE utility */
/* configuration parameters for TTRACE utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*------------------------------------------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------------------------------------*/
#define TTRACER_DEFAULT_PORTNUM 2021
#define CMDLINE_TTRACEPARAMS_DESC { \
#define CMDLINE_TTRACEPARAMS_DESC { \
{"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:2021, TYPE_INT, 0},
\
{"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:TTRACER_DEFAULT_PORTNUM, TYPE_INT, 0},
\
{"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0},
\
{"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0},
\
{"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0},
\
{"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0},
\
{"T_stdout", CONFIG_HLP_STDOUT, PARAMFLAG_BOOL, iptr:&T_stdout, defintval:1, TYPE_INT, 0},
\
{"T_stdout", CONFIG_HLP_STDOUT, PARAMFLAG_BOOL, iptr:&T_stdout, defintval:1, TYPE_INT, 0},
\
}
}
/* log on stdout */
/* log on stdout */
void
T_init
(
int
remote_port
,
int
wait_for_tracer
,
int
dont_fork
);
void
T_init
(
int
remote_port
,
int
wait_for_tracer
,
int
dont_fork
);
void
T_Config_Init
(
void
);
void
T_Config_Init
(
void
);
#else
/* T_TRACER */
#else
/* T_TRACER */
...
...
common/utils/msc/msc.c
View file @
d171e18c
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
//-------------------------------
//-------------------------------
FILE
*
g_msc_fd
;
FILE
*
g_msc_fd
;
char
g_msc_proto2str
[
MAX_MSC_PROTOS
][
MSC_MAX_PROTO_NAME_LENGTH
];
char
g_msc_proto2str
[
MAX_MSC_PROTOS
][
MSC_MAX_PROTO_NAME_LENGTH
];
...
@@ -70,15 +70,11 @@ void *msc_task(void *args_p)
...
@@ -70,15 +70,11 @@ void *msc_task(void *args_p)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
{
{
MessageDef
*
received_message_p
=
NULL
;
MessageDef
*
received_message_p
=
NULL
;
// const char *msg_name = NULL;
// const char *msg_name = NULL;
// instance_t instance = 0;
// instance_t instance = 0;
long
timer_id
;
long
timer_id
;
itti_mark_task_ready
(
TASK_MSC
);
itti_mark_task_ready
(
TASK_MSC
);
msc_start_use
();
msc_start_use
();
timer_setup
(
0
,
// seconds
timer_setup
(
0
,
// seconds
50000
,
// usec
50000
,
// usec
TASK_MSC
,
TASK_MSC
,
...
@@ -91,11 +87,9 @@ void *msc_task(void *args_p)
...
@@ -91,11 +87,9 @@ void *msc_task(void *args_p)
itti_receive_msg
(
TASK_MSC
,
&
received_message_p
);
itti_receive_msg
(
TASK_MSC
,
&
received_message_p
);
if
(
received_message_p
!=
NULL
)
{
if
(
received_message_p
!=
NULL
)
{
// msg_name = ITTI_MSG_NAME (received_message_p);
// msg_name = ITTI_MSG_NAME (received_message_p);
// instance = ITTI_MSG_INSTANCE (received_message_p);
// instance = ITTI_MSG_INSTANCE (received_message_p);
switch
(
ITTI_MSG_ID
(
received_message_p
))
{
switch
(
ITTI_MSG_ID
(
received_message_p
))
{
case
TIMER_HAS_EXPIRED
:
{
case
TIMER_HAS_EXPIRED
:
{
msc_flush_messages
();
msc_flush_messages
();
}
}
...
@@ -119,6 +113,7 @@ void *msc_task(void *args_p)
...
@@ -119,6 +113,7 @@ void *msc_task(void *args_p)
}
}
}
}
}
}
fprintf
(
stderr
,
"Task MSC exiting
\n
"
);
fprintf
(
stderr
,
"Task MSC exiting
\n
"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -132,15 +127,16 @@ int msc_init(const msc_env_t envP, const int max_threadsP)
...
@@ -132,15 +127,16 @@ int msc_init(const msc_env_t envP, const int max_threadsP)
void
*
pointer_p
;
void
*
pointer_p
;
char
msc_filename
[
256
];
char
msc_filename
[
256
];
fprintf
(
stderr
,
"Initializing MSC logs
\n
"
);
fprintf
(
stderr
,
"Initializing MSC logs
\n
"
);
rv
=
snprintf
(
msc_filename
,
256
,
"/tmp/openair.msc.%i.log"
,
envP
);
// TODO NAME
rv
=
snprintf
(
msc_filename
,
256
,
"/tmp/openair.msc.%u.log"
,
envP
);
// TODO NAME
if
((
0
>=
rv
)
||
(
256
<
rv
))
{
if
((
0
>=
rv
)
||
(
256
<
rv
)){
fprintf
(
stderr
,
"Error in MSC log file name"
);
fprintf
(
stderr
,
"Error in MSC log file name"
);
}
}
g_msc_fd
=
fopen
(
msc_filename
,
"w"
);
g_msc_fd
=
fopen
(
msc_filename
,
"w"
);
AssertFatal
(
g_msc_fd
!=
NULL
,
"Could not open MSC log file %s : %s"
,
msc_filename
,
strerror
(
errno
));
AssertFatal
(
g_msc_fd
!=
NULL
,
"Could not open MSC log file %s : %s"
,
msc_filename
,
strerror
(
errno
));
rv
=
lfds611_stack_new
(
&
g_msc_memory_stack_p
,
(
lfds611_atom_t
)
max_threadsP
+
2
);
rv
=
lfds611_stack_new
(
&
g_msc_memory_stack_p
,
(
lfds611_atom_t
)
max_threadsP
+
2
);
if
(
0
>=
rv
)
{
if
(
0
>=
rv
)
{
AssertFatal
(
0
,
"lfds611_stack_new failed!
\n
"
);
AssertFatal
(
0
,
"lfds611_stack_new failed!
\n
"
);
}
}
...
@@ -161,182 +157,335 @@ int msc_init(const msc_env_t envP, const int max_threadsP)
...
@@ -161,182 +157,335 @@ int msc_init(const msc_env_t envP, const int max_threadsP)
switch
(
i
)
{
switch
(
i
)
{
case
MSC_IP_UE
:
case
MSC_IP_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"IP_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"IP_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_IP_ENB
:
case
MSC_IP_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"IP_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"IP_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
(
envP
==
MSC_E_UTRAN_LIPA
)
{
if
(
envP
==
MSC_E_UTRAN_LIPA
)
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_NAS_UE
:
case
MSC_NAS_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_RRC_UE
:
case
MSC_RRC_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RRC_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RRC_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_PDCP_UE
:
case
MSC_PDCP_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PDCP_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PDCP_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_RLC_UE
:
case
MSC_RLC_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RLC_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RLC_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_MAC_UE
:
case
MSC_MAC_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MAC_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MAC_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_PHY_UE
:
case
MSC_PHY_UE
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PHY_UE"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PHY_UE"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_PHY_ENB
:
case
MSC_PHY_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PHY_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PHY_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_MAC_ENB
:
case
MSC_MAC_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MAC_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MAC_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_RLC_ENB
:
case
MSC_RLC_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RLC_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RLC_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_PDCP_ENB
:
case
MSC_PDCP_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PDCP_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"PDCP_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_RRC_ENB
:
case
MSC_RRC_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RRC_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"RRC_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_S1AP_ENB
:
case
MSC_S1AP_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S1AP_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S1AP_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_GTPU_ENB
:
case
MSC_GTPU_ENB
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"GTPU_ENB"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"GTPU_ENB"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_GTPU_SGW
:
case
MSC_GTPU_SGW
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"GTPU_SGW"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"GTPU_SGW"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_S1AP_MME
:
case
MSC_S1AP_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S1AP_MME"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S1AP_MME"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
)
||
(
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
)
||
(
envP
==
MSC_E_UTRAN
)
||
(
envP
==
MSC_E_UTRAN_LIPA
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_MMEAPP_MME
:
case
MSC_MMEAPP_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MME_APP"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"MME_APP"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_NAS_MME
:
case
MSC_NAS_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_MME"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_MME"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
break
;
break
;
case
MSC_NAS_EMM_MME
:
case
MSC_NAS_EMM_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_EMM"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_EMM"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_NAS_ESM_MME
:
case
MSC_NAS_ESM_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_ESM"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"NAS_ESM"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_SP_GWAPP_MME
:
case
MSC_SP_GWAPP_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"SP_GW_MME"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"SP_GW_MME"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
(
envP
==
MSC_MME_GW
)
{
if
(
envP
==
MSC_MME_GW
)
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_S11_MME
:
case
MSC_S11_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S11_MME"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S11_MME"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
(
envP
==
MSC_MME
)
{
if
(
envP
==
MSC_MME
)
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_S6A_MME
:
case
MSC_S6A_MME
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S6A"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"S6A"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
case
MSC_HSS
:
case
MSC_HSS
:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"HSS"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"HSS"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
if
((
envP
==
MSC_MME_GW
)
||
(
envP
==
MSC_MME
))
{
msc_log_declare_proto
(
i
);
msc_log_declare_proto
(
i
);
}
}
break
;
break
;
default:
default:
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"UNKNOWN"
);
rv
=
snprintf
(
&
g_msc_proto2str
[
i
][
0
],
MSC_MAX_PROTO_NAME_LENGTH
,
"UNKNOWN"
);
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;}
if
(
rv
>=
MSC_MAX_PROTO_NAME_LENGTH
)
{
g_msc_proto2str
[
i
][
MSC_MAX_PROTO_NAME_LENGTH
-
1
]
=
0
;
}
}
}
}
}
rv
=
itti_create_task
(
TASK_MSC
,
msc_task
,
NULL
);
rv
=
itti_create_task
(
TASK_MSC
,
msc_task
,
NULL
);
AssertFatal
(
rv
==
0
,
"Create task for MSC failed!
\n
"
);
AssertFatal
(
rv
==
0
,
"Create task for MSC failed!
\n
"
);
fprintf
(
stderr
,
"Initializing MSC logs Done
\n
"
);
fprintf
(
stderr
,
"Initializing MSC logs Done
\n
"
);
...
@@ -359,15 +508,17 @@ void msc_flush_messages(void)
...
@@ -359,15 +508,17 @@ void msc_flush_messages(void)
int
rv
;
int
rv
;
msc_queue_item_t
*
item_p
=
NULL
;
msc_queue_item_t
*
item_p
=
NULL
;
while
((
rv
=
lfds611_queue_dequeue
(
g_msc_message_queue_p
,
(
void
**
)
&
item_p
))
==
1
)
{
while
((
rv
=
lfds611_queue_dequeue
(
g_msc_message_queue_p
,
(
void
**
)
&
item_p
))
==
1
)
{
if
(
NULL
!=
item_p
->
message_str
)
{
if
(
NULL
!=
item_p
->
message_str
)
{
fputs
(
item_p
->
message_str
,
g_msc_fd
);
fputs
(
item_p
->
message_str
,
g_msc_fd
);
// TODO BIN DATA
// TODO BIN DATA
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
item_p
->
message_str
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
item_p
->
message_str
);
}
}
// TODO FREE BIN DATA
// TODO FREE BIN DATA
free
(
item_p
);
free
(
item_p
);
}
}
fflush
(
g_msc_fd
);
fflush
(
g_msc_fd
);
}
}
...
@@ -377,13 +528,17 @@ void msc_end(void)
...
@@ -377,13 +528,17 @@ void msc_end(void)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
{
{
int
rv
;
int
rv
;
if
(
NULL
!=
g_msc_fd
)
{
if
(
NULL
!=
g_msc_fd
)
{
msc_flush_messages
();
msc_flush_messages
();
rv
=
fflush
(
g_msc_fd
);
rv
=
fflush
(
g_msc_fd
);
if
(
rv
!=
0
)
{
if
(
rv
!=
0
)
{
fprintf
(
stderr
,
"Error while flushing stream of MSC log file: %s"
,
strerror
(
errno
));
fprintf
(
stderr
,
"Error while flushing stream of MSC log file: %s"
,
strerror
(
errno
));
}
}
rv
=
fclose
(
g_msc_fd
);
rv
=
fclose
(
g_msc_fd
);
if
(
rv
!=
0
)
{
if
(
rv
!=
0
)
{
fprintf
(
stderr
,
"Error while closing MSC log file: %s"
,
strerror
(
errno
));
fprintf
(
stderr
,
"Error while closing MSC log file: %s"
,
strerror
(
errno
));
}
}
...
@@ -393,7 +548,7 @@ void msc_end(void)
...
@@ -393,7 +548,7 @@ void msc_end(void)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
msc_log_declare_proto
(
void
msc_log_declare_proto
(
const
msc_proto_t
protoP
const
msc_proto_t
protoP
)
)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
{
{
int
rv
=
0
;
int
rv
=
0
;
...
@@ -403,35 +558,43 @@ void msc_log_declare_proto(
...
@@ -403,35 +558,43 @@ void msc_log_declare_proto(
if
((
MIN_MSC_PROTOS
<=
protoP
)
&&
(
MAX_MSC_PROTOS
>
protoP
))
{
if
((
MIN_MSC_PROTOS
<=
protoP
)
&&
(
MAX_MSC_PROTOS
>
protoP
))
{
// may be build a memory pool for that also ?
// may be build a memory pool for that also ?
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
if
(
NULL
!=
new_item_p
)
{
if
(
NULL
!=
new_item_p
)
{
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
msc_flush_messages
();
msc_flush_messages
();
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
}
}
if
(
1
==
rv
)
{
if
(
1
==
rv
)
{
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [PROTO] %d %s
\n
"
,
__sync_fetch_and_add
(
&
g_message_number
,
1
),
protoP
,
&
g_msc_proto2str
[
protoP
][
0
]);
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [PROTO] %d %s
\n
"
,
__sync_fetch_and_add
(
&
g_message_number
,
1
),
protoP
,
&
g_msc_proto2str
[
protoP
][
0
]);
if
(
0
>
rv
)
{
if
(
0
>
rv
)
{
fprintf
(
stderr
,
"Error while declaring new protocol in MSC: %s"
,
strerror
(
errno
));
fprintf
(
stderr
,
"Error while declaring new protocol in MSC: %s"
,
strerror
(
errno
));
}
}
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_bin
=
NULL
;
new_item_p
->
message_bin
=
NULL
;
new_item_p
->
message_bin_size
=
0
;
new_item_p
->
message_bin_size
=
0
;
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
rv
=
lfds611_queue_guaranteed_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
rv
=
lfds611_queue_guaranteed_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
free
(
new_item_p
);
free
(
new_item_p
);
}
}
}
}
return
;
return
;
}
else
{
}
else
{
fprintf
(
stderr
,
"Error while lfds611_stack_pop()
\n
"
);
fprintf
(
stderr
,
"Error while lfds611_stack_pop()
\n
"
);
}
}
free
(
new_item_p
);
free
(
new_item_p
);
}
else
{
}
else
{
fprintf
(
stderr
,
"Error while malloc in MSC"
);
fprintf
(
stderr
,
"Error while malloc in MSC"
);
...
@@ -450,43 +613,52 @@ void msc_log_event(
...
@@ -450,43 +613,52 @@ void msc_log_event(
msc_queue_item_t
*
new_item_p
=
NULL
;
msc_queue_item_t
*
new_item_p
=
NULL
;
char
*
char_message_p
=
NULL
;
char
*
char_message_p
=
NULL
;
if
((
MIN_MSC_PROTOS
>
protoP
)
||
(
MAX_MSC_PROTOS
<=
protoP
))
{
if
((
MIN_MSC_PROTOS
>
protoP
)
||
(
MAX_MSC_PROTOS
<=
protoP
))
{
return
;
return
;
}
}
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
if
(
NULL
!=
new_item_p
)
{
if
(
NULL
!=
new_item_p
)
{
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
msc_flush_messages
();
msc_flush_messages
();
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
}
}
if
(
1
==
rv
)
{
if
(
1
==
rv
)
{
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [EVENT] %d "
,
__sync_fetch_and_add
(
&
g_message_number
,
1
),
protoP
);
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [EVENT] %d "
,
__sync_fetch_and_add
(
&
g_message_number
,
1
),
protoP
);
if
((
0
>
rv
)
||
(
MSC_MAX_MESSAGE_LENGTH
<
rv
))
{
if
((
0
>
rv
)
||
(
MSC_MAX_MESSAGE_LENGTH
<
rv
))
{
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
va_start
(
args
,
format
);
va_start
(
args
,
format
);
rv2
=
vsnprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
format
,
args
);
rv2
=
vsnprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
format
,
args
);
va_end
(
args
);
va_end
(
args
);
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
rv
+=
rv2
;
rv
+=
rv2
;
rv2
=
snprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
"
\n
"
);
rv2
=
snprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
"
\n
"
);
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC event : %s"
,
&
g_msc_proto2str
[
protoP
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
rv
+=
rv2
;
rv
+=
rv2
;
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_bin
=
NULL
;
new_item_p
->
message_bin
=
NULL
;
new_item_p
->
message_bin_size
=
0
;
new_item_p
->
message_bin_size
=
0
;
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
...
@@ -496,6 +668,7 @@ void msc_log_event(
...
@@ -496,6 +668,7 @@ void msc_log_event(
fprintf
(
stderr
,
"Error while lfds611_stack_pop()
\n
"
);
fprintf
(
stderr
,
"Error while lfds611_stack_pop()
\n
"
);
}
}
}
}
return
;
return
;
error_event:
error_event:
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
...
@@ -503,10 +676,10 @@ error_event:
...
@@ -503,10 +676,10 @@ error_event:
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
msc_log_message
(
void
msc_log_message
(
const
char
*
const
message_operationP
,
const
char
*
const
message_operationP
,
const
msc_proto_t
proto1P
,
const
msc_proto_t
proto1P
,
const
msc_proto_t
proto2P
,
const
msc_proto_t
proto2P
,
const
uint8_t
*
const
bytesP
,
const
uint8_t
*
const
bytesP
,
const
unsigned
int
num_bytes
,
const
unsigned
int
num_bytes
,
char
*
format
,
...)
char
*
format
,
...)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -518,46 +691,54 @@ void msc_log_message(
...
@@ -518,46 +691,54 @@ void msc_log_message(
msc_queue_item_t
*
new_item_p
=
NULL
;
msc_queue_item_t
*
new_item_p
=
NULL
;
char
*
char_message_p
=
NULL
;
char
*
char_message_p
=
NULL
;
if
((
MIN_MSC_PROTOS
>
proto1P
)
||
(
MAX_MSC_PROTOS
<=
proto1P
)
||
if
((
MIN_MSC_PROTOS
>
proto1P
)
||
(
MAX_MSC_PROTOS
<=
proto1P
)
||
(
MIN_MSC_PROTOS
>
proto2P
)
||
(
MAX_MSC_PROTOS
<=
proto2P
)
)
{
(
MIN_MSC_PROTOS
>
proto2P
)
||
(
MAX_MSC_PROTOS
<=
proto2P
)
)
{
return
;
return
;
}
}
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
new_item_p
=
malloc
(
sizeof
(
msc_queue_item_t
));
if
(
NULL
!=
new_item_p
)
{
if
(
NULL
!=
new_item_p
)
{
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
msc_flush_messages
();
msc_flush_messages
();
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
rv
=
lfds611_stack_pop
(
g_msc_memory_stack_p
,
(
void
**
)
&
char_message_p
);
}
}
if
(
1
==
rv
)
{
if
(
1
==
rv
)
{
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [MESSAGE] %d %s %d %"
PRIu64
" "
,
rv
=
snprintf
(
char_message_p
,
MSC_MAX_MESSAGE_LENGTH
,
"%"
PRIu64
" [MESSAGE] %d %s %d %"
PRIu64
" "
,
__sync_fetch_and_add
(
&
g_message_number
,
1
),
proto1P
,
message_operationP
,
proto2P
,
mac
);
__sync_fetch_and_add
(
&
g_message_number
,
1
),
proto1P
,
message_operationP
,
proto2P
,
mac
);
if
((
0
>
rv
)
||
(
MSC_MAX_MESSAGE_LENGTH
<
rv
))
{
if
((
0
>
rv
)
||
(
MSC_MAX_MESSAGE_LENGTH
<
rv
))
{
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
va_start
(
args
,
format
);
va_start
(
args
,
format
);
rv2
=
vsnprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
format
,
args
);
rv2
=
vsnprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
format
,
args
);
va_end
(
args
);
va_end
(
args
);
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
rv
+=
rv2
;
rv
+=
rv2
;
rv2
=
snprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
"
\n
"
);
rv2
=
snprintf
(
&
char_message_p
[
rv
],
MSC_MAX_MESSAGE_LENGTH
-
rv
,
"
\n
"
);
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
if
((
0
>
rv2
)
||
((
MSC_MAX_MESSAGE_LENGTH
-
rv
)
<
rv2
))
{
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
fprintf
(
stderr
,
"Error while logging MSC message : %s/%s"
,
&
g_msc_proto2str
[
proto1P
][
0
],
&
g_msc_proto2str
[
proto2P
][
0
]);
goto
error_event
;
goto
error_event
;
}
}
rv
+=
rv2
;
rv
+=
rv2
;
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str
=
char_message_p
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_str_size
=
rv
;
new_item_p
->
message_bin
=
NULL
;
// TO DO
new_item_p
->
message_bin
=
NULL
;
// TO DO
new_item_p
->
message_bin_size
=
0
;
// TO DO
new_item_p
->
message_bin_size
=
0
;
// TO DO
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
rv
=
lfds611_queue_enqueue
(
g_msc_message_queue_p
,
new_item_p
);
if
(
0
==
rv
)
{
if
(
0
==
rv
)
{
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
fprintf
(
stderr
,
"Error while lfds611_queue_guaranteed_enqueue message %s in MSC"
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
...
@@ -568,6 +749,7 @@ void msc_log_message(
...
@@ -568,6 +749,7 @@ void msc_log_message(
msc_flush_messages
();
msc_flush_messages
();
}
}
}
}
return
;
return
;
error_event:
error_event:
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
rv
=
lfds611_stack_guaranteed_push
(
g_msc_memory_stack_p
,
char_message_p
);
...
@@ -578,8 +760,7 @@ error_event:
...
@@ -578,8 +760,7 @@ error_event:
// function called when oai loader loads the msc shared lib
// function called when oai loader loads the msc shared lib
int
msc_autoinit
(
msc_interface_t
*
msc_interface
)
int
msc_autoinit
(
msc_interface_t
*
msc_interface
)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
{
{
msc_interface
->
msc_init
=
msc_init
;
msc_interface
->
msc_init
=
msc_init
;
msc_interface
->
msc_start_use
=
msc_start_use
;
msc_interface
->
msc_start_use
=
msc_start_use
;
msc_interface
->
msc_end
=
msc_end
;
msc_interface
->
msc_end
=
msc_end
;
...
@@ -587,4 +768,4 @@ int msc_autoinit(msc_interface_t *msc_interface)
...
@@ -587,4 +768,4 @@ int msc_autoinit(msc_interface_t *msc_interface)
msc_interface
->
msc_log_message
=
msc_log_message
;
msc_interface
->
msc_log_message
=
msc_log_message
;
msc_interface
->
msc_loaded
=
1
;
msc_interface
->
msc_loaded
=
1
;
return
0
;
return
0
;
}
}
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