summaryrefslogtreecommitdiff
path: root/accel-pptpd/ppp
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-23 09:54:52 +0400
committerKozlov Dmitry <dima@server>2010-09-23 09:54:52 +0400
commit82b0f0953159fc9ab8e387f5e6014dc377b14b38 (patch)
tree974bf5ff111aed10829c4326d627c9e26d7f2189 /accel-pptpd/ppp
parent3e61cb3f8d58f64c8023e95bf74341e6bc61560e (diff)
downloadaccel-ppp-xebd-82b0f0953159fc9ab8e387f5e6014dc377b14b38.tar.gz
accel-ppp-xebd-82b0f0953159fc9ab8e387f5e6014dc377b14b38.zip
radius: implemented attributes Calling-Station-Id, Called-Station-Id, NAS-IP-Address
radius: implemented extension Acct-Input-Gigawords, Acct-Output-Gigawords lcp: implemented maximum/minimum mtu/mru checks
Diffstat (limited to 'accel-pptpd/ppp')
-rw-r--r--accel-pptpd/ppp/lcp_opt_mru.c73
-rw-r--r--accel-pptpd/ppp/ppp.h3
-rw-r--r--accel-pptpd/ppp/ppp_lcp.c13
3 files changed, 57 insertions, 32 deletions
diff --git a/accel-pptpd/ppp/lcp_opt_mru.c b/accel-pptpd/ppp/lcp_opt_mru.c
index 4dc9685..f13b014 100644
--- a/accel-pptpd/ppp/lcp_opt_mru.c
+++ b/accel-pptpd/ppp/lcp_opt_mru.c
@@ -13,7 +13,8 @@
#include "memdebug.h"
-#define MAX_MTU 1436
+static int conf_mtu;
+static int conf_min_mtu = 100;
static struct lcp_option_t *mru_init(struct ppp_lcp_t *lcp);
static void mru_free(struct ppp_lcp_t *lcp, struct lcp_option_t *opt);
@@ -44,52 +45,52 @@ static struct lcp_option_handler_t mru_opt_hnd=
static struct lcp_option_t *mru_init(struct ppp_lcp_t *lcp)
{
struct mru_option_t *mru_opt=_malloc(sizeof(*mru_opt));
- memset(mru_opt,0,sizeof(*mru_opt));
- mru_opt->mtu=0;
- mru_opt->mru=MAX_MTU;
- mru_opt->opt.id=CI_MRU;
- mru_opt->opt.len=4;
+ memset(mru_opt, 0, sizeof(*mru_opt));
+ mru_opt->mtu = 0;
+ mru_opt->mru = (conf_mtu && conf_mtu <= lcp->ppp->ctrl->max_mtu) ? conf_mtu : lcp->ppp->ctrl->max_mtu;
+ mru_opt->opt.id = CI_MRU;
+ mru_opt->opt.len = 4;
return &mru_opt->opt;
}
static void mru_free(struct ppp_lcp_t *lcp, struct lcp_option_t *opt)
{
- struct mru_option_t *mru_opt=container_of(opt,typeof(*mru_opt),opt);
+ struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
_free(mru_opt);
}
static int mru_send_conf_req(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);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
- opt16->hdr.id=CI_MRU;
- opt16->hdr.len=4;
- opt16->val=htons(mru_opt->mru);
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+ opt16->hdr.id = CI_MRU;
+ opt16->hdr.len = 4;
+ opt16->val = htons(mru_opt->mru);
return 4;
}
static int mru_send_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);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
- opt16->hdr.id=CI_MRU;
- opt16->hdr.len=4;
- opt16->val=htons(mru_opt->mtu);
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+ opt16->hdr.id = CI_MRU;
+ opt16->hdr.len = 4;
+ opt16->val = htons(mru_opt->mtu ? mru_opt->mtu : lcp->ppp->ctrl->max_mtu);
return 4;
}
static int mru_recv_conf_req(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);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
-
- if (!mru_opt->mtu || mru_opt->mtu==ntohs(opt16->val))
- {
- mru_opt->mtu=ntohs(opt16->val);
- return LCP_OPT_ACK;
- }else return LCP_OPT_NAK;
+ struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt),opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
+
+ if (ntohs(opt16->val) < conf_min_mtu || ntohs(opt16->val) > lcp->ppp->ctrl->max_mtu)
+ return LCP_OPT_NAK;
+
+ mru_opt->mtu = ntohs(opt16->val);
+ return LCP_OPT_ACK;
}
static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
@@ -110,17 +111,29 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
return 0;
}
-static void mru_print(void (*print)(const char *fmt,...),struct lcp_option_t *opt, uint8_t *ptr)
+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);
- struct lcp_opt16_t *opt16=(struct lcp_opt16_t*)ptr;
+ struct mru_option_t *mru_opt = container_of(opt, typeof(*mru_opt), opt);
+ struct lcp_opt16_t *opt16 = (struct lcp_opt16_t*)ptr;
- if (ptr) print("<mru %i>",ntohs(opt16->val));
- else print("<mru %i>",mru_opt->mru);
+ if (ptr)
+ print("<mru %i>",ntohs(opt16->val));
+ else
+ print("<mru %i>",mru_opt->mru);
}
static void __init mru_opt_init()
{
+ char *opt;
+
+ opt = conf_get_opt("ppp", "mtu");
+ if (opt && atoi(opt) > 0)
+ conf_mtu = atoi(opt);
+
+ opt = conf_get_opt("ppp", "min-mtu");
+ if (opt && atoi(opt) > 0)
+ conf_min_mtu = atoi(opt);
+
lcp_option_register(&mru_opt_hnd);
}
diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h
index 641a74b..5a8ac57 100644
--- a/accel-pptpd/ppp/ppp.h
+++ b/accel-pptpd/ppp/ppp.h
@@ -51,6 +51,9 @@ struct ppp_t;
struct ppp_ctrl_t
{
struct triton_context_t *ctx;
+ int max_mtu;
+ char *calling_station_id;
+ char *called_station_id;
void (*started)(struct ppp_t*);
void (*finished)(struct ppp_t*);
};
diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c
index a85b3d1..d28167e 100644
--- a/accel-pptpd/ppp/ppp_lcp.c
+++ b/accel-pptpd/ppp/ppp_lcp.c
@@ -29,6 +29,7 @@ static LIST_HEAD(option_handlers);
static void lcp_layer_up(struct ppp_fsm_t*);
static void lcp_layer_down(struct ppp_fsm_t*);
+static void lcp_layer_finished(struct ppp_fsm_t*);
static int send_conf_req(struct ppp_fsm_t*);
static void send_conf_ack(struct ppp_fsm_t*);
static void send_conf_nak(struct ppp_fsm_t*);
@@ -88,7 +89,8 @@ static struct ppp_layer_data_t *lcp_layer_init(struct ppp_t *ppp)
ppp_fsm_init(&lcp->fsm);
lcp->fsm.layer_up=lcp_layer_up;
- lcp->fsm.layer_finished=lcp_layer_down;
+ lcp->fsm.layer_down=lcp_layer_down;
+ lcp->fsm.layer_finished=lcp_layer_finished;
lcp->fsm.send_conf_req=send_conf_req;
lcp->fsm.send_conf_ack=send_conf_ack;
lcp->fsm.send_conf_nak=send_conf_nak;
@@ -150,7 +152,14 @@ 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);
- ppp_fsm_close(&lcp->fsm);
+ //ppp_fsm_close(&lcp->fsm);
+ stop_echo(lcp);
+ //ppp_layer_finished(lcp->ppp,&lcp->ld);
+}
+
+static void lcp_layer_finished(struct ppp_fsm_t *fsm)
+{
+ struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm);
log_ppp_debug("lcp_layer_finished\n");
stop_echo(lcp);
ppp_layer_finished(lcp->ppp,&lcp->ld);