summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pptpd/ppp/ppp.c23
-rw-r--r--accel-pptpd/ppp/ppp.h2
-rw-r--r--accel-pptpd/ppp/ppp_ccp.c20
-rw-r--r--accel-pptpd/ppp/ppp_ccp.h2
-rw-r--r--accel-pptpd/ppp/ppp_fsm.c4
-rw-r--r--accel-pptpd/ppp/ppp_ipcp.c4
-rw-r--r--accel-pptpd/ppp/ppp_lcp.c5
7 files changed, 51 insertions, 9 deletions
diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c
index 4acf451d..9ba899f3 100644
--- a/accel-pptpd/ppp/ppp.c
+++ b/accel-pptpd/ppp/ppp.c
@@ -312,6 +312,27 @@ cont:
}
}
+void ppp_recv_proto_rej(struct ppp_t *ppp, uint16_t proto)
+{
+ struct ppp_handler_t *ppp_h;
+
+ list_for_each_entry(ppp_h, &ppp->chan_handlers, entry) {
+ if (ppp_h->proto == proto) {
+ if (ppp_h->recv_proto_rej)
+ ppp_h->recv_proto_rej(ppp_h);
+ return;
+ }
+ }
+
+ list_for_each_entry(ppp_h, &ppp->unit_handlers, entry) {
+ if (ppp_h->proto == proto) {
+ if (ppp_h->recv_proto_rej)
+ ppp_h->recv_proto_rej(ppp_h);
+ return;
+ }
+ }
+}
+
void __export ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d)
{
struct layer_node_t *n = d->node;
@@ -410,7 +431,7 @@ static int get_layer_order(const char *name)
if (!strcmp(name,"lcp")) return 0;
if (!strcmp(name,"auth")) return 1;
if (!strcmp(name,"ccp")) return 2;
- if (!strcmp(name,"ipcp")) return 3;
+ if (!strcmp(name,"ipcp")) return 2;
return -1;
}
diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h
index fb6b20f6..372520de 100644
--- a/accel-pptpd/ppp/ppp.h
+++ b/accel-pptpd/ppp/ppp.h
@@ -130,6 +130,7 @@ struct ppp_handler_t
struct list_head entry;
int proto;
void (*recv)(struct ppp_handler_t*);
+ void (*recv_proto_rej)(struct ppp_handler_t *h);
};
struct ppp_t *alloc_ppp(void);
@@ -138,6 +139,7 @@ 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);
void lcp_send_proto_rej(struct ppp_t *ppp, uint16_t proto);
+void ppp_recv_proto_rej(struct ppp_t *ppp, uint16_t proto);
struct ppp_fsm_t* ppp_lcp_init(struct ppp_t *ppp);
void ppp_layer_started(struct ppp_t *ppp,struct ppp_layer_data_t*);
diff --git a/accel-pptpd/ppp/ppp_ccp.c b/accel-pptpd/ppp/ppp_ccp.c
index 24f0e517..613fb52c 100644
--- a/accel-pptpd/ppp/ppp_ccp.c
+++ b/accel-pptpd/ppp/ppp_ccp.c
@@ -37,6 +37,7 @@ static void send_conf_rej(struct ppp_fsm_t*);
static void send_term_req(struct ppp_fsm_t *fsm);
static void send_term_ack(struct ppp_fsm_t *fsm);
static void ccp_recv(struct ppp_handler_t*);
+static void ccp_recv_proto_rej(struct ppp_handler_t*);
static void ccp_options_init(struct ppp_ccp_t *ccp)
{
@@ -98,6 +99,7 @@ static struct ppp_layer_data_t *ccp_layer_init(struct ppp_t *ppp)
ccp->hnd.proto = PPP_CCP;
ccp->hnd.recv = ccp_recv;
+ ccp->hnd.recv_proto_rej = ccp_recv_proto_rej;
ppp_register_unit_handler(ppp, &ccp->hnd);
@@ -223,8 +225,10 @@ static int send_conf_req(struct ppp_fsm_t *fsm)
ccp->need_req = 0;
- if (ccp->passive)
+ if (ccp->passive) {
+ ccp->passive--;
return 0;
+ }
buf = _malloc(ccp->conf_req_len);
ccp_hdr = (struct ccp_hdr_t*)buf;
@@ -508,8 +512,9 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp, uint8_t *data, int size)
log_ppp_info(" ");
lopt->h->print(log_ppp_info, lopt, data);
}
- if (lopt->h->recv_conf_nak(ccp, lopt, data))
+ if (lopt->h->recv_conf_nak && lopt->h->recv_conf_nak(ccp, lopt, data))
res = -1;
+ lopt->state = CCP_OPT_NAK;
break;
}
}
@@ -688,6 +693,17 @@ static void ccp_recv(struct ppp_handler_t*h)
}
}
+static void ccp_recv_proto_rej(struct ppp_handler_t *h)
+{
+ struct ppp_ccp_t *ccp = container_of(h, typeof(*ccp), hnd);
+
+ if (ccp->fsm.fsm_state == FSM_Initial || ccp->fsm.fsm_state == FSM_Closed)
+ return;
+
+ ppp_fsm_lower_down(&ccp->fsm);
+ ppp_fsm_close(&ccp->fsm);
+}
+
int ccp_option_register(struct ccp_option_handler_t *h)
{
/*struct ccp_option_drv_t *p;
diff --git a/accel-pptpd/ppp/ppp_ccp.h b/accel-pptpd/ppp/ppp_ccp.h
index 27b303e6..2c2dc6dd 100644
--- a/accel-pptpd/ppp/ppp_ccp.h
+++ b/accel-pptpd/ppp/ppp_ccp.h
@@ -84,8 +84,8 @@ struct ppp_ccp_t
int ropt_len;
int conf_req_len;
+ int passive;
int started:1;
- int passive:1;
int need_req:1;
};
diff --git a/accel-pptpd/ppp/ppp_fsm.c b/accel-pptpd/ppp/ppp_fsm.c
index 596d941f..495b3464 100644
--- a/accel-pptpd/ppp/ppp_fsm.c
+++ b/accel-pptpd/ppp/ppp_fsm.c
@@ -127,11 +127,13 @@ void ppp_fsm_close(struct ppp_fsm_t *layer)
switch(layer->fsm_state)
{
case FSM_Starting:
- if (layer->layer_finished) layer->layer_finished(layer);
+ stop_timer(layer);
layer->fsm_state=FSM_Initial;
+ if (layer->layer_finished) layer->layer_finished(layer);
break;
case FSM_Stopped:
layer->fsm_state=FSM_Closed;
+ stop_timer(layer);
break;
case FSM_Stopping:
layer->fsm_state=FSM_Closing;
diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c
index a81fac55..2da67805 100644
--- a/accel-pptpd/ppp/ppp_ipcp.c
+++ b/accel-pptpd/ppp/ppp_ipcp.c
@@ -613,8 +613,8 @@ static void ipcp_recv(struct ppp_handler_t*h)
case TERMACK:
if (conf_ppp_verbose)
log_ppp_info("recv [IPCP TermAck id=%x]\n", hdr->id);
- ppp_fsm_recv_term_ack(&ipcp->fsm);
- ppp_terminate(ipcp->ppp, 0);
+ //ppp_fsm_recv_term_ack(&ipcp->fsm);
+ //ppp_terminate(ipcp->ppp, 0);
break;
case CODEREJ:
if (conf_ppp_verbose)
diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c
index e5063f3f..c57afedd 100644
--- a/accel-pptpd/ppp/ppp_lcp.c
+++ b/accel-pptpd/ppp/ppp_lcp.c
@@ -674,7 +674,7 @@ void lcp_send_proto_rej(struct ppp_t *ppp, uint16_t proto)
.hdr.code = PROTOREJ,
.hdr.id = ++lcp->fsm.id,
.hdr.len = htons(6),
- .proto = proto,
+ .proto = ntohs(proto),
};
if (conf_ppp_verbose)
@@ -775,7 +775,8 @@ static void lcp_recv(struct ppp_handler_t*h)
break;
case PROTOREJ:
if (conf_ppp_verbose)
- log_ppp_info("recv [LCP ProtoRej id=%x <%x>]\n", hdr->code, hdr->id, *(uint16_t*)(hdr + 1));
+ log_ppp_info("recv [LCP ProtoRej id=%x <%04x>]\n", hdr->code, hdr->id, ntohs(*(uint16_t*)(hdr + 1)));
+ ppp_recv_proto_rej(lcp->ppp, ntohs(*(uint16_t *)(hdr + 1)));
break;
case IDENT:
if (conf_ppp_verbose) {