diff options
author | Kozlov Dmitry <dima@server> | 2010-08-06 13:59:54 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-08-06 13:59:54 +0400 |
commit | 4a268755565ced740c391a4c8c7fc7c98b7fc3c7 (patch) | |
tree | abfd4918ffbb26dac07ae970aa4ff628fd19c583 /accel-pptpd/ppp_auth.c | |
parent | 00785e9cb2adc570a267c160b869bbf9d33bbbe4 (diff) | |
download | accel-ppp-xebd-4a268755565ced740c391a4c8c7fc7c98b7fc3c7.tar.gz accel-ppp-xebd-4a268755565ced740c391a4c8c7fc7c98b7fc3c7.zip |
* written base code of lcp module
* written generic auth module
Diffstat (limited to 'accel-pptpd/ppp_auth.c')
-rw-r--r-- | accel-pptpd/ppp_auth.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/accel-pptpd/ppp_auth.c b/accel-pptpd/ppp_auth.c new file mode 100644 index 0000000..b66727b --- /dev/null +++ b/accel-pptpd/ppp_auth.c @@ -0,0 +1,111 @@ +#include "triton/triton.h" + +#include "ppp.h" +#include "ppp_lcp.h" +#include "ppp_fsm.h" +#include "ppp_auth.h" + +static LIST_HEAD(drv_list); + +int auth_register(struct auth_driver_t *new) +{ + struct auth_driver_t *drv; + + list_for_each_entry(drv,&drv_list,entry) + { + if (drv->type==new->type) + return -1; + } + list_add_tail(&new->entry,&drv_list); + return 0; +} + +int auth_get_conf_req(struct ppp_layer_t *l, struct lcp_opt32_t *opt) +{ + int i,n; + struct auth_driver_t *drv; + + for(i=0; i<AUTH_MAX; i++) + { + if (l->auth[i] && l->options.lcp.neg_auth[i]>0) + goto cont; + } + for(i=0; i<AUTH_MAX; i++) + { + if (l->auth[i] && l->options.lcp.neg_auth[i]==0) + goto cont; + } + return -1; + +cont: + list_for_each_entry(drv,&drv_list,entry) + { + if (drv->type==l->auth[i]) + break; + } + n=drv->get_conf_req(drv,l,opt); + opt->val=l->auth[i]; + opt->hdr.len=6+n; + return 0; +} +int auth_recv_conf_req(struct ppp_layer_t *l, struct lcp_opt_hdr_t *hdr) +{ + struct lcp_opt32_t *opt=(struct lcp_opt32_t*)hdr; + struct auth_driver_t *drv; + int i; + + for(i=0; i<AUTH_MAX; i++) + { + if (l->auth[i]==opt->val) + { + list_for_each_entry(drv,&drv_list,entry) + { + if (drv->type==l->auth[i]) + { + if (drv->recv_conf_req(drv,l,opt)) + return -1; + l->options.lcp.neg_auth[i]=1; + return 0; + } + } + return -1; + } + } + return -1; +} +int auth_recv_conf_rej(struct ppp_layer_t *l, struct lcp_opt_hdr_t *hdr) +{ + struct lcp_opt32_t *opt=(struct lcp_opt32_t*)hdr; + int i; + + for(i=0; i<AUTH_MAX; i++) + { + if (l->auth[i]==opt->val) + { + l->options.lcp.neg_auth[i]=-1; + break; + } + } + for(i=0; i<3; i++) + { + if (l->auth[i] && l->options.lcp.neg_auth[i]!=-1) + return 0; + } + return -1; +} +int auth_recv_conf_nak(struct ppp_layer_t *l, struct lcp_opt_hdr_t *hdr) +{ + struct lcp_opt32_t *opt=(struct lcp_opt32_t*)hdr; + int i; + + for(i=0; i<AUTH_MAX; i++) + { + if (l->auth[i]==opt->val) + { + l->options.lcp.neg_auth[i]=2; + return 0; + } + } + return -1; +} + |