summaryrefslogtreecommitdiff
path: root/accel-pptpd/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/ppp')
-rw-r--r--accel-pptpd/ppp/ipcp_opt_ipaddr.c17
-rw-r--r--accel-pptpd/ppp/lcp_opt_magic.c2
-rw-r--r--accel-pptpd/ppp/lcp_opt_mru.c7
-rw-r--r--accel-pptpd/ppp/ppp.c58
-rw-r--r--accel-pptpd/ppp/ppp.h3
-rw-r--r--accel-pptpd/ppp/ppp_auth.c24
-rw-r--r--accel-pptpd/ppp/ppp_ccp.c97
-rw-r--r--accel-pptpd/ppp/ppp_fsm.c12
-rw-r--r--accel-pptpd/ppp/ppp_ipcp.c95
-rw-r--r--accel-pptpd/ppp/ppp_lcp.c106
10 files changed, 209 insertions, 212 deletions
diff --git a/accel-pptpd/ppp/ipcp_opt_ipaddr.c b/accel-pptpd/ppp/ipcp_opt_ipaddr.c
index 64f06cd..b7f8636 100644
--- a/accel-pptpd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pptpd/ppp/ipcp_opt_ipaddr.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
@@ -64,12 +65,12 @@ static int ipaddr_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
if (!ipaddr_opt->ip) {
ipaddr_opt->ip = ipdb_get(ipcp->ppp);
if (!ipaddr_opt->ip) {
- log_warn("ppp:ipcp: no free IP address\n");
+ log_ppp_warn("ppp:ipcp: no free IP address\n");
return -1;
}
}
if (!iprange_client_check(ipaddr_opt->ip->peer_addr)) {
- log_warn("ppp:ipcp: to avoid hard loops requested IP cannot be assigned (%i.%i.%i.%i)\n",
+ log_ppp_warn("ppp:ipcp: to avoid hard loops requested IP cannot be assigned (%i.%i.%i.%i)\n",
ipaddr_opt->ip->peer_addr&0xff,
(ipaddr_opt->ip->peer_addr >> 8)&0xff,
(ipaddr_opt->ip->peer_addr >> 16)&0xff,
@@ -115,34 +116,34 @@ ack:
memset(&ifr, 0, sizeof(ifr));
memset(&addr, 0, sizeof(addr));
- sprintf(ifr.ifr_name,"ppp%i",ipcp->ppp->unit_idx);
+ strcpy(ifr.ifr_name, ipcp->ppp->ifname);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = ipaddr_opt->ip->addr;
memcpy(&ifr.ifr_addr,&addr,sizeof(addr));
if (ioctl(sock_fd, SIOCSIFADDR, &ifr))
- log_error("\nipcp: failed to set PA address: %s\n", strerror(errno));
+ log_ppp_error("ipcp: failed to set PA address: %s\n", strerror(errno));
addr.sin_addr.s_addr = ipaddr_opt->ip->peer_addr;
memcpy(&ifr.ifr_dstaddr,&addr,sizeof(addr));
if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr))
- log_error("\nipcp: failed to set remote PA address: %s\n", strerror(errno));
+ log_ppp_error("ipcp: failed to set remote PA address: %s\n", strerror(errno));
if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr))
- log_error("\nipcp: failed to get interface flags: %s\n", strerror(errno));
+ log_ppp_error("ipcp: failed to get interface flags: %s\n", strerror(errno));
ifr.ifr_flags |= IFF_UP | IFF_POINTOPOINT;
if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
- log_error("\nipcp: failed to set interface flags: %s\n", strerror(errno));
+ log_ppp_error("ipcp: failed to set interface flags: %s\n", strerror(errno));
np.protocol = PPP_IP;
np.mode = NPMODE_PASS;
if (ioctl(ipcp->ppp->unit_fd, PPPIOCSNPMODE, &np))
- log_error("\nipcp: failed to set NP mode: %s\n", strerror(errno));
+ log_ppp_error("ipcp: failed to set NP mode: %s\n", strerror(errno));
return IPCP_OPT_ACK;
}
diff --git a/accel-pptpd/ppp/lcp_opt_magic.c b/accel-pptpd/ppp/lcp_opt_magic.c
index dc94ac6..d6094c0 100644
--- a/accel-pptpd/ppp/lcp_opt_magic.c
+++ b/accel-pptpd/ppp/lcp_opt_magic.c
@@ -64,7 +64,7 @@ static int magic_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt,
if (magic_opt->magic==ntohl(opt32->val))
{
- log_error("loop detected");
+ log_ppp_error("loop detected");
return -1;
}
return LCP_OPT_ACK;
diff --git a/accel-pptpd/ppp/lcp_opt_mru.c b/accel-pptpd/ppp/lcp_opt_mru.c
index e1c13b4..fc79db3 100644
--- a/accel-pptpd/ppp/lcp_opt_mru.c
+++ b/accel-pptpd/ppp/lcp_opt_mru.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <stdio.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <linux/if_ppp.h>
@@ -96,13 +97,13 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
.ifr_mtu = mru_opt->mtu,
};
- sprintf(ifr.ifr_name,"ppp%i",lcp->ppp->unit_idx);
+ strcpy(ifr.ifr_name, lcp->ppp->ifname);
if (ioctl(lcp->ppp->unit_fd, PPPIOCSMRU, &mru_opt->mru))
- log_error("\nlcp:mru: failed to set MRU: %s\n", strerror(errno));
+ log_ppp_error("lcp:mru: failed to set MRU: %s\n", strerror(errno));
if (ioctl(sock_fd, SIOCSIFMTU, &ifr))
- log_error("\nlcp:mru: failed to set MTU: %s\n", strerror(errno));
+ log_ppp_error("lcp:mru: failed to set MTU: %s\n", strerror(errno));
return 0;
}
diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c
index 8f385e7..87c8e8e 100644
--- a/accel-pptpd/ppp/ppp.c
+++ b/accel-pptpd/ppp/ppp.c
@@ -37,11 +37,12 @@ static void init_layers(struct ppp_t *);
static void free_layers(struct ppp_t *);
static void start_first_layer(struct ppp_t *);
-struct ppp_t *init_ppp(void)
+void __export ppp_init(struct ppp_t *ppp)
{
- struct ppp_t *ppp=malloc(sizeof(*ppp));
memset(ppp,0,sizeof(*ppp));
- return ppp;
+ INIT_LIST_HEAD(&ppp->chan_handlers);
+ INIT_LIST_HEAD(&ppp->unit_handlers);
+ INIT_LIST_HEAD(&ppp->pd_list);
}
static void free_ppp(struct ppp_t *ppp)
@@ -77,70 +78,67 @@ int __export establish_ppp(struct ppp_t *ppp)
/* Open an instance of /dev/ppp and connect the channel to it */
if (ioctl(ppp->fd, PPPIOCGCHAN, &ppp->chan_idx)==-1)
{
- log_error("Couldn't get channel number\n");
+ log_ppp_error("Couldn't get channel number\n");
return -1;
}
ppp->chan_fd=open("/dev/ppp", O_RDWR);
if (ppp->chan_fd<0)
{
- log_error("Couldn't reopen /dev/ppp\n");
+ log_ppp_error("Couldn't reopen /dev/ppp\n");
return -1;
}
if (ioctl(ppp->chan_fd, PPPIOCATTCHAN, &ppp->chan_idx)<0)
{
- log_error("Couldn't attach to channel %d\n", ppp->chan_idx);
+ log_ppp_error("Couldn't attach to channel %d\n", ppp->chan_idx);
goto exit_close_chan;
}
ppp->unit_fd=open("/dev/ppp", O_RDWR);
if (ppp->unit_fd<0)
{
- log_error("Couldn't reopen /dev/ppp\n");
+ log_ppp_error("Couldn't reopen /dev/ppp\n");
goto exit_close_chan;
}
ppp->unit_idx=-1;
if (ioctl(ppp->unit_fd, PPPIOCNEWUNIT, &ppp->unit_idx)<0)
{
- log_error("Couldn't create new ppp unit\n");
+ log_ppp_error("Couldn't create new ppp unit\n");
goto exit_close_unit;
}
if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->unit_idx)<0)
{
- log_error("Couldn't attach to PPP unit %d\n", ppp->unit_idx);
+ log_ppp_error("Couldn't attach to PPP unit %d\n", ppp->unit_idx);
goto exit_close_unit;
}
ppp->start_time = time(NULL);
generate_sessionid(ppp);
+ sprintf(ppp->ifname, "ppp%i", ppp->unit_idx);
- log_info("connect: ppp%i <--> pptp(%s)\n",ppp->unit_idx,ppp->chan_name);
+ log_ppp_info("connect: ppp%i <--> pptp(%s)\n",ppp->unit_idx,ppp->chan_name);
ppp->chan_buf=malloc(PPP_MRU);
ppp->unit_buf=malloc(PPP_MRU);
- INIT_LIST_HEAD(&ppp->chan_handlers);
- INIT_LIST_HEAD(&ppp->unit_handlers);
- INIT_LIST_HEAD(&ppp->pd_list);
-
init_layers(ppp);
if (list_empty(&ppp->layers))
{
- log_error("no layers to start\n");
+ log_ppp_error("no layers to start\n");
goto exit_close_unit;
}
if (fcntl(ppp->chan_fd, F_SETFL, O_NONBLOCK)) {
- log_error("ppp: cann't to set nonblocking mode: %s\n", strerror(errno));
+ log_ppp_error("ppp: cann't to set nonblocking mode: %s\n", strerror(errno));
goto exit_close_unit;
}
if (fcntl(ppp->unit_fd, F_SETFL, O_NONBLOCK)) {
- log_error("ppp: cann't to set nonblocking mode: %s\n", strerror(errno));
+ log_ppp_error("ppp: cann't to set nonblocking mode: %s\n", strerror(errno));
goto exit_close_unit;
}
@@ -156,7 +154,7 @@ int __export establish_ppp(struct ppp_t *ppp)
triton_md_enable_handler(&ppp->chan_hnd,MD_MODE_READ);
triton_md_enable_handler(&ppp->unit_hnd,MD_MODE_READ);
- log_debug("ppp established\n");
+ log_ppp_debug("ppp established\n");
triton_event_fire(EV_PPP_STARTING, ppp);
start_first_layer(ppp);
@@ -180,6 +178,7 @@ static void destablish_ppp(struct ppp_t *ppp)
close(ppp->unit_fd);
close(ppp->chan_fd);
+ close(ppp->fd);
ppp->unit_fd = -1;
ppp->chan_fd = -1;
@@ -189,7 +188,7 @@ static void destablish_ppp(struct ppp_t *ppp)
free_layers(ppp);
- log_debug("ppp destablished\n");
+ log_ppp_debug("ppp destablished\n");
triton_event_fire(EV_PPP_FINISHED, ppp);
ppp->ctrl->finished(ppp);
@@ -212,7 +211,7 @@ int __export ppp_chan_send(struct ppp_t *ppp, void *data, int size)
n=write(ppp->chan_fd,data,size);
if (n<size)
- log_error("ppp_chan_send: short write %i, excpected %i\n",n,size);
+ log_ppp_error("ppp_chan_send: short write %i, excpected %i\n",n,size);
return n;
}
@@ -225,7 +224,7 @@ int __export ppp_unit_send(struct ppp_t *ppp, void *data, int size)
n=write(ppp->unit_fd,data,size);
if (n<size)
- log_error("ppp_unit_send: short write %i, excpected %i\n",n,size);
+ log_ppp_error("ppp_unit_send: short write %i, excpected %i\n",n,size);
return n;
}
@@ -243,7 +242,7 @@ cont:
continue;
if (errno == EAGAIN)
return 0;
- log_error("ppp_chan_read: %s\n",strerror(errno));
+ log_ppp_error("ppp_chan_read: %s\n",strerror(errno));
return 0;
}
@@ -251,7 +250,7 @@ cont:
//print_buf(ppp->chan_buf,ppp->chan_buf_size);
if (ppp->chan_buf_size < 2) {
- log_error("ppp_chan_read: short read %i\n", ppp->chan_buf_size);
+ log_ppp_error("ppp_chan_read: short read %i\n", ppp->chan_buf_size);
continue;
}
@@ -267,7 +266,7 @@ cont:
}
}
- log_warn("ppp_chan_read: discarding unknown packet %x\n", proto);
+ log_ppp_warn("ppp_chan_read: discarding unknown packet %x\n", proto);
}
}
@@ -285,7 +284,7 @@ cont:
continue;
if (errno == EAGAIN)
return 0;
- log_error("ppp_chan_read: %s\n",strerror(errno));
+ log_ppp_error("ppp_chan_read: %s\n",strerror(errno));
return 0;
}
@@ -293,7 +292,7 @@ cont:
//print_buf(ppp->unit_buf,ppp->unit_buf_size);
if (ppp->unit_buf_size < 2) {
- log_error("ppp_chan_read: short read %i\n", ppp->unit_buf_size);
+ log_ppp_error("ppp_chan_read: short read %i\n", ppp->unit_buf_size);
continue;
}
@@ -309,7 +308,7 @@ cont:
}
}
- log_warn("ppp_unit_read: discarding unknown packet %x\n",proto);
+ log_ppp_warn("ppp_unit_read: discarding unknown packet %x\n",proto);
}
}
@@ -365,7 +364,7 @@ void __export ppp_terminate(struct ppp_t *ppp, int hard)
struct ppp_layer_data_t *d;
int s = 0;
- log_debug("ppp_terminate\n");
+ log_ppp_debug("ppp_terminate\n");
triton_event_fire(EV_PPP_FINISHING, ppp);
@@ -523,7 +522,7 @@ struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *ppp, struct ppp_layer
return NULL;
}
-static void __init ppp_init(void)
+static void __init init(void)
{
char *opt;
@@ -537,3 +536,4 @@ static void __init ppp_init(void)
if (opt && atoi(opt) > 0)
conf_ppp_verbose = 1;
}
+
diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h
index ce6854a..76b379f 100644
--- a/accel-pptpd/ppp/ppp.h
+++ b/accel-pptpd/ppp/ppp.h
@@ -43,6 +43,7 @@
#define PPP_LAYER_IPCP 4
#define PPP_SESSIONID_LEN 32
+#define PPP_IFNAME_LEN 10
struct ppp_t;
@@ -71,6 +72,7 @@ struct ppp_t
int unit_idx;
char *chan_name;
+ char ifname[PPP_IFNAME_LEN];
char sessionid[PPP_SESSIONID_LEN+1];
time_t start_time;
char *username;
@@ -122,6 +124,7 @@ struct ppp_handler_t
};
struct ppp_t *alloc_ppp(void);
+void ppp_init(struct ppp_t *ppp);
int establish_ppp(struct ppp_t *ppp);
int ppp_chan_send(struct ppp_t *ppp, void *data, int size);
int ppp_unit_send(struct ppp_t *ppp, void *data, int size);
diff --git a/accel-pptpd/ppp/ppp_auth.c b/accel-pptpd/ppp/ppp_auth.c
index 0a6630b..5ad7444 100644
--- a/accel-pptpd/ppp/ppp_auth.c
+++ b/accel-pptpd/ppp/ppp_auth.c
@@ -160,7 +160,7 @@ static int auth_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u
}
}
- log_msg("cann't negotiate authentication type\n");
+ log_ppp_msg("cann't negotiate authentication type\n");
return LCP_OPT_FAIL;
}
@@ -180,7 +180,7 @@ static int auth_recv_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u
if (!auth_opt->auth)
{
- log_error("auth: unexcepcted configure-nak\n");
+ log_ppp_error("auth: unexcepcted configure-nak\n");
return -1;
}
auth_opt->auth->state=LCP_OPT_NAK;
@@ -193,7 +193,7 @@ static int auth_recv_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u
return 0;
}
- log_msg("cann't negotiate authentication type\n");
+ log_ppp_msg("cann't negotiate authentication type\n");
return -1;
}
@@ -204,7 +204,7 @@ static int auth_recv_conf_rej(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u
if (!auth_opt->auth)
{
- log_error("auth: unexcepcted configure-reject\n");
+ log_ppp_error("auth: unexcepcted configure-reject\n");
return -1;
}
auth_opt->auth->state=LCP_OPT_NAK;
@@ -217,7 +217,7 @@ static int auth_recv_conf_rej(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u
return 0;
}
- log_msg("cann't negotiate authentication type\n");
+ log_ppp_msg("cann't negotiate authentication type\n");
return -1;
}
@@ -249,7 +249,7 @@ static struct ppp_layer_data_t *auth_layer_init(struct ppp_t *ppp)
{
struct auth_layer_data_t *ad=(struct auth_layer_data_t*)malloc(sizeof(*ad));
- log_debug("auth_layer_init\n");
+ log_ppp_debug("auth_layer_init\n");
memset(ad,0,sizeof(*ad));
@@ -262,13 +262,13 @@ static int auth_layer_start(struct ppp_layer_data_t *ld)
{
struct auth_layer_data_t *ad=container_of(ld,typeof(*ad),ld);
- log_debug("auth_layer_start\n");
+ log_ppp_debug("auth_layer_start\n");
if (ad->auth_opt.auth)
ad->auth_opt.auth->h->start(ad->ppp,ad->auth_opt.auth);
else
{
- log_debug("auth_layer_started\n");
+ log_ppp_debug("auth_layer_started\n");
ppp_layer_started(ad->ppp,ld);
}
@@ -279,12 +279,12 @@ static void auth_layer_finish(struct ppp_layer_data_t *ld)
{
struct auth_layer_data_t *ad=container_of(ld,typeof(*ad),ld);
- log_debug("auth_layer_finish\n");
+ log_ppp_debug("auth_layer_finish\n");
if (ad->auth_opt.auth)
ad->auth_opt.auth->h->finish(ad->ppp,ad->auth_opt.auth);
- log_debug("auth_layer_finished\n");
+ log_ppp_debug("auth_layer_finished\n");
ppp_layer_finished(ad->ppp,ld);
}
@@ -292,7 +292,7 @@ static void auth_layer_free(struct ppp_layer_data_t *ld)
{
struct auth_layer_data_t *ad=container_of(ld,typeof(*ad),ld);
- log_debug("auth_layer_free\n");
+ log_ppp_debug("auth_layer_free\n");
free(ad);
}
@@ -300,7 +300,7 @@ static void auth_layer_free(struct ppp_layer_data_t *ld)
void __export auth_successed(struct ppp_t *ppp, char *username)
{
struct auth_layer_data_t *ad=container_of(ppp_find_layer_data(ppp,&auth_layer),typeof(*ad),ld);
- log_debug("auth_layer_started\n");
+ log_ppp_debug("auth_layer_started\n");
ppp->username = username;
triton_event_fire(EV_PPP_AUTHORIZED, ppp);
ppp_layer_started(ppp,&ad->ld);
diff --git a/accel-pptpd/ppp/ppp_ccp.c b/accel-pptpd/ppp/ppp_ccp.c
index f895da9..8f240bc 100644
--- a/accel-pptpd/ppp/ppp_ccp.c
+++ b/accel-pptpd/ppp/ppp_ccp.c
@@ -35,8 +35,6 @@ static void ccp_options_init(struct ppp_ccp_t *ccp)
struct ccp_option_t *lopt;
struct ccp_option_handler_t *h;
- INIT_LIST_HEAD(&ccp->options);
-
list_for_each_entry(h,&option_handlers,entry)
{
lopt=h->init(ccp);
@@ -66,7 +64,7 @@ static struct ppp_layer_data_t *ccp_layer_init(struct ppp_t *ppp)
struct ppp_ccp_t *ccp=malloc(sizeof(*ccp));
memset(ccp,0,sizeof(*ccp));
- log_debug("ccp_layer_init\n");
+ log_ppp_debug("ccp_layer_init\n");
ccp->ppp=ppp;
ccp->fsm.ppp=ppp;
@@ -85,6 +83,7 @@ static struct ppp_layer_data_t *ccp_layer_init(struct ppp_t *ppp)
ccp->fsm.send_conf_nak=send_conf_nak;
ccp->fsm.send_conf_rej=send_conf_rej;
+ INIT_LIST_HEAD(&ccp->options);
INIT_LIST_HEAD(&ccp->ropt_list);
return &ccp->ld;
@@ -94,7 +93,7 @@ int ccp_layer_start(struct ppp_layer_data_t *ld)
{
struct ppp_ccp_t *ccp=container_of(ld,typeof(*ccp),ld);
- log_debug("ccp_layer_start\n");
+ log_ppp_debug("ccp_layer_start\n");
ccp_options_init(ccp);
ppp_fsm_lower_up(&ccp->fsm);
@@ -108,7 +107,7 @@ void ccp_layer_finish(struct ppp_layer_data_t *ld)
{
struct ppp_ccp_t *ccp=container_of(ld,typeof(*ccp),ld);
- log_debug("ccp_layer_finish\n");
+ log_ppp_debug("ccp_layer_finish\n");
ccp->fsm.fsm_state = FSM_Closed;
ppp_layer_finished(ccp->ppp,&ccp->ld);
@@ -118,7 +117,7 @@ void ccp_layer_free(struct ppp_layer_data_t *ld)
{
struct ppp_ccp_t *ccp=container_of(ld,typeof(*ccp),ld);
- log_debug("ccp_layer_free\n");
+ log_ppp_debug("ccp_layer_free\n");
ppp_unregister_handler(ccp->ppp,&ccp->hnd);
ccp_options_free(ccp);
@@ -130,14 +129,14 @@ void ccp_layer_free(struct ppp_layer_data_t *ld)
static void ccp_layer_up(struct ppp_fsm_t *fsm)
{
struct ppp_ccp_t *ccp=container_of(fsm,typeof(*ccp),fsm);
- log_debug("ccp_layer_started\n");
+ log_ppp_debug("ccp_layer_started\n");
ppp_layer_started(ccp->ppp,&ccp->ld);
}
static void ccp_layer_down(struct ppp_fsm_t *fsm)
{
struct ppp_ccp_t *ccp=container_of(fsm,typeof(*ccp),fsm);
- log_debug("ccp_layer_finished\n");
+ log_ppp_debug("ccp_layer_finished\n");
ppp_layer_finished(ccp->ppp,&ccp->ld);
}
@@ -146,12 +145,12 @@ static void print_ropt(struct recv_opt_t *ropt)
int i;
uint8_t *ptr=(uint8_t*)ropt->hdr;
- log_debug(" <");
+ log_ppp_debug(" <");
for(i=0; i<ropt->len; i++)
{
- log_debug(" %x",ptr[i]);
+ log_ppp_debug(" %x",ptr[i]);
}
- log_debug(" >");
+ log_ppp_debug(" >");
}
static int send_conf_req(struct ppp_fsm_t *fsm)
@@ -162,12 +161,12 @@ static int send_conf_req(struct ppp_fsm_t *fsm)
struct ccp_option_t *lopt;
int n;
- log_debug("send [CCP ConfReq");
+ log_ppp_debug("send [CCP ConfReq");
ccp_hdr->proto=htons(PPP_CCP);
ccp_hdr->code=CONFREQ;
ccp_hdr->id=++ccp->fsm.id;
ccp_hdr->len=0;
- log_debug(" id=%x",ccp_hdr->id);
+ log_ppp_debug(" id=%x",ccp_hdr->id);
ptr+=sizeof(*ccp_hdr);
@@ -178,13 +177,13 @@ static int send_conf_req(struct ppp_fsm_t *fsm)
return -1;
if (n)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,NULL);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,NULL);
ptr+=n;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
ccp_hdr->len=htons((ptr-buf)-2);
ppp_unit_send(ccp->ppp,ccp_hdr,ptr-buf);
@@ -198,7 +197,7 @@ static void send_conf_ack(struct ppp_fsm_t *fsm)
struct ccp_hdr_t *hdr=(struct ccp_hdr_t*)ccp->ppp->unit_buf;
hdr->code=CONFACK;
- log_debug("send [CCP ConfAck id=%x ]\n",ccp->fsm.recv_id);
+ log_ppp_debug("send [CCP ConfAck id=%x ]\n",ccp->fsm.recv_id);
ppp_unit_send(ccp->ppp,hdr,ntohs(hdr->len)+2);
}
@@ -210,7 +209,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
struct ccp_hdr_t *ccp_hdr=(struct ccp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [CCP ConfNak id=%x",ccp->fsm.recv_id);
+ log_ppp_debug("send [CCP ConfNak id=%x",ccp->fsm.recv_id);
ccp_hdr->proto=htons(PPP_CCP);
ccp_hdr->code=CONFNAK;
@@ -223,13 +222,13 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
{
if (ropt->state==CCP_OPT_NAK)
{
- log_debug(" ");
- ropt->lopt->h->print(log_debug,ropt->lopt,NULL);
+ log_ppp_debug(" ");
+ ropt->lopt->h->print(log_ppp_debug,ropt->lopt,NULL);
ptr+=ropt->lopt->h->send_conf_nak(ccp,ropt->lopt,ptr);
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
ccp_hdr->len=htons((ptr-buf)-2);
ppp_unit_send(ccp->ppp,ccp_hdr,ptr-buf);
@@ -242,7 +241,7 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
struct ccp_hdr_t *ccp_hdr=(struct ccp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [CCP ConfRej id=%x ",ccp->fsm.recv_id);
+ log_ppp_debug("send [CCP ConfRej id=%x ",ccp->fsm.recv_id);
ccp_hdr->proto=htons(PPP_CCP);
ccp_hdr->code=CONFREJ;
@@ -255,15 +254,15 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
{
if (ropt->state==CCP_OPT_REJ)
{
- log_debug(" ");
- if (ropt->lopt) ropt->lopt->h->print(log_debug,ropt->lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ if (ropt->lopt) ropt->lopt->h->print(log_ppp_debug,ropt->lopt,(uint8_t*)ropt->hdr);
else print_ropt(ropt);
memcpy(ptr,ropt->hdr,ropt->len);
ptr+=ropt->len;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
ccp_hdr->len=htons((ptr-buf)-2);
ppp_unit_send(ccp->ppp,ccp_hdr,ptr-buf);
@@ -297,15 +296,15 @@ static int ccp_recv_conf_req(struct ppp_ccp_t *ccp,uint8_t *data,int size)
list_for_each_entry(lopt,&ccp->options,entry)
lopt->state=CCP_OPT_NONE;
- log_debug("recv [CCP ConfReq id=%x",ccp->fsm.recv_id);
+ log_ppp_debug("recv [CCP ConfReq id=%x",ccp->fsm.recv_id);
list_for_each_entry(ropt,&ccp->ropt_list,entry)
{
list_for_each_entry(lopt,&ccp->options,entry)
{
if (lopt->id==ropt->hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,(uint8_t*)ropt->hdr);
r=lopt->h->recv_conf_req(ccp,lopt,(uint8_t*)ropt->hdr);
if (ack)
{
@@ -325,13 +324,13 @@ static int ccp_recv_conf_req(struct ppp_ccp_t *ccp,uint8_t *data,int size)
ack=1;
else if (!ropt->lopt)
{
- log_debug(" ");
+ log_ppp_debug(" ");
print_ropt(ropt);
ropt->state=CCP_OPT_REJ;
ret=CCP_OPT_REJ;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
/*list_for_each_entry(lopt,&ccp->options,entry)
{
@@ -364,11 +363,11 @@ static int ccp_recv_conf_rej(struct ppp_ccp_t *ccp,uint8_t *data,int size)
struct ccp_option_t *lopt;
int res=0;
- log_debug("recv [CCP ConfRej id=%x",ccp->fsm.recv_id);
+ log_ppp_debug("recv [CCP ConfRej id=%x",ccp->fsm.recv_id);
if (ccp->fsm.recv_id!=ccp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -391,7 +390,7 @@ static int ccp_recv_conf_rej(struct ppp_ccp_t *ccp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -401,11 +400,11 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp,uint8_t *data,int size)
struct ccp_option_t *lopt;
int res=0;
- log_debug("recv [CCP ConfNak id=%x",ccp->fsm.recv_id);
+ log_ppp_debug("recv [CCP ConfNak id=%x",ccp->fsm.recv_id);
if (ccp->fsm.recv_id!=ccp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -417,8 +416,8 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (lopt->h->recv_conf_nak(ccp,lopt,data))
res=-1;
break;
@@ -428,7 +427,7 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -438,11 +437,11 @@ static int ccp_recv_conf_ack(struct ppp_ccp_t *ccp,uint8_t *data,int size)
struct ccp_option_t *lopt;
int res=0;
- log_debug("recv [CCP ConfAck id=%x",ccp->fsm.recv_id);
+ log_ppp_debug("recv [CCP ConfAck id=%x",ccp->fsm.recv_id);
if (ccp->fsm.recv_id!=ccp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -454,8 +453,8 @@ static int ccp_recv_conf_ack(struct ppp_ccp_t *ccp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (!lopt->h->recv_conf_ack)
break;
if (lopt->h->recv_conf_ack(ccp,lopt,data))
@@ -467,7 +466,7 @@ static int ccp_recv_conf_ack(struct ppp_ccp_t *ccp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -480,20 +479,20 @@ static void ccp_recv(struct ppp_handler_t*h)
if (ccp->fsm.fsm_state==FSM_Initial || ccp->fsm.fsm_state==FSM_Closed)
{
- log_warn("CCP: discaring packet\n");
+ log_ppp_warn("CCP: discaring packet\n");
return;
}
if (ccp->ppp->unit_buf_size<PPP_HEADERLEN+2)
{
- log_warn("CCP: short packet received\n");
+ log_ppp_warn("CCP: short packet received\n");
return;
}
hdr=(struct ccp_hdr_t *)ccp->ppp->unit_buf;
if (ntohs(hdr->len)<PPP_HEADERLEN)
{
- log_warn("CCP: short packet received\n");
+ log_ppp_warn("CCP: short packet received\n");
return;
}
@@ -536,19 +535,19 @@ static void ccp_recv(struct ppp_handler_t*h)
break;
case TERMREQ:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [CCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [CCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_req(&ccp->fsm);
ppp_terminate(ccp->ppp, 0);
break;
case TERMACK:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [CCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [CCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_ack(&ccp->fsm);
break;
case CODEREJ:
- log_debug("recv [CCP CodeRej id=%x]\n",hdr->id);
+ log_ppp_debug("recv [CCP CodeRej id=%x]\n",hdr->id);
ppp_fsm_recv_code_rej_bad(&ccp->fsm);
break;
default:
diff --git a/accel-pptpd/ppp/ppp_fsm.c b/accel-pptpd/ppp/ppp_fsm.c
index a99453f..20fe8ff 100644
--- a/accel-pptpd/ppp/ppp_fsm.c
+++ b/accel-pptpd/ppp/ppp_fsm.c
@@ -466,7 +466,7 @@ void send_term_req(struct ppp_fsm_t *layer)
.len = htons(4),
};
- log_debug("send [LCP TermReq id=%i \"\"]\n",hdr.id);
+ log_ppp_debug("send [LCP TermReq id=%i \"\"]\n",hdr.id);
--layer->restart_counter;
ppp_chan_send(layer->ppp, &hdr, 6);
@@ -480,27 +480,23 @@ void send_term_ack(struct ppp_fsm_t *layer)
.len = htons(4),
};
- log_debug("send [LCP TermAck id=%i \"\"]\n", hdr.id);
+ log_ppp_debug("send [LCP TermAck id=%i \"\"]\n", hdr.id);
ppp_chan_send(layer->ppp, &hdr, 6);
}
static void stop_timer(struct ppp_fsm_t *fsm)
{
- if (fsm->restart_timer.period) {
- fsm->restart_timer.period = 0;
+ if (fsm->restart_timer.tpd)
triton_timer_del(&fsm->restart_timer);
- }
}
static void init_req_counter(struct ppp_fsm_t *layer,int timeout)
{
layer->restart_timer.expire_tv.tv_sec=0;
layer->restart_counter = timeout;
- if (!layer->restart_timer.period) {
- layer->restart_timer.period = layer->timeout * 1000;
+ if (!layer->restart_timer.tpd)
triton_timer_add(layer->ppp->ctrl->ctx, &layer->restart_timer, 0);
- }
}
static void zero_req_counter(struct ppp_fsm_t *layer)
{
diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c
index bb6369e..b8dfe7f 100644
--- a/accel-pptpd/ppp/ppp_ipcp.c
+++ b/accel-pptpd/ppp/ppp_ipcp.c
@@ -35,8 +35,6 @@ static void ipcp_options_init(struct ppp_ipcp_t *ipcp)
struct ipcp_option_t *lopt;
struct ipcp_option_handler_t *h;
- INIT_LIST_HEAD(&ipcp->options);
-
list_for_each_entry(h,&option_handlers,entry)
{
lopt=h->init(ipcp);
@@ -66,7 +64,7 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp)
struct ppp_ipcp_t *ipcp=malloc(sizeof(*ipcp));
memset(ipcp,0,sizeof(*ipcp));
- log_debug("ipcp_layer_init\n");
+ log_ppp_debug("ipcp_layer_init\n");
ipcp->ppp=ppp;
ipcp->fsm.ppp=ppp;
@@ -85,6 +83,7 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp)
ipcp->fsm.send_conf_nak=send_conf_nak;
ipcp->fsm.send_conf_rej=send_conf_rej;
+ INIT_LIST_HEAD(&ipcp->options);
INIT_LIST_HEAD(&ipcp->ropt_list);
return &ipcp->ld;
@@ -94,7 +93,7 @@ int ipcp_layer_start(struct ppp_layer_data_t *ld)
{
struct ppp_ipcp_t *ipcp=container_of(ld,typeof(*ipcp),ld);
- log_debug("ipcp_layer_start\n");
+ log_ppp_debug("ipcp_layer_start\n");
ipcp_options_init(ipcp);
ppp_fsm_lower_up(&ipcp->fsm);
@@ -108,7 +107,7 @@ void ipcp_layer_finish(struct ppp_layer_data_t *ld)
{
struct ppp_ipcp_t *ipcp=container_of(ld,typeof(*ipcp),ld);
- log_debug("ipcp_layer_finish\n");
+ log_ppp_debug("ipcp_layer_finish\n");
ipcp->fsm.fsm_state = FSM_Closed;
ppp_layer_finished(ipcp->ppp,&ipcp->ld);
@@ -118,7 +117,7 @@ void ipcp_layer_free(struct ppp_layer_data_t *ld)
{
struct ppp_ipcp_t *ipcp=container_of(ld,typeof(*ipcp),ld);
- log_debug("ipcp_layer_free\n");
+ log_ppp_debug("ipcp_layer_free\n");
ppp_unregister_handler(ipcp->ppp,&ipcp->hnd);
ipcp_options_free(ipcp);
@@ -130,14 +129,14 @@ void ipcp_layer_free(struct ppp_layer_data_t *ld)
static void ipcp_layer_up(struct ppp_fsm_t *fsm)
{
struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm);
- log_debug("ipcp_layer_started\n");
+ log_ppp_debug("ipcp_layer_started\n");
ppp_layer_started(ipcp->ppp,&ipcp->ld);
}
static void ipcp_layer_down(struct ppp_fsm_t *fsm)
{
struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm);
- log_debug("ipcp_layer_finished\n");
+ log_ppp_debug("ipcp_layer_finished\n");
ppp_layer_finished(ipcp->ppp,&ipcp->ld);
}
@@ -146,12 +145,12 @@ static void print_ropt(struct recv_opt_t *ropt)
int i;
uint8_t *ptr=(uint8_t*)ropt->hdr;
- log_debug(" <");
+ log_ppp_debug(" <");
for(i=0; i<ropt->len; i++)
{
- log_debug(" %x",ptr[i]);
+ log_ppp_debug(" %x",ptr[i]);
}
- log_debug(" >");
+ log_ppp_debug(" >");
}
static int send_conf_req(struct ppp_fsm_t *fsm)
@@ -182,14 +181,14 @@ static int send_conf_req(struct ppp_fsm_t *fsm)
}
if (conf_ppp_verbose) {
- log_debug("send [IPCP ConfReq id=%x", ipcp_hdr->id);
+ log_ppp_debug("send [IPCP ConfReq id=%x", ipcp_hdr->id);
list_for_each_entry(lopt,&ipcp->options,entry){
if (lopt->print) {
- log_debug(" ");
- lopt->h->print(log_debug,lopt,NULL);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,NULL);
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
}
ipcp_hdr->len=htons((ptr-buf)-2);
@@ -204,7 +203,7 @@ static void send_conf_ack(struct ppp_fsm_t *fsm)
struct ipcp_hdr_t *hdr=(struct ipcp_hdr_t*)ipcp->ppp->unit_buf;
hdr->code=CONFACK;
- log_debug("send [IPCP ConfAck id=%x ]\n",ipcp->fsm.recv_id);
+ log_ppp_debug("send [IPCP ConfAck id=%x ]\n",ipcp->fsm.recv_id);
ppp_unit_send(ipcp->ppp,hdr,ntohs(hdr->len)+2);
}
@@ -216,7 +215,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
struct ipcp_hdr_t *ipcp_hdr=(struct ipcp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [IPCP ConfNak id=%x",ipcp->fsm.recv_id);
+ log_ppp_debug("send [IPCP ConfNak id=%x",ipcp->fsm.recv_id);
ipcp_hdr->proto=htons(PPP_IPCP);
ipcp_hdr->code=CONFNAK;
@@ -229,13 +228,13 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
{
if (ropt->state==IPCP_OPT_NAK)
{
- log_debug(" ");
- ropt->lopt->h->print(log_debug,ropt->lopt,NULL);
+ log_ppp_debug(" ");
+ ropt->lopt->h->print(log_ppp_debug,ropt->lopt,NULL);
ptr+=ropt->lopt->h->send_conf_nak(ipcp,ropt->lopt,ptr);
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
ipcp_hdr->len=htons((ptr-buf)-2);
ppp_unit_send(ipcp->ppp,ipcp_hdr,ptr-buf);
@@ -248,7 +247,7 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
struct ipcp_hdr_t *ipcp_hdr=(struct ipcp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [IPCP ConfRej id=%x ",ipcp->fsm.recv_id);
+ log_ppp_debug("send [IPCP ConfRej id=%x ",ipcp->fsm.recv_id);
ipcp_hdr->proto=htons(PPP_IPCP);
ipcp_hdr->code=CONFREJ;
@@ -261,15 +260,15 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
{
if (ropt->state==IPCP_OPT_REJ)
{
- log_debug(" ");
- if (ropt->lopt) ropt->lopt->h->print(log_debug,ropt->lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ if (ropt->lopt) ropt->lopt->h->print(log_ppp_debug,ropt->lopt,(uint8_t*)ropt->hdr);
else print_ropt(ropt);
memcpy(ptr,ropt->hdr,ropt->len);
ptr+=ropt->len;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
ipcp_hdr->len=htons((ptr-buf)-2);
ppp_unit_send(ipcp->ppp,ipcp_hdr,ptr-buf);
@@ -303,15 +302,15 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
list_for_each_entry(lopt,&ipcp->options,entry)
lopt->state=IPCP_OPT_NONE;
- log_debug("recv [IPCP ConfReq id=%x",ipcp->fsm.recv_id);
+ log_ppp_debug("recv [IPCP ConfReq id=%x",ipcp->fsm.recv_id);
list_for_each_entry(ropt,&ipcp->ropt_list,entry)
{
list_for_each_entry(lopt,&ipcp->options,entry)
{
if (lopt->id==ropt->hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,(uint8_t*)ropt->hdr);
r=lopt->h->recv_conf_req(ipcp,lopt,(uint8_t*)ropt->hdr);
lopt->state=r;
ropt->state=r;
@@ -322,13 +321,13 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
}
if (!ropt->lopt)
{
- log_debug(" ");
+ log_ppp_debug(" ");
print_ropt(ropt);
ropt->state=IPCP_OPT_REJ;
ret=IPCP_OPT_REJ;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
/*list_for_each_entry(lopt,&ipcp->options,entry)
{
@@ -361,11 +360,11 @@ static int ipcp_recv_conf_rej(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
struct ipcp_option_t *lopt;
int res=0;
- log_debug("recv [IPCP ConfRej id=%x",ipcp->fsm.recv_id);
+ log_ppp_debug("recv [IPCP ConfRej id=%x",ipcp->fsm.recv_id);
if (ipcp->fsm.recv_id!=ipcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -388,7 +387,7 @@ static int ipcp_recv_conf_rej(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -398,11 +397,11 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
struct ipcp_option_t *lopt;
int res=0;
- log_debug("recv [IPCP ConfNak id=%x",ipcp->fsm.recv_id);
+ log_ppp_debug("recv [IPCP ConfNak id=%x",ipcp->fsm.recv_id);
if (ipcp->fsm.recv_id!=ipcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -414,8 +413,8 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (lopt->h->recv_conf_nak(ipcp,lopt,data))
res=-1;
break;
@@ -425,7 +424,7 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -435,11 +434,11 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
struct ipcp_option_t *lopt;
int res=0;
- log_debug("recv [IPCP ConfAck id=%x",ipcp->fsm.recv_id);
+ log_ppp_debug("recv [IPCP ConfAck id=%x",ipcp->fsm.recv_id);
if (ipcp->fsm.recv_id!=ipcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -451,8 +450,8 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (!lopt->h->recv_conf_ack)
break;
if (lopt->h->recv_conf_ack(ipcp,lopt,data))
@@ -464,7 +463,7 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -477,20 +476,20 @@ static void ipcp_recv(struct ppp_handler_t*h)
if (ipcp->fsm.fsm_state==FSM_Initial || ipcp->fsm.fsm_state==FSM_Closed)
{
- log_warn("IPCP: discaring packet\n");
+ log_ppp_warn("IPCP: discaring packet\n");
return;
}
if (ipcp->ppp->unit_buf_size<PPP_HEADERLEN+2)
{
- log_warn("IPCP: short packet received\n");
+ log_ppp_warn("IPCP: short packet received\n");
return;
}
hdr=(struct ipcp_hdr_t *)ipcp->ppp->unit_buf;
if (ntohs(hdr->len)<PPP_HEADERLEN)
{
- log_warn("IPCP: short packet received\n");
+ log_ppp_warn("IPCP: short packet received\n");
return;
}
@@ -533,19 +532,19 @@ static void ipcp_recv(struct ppp_handler_t*h)
break;
case TERMREQ:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [IPCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [IPCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_req(&ipcp->fsm);
ppp_terminate(ipcp->ppp, 0);
break;
case TERMACK:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [IPCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [IPCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_ack(&ipcp->fsm);
break;
case CODEREJ:
- log_debug("recv [IPCP CodeRej id=%x]\n",hdr->id);
+ log_ppp_debug("recv [IPCP CodeRej id=%x]\n",hdr->id);
ppp_fsm_recv_code_rej_bad(&ipcp->fsm);
break;
default:
diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c
index 22e6313..3b937d6 100644
--- a/accel-pptpd/ppp/ppp_lcp.c
+++ b/accel-pptpd/ppp/ppp_lcp.c
@@ -71,7 +71,7 @@ static struct ppp_layer_data_t *lcp_layer_init(struct ppp_t *ppp)
struct ppp_lcp_t *lcp=malloc(sizeof(*lcp));
memset(lcp,0,sizeof(*lcp));
- log_debug("lcp_layer_init\n");
+ log_ppp_debug("lcp_layer_init\n");
lcp->ppp=ppp;
lcp->fsm.ppp=ppp;
@@ -99,7 +99,7 @@ int lcp_layer_start(struct ppp_layer_data_t *ld)
{
struct ppp_lcp_t *lcp=container_of(ld,typeof(*lcp),ld);
- log_debug("lcp_layer_start\n");
+ log_ppp_debug("lcp_layer_start\n");
lcp_options_init(lcp);
ppp_fsm_lower_up(&lcp->fsm);
@@ -113,7 +113,7 @@ void lcp_layer_finish(struct ppp_layer_data_t *ld)
{
struct ppp_lcp_t *lcp=container_of(ld,typeof(*lcp),ld);
- log_debug("lcp_layer_finish\n");
+ log_ppp_debug("lcp_layer_finish\n");
stop_echo(lcp);
@@ -124,7 +124,7 @@ void lcp_layer_free(struct ppp_layer_data_t *ld)
{
struct ppp_lcp_t *lcp=container_of(ld,typeof(*lcp),ld);
- log_debug("lcp_layer_free\n");
+ log_ppp_debug("lcp_layer_free\n");
stop_echo(lcp);
ppp_unregister_handler(lcp->ppp,&lcp->hnd);
@@ -137,7 +137,7 @@ void lcp_layer_free(struct ppp_layer_data_t *ld)
static void lcp_layer_up(struct ppp_fsm_t *fsm)
{
struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm);
- log_debug("lcp_layer_started\n");
+ log_ppp_debug("lcp_layer_started\n");
ppp_layer_started(lcp->ppp,&lcp->ld);
start_echo(lcp);
@@ -146,7 +146,7 @@ static void lcp_layer_up(struct ppp_fsm_t *fsm)
static void lcp_layer_down(struct ppp_fsm_t *fsm)
{
struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm);
- log_debug("lcp_layer_finished\n");
+ log_ppp_debug("lcp_layer_finished\n");
stop_echo(lcp);
ppp_layer_finished(lcp->ppp,&lcp->ld);
}
@@ -156,12 +156,12 @@ static void print_ropt(struct recv_opt_t *ropt)
int i;
uint8_t *ptr=(uint8_t*)ropt->hdr;
- log_debug(" <");
+ log_ppp_debug(" <");
for(i=0; i<ropt->len; i++)
{
- log_debug(" %x",ptr[i]);
+ log_ppp_debug(" %x",ptr[i]);
}
- log_debug(" >");
+ log_ppp_debug(" >");
}
static int send_conf_req(struct ppp_fsm_t *fsm)
@@ -193,15 +193,15 @@ static int send_conf_req(struct ppp_fsm_t *fsm)
}
if (conf_ppp_verbose) {
- log_debug("send [LCP ConfReq id=%x", lcp_hdr->id);
+ log_ppp_debug("send [LCP ConfReq id=%x", lcp_hdr->id);
list_for_each_entry(lopt,&lcp->options,entry)
{
if (lopt->print) {
- log_debug(" ");
- lopt->h->print(log_debug,lopt,NULL);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,NULL);
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
}
lcp_hdr->len=htons((ptr-buf)-2);
@@ -216,7 +216,7 @@ static void send_conf_ack(struct ppp_fsm_t *fsm)
struct lcp_hdr_t *hdr=(struct lcp_hdr_t*)lcp->ppp->chan_buf;
hdr->code=CONFACK;
- log_debug("send [LCP ConfAck id=%x ]\n",lcp->fsm.recv_id);
+ log_ppp_debug("send [LCP ConfAck id=%x ]\n",lcp->fsm.recv_id);
ppp_chan_send(lcp->ppp,hdr,ntohs(hdr->len)+2);
}
@@ -228,7 +228,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
struct lcp_hdr_t *lcp_hdr=(struct lcp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [LCP ConfNak id=%x",lcp->fsm.recv_id);
+ log_ppp_debug("send [LCP ConfNak id=%x",lcp->fsm.recv_id);
lcp_hdr->proto=htons(PPP_LCP);
lcp_hdr->code=CONFNAK;
@@ -241,13 +241,13 @@ static void send_conf_nak(struct ppp_fsm_t *fsm)
{
if (ropt->state==LCP_OPT_NAK)
{
- log_debug(" ");
- ropt->lopt->h->print(log_debug,ropt->lopt,NULL);
+ log_ppp_debug(" ");
+ ropt->lopt->h->print(log_ppp_debug,ropt->lopt,NULL);
ptr+=ropt->lopt->h->send_conf_nak(lcp,ropt->lopt,ptr);
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
lcp_hdr->len=htons((ptr-buf)-2);
ppp_chan_send(lcp->ppp,lcp_hdr,ptr-buf);
@@ -260,7 +260,7 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
struct lcp_hdr_t *lcp_hdr=(struct lcp_hdr_t*)ptr;
struct recv_opt_t *ropt;
- log_debug("send [LCP ConfRej id=%x ",lcp->fsm.recv_id);
+ log_ppp_debug("send [LCP ConfRej id=%x ",lcp->fsm.recv_id);
lcp_hdr->proto=htons(PPP_LCP);
lcp_hdr->code=CONFREJ;
@@ -273,15 +273,15 @@ static void send_conf_rej(struct ppp_fsm_t *fsm)
{
if (ropt->state==LCP_OPT_REJ)
{
- log_debug(" ");
- if (ropt->lopt) ropt->lopt->h->print(log_debug,ropt->lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ if (ropt->lopt) ropt->lopt->h->print(log_ppp_debug,ropt->lopt,(uint8_t*)ropt->hdr);
else print_ropt(ropt);
memcpy(ptr,ropt->hdr,ropt->len);
ptr+=ropt->len;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
lcp_hdr->len=htons((ptr-buf)-2);
ppp_chan_send(lcp->ppp,lcp_hdr,ptr-buf);
@@ -314,15 +314,15 @@ static int lcp_recv_conf_req(struct ppp_lcp_t *lcp,uint8_t *data,int size)
list_for_each_entry(lopt,&lcp->options,entry)
lopt->state=LCP_OPT_NONE;
- log_debug("recv [LCP ConfReq id=%x",lcp->fsm.recv_id);
+ log_ppp_debug("recv [LCP ConfReq id=%x",lcp->fsm.recv_id);
list_for_each_entry(ropt,&lcp->ropt_list,entry)
{
list_for_each_entry(lopt,&lcp->options,entry)
{
if (lopt->id==ropt->hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,(uint8_t*)ropt->hdr);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,(uint8_t*)ropt->hdr);
r=lopt->h->recv_conf_req(lcp,lopt,(uint8_t*)ropt->hdr);
lopt->state=r;
ropt->state=r;
@@ -333,13 +333,13 @@ static int lcp_recv_conf_req(struct ppp_lcp_t *lcp,uint8_t *data,int size)
}
if (!ropt->lopt)
{
- log_debug(" ");
+ log_ppp_debug(" ");
print_ropt(ropt);
ropt->state=LCP_OPT_REJ;
ret=LCP_OPT_REJ;
}
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
/*list_for_each_entry(lopt,&lcp->options,entry)
{
@@ -372,11 +372,11 @@ static int lcp_recv_conf_rej(struct ppp_lcp_t *lcp,uint8_t *data,int size)
struct lcp_option_t *lopt;
int res=0;
- log_debug("recv [LCP ConfRej id=%x",lcp->fsm.recv_id);
+ log_ppp_debug("recv [LCP ConfRej id=%x",lcp->fsm.recv_id);
if (lcp->fsm.recv_id!=lcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -399,7 +399,7 @@ static int lcp_recv_conf_rej(struct ppp_lcp_t *lcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -409,11 +409,11 @@ static int lcp_recv_conf_nak(struct ppp_lcp_t *lcp,uint8_t *data,int size)
struct lcp_option_t *lopt;
int res=0;
- log_debug("recv [LCP ConfNak id=%x",lcp->fsm.recv_id);
+ log_ppp_debug("recv [LCP ConfNak id=%x",lcp->fsm.recv_id);
if (lcp->fsm.recv_id!=lcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -425,8 +425,8 @@ static int lcp_recv_conf_nak(struct ppp_lcp_t *lcp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (lopt->h->recv_conf_nak(lcp,lopt,data))
res=-1;
break;
@@ -436,7 +436,7 @@ static int lcp_recv_conf_nak(struct ppp_lcp_t *lcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -446,11 +446,11 @@ static int lcp_recv_conf_ack(struct ppp_lcp_t *lcp,uint8_t *data,int size)
struct lcp_option_t *lopt;
int res=0;
- log_debug("recv [LCP ConfAck id=%x",lcp->fsm.recv_id);
+ log_ppp_debug("recv [LCP ConfAck id=%x",lcp->fsm.recv_id);
if (lcp->fsm.recv_id!=lcp->fsm.id)
{
- log_debug(": id mismatch ]\n");
+ log_ppp_debug(": id mismatch ]\n");
return 0;
}
@@ -462,8 +462,8 @@ static int lcp_recv_conf_ack(struct ppp_lcp_t *lcp,uint8_t *data,int size)
{
if (lopt->id==hdr->id)
{
- log_debug(" ");
- lopt->h->print(log_debug,lopt,data);
+ log_ppp_debug(" ");
+ lopt->h->print(log_ppp_debug,lopt,data);
if (!lopt->h->recv_conf_ack)
break;
if (lopt->h->recv_conf_ack(lcp,lopt,data))
@@ -475,7 +475,7 @@ static int lcp_recv_conf_ack(struct ppp_lcp_t *lcp,uint8_t *data,int size)
data+=hdr->len;
size-=hdr->len;
}
- log_debug("]\n");
+ log_ppp_debug("]\n");
return res;
}
@@ -484,14 +484,14 @@ static void lcp_recv_echo_repl(struct ppp_lcp_t *lcp,uint8_t *data,int size)
uint32_t magic = *(uint32_t *)data;
if (size != 4) {
- log_error("lcp:echo: magic number size mismatch\n");
+ log_ppp_error("lcp:echo: magic number size mismatch\n");
ppp_terminate(lcp->ppp, 0);
}
- log_debug("recv [LCP EchoRep id=%x <magic %x>]\n",lcp->fsm.recv_id,magic);
+ log_ppp_debug("recv [LCP EchoRep id=%x <magic %x>]\n",lcp->fsm.recv_id,magic);
if (magic == lcp->magic) {
- log_error("lcp:echo: loop-back detected\n");
+ log_ppp_error("lcp:echo: loop-back detected\n");
ppp_terminate(lcp->ppp, 0);
}
@@ -504,7 +504,7 @@ static void send_echo_reply(struct ppp_lcp_t *lcp)
uint32_t magic = *(uint32_t *)(hdr+1);
hdr->code=ECHOREP;
- log_debug("send [LCP EchoRep id=%x <magic %x>]\n", hdr->id, magic);
+ log_ppp_debug("send [LCP EchoRep id=%x <magic %x>]\n", hdr->id, magic);
ppp_chan_send(lcp->ppp,hdr,ntohs(hdr->len)+2);
}
@@ -524,10 +524,10 @@ static void send_echo_request(struct triton_timer_t *t)
};
if (++lcp->echo_sent > lcp->echo_failure) {
- log_warn("lcp: no echo reply\n");
+ log_ppp_warn("lcp: no echo reply\n");
ppp_terminate(lcp->ppp, 0);
} else {
- log_debug("send [LCP EchoReq id=%x <magic %x>]\n", msg.hdr.id, msg.magic);
+ log_ppp_debug("send [LCP EchoReq id=%x <magic %x>]\n", msg.hdr.id, msg.magic);
ppp_chan_send(lcp->ppp,&msg,ntohs(msg.hdr.len)+2);
}
}
@@ -544,10 +544,8 @@ static void start_echo(struct ppp_lcp_t *lcp)
}
static void stop_echo(struct ppp_lcp_t *lcp)
{
- if (lcp->echo_interval) {
+ if (lcp->echo_timer.tpd)
triton_timer_del(&lcp->echo_timer);
- lcp->echo_interval = 0;
- }
}
static void lcp_recv(struct ppp_handler_t*h)
@@ -559,14 +557,14 @@ static void lcp_recv(struct ppp_handler_t*h)
if (lcp->ppp->chan_buf_size<PPP_HEADERLEN+2)
{
- log_warn("LCP: short packet received\n");
+ log_ppp_warn("LCP: short packet received\n");
return;
}
hdr=(struct lcp_hdr_t *)lcp->ppp->chan_buf;
if (ntohs(hdr->len)<PPP_HEADERLEN)
{
- log_warn("LCP: short packet received\n");
+ log_ppp_warn("LCP: short packet received\n");
return;
}
@@ -609,19 +607,19 @@ static void lcp_recv(struct ppp_handler_t*h)
break;
case TERMREQ:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [LCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [LCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_req(&lcp->fsm);
ppp_terminate(lcp->ppp, 0);
break;
case TERMACK:
term_msg=strndup((char*)(hdr+1),ntohs(hdr->len));
- log_debug("recv [LCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
+ log_ppp_debug("recv [LCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg);
free(term_msg);
ppp_fsm_recv_term_ack(&lcp->fsm);
break;
case CODEREJ:
- log_debug("recv [LCP CodeRej id=%x]\n",hdr->id);
+ log_ppp_debug("recv [LCP CodeRej id=%x]\n",hdr->id);
ppp_fsm_recv_code_rej_bad(&lcp->fsm);
break;
case ECHOREQ: