diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2015-11-23 00:52:22 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2015-12-04 21:30:40 +0300 |
commit | 86b151891a2f11c863e9d31e132deb8eab2cf30f (patch) | |
tree | 761ce676c0a563a588bb042677845fe398f34bde | |
parent | 2dbcda2be5cbc221a827d0559da53aa4333a6d56 (diff) | |
download | accel-ppp-86b151891a2f11c863e9d31e132deb8eab2cf30f.tar.gz accel-ppp-86b151891a2f11c863e9d31e132deb8eab2cf30f.zip |
preparation for DPDK intergation (part 4)
-rw-r--r-- | accel-pppd/include/ap_net.h | 20 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 18 | ||||
-rw-r--r-- | accel-pppd/net.c | 10 | ||||
-rw-r--r-- | accel-pppd/net/dpdk.c | 9 |
4 files changed, 39 insertions, 18 deletions
diff --git a/accel-pppd/include/ap_net.h b/accel-pppd/include/ap_net.h new file mode 100644 index 00000000..8ed8536d --- /dev/null +++ b/accel-pppd/include/ap_net.h @@ -0,0 +1,20 @@ +#ifndef __AP_NET_H +#define __AP_NET_H + +struct ap_net { + int (*socket)(int domain, int type, int proto); + int (*connect)(int sock, const struct sockaddr *, socklen_t len); + int (*bind)(int sock, const struct sockaddr *, socklen_t len); + int (*listen)(int sock, int backlog); + ssize_t (*recv)(int sock, void *buf, size_t len, int flags); + ssize_t (*recvfrom)(int sock, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); + ssize_t (*send)(int sock, const void *buf, size_t len, int flags); + ssize_t (*sendto)(int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); + int (*set_nonblocking)(int sock, int f); + int (*setsockopt)(int sockfd, int level, int optname, const void *optval, socklen_t optlen); + int (*ppp_open)(); + int (*ppp_ioctl)(int fd, unsigned long request, void *arg); + int (*sock_ioctl)(unsigned long request, void *arg); +}; + +#endif diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index f2298330..7a8db12b 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -1,6 +1,8 @@ #ifndef __AP_SESSION_H__ #define __AP_SESSION_H__ +#include "ap_net.h" + //#define AP_SESSIONID_LEN 16 #define AP_IFNAME_LEN 16 @@ -36,22 +38,6 @@ struct ap_session; struct backup_data; struct rtnl_link_stats; -struct sockaddr; - -struct ap_net { - int (*socket)(int domain, int type, int proto); - int (*connect)(int sock, const struct sockaddr *, socklen_t len); - int (*bind)(int sock, const struct sockaddr *, socklen_t len); - int (*listen)(int sock, int backlog); - ssize_t (*recv)(int sock, void *buf, size_t len, int flags); - ssize_t (*recvfrom)(int sock, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); - ssize_t (*send)(int sock, const void *buf, size_t len, int flags); - ssize_t (*sendto)(int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); - int (*set_nonblocking)(int sock, int f); - int (*ppp_open)(); - int (*ppp_ioctl)(int fd, unsigned long request, void *arg); - int (*sock_ioctl)(unsigned long request, void *arg); -}; struct ap_ctrl { struct triton_context_t *ctx; diff --git a/accel-pppd/net.c b/accel-pppd/net.c index cbd47304..d2683b1b 100644 --- a/accel-pppd/net.c +++ b/accel-pppd/net.c @@ -4,7 +4,9 @@ #include "triton.h" -#include "ap_session.h" +#include "ap_net.h" + +extern int sock_fd; __export __thread const struct ap_net *net; @@ -53,6 +55,11 @@ static int def_set_nonblocking(int sock, int f) return fcntl(sock, F_SETFL, O_NONBLOCK); } +static int def_setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen) +{ + return setsockopt(sock, level, optname, optval, optlen); +} + static int def_ppp_open() { return open("/dev/ppp", O_RDWR); @@ -78,6 +85,7 @@ __export const struct ap_net def_net = { .send = def_send, .sendto = def_sendto, .set_nonblocking = def_set_nonblocking, + .setsockopt = def_setsockopt, .ppp_open = def_ppp_open, .ppp_ioctl = def_ppp_ioctl, .sock_ioctl = def_sock_ioctl, diff --git a/accel-pppd/net/dpdk.c b/accel-pppd/net/dpdk.c index cfd64bad..62d0e26f 100644 --- a/accel-pppd/net/dpdk.c +++ b/accel-pppd/net/dpdk.c @@ -8,7 +8,7 @@ #include <linux/if.h> #include "triton.h" -#include "ap_session.h" +#include "ap_net.h" #include "log.h" #include "if_dpdk.h" @@ -311,6 +311,12 @@ static int dpdk_set_nonblocking(int sock, int f) return 0; } +static int dpdk_setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen) +{ + return 0; +} + + static int dpdk_ppp_open() { int id = MSG_PPP_OPEN; @@ -451,6 +457,7 @@ static const struct ap_net dpdk_net = { .send = dpdk_send, .sendto = dpdk_sendto, .set_nonblocking = dpdk_set_nonblocking, + .setsockopt = dpdk_setsockopt, .ppp_open = dpdk_ppp_open, .ppp_ioctl = dpdk_ppp_ioctl, .sock_ioctl = dpdk_sock_ioctl, |