X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/bcc2c7408be2d278ceef675b5d989ce6ed395315..ec4f5a95de78fd6dea23e8a20ace3144e4e3eea6:/radius.c diff --git a/radius.c b/radius.c index 843931f..34806c5 100644 --- a/radius.c +++ b/radius.c @@ -22,6 +22,7 @@ #ifdef LAC #include "l2tplac.h" #endif +#include "pppoe.h" extern radiust *radius; extern sessiont *session; @@ -600,6 +601,7 @@ void processrad(uint8_t *buf, int len, char socket_index) run_plugins(PLUGIN_POST_AUTH, &packet); r_code = packet.auth_allowed ? AccessAccept : AccessReject; +#ifndef LAC // process auth response if (radius[r].chap) { @@ -631,6 +633,7 @@ void processrad(uint8_t *buf, int len, char socket_index) LOG(3, s, session[s].tunnel, " PAP User %s authentication %s.\n", session[s].user, (r_code == AccessAccept) ? "allowed" : "denied"); } +#endif if (r_code == AccessAccept) { @@ -958,14 +961,43 @@ void processrad(uint8_t *buf, int len, char socket_index) { session[s].route[ro].ip = 0; } - - // Restart LCP auth... - lcp_restart(s); - sendlcp(s, t); break; } } + + // process auth response + if (radius[r].chap) + { + // CHAP + uint8_t *p = makeppp(b, sizeof(b), 0, 0, s, t, PPPCHAP, 0, 0, 0); + if (!p) return; // Abort! + + *p = (r_code == AccessAccept) ? 3 : 4; // ack/nak + p[1] = radius[r].id; + *(uint16_t *) (p + 2) = ntohs(4); // no message + tunnelsend(b, (p - b) + 4, t); // send it + + LOG(3, s, session[s].tunnel, " CHAP User %s authentication %s.\n", session[s].user, + (r_code == AccessAccept) ? "allowed" : "denied"); + } + else + { + // PAP + uint8_t *p = makeppp(b, sizeof(b), 0, 0, s, t, PPPPAP, 0, 0, 0); + if (!p) return; // Abort! + + // ack/nak + *p = r_code; + p[1] = radius[r].id; + *(uint16_t *) (p + 2) = ntohs(5); + p[4] = 0; // no message + tunnelsend(b, (p - b) + 5, t); // send it + + LOG(3, s, session[s].tunnel, " PAP User %s authentication %s.\n", session[s].user, + (r_code == AccessAccept) ? "allowed" : "denied"); + } #endif + if (!session[s].dns1 && config->default_dns1) { session[s].dns1 = ntohl(config->default_dns1);