summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorQiuwen Lu <[email protected]>2017-06-01 14:36:21 +0800
committerQiuwen Lu <[email protected]>2017-06-01 14:36:21 +0800
commitb4651f83fc63345dbe06c60f6655606979f3840f (patch)
tree9a2d06977647e2cb71b2266948daae02df13502b /examples
parent5195a74d2074ab59f46520e9d9d83a0dd885dc7e (diff)
增加rxonly示例程序回环收发包功能。增加session表删除表项时的统计。
Diffstat (limited to 'examples')
-rw-r--r--examples/rxonly.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/examples/rxonly.c b/examples/rxonly.c
index ea47055..cab15e1 100644
--- a/examples/rxonly.c
+++ b/examples/rxonly.c
@@ -14,9 +14,11 @@ unsigned int nr_thread;
struct mr_instance * mr_instance = NULL;
struct mr_vdev * dev_handler = NULL;
+struct mr_sendpath * sendpath = NULL;
#define BURST_MAX 64
unsigned int nr_burst = 32;
+unsigned int self_loop = 0;
void * rxonly_loop(void * arg)
{
@@ -29,7 +31,15 @@ void * rxonly_loop(void * arg)
for (;;)
{
ret = marsio_recv_burst(dev_handler, sid, rx_buff, nr_burst);
- marsio_buff_free(mr_instance, rx_buff, ret, 0, 0);
+
+ if (!self_loop)
+ {
+ marsio_buff_free(mr_instance, rx_buff, ret, 0, 0);
+ }
+ else
+ {
+ marsio_send_burst(sendpath, sid, rx_buff, ret);
+ }
}
return (void *)NULL;
@@ -43,7 +53,7 @@ int help()
int main(int argc, char * argv[])
{
int opt = 0;
- while ((opt = getopt(argc, argv, "s:t:a:c:b:d:h?r")) != -1)
+ while ((opt = getopt(argc, argv, "s:t:a:c:b:d:h?rl")) != -1)
{
char * endptr = NULL;
switch (opt)
@@ -76,6 +86,11 @@ int main(int argc, char * argv[])
if (nr_burst == 0 && endptr == optarg) help();
break;
}
+ case 'l':
+ {
+ self_loop = 1;
+ break;
+ }
default:
help();
@@ -99,6 +114,11 @@ int main(int argc, char * argv[])
dev_handler = marsio_open_device(mr_instance, dev_symbol, nr_thread, nr_thread);
fprintf(stdout, "Thread Count = %d\n", nr_thread);
+ if (self_loop)
+ {
+ sendpath = marsio_sendpath_create(mr_instance, MR_SENDPATH_VDEV, dev_handler);
+ }
+
pthread_t __tmp_pid[nr_thread];
for (int i = 0; i < nr_thread; i++)
{