summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2010-10-23 15:16:04 +0400
committerKozlov Dmitry <xeb@mail.ru>2010-10-23 15:16:04 +0400
commita970c053a5c74d39ec5f6c14fb36b4f092eaf1b5 (patch)
tree3663cafa808021001f7b59cda458b84f5abc2ef3
parentce95b416f4b6c5012073bb14c0b48c6b3a81fc33 (diff)
downloadaccel-ppp-a970c053a5c74d39ec5f6c14fb36b4f092eaf1b5.tar.gz
accel-ppp-a970c053a5c74d39ec5f6c14fb36b4f092eaf1b5.zip
pppd_compat: ip-pre-up call moved to proper place
ppp: don't negotiate mru after ConfNak received
-rw-r--r--accel-pptpd/extra/pppd_compat.c26
-rw-r--r--accel-pptpd/include/events.h1
-rw-r--r--accel-pptpd/ppp/ipcp_opt_ipaddr.c5
-rw-r--r--accel-pptpd/ppp/lcp_opt_mru.c14
-rw-r--r--accel-pptpd/ppp/ppp_ipcp.c36
5 files changed, 68 insertions, 14 deletions
diff --git a/accel-pptpd/extra/pppd_compat.c b/accel-pptpd/extra/pppd_compat.c
index 017a8275..9655269a 100644
--- a/accel-pptpd/extra/pppd_compat.c
+++ b/accel-pptpd/extra/pppd_compat.c
@@ -113,7 +113,8 @@ static void ev_ppp_starting(struct ppp_t *ppp)
pd->ip_change_hnd.handler = ip_change_handler;
list_add_tail(&pd->pd.entry, &ppp->pd_list);
}
-static void ev_ppp_started(struct ppp_t *ppp)
+
+static void ev_ppp_pre_up(struct ppp_t *ppp)
{
pid_t pid;
char *argv[8];
@@ -157,6 +158,28 @@ static void ev_ppp_started(struct ppp_t *ppp)
} else
log_error("pppd_compat: fork: %s\n", strerror(errno));
}
+}
+
+static void ev_ppp_started(struct ppp_t *ppp)
+{
+ pid_t pid;
+ char *argv[8];
+ char *env[2];
+ char ipaddr[16];
+ char peer_ipaddr[16];
+ char peername[64];
+ struct pppd_compat_pd_t *pd = find_pd(ppp);
+
+ if (!pd)
+ return;
+
+ argv[4] = ipaddr;
+ argv[5] = peer_ipaddr;
+ fill_argv(argv, ppp, conf_ip_up);
+
+ env[0] = peername;
+ env[1] = NULL;
+ fill_env(env, pd);
if (conf_ip_up) {
sigchld_lock();
@@ -479,6 +502,7 @@ static void __init init(void)
conf_verbose = 1;
triton_event_register_handler(EV_PPP_STARTING, (triton_event_func)ev_ppp_starting);
+ triton_event_register_handler(EV_PPP_PRE_UP, (triton_event_func)ev_ppp_pre_up);
triton_event_register_handler(EV_PPP_STARTED, (triton_event_func)ev_ppp_started);
triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ev_ppp_finishing);
triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ev_ppp_finished);
diff --git a/accel-pptpd/include/events.h b/accel-pptpd/include/events.h
index f0785be8..bc1e6744 100644
--- a/accel-pptpd/include/events.h
+++ b/accel-pptpd/include/events.h
@@ -11,6 +11,7 @@
#define EV_CTRL_STARTING 6
#define EV_CTRL_STARTED 7
#define EV_CTRL_FINISHED 8
+#define EV_PPP_PRE_UP 9
#define EV_IP_CHANGED 100
#define EV_SHAPE_CHANGED 101
#define EV_MPPE_KEYS 102
diff --git a/accel-pptpd/ppp/ipcp_opt_ipaddr.c b/accel-pptpd/ppp/ipcp_opt_ipaddr.c
index 3bec543d..ffba0724 100644
--- a/accel-pptpd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pptpd/ppp/ipcp_opt_ipaddr.c
@@ -12,6 +12,7 @@
#include "log.h"
#include "ipdb.h"
#include "iprange.h"
+#include "events.h"
#include "memdebug.h"
@@ -121,6 +122,10 @@ ack:
ipcp->ppp->ipaddr = ipaddr_opt->ip->addr;
ipcp->ppp->peer_ipaddr = ipaddr_opt->ip->peer_addr;
+ triton_event_fire(EV_PPP_PRE_UP, ipcp->ppp);
+ if (ipcp->ppp->stop_time)
+ return IPCP_OPT_ACK;
+
memset(&ifr, 0, sizeof(ifr));
memset(&addr, 0, sizeof(addr));
diff --git a/accel-pptpd/ppp/lcp_opt_mru.c b/accel-pptpd/ppp/lcp_opt_mru.c
index 8f460a12..7ab75f9e 100644
--- a/accel-pptpd/ppp/lcp_opt_mru.c
+++ b/accel-pptpd/ppp/lcp_opt_mru.c
@@ -24,6 +24,7 @@ static int mru_send_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
static int mru_send_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr);
static int mru_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr);
static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr);
+static int mru_recv_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr);
static void mru_print(void (*print)(const char *fmt,...),struct lcp_option_t*, uint8_t *ptr);
struct mru_option_t
@@ -31,6 +32,7 @@ struct mru_option_t
struct lcp_option_t opt;
int mru;
int mtu;
+ int naked:1;
};
static struct lcp_option_handler_t mru_opt_hnd=
@@ -40,6 +42,7 @@ static struct lcp_option_handler_t mru_opt_hnd=
.send_conf_nak=mru_send_conf_nak,
.recv_conf_req=mru_recv_conf_req,
.recv_conf_ack=mru_recv_conf_ack,
+ .recv_conf_nak=mru_recv_conf_nak,
.free=mru_free,
.print=mru_print,
};
@@ -71,6 +74,10 @@ static int mru_send_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
{
struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+
+ if (mru_opt->naked)
+ return 0;
+
opt16->hdr.id = CI_MRU;
opt16->hdr.len = 4;
opt16->val = htons(mru_opt->mru);
@@ -123,6 +130,13 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
return 0;
}
+static int mru_recv_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
+{
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt), opt);
+ mru_opt->naked = 1;
+ return 0;
+}
+
static void mru_print(void (*print)(const char *fmt,...), struct lcp_option_t *opt, uint8_t *ptr)
{
struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c
index 616714ce..3248db6c 100644
--- a/accel-pptpd/ppp/ppp_ipcp.c
+++ b/accel-pptpd/ppp/ppp_ipcp.c
@@ -335,17 +335,32 @@ 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;
- if (conf_ppp_verbose)
+ if (conf_ppp_verbose) {
log_ppp_info("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) {
- if (conf_ppp_verbose) {
+ list_for_each_entry(ropt, &ipcp->ropt_list, entry) {
+ list_for_each_entry(lopt, &ipcp->options, entry) {
+ if (lopt->id == ropt->hdr->id) {
+ ropt->lopt = lopt;
log_ppp_info(" ");
lopt->h->print(log_ppp_info, lopt, (uint8_t*)ropt->hdr);
+ break;
}
+ }
+ if (!ropt->lopt) {
+ log_ppp_info(" ");
+ print_ropt(ropt);
+ }
+ }
+ log_ppp_info("]\n");
+ }
+
+ list_for_each_entry(ropt, &ipcp->ropt_list, entry) {
+ list_for_each_entry(lopt, &ipcp->options, entry) {
+ if (lopt->id == ropt->hdr->id) {
r = lopt->h->recv_conf_req(ipcp, lopt, (uint8_t*)ropt->hdr);
+ if (ipcp->ppp->stop_time)
+ return -1;
lopt->state = r;
ropt->state = r;
ropt->lopt = lopt;
@@ -354,19 +369,12 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp, uint8_t *data, int size)
break;
}
}
- if (!ropt->lopt)
- {
- if (conf_ppp_verbose) {
- log_ppp_info(" ");
- print_ropt(ropt);
- }
+ if (!ropt->lopt) {
ropt->state = IPCP_OPT_REJ;
ret = IPCP_OPT_REJ;
}
}
- if (conf_ppp_verbose)
- log_ppp_info("]\n");
/*list_for_each_entry(lopt,&ipcp->options,entry)
{
@@ -571,6 +579,8 @@ static void ipcp_recv(struct ppp_handler_t*h)
switch(hdr->code) {
case CONFREQ:
r = ipcp_recv_conf_req(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN);
+ if (ipcp->ppp->stop_time)
+ return;
switch(r) {
case IPCP_OPT_ACK:
ppp_fsm_recv_conf_req_ack(&ipcp->fsm);