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
ee5d8c60
Commit
ee5d8c60
authored
Mar 19, 2016
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prepare forwarder
parent
2bd870af
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
2 deletions
+84
-2
T.h
T.h
+13
-0
tracer/Makefile
tracer/Makefile
+1
-1
tracer/defs.h
tracer/defs.h
+3
-0
tracer/forward.c
tracer/forward.c
+10
-0
tracer/main.c
tracer/main.c
+57
-1
No files found.
T.h
View file @
ee5d8c60
...
@@ -115,11 +115,24 @@ extern T_cache_t *T_cache;
...
@@ -115,11 +115,24 @@ extern T_cache_t *T_cache;
#define T_ACTIVE(x) T_active[(intptr_t)x]
#define T_ACTIVE(x) T_active[(intptr_t)x]
#ifdef T_USE_SHARED_MEMORY
#define T_SEND() \
#define T_SEND() \
T_cache[T_LOCAL_slot].busy = 1; \
T_cache[T_LOCAL_slot].busy = 1; \
T_cache[T_LOCAL_slot].length = T_LOCAL_size; \
T_cache[T_LOCAL_slot].length = T_LOCAL_size; \
T_send(T_LOCAL_buf, T_LOCAL_size)
T_send(T_LOCAL_buf, T_LOCAL_size)
#else
/* T_USE_SHARED_MEMORY */
/* when not using shared memory, wait for send to finish */
#define T_SEND() \
T_cache[T_LOCAL_slot].busy = 1; \
T_cache[T_LOCAL_slot].length = T_LOCAL_size; \
T_send(T_LOCAL_buf, T_LOCAL_size); \
while (T_cache[T_LOCAL_slot].busy) usleep(1*1000)
#endif
/* T_USE_SHARED_MEMORY */
#define T_CHECK_SIZE(len, argnum) \
#define T_CHECK_SIZE(len, argnum) \
if (T_LOCAL_size + (len) > T_BUFFER_MAX) { \
if (T_LOCAL_size + (len) > T_BUFFER_MAX) { \
printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \
printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \
...
...
tracer/Makefile
View file @
ee5d8c60
...
@@ -10,7 +10,7 @@ CFLAGS += -DT_USE_SHARED_MEMORY
...
@@ -10,7 +10,7 @@ CFLAGS += -DT_USE_SHARED_MEMORY
LIBS
+=
-lrt
LIBS
+=
-lrt
PROG
=
tracer
PROG
=
tracer
OBJS
=
main.o plot.o database.o
OBJS
=
main.o plot.o database.o
forward.o
$(PROG)
:
$(OBJS)
$(PROG)
:
$(OBJS)
$(CC)
$(CFLAGS)
-o
$(PROG)
$(OBJS)
$(LIBS)
$(CC)
$(CFLAGS)
-o
$(PROG)
$(OBJS)
$(LIBS)
...
...
tracer/defs.h
View file @
ee5d8c60
...
@@ -21,4 +21,7 @@ void list_ids(void *database);
...
@@ -21,4 +21,7 @@ void list_ids(void *database);
void
list_groups
(
void
*
database
);
void
list_groups
(
void
*
database
);
void
on_off
(
void
*
d
,
char
*
item
,
int
*
a
,
int
onoff
);
void
on_off
(
void
*
d
,
char
*
item
,
int
*
a
,
int
onoff
);
void
*
forwarder
(
char
*
ip
,
int
port
);
void
forward
(
void
*
forwarder
,
char
*
buf
,
int
size
);
#endif
/* _TRACER_DEFS_H_ */
#endif
/* _TRACER_DEFS_H_ */
tracer/forward.c
0 → 100644
View file @
ee5d8c60
#include "defs.h"
void
*
forwarder
(
char
*
ip
,
int
port
)
{
return
0
;
}
void
forward
(
void
*
_fowarder
,
char
*
buf
,
int
size
)
{
}
tracer/main.c
View file @
ee5d8c60
...
@@ -371,7 +371,7 @@ void init_shm(void)
...
@@ -371,7 +371,7 @@ void init_shm(void)
void
usage
(
void
)
void
usage
(
void
)
{
{
printf
(
printf
(
"options:
\n
"
"
common
options:
\n
"
" -d <database file> this option is mandatory
\n
"
" -d <database file> this option is mandatory
\n
"
" -li print IDs in the database
\n
"
" -li print IDs in the database
\n
"
" -lg print GROUPs in the database
\n
"
" -lg print GROUPs in the database
\n
"
...
@@ -383,6 +383,10 @@ void usage(void)
...
@@ -383,6 +383,10 @@ void usage(void)
" -OFF turn all logs OFF
\n
"
" -OFF turn all logs OFF
\n
"
"note: you may pass several -on/-off/-ON/-OFF, they will be processed in order
\n
"
"note: you may pass several -on/-off/-ON/-OFF, they will be processed in order
\n
"
" by default, all is off
\n
"
" by default, all is off
\n
"
"
\n
"
"remote mode options: in this mode you run a local tracer and a remote one
\n
"
" -r remote side
\n
"
" -l <IP address> <port> local side (forwards packets to remote IP:port)
\n
"
);
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -403,6 +407,13 @@ int main(int n, char **v)
...
@@ -403,6 +407,13 @@ int main(int n, char **v)
int
*
on_off_action
;
int
*
on_off_action
;
int
on_off_n
=
0
;
int
on_off_n
=
0
;
int
is_on
[
T_NUMBER_OF_IDS
];
int
is_on
[
T_NUMBER_OF_IDS
];
int
remote_local
=
0
;
int
remote_remote
=
0
;
char
*
remote_ip
=
NULL
;
int
remote_port
=
-
1
;
#ifdef T_USE_SHARED_MEMORY
void
*
f
;
#endif
memset
(
is_on
,
0
,
sizeof
(
is_on
));
memset
(
is_on
,
0
,
sizeof
(
is_on
));
...
@@ -425,10 +436,43 @@ int main(int n, char **v)
...
@@ -425,10 +436,43 @@ int main(int n, char **v)
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
1
;
continue
;
}
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-OFF"
))
if
(
!
strcmp
(
v
[
i
],
"-OFF"
))
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
0
;
continue
;
}
{
on_off_name
[
on_off_n
]
=
NULL
;
on_off_action
[
on_off_n
++
]
=
0
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-r"
))
{
remote_remote
=
1
;
continue
;
}
if
(
!
strcmp
(
v
[
i
],
"-l"
))
{
if
(
i
>
n
-
3
)
usage
();
remote_local
=
1
;
remote_ip
=
v
[
++
i
];
remote_port
=
atoi
(
v
[
++
i
]);
continue
;
}
printf
(
"ERROR: unknown option %s
\n
"
,
v
[
i
]);
printf
(
"ERROR: unknown option %s
\n
"
,
v
[
i
]);
usage
();
usage
();
}
}
#ifndef T_USE_SHARED_MEMORY
/* gcc shut up */
(
void
)
remote_port
;
(
void
)
remote_ip
;
#endif
#ifdef T_USE_SHARED_MEMORY
if
(
remote_remote
)
{
printf
(
"ERROR: remote 'remote side' does not run with shared memory
\n
"
);
printf
(
"recompile without T_USE_SHARED_MEMORY (edit Makefile)
\n
"
);
exit
(
1
);
}
#endif
if
(
remote_remote
)
{
/* TODO: setup 'secure' connection with remote part */
}
#ifndef T_USE_SHARED_MEMORY
if
(
remote_local
)
{
printf
(
"ERROR: remote 'local side' does not run without shared memory
\n
"
);
printf
(
"recompile with T_USE_SHARED_MEMORY (edit Makefile)
\n
"
);
exit
(
1
);
}
#endif
#ifdef T_USE_SHARED_MEMORY
if
(
remote_local
)
f
=
forwarder
(
remote_ip
,
remote_port
);
#endif
if
(
database_filename
==
NULL
)
{
if
(
database_filename
==
NULL
)
{
printf
(
"ERROR: provide a database file (-d)
\n
"
);
printf
(
"ERROR: provide a database file (-d)
\n
"
);
exit
(
1
);
exit
(
1
);
...
@@ -479,6 +523,18 @@ int main(int n, char **v)
...
@@ -479,6 +523,18 @@ int main(int n, char **v)
#ifdef T_USE_SHARED_MEMORY
#ifdef T_USE_SHARED_MEMORY
wait_message
();
wait_message
();
#endif
#endif
#ifdef T_USE_SHARED_MEMORY
if
(
remote_local
)
{
forward
(
f
,
T_cache
[
T_busylist_head
].
buffer
,
T_cache
[
T_busylist_head
].
length
);
T_cache
[
T_busylist_head
].
busy
=
0
;
T_busylist_head
++
;
T_busylist_head
&=
T_CACHE_SIZE
-
1
;
continue
;
}
#endif
get_message
(
s
);
get_message
(
s
);
}
}
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