diff options
| author | Qiuwen Lu <[email protected]> | 2016-09-09 10:34:30 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2016-09-09 10:34:30 +0800 |
| commit | 2dad3145217a5bbfdc62940a464f2ae6f8015333 (patch) | |
| tree | 8be7c069d5d09d16b50f661e7a4bdd15d96b1422 /examples | |
| parent | 063293e0e275adf396f6fa162ed8974a4720317a (diff) | |
Slave库的正式实现,实现了初始化、进程注册和样例测试程序。
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | examples/TestRawIO.c | 23 | ||||
| -rw-r--r-- | examples/TestTradition.c | 46 | ||||
| -rw-r--r-- | examples/r2 | 1 | ||||
| -rw-r--r-- | examples/r3 | 13 | ||||
| -rw-r--r-- | examples/testapp.c | 9 |
6 files changed, 11 insertions, 91 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9b3f4f7..c62ac90 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,9 +1,3 @@ -# Include Directories -include_directories(${CMAKE_SOURCE_DIR}/include/extern) -# Old Interface -add_executable(marsio-forward-test TestTradition.c) -target_link_libraries(marsio-forward-test libmarsio) -# New Interface -add_executable(marsio-rawio-test TestRawIO.c) -target_link_libraries(marsio-rawio-test libmarsio)
\ No newline at end of file +add_executable(testapp testapp.c) +target_link_libraries(testapp marsio)
\ No newline at end of file diff --git a/examples/TestRawIO.c b/examples/TestRawIO.c deleted file mode 100644 index 5612647..0000000 --- a/examples/TestRawIO.c +++ /dev/null @@ -1,23 +0,0 @@ -// -// Created by luqiu on 2016/5/10. -// - -#include <marsio.h> - -int test_rawio_recv(const char * data, int datalen, int seq, mr_pkt_desc_t * desc, void * arg) -{ - // Drop Packets - return 0; -} - -int test_rawio_forward(const char * data, int datalen, int seq, mr_pkt_desc_t * desc, void * arg) -{ - return 1; -} - -int main(int argc, char * argv[]) -{ - dpdk_init(argc, argv); - marsio_rawio_cb_reg(test_rawio_recv, NULL); - dpdk_run(); -}
\ No newline at end of file diff --git a/examples/TestTradition.c b/examples/TestTradition.c deleted file mode 100644 index ca67a00..0000000 --- a/examples/TestTradition.c +++ /dev/null @@ -1,46 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <arpa/inet.h> -#include <marsio.h> - -static int udp_fd = 0; - -int udpstack_test(const unsigned char *data, int datalen, int dst, int lcore) -{ - if (udp_fd == 0) udp_fd = marsio_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - struct marsio_udp_buff * udp_buff = marsio_udp_alloc(); - if (udp_buff == NULL) return 0; - - int send_datalen = datalen >= udp_buff->len ? udp_buff->len : datalen; - //memcpy(udp_buff->start, data, send_datalen); - memset(udp_buff->start, 0xff, send_datalen); - - struct sockaddr_in in_addr; - unsigned addr_len = sizeof(struct sockaddr_in); - - inet_pton(AF_INET, "192.168.200.2", &in_addr.sin_addr); - in_addr.sin_port = ntohs(5000); - in_addr.sin_family = AF_INET; - - struct sockaddr_in * ptr[10] = { &in_addr }; - unsigned int ptrlen[10] = { addr_len }; - marsio_udp_sendto_burst(udp_fd, &udp_buff, 1, 0, ptr, ptrlen, 1); - return 0; -} - - -int l2fwd_data(const unsigned char *data,int datalen,int dst,int lcore) -{ -// dpdk_send_packet_dst(data, datalen, dst); - return 1; -} - -int main(int argc,char **argv) -{ - dpdk_register_callfunc_dst(l2fwd_data); - //dpdk_register_callfunc_dst(udpstack_test); - dpdk_init(argc,argv); - dpdk_run(); - - return 0; -}
\ No newline at end of file diff --git a/examples/r2 b/examples/r2 deleted file mode 100644 index 4c15a9b..0000000 --- a/examples/r2 +++ /dev/null @@ -1 +0,0 @@ -./r3 &> /dev/null & diff --git a/examples/r3 b/examples/r3 deleted file mode 100644 index 8f4b5d5..0000000 --- a/examples/r3 +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -while [ 1 ]; do - papp_num=`ps -ef|grep ./test|grep -v grep | wc -l` - if [ $papp_num -lt 1 ] - then - ulimit -c unlimited - #./jz -c 0x7 -b 00:04:00.1 -b 00:04:00.2 -b 00:04:00.3 -b 00:04:00.4 &>/dev/null - ./test -c 0x7 -b 00:04:00.1 -b 00:04:00.2 -b 00:04:00.3 -b 00:04:00.4 &> log.txt - echo program crashed, restart at `date +"%w %Y/%m/%d, %H:%M:%S"` >> RESTART.log - fi - sleep 35 -done diff --git a/examples/testapp.c b/examples/testapp.c new file mode 100644 index 0000000..deb6431 --- /dev/null +++ b/examples/testapp.c @@ -0,0 +1,9 @@ +
+#include <mrlib.h>
+#include <stdio.h>
+
+int main(int argc, char * argv[])
+{
+ int ret = mrlib_init("testapp", stderr);
+ return ret;
+}
|
