diff options
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 4 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 11 | ||||
-rw-r--r-- | accel-pppd/net.c | 52 | ||||
-rw-r--r-- | accel-pppd/ppp/ccp_mppe.c | 4 |
4 files changed, 60 insertions, 11 deletions
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 74b368b3..44851c25 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -411,7 +411,7 @@ static void connect_channel(struct pppoe_conn_t *conn) triton_event_fire(EV_CTRL_STARTING, &conn->ppp.ses); triton_event_fire(EV_CTRL_STARTED, &conn->ppp.ses); - sock = net->pppox_socket(PX_PROTO_OE); + sock = net->socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OE); if (!sock) { log_error("pppoe: socket(PPPOX): %s\n", strerror(errno)); goto out_err; @@ -427,7 +427,7 @@ static void connect_channel(struct pppoe_conn_t *conn) strcpy(sp.sa_addr.pppoe.dev, conn->serv->ifname); memcpy(sp.sa_addr.pppoe.remote, conn->addr, ETH_ALEN); - if (net->pppox_connect(sock, (struct sockaddr *)&sp, sizeof(sp))) { + if (net->connect(sock, (struct sockaddr *)&sp, sizeof(sp))) { log_error("pppoe: connect: %s\n", strerror(errno)); goto out_err_close; } diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index aea2fa66..f2298330 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -39,8 +39,15 @@ struct rtnl_link_stats; struct sockaddr; struct ap_net { - int (*pppox_socket)(int proto); - int (*pppox_connect)(int sock, const struct sockaddr *, socklen_t len); + 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); diff --git a/accel-pppd/net.c b/accel-pppd/net.c index 054885e4..cbd47304 100644 --- a/accel-pppd/net.c +++ b/accel-pppd/net.c @@ -8,16 +8,51 @@ __export __thread const struct ap_net *net; -static int def_pppox_socket(int proto) +static int def_socket(int domain, int type, int proto) { - return socket(AF_PPPOX, SOCK_STREAM, proto); + return socket(domain, type, proto); } -static int def_pppox_connect(int sock, const struct sockaddr *addr, socklen_t len) +static int def_connect(int sock, const struct sockaddr *addr, socklen_t len) { return connect(sock, addr, len); } +static int def_bind(int sock, const struct sockaddr *addr, socklen_t len) +{ + return bind(sock, addr, len); +} + +static int def_listen(int sock, int backlog) +{ + return listen(sock, backlog); +} + +static ssize_t def_recv(int sock, void *buf, size_t len, int flags) +{ + return recv(sock, buf, len, flags); +} + +static ssize_t def_recvfrom(int sock, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) +{ + return recvfrom(sock, buf, len, flags, src_addr, addrlen); +} + +static ssize_t def_send(int sock, const void *buf, size_t len, int flags) +{ + return send(sock, buf, len, flags); +} + +static ssize_t def_sendto(int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) +{ + return sendto(sock, buf, len, flags, dest_addr, addrlen); +} + +static int def_set_nonblocking(int sock, int f) +{ + return fcntl(sock, F_SETFL, O_NONBLOCK); +} + static int def_ppp_open() { return open("/dev/ppp", O_RDWR); @@ -34,8 +69,15 @@ static int def_sock_ioctl(unsigned long request, void *arg) } __export const struct ap_net def_net = { - .pppox_socket = def_pppox_socket, - .pppox_connect = def_pppox_connect, + .socket = def_socket, + .connect = def_connect, + .bind = def_bind, + .listen = def_listen, + .recv = def_recv, + .recvfrom = def_recvfrom, + .send = def_send, + .sendto = def_sendto, + .set_nonblocking = def_set_nonblocking, .ppp_open = def_ppp_open, .ppp_ioctl = def_ppp_ioctl, .sock_ioctl = def_sock_ioctl, diff --git a/accel-pppd/ppp/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c index 4e8d6b93..456fe821 100644 --- a/accel-pppd/ppp/ccp_mppe.c +++ b/accel-pppd/ppp/ccp_mppe.c @@ -129,14 +129,14 @@ static int decrease_mtu(struct ppp_t *ppp) strcpy(ifr.ifr_name, ppp->ses.ifname); - if (net->ppp_ioctl(sock_fd, SIOCGIFMTU, &ifr)) { + if (net->sock_ioctl(SIOCGIFMTU, &ifr)) { log_ppp_error("mppe: failed to get MTU: %s\n", strerror(errno)); return -1; } ifr.ifr_mtu -= MPPE_PAD; - if (net->ppp_ioctl(sock_fd, SIOCSIFMTU, &ifr)) { + if (net->sock_ioctl(SIOCSIFMTU, &ifr)) { log_ppp_error("mppe: failed to set MTU: %s\n", strerror(errno)); return -1; } |