diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-04-21 22:01:56 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-04-21 22:04:11 +0400 |
commit | 88b01cc61f8cbd41162041da7bf206eca7e04b2f (patch) | |
tree | 5cb9d64fb9ec05c2f3956bbccbee9e1660c616af /accel-pppd/ppp | |
parent | 3b3aa52ec2b316f8c5ee1593ca11ce1f437828e6 (diff) | |
download | accel-ppp-88b01cc61f8cbd41162041da7bf206eca7e04b2f.tar.gz accel-ppp-88b01cc61f8cbd41162041da7bf206eca7e04b2f.zip |
implemented per CTRL mppe config
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/ccp_mppe.c | 62 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp.h | 7 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ccp.c | 1 |
3 files changed, 49 insertions, 21 deletions
diff --git a/accel-pppd/ppp/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c index 9099fb0..7c43284 100644 --- a/accel-pppd/ppp/ccp_mppe.c +++ b/accel-pppd/ppp/ccp_mppe.c @@ -32,7 +32,7 @@ static int mppe_recv_conf_nak(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u static int mppe_recv_conf_rej(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, uint8_t *ptr); static void mppe_print(void (*print)(const char *fmt,...),struct ccp_option_t*, uint8_t *ptr); -static int conf_mppe = -1; +static int conf_mppe = MPPE_ALLOW; struct mppe_option_t { @@ -59,18 +59,24 @@ static struct ccp_option_t *mppe_init(struct ppp_ccp_t *ccp) { struct mppe_option_t *mppe_opt = _malloc(sizeof(*mppe_opt)); memset(mppe_opt, 0, sizeof(*mppe_opt)); + int mppe; + + if (ccp->ppp->ctrl->mppe == MPPE_UNSET) + mppe = conf_mppe; + else + mppe = ccp->ppp->ctrl->mppe; - if (conf_mppe != -1) - mppe_opt->policy = conf_mppe; + if (mppe != MPPE_ALLOW) + mppe_opt->policy = mppe; else mppe_opt->policy = 1; - if (conf_mppe > 0) + if (mppe > 0) mppe_opt->mppe = 1; else mppe_opt->mppe = -1; - if (conf_mppe == 2) + if (mppe == MPPE_REQUIRE) ccp->ld.passive = 0; mppe_opt->opt.id = CI_MPPE; @@ -165,6 +171,12 @@ static int mppe_recv_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u { struct mppe_option_t *mppe_opt = container_of(opt, typeof(*mppe_opt), opt); struct ccp_opt32_t *opt32 = (struct ccp_opt32_t *)ptr; + int mppe; + + if (ccp->ppp->ctrl->mppe == MPPE_UNSET) + mppe = conf_mppe; + else + mppe = ccp->ppp->ctrl->mppe; if (!ptr) { if (mppe_opt->policy == 2) @@ -181,7 +193,7 @@ static int mppe_recv_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u } else if (mppe_opt->policy == 1) { if (ntohl(opt32->val) == (MPPE_S | MPPE_H)) mppe_opt->mppe = 1; - else if ((ntohl(opt32->val) & (MPPE_S | MPPE_H)) || conf_mppe == 1) { + else if ((ntohl(opt32->val) & (MPPE_S | MPPE_H)) || mppe == 1) { mppe_opt->mppe = 1; return CCP_OPT_NAK; } else if (opt32->val) { @@ -271,6 +283,7 @@ static void ev_mppe_keys(struct ev_mppe_keys_t *ev) { struct ppp_ccp_t *ccp = ccp_find_layer_data(ev->ppp); struct mppe_option_t *mppe_opt = container_of(ccp_find_option(ev->ppp, &mppe_opt_hnd), typeof(*mppe_opt), opt); + int mppe; memcpy(mppe_opt->recv_key, ev->recv_key, 16); memcpy(mppe_opt->send_key, ev->send_key, 16); @@ -284,19 +297,26 @@ static void ev_mppe_keys(struct ev_mppe_keys_t *ev) return; } - mppe_opt->policy = ev->policy; + if (ccp->ppp->ctrl->mppe == MPPE_UNSET) + mppe = conf_mppe; + else + mppe = ev->ppp->ctrl->mppe; - if (ev->policy == 2) { - mppe_opt->mppe = 1; - ccp->ld.passive = 0; - } else if (ev->policy == 1) { - if (conf_mppe == 1) - mppe_opt->mppe = 1; - else - mppe_opt->mppe = -1; + if (ev->ppp->ctrl->mppe == MPPE_UNSET) { + mppe_opt->policy = ev->policy; - if (conf_mppe == 2) - ccp->ld.passive = 1; + if (ev->policy == 2) { + mppe_opt->mppe = 1; + ccp->ld.passive = 0; + } else if (ev->policy == 1) { + if (mppe == 1) + mppe_opt->mppe = 1; + else + mppe_opt->mppe = -1; + + if (mppe == 2) + ccp->ld.passive = 1; + } } } @@ -307,13 +327,13 @@ static void load_config(void) opt = conf_get_opt("ppp", "mppe"); if (opt) { if (!strcmp(opt,"require")) - conf_mppe = 2; + conf_mppe = MPPE_REQUIRE; else if (!strcmp(opt,"prefer") || !strcmp(opt,"prefere")) - conf_mppe = 1; + conf_mppe = MPPE_PREFER; else if (!strcmp(opt,"deny")) - conf_mppe = 0; + conf_mppe = MPPE_DENY; } else - conf_mppe = -1; + conf_mppe = MPPE_ALLOW; } static void mppe_opt_init() diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h index bb30889..18cb5c2 100644 --- a/accel-pppd/ppp/ppp.h +++ b/accel-pppd/ppp/ppp.h @@ -60,6 +60,12 @@ #define CTRL_TYPE_L2TP 2 #define CTRL_TYPE_PPPOE 3 +#define MPPE_UNSET -2 +#define MPPE_ALLOW -1 +#define MPPE_DENY 0 +#define MPPE_PREFER 1 +#define MPPE_REQUIRE 2 + struct ppp_t; struct ipv4db_item_t; @@ -71,6 +77,7 @@ struct ppp_ctrl_t int type; const char *name; int max_mtu; + int mppe; char *calling_station_id; char *called_station_id; void (*started)(struct ppp_t*); diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c index ee32fbc..297d9bc 100644 --- a/accel-pppd/ppp/ppp_ccp.c +++ b/accel-pppd/ppp/ppp_ccp.c @@ -719,6 +719,7 @@ static void ccp_recv(struct ppp_handler_t*h) ppp_fsm_recv_code_rej_bad(&ccp->fsm); break; default: + log_ppp_info2("recv [CCP Unknown code=%x id=%x]\n", hdr->code, hdr->id); ppp_fsm_recv_unk(&ccp->fsm); break; } |