summaryrefslogtreecommitdiff
path: root/accel-pppd/ppp
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2015-11-22 12:42:10 +0300
committerDmitry Kozlov <xeb@mail.ru>2015-12-04 21:30:40 +0300
commit939ff04fb80605e688720f64c824be3d21dad07e (patch)
tree474b80eb4aef7c33070b2d2255ad5ce7cf2a6405 /accel-pppd/ppp
parentbf84f9763ca3b6f018774b2b1664e838e119b028 (diff)
downloadaccel-ppp-939ff04fb80605e688720f64c824be3d21dad07e.tar.gz
accel-ppp-939ff04fb80605e688720f64c824be3d21dad07e.zip
preparation for DPDK intergation (part 2)
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r--accel-pppd/ppp/ccp_mppe.c6
-rw-r--r--accel-pppd/ppp/lcp_opt_accomp.c4
-rw-r--r--accel-pppd/ppp/lcp_opt_mru.c2
-rw-r--r--accel-pppd/ppp/lcp_opt_pcomp.c4
-rw-r--r--accel-pppd/ppp/ppp.c20
-rw-r--r--accel-pppd/ppp/ppp_ccp.c4
-rw-r--r--accel-pppd/ppp/ppp_ifcfg.c16
7 files changed, 28 insertions, 28 deletions
diff --git a/accel-pppd/ppp/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c
index 31bbad4d..4e8d6b93 100644
--- a/accel-pppd/ppp/ccp_mppe.c
+++ b/accel-pppd/ppp/ccp_mppe.c
@@ -115,7 +115,7 @@ static int setup_mppe_key(int fd, int transmit, uint8_t *key)
data.length = sizeof(buf);
data.transmit = transmit;
- if (ioctl(fd, PPPIOCSCOMPRESS, &data)) {
+ if (net->ppp_ioctl(fd, PPPIOCSCOMPRESS, &data)) {
log_ppp_warn("mppe: MPPE requested but not supported by kernel\n");
return -1;
}
@@ -129,14 +129,14 @@ static int decrease_mtu(struct ppp_t *ppp)
strcpy(ifr.ifr_name, ppp->ses.ifname);
- if (ioctl(sock_fd, SIOCGIFMTU, &ifr)) {
+ if (net->ppp_ioctl(sock_fd, SIOCGIFMTU, &ifr)) {
log_ppp_error("mppe: failed to get MTU: %s\n", strerror(errno));
return -1;
}
ifr.ifr_mtu -= MPPE_PAD;
- if (ioctl(sock_fd, SIOCSIFMTU, &ifr)) {
+ if (net->ppp_ioctl(sock_fd, SIOCSIFMTU, &ifr)) {
log_ppp_error("mppe: failed to set MTU: %s\n", strerror(errno));
return -1;
}
diff --git a/accel-pppd/ppp/lcp_opt_accomp.c b/accel-pppd/ppp/lcp_opt_accomp.c
index f55ed3cf..7440fcf2 100644
--- a/accel-pppd/ppp/lcp_opt_accomp.c
+++ b/accel-pppd/ppp/lcp_opt_accomp.c
@@ -112,14 +112,14 @@ static int accomp_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt,
struct accomp_option_t *accomp_opt = container_of(opt, typeof(*accomp_opt), opt);
int flags;
- if (ioctl(lcp->ppp->chan_fd, PPPIOCGFLAGS, &flags))
+ if (net->ppp_ioctl(lcp->ppp->chan_fd, PPPIOCGFLAGS, &flags))
goto err;
flags &= ~SC_COMP_AC;
if (accomp_opt->accomp & 1)
flags |= SC_COMP_AC;
- if (ioctl(lcp->ppp->chan_fd, PPPIOCSFLAGS, &flags))
+ if (net->ppp_ioctl(lcp->ppp->chan_fd, PPPIOCSFLAGS, &flags))
goto err;
return 0;
diff --git a/accel-pppd/ppp/lcp_opt_mru.c b/accel-pppd/ppp/lcp_opt_mru.c
index 1a6b187d..5f19bb21 100644
--- a/accel-pppd/ppp/lcp_opt_mru.c
+++ b/accel-pppd/ppp/lcp_opt_mru.c
@@ -125,7 +125,7 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
{
struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
- if (ioctl(lcp->ppp->chan_fd, PPPIOCSMRU, &mru_opt->mru) &&
+ if (net->ppp_ioctl(lcp->ppp->chan_fd, PPPIOCSMRU, &mru_opt->mru) &&
errno != EIO && errno != ENOTTY)
log_ppp_error("lcp:mru: failed to set channel MRU: %s\n", strerror(errno));
diff --git a/accel-pppd/ppp/lcp_opt_pcomp.c b/accel-pppd/ppp/lcp_opt_pcomp.c
index 28ca98f9..97560ccf 100644
--- a/accel-pppd/ppp/lcp_opt_pcomp.c
+++ b/accel-pppd/ppp/lcp_opt_pcomp.c
@@ -112,14 +112,14 @@ static int pcomp_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt,
struct pcomp_option_t *pcomp_opt = container_of(opt, typeof(*pcomp_opt), opt);
int flags;
- if (ioctl(lcp->ppp->chan_fd, PPPIOCGFLAGS, &flags))
+ if (net->ppp_ioctl(lcp->ppp->chan_fd, PPPIOCGFLAGS, &flags))
goto err;
flags &= ~SC_COMP_AC;
if (pcomp_opt->pcomp & 1)
flags |= SC_COMP_AC;
- if (ioctl(lcp->ppp->chan_fd, PPPIOCSFLAGS, &flags))
+ if (net->ppp_ioctl(lcp->ppp->chan_fd, PPPIOCSFLAGS, &flags))
goto err;
return 0;
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index c47d8d93..22ebc24f 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -80,12 +80,12 @@ int __export establish_ppp(struct ppp_t *ppp)
return -1;
/* Open an instance of /dev/ppp and connect the channel to it */
- if (ioctl(ppp->fd, PPPIOCGCHAN, &ppp->chan_idx) == -1) {
+ if (net->ppp_ioctl(ppp->fd, PPPIOCGCHAN, &ppp->chan_idx) == -1) {
log_ppp_error("ioctl(PPPIOCGCHAN): %s\n", strerror(errno));
return -1;
}
- ppp->chan_fd = open("/dev/ppp", O_RDWR);
+ ppp->chan_fd = net->ppp_open();
if (ppp->chan_fd < 0) {
log_ppp_error("open(chan) /dev/ppp: %s\n", strerror(errno));
return -1;
@@ -98,7 +98,7 @@ int __export establish_ppp(struct ppp_t *ppp)
goto exit_close_chan;
}
- if (ioctl(ppp->chan_fd, PPPIOCATTCHAN, &ppp->chan_idx) < 0) {
+ if (net->ppp_ioctl(ppp->chan_fd, PPPIOCATTCHAN, &ppp->chan_idx) < 0) {
log_ppp_error("ioctl(PPPIOCATTCHAN): %s\n", strerror(errno));
goto exit_close_chan;
}
@@ -155,7 +155,7 @@ int __export connect_ppp_channel(struct ppp_t *ppp)
ppp->ses.unit_idx = uc->unit_idx;
mempool_free(uc);
} else {
- ppp->unit_fd = open("/dev/ppp", O_RDWR);
+ ppp->unit_fd = net->ppp_open();
if (ppp->unit_fd < 0) {
log_ppp_error("open(unit) /dev/ppp: %s\n", strerror(errno));
goto exit;
@@ -163,7 +163,7 @@ int __export connect_ppp_channel(struct ppp_t *ppp)
fcntl(ppp->unit_fd, F_SETFD, fcntl(ppp->unit_fd, F_GETFD) | FD_CLOEXEC);
- if (ioctl(ppp->unit_fd, PPPIOCNEWUNIT, &ppp->ses.unit_idx) < 0) {
+ if (net->ppp_ioctl(ppp->unit_fd, PPPIOCNEWUNIT, &ppp->ses.unit_idx) < 0) {
log_ppp_error("ioctl(PPPIOCNEWUNIT): %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -174,7 +174,7 @@ int __export connect_ppp_channel(struct ppp_t *ppp)
}
}
- if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->ses.unit_idx) < 0) {
+ if (net->ppp_ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->ses.unit_idx) < 0) {
log_ppp_error("ioctl(PPPIOCCONNECT): %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -185,17 +185,17 @@ int __export connect_ppp_channel(struct ppp_t *ppp)
ifr.ifr_mtu = ppp->mtu;
strcpy(ifr.ifr_name, ppp->ses.ifname);
- if (ppp->mtu && ioctl(sock_fd, SIOCSIFMTU, &ifr)) {
+ if (ppp->mtu && net->sock_ioctl(SIOCSIFMTU, &ifr)) {
log_ppp_error("failed to set MTU: %s\n", strerror(errno));
goto exit_close_unit;
}
- if (ppp->mru && ioctl(ppp->unit_fd, PPPIOCSMRU, &ppp->mru)) {
+ if (ppp->mru && net->ppp_ioctl(ppp->unit_fd, PPPIOCSMRU, &ppp->mru)) {
log_ppp_error("failed to set MRU: %s\n", strerror(errno));
goto exit_close_unit;
}
- if (ioctl(sock_fd, SIOCGIFINDEX, &ifr)) {
+ if (net->sock_ioctl(SIOCGIFINDEX, &ifr)) {
log_ppp_error("ioctl(SIOCGIFINDEX): %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -247,7 +247,7 @@ static void destablish_ppp(struct ppp_t *ppp)
sprintf(ifr.ifr_newname, "ppp%i", ppp->ses.unit_idx);
if (strcmp(ifr.ifr_newname, ppp->ses.ifname)) {
strncpy(ifr.ifr_name, ppp->ses.ifname, IFNAMSIZ);
- if (ioctl(sock_fd, SIOCSIFNAME, &ifr)) {
+ if (net->sock_ioctl(SIOCSIFNAME, &ifr)) {
triton_md_unregister_handler(&ppp->unit_hnd, 1);
goto skip;
}
diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c
index ceaccee2..f9e05e89 100644
--- a/accel-pppd/ppp/ppp_ccp.c
+++ b/accel-pppd/ppp/ppp_ccp.c
@@ -75,7 +75,7 @@ static int ccp_set_flags(int fd, int isopen, int isup)
{
int flags;
- if (ioctl(fd, PPPIOCGFLAGS, &flags)) {
+ if (net->ppp_ioctl(fd, PPPIOCGFLAGS, &flags)) {
log_ppp_error("ccp: failed to get flags: %s\n", strerror(errno));
return -1;
}
@@ -83,7 +83,7 @@ static int ccp_set_flags(int fd, int isopen, int isup)
flags &= ~(SC_CCP_OPEN | SC_CCP_UP);
flags |= (isopen ? SC_CCP_OPEN : 0) | (isup ? SC_CCP_UP : 0);
- if (ioctl(fd, PPPIOCSFLAGS, &flags)) {
+ if (net->ppp_ioctl(fd, PPPIOCSFLAGS, &flags)) {
log_ppp_error("ccp: failed to set flags: %s\n", strerror(errno));
return -1;
}
diff --git a/accel-pppd/ppp/ppp_ifcfg.c b/accel-pppd/ppp/ppp_ifcfg.c
index f2d6bff1..5f767219 100644
--- a/accel-pppd/ppp/ppp_ifcfg.c
+++ b/accel-pppd/ppp/ppp_ifcfg.c
@@ -76,13 +76,13 @@ void ppp_ifup(struct ppp_t *ppp)
addr.sin_addr.s_addr = ppp->ses.ipv4->addr;
memcpy(&ifr.ifr_addr,&addr,sizeof(addr));
- if (ioctl(sock_fd, SIOCSIFADDR, &ifr))
+ if (net->sock_ioctl(SIOCSIFADDR, &ifr))
log_ppp_error("ppp: failed to set IPv4 address: %s\n", strerror(errno));
addr.sin_addr.s_addr = ppp->ses.ipv4->peer_addr;
memcpy(&ifr.ifr_dstaddr,&addr,sizeof(addr));
- if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr))
+ if (net->sock_ioctl(SIOCSIFDSTADDR, &ifr))
log_ppp_error("ppp: failed to set peer IPv4 address: %s\n", strerror(errno));
}
@@ -112,19 +112,19 @@ void ppp_ifup(struct ppp_t *ppp)
}
}
- if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr))
+ if (net->sock_ioctl(SIOCGIFFLAGS, &ifr))
log_ppp_error("ppp: failed to get interface flags: %s\n", strerror(errno));
ifr.ifr_flags |= IFF_UP | IFF_POINTOPOINT;
- if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
+ if (net->sock_ioctl(SIOCSIFFLAGS, &ifr))
log_ppp_error("ppp: failed to set interface flags: %s\n", strerror(errno));
if (ppp->ses.ipv4) {
np.protocol = PPP_IP;
np.mode = NPMODE_PASS;
- if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
+ if (net->ppp_ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
log_ppp_error("ppp: failed to set NP (IPv4) mode: %s\n", strerror(errno));
}
@@ -132,7 +132,7 @@ void ppp_ifup(struct ppp_t *ppp)
np.protocol = PPP_IPV6;
np.mode = NPMODE_PASS;
- if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
+ if (net->ppp_ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np))
log_ppp_error("ppp: failed to set NP (IPv6) mode: %s\n", strerror(errno));
}
@@ -150,13 +150,13 @@ void __export ppp_ifdown(struct ppp_t *ppp)
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ppp->ifname);
- ioctl(sock_fd, SIOCSIFFLAGS, &ifr);
+ net->sock_ioctl(SIOCSIFFLAGS, &ifr);
if (ppp->ses.ipv4) {
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
memcpy(&ifr.ifr_addr,&addr,sizeof(addr));
- ioctl(sock_fd, SIOCSIFADDR, &ifr);
+ net->sock_ioctl(SIOCSIFADDR, &ifr);
}
if (ppp->ses.ipv6) {