f0500b8a37dd86a407f75c652734112f011da3e7
[l2tpns.git] / radius.c
1 // L2TPNS Radius Stuff
2
3 char const *cvs_id_radius = "$Id: radius.c,v 1.33 2005-06-04 15:42:36 bodea Exp $";
4
5 #include <time.h>
6 #include <stdio.h>
7 #include <sys/types.h>
8 #include <sys/socket.h>
9 #include <malloc.h>
10 #include <string.h>
11 #include <fcntl.h>
12 #include <arpa/inet.h>
13 #include <ctype.h>
14 #include <netinet/in.h>
15 #include "md5.h"
16 #include "constants.h"
17 #include "l2tpns.h"
18 #include "plugin.h"
19 #include "util.h"
20
21 extern radiust *radius;
22 extern sessiont *session;
23 extern tunnelt *tunnel;
24 extern configt *config;
25 extern int *radfds;
26 extern ip_filtert *ip_filters;
27
28 // Set up socket for radius requests
29 void initrad(void)
30 {
31 int i;
32 LOG(3, 0, 0, "Creating %d sockets for RADIUS queries\n", RADIUS_FDS);
33 radfds = calloc(sizeof(int), RADIUS_FDS);
34 for (i = 0; i < RADIUS_FDS; i++)
35 {
36 int flags;
37 radfds[i] = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
38 flags = fcntl(radfds[i], F_GETFL, 0);
39 fcntl(radfds[i], F_SETFL, flags | O_NONBLOCK);
40 }
41 }
42
43 void radiusclear(uint16_t r, sessionidt s)
44 {
45 if (s) sess_local[s].radius = 0;
46 memset(&radius[r], 0, sizeof(radius[r])); // radius[r].state = RADIUSNULL;
47 }
48
49 static uint16_t get_free_radius()
50 {
51 int count;
52 static uint32_t next_radius_id = 0;
53
54 for (count = MAXRADIUS; count > 0 ; --count)
55 {
56 ++next_radius_id; // Find the next ID to check.
57 if (next_radius_id >= MAXRADIUS)
58 next_radius_id = 1;
59
60 if (radius[next_radius_id].state == RADIUSNULL)
61 {
62 return next_radius_id;
63 }
64 }
65
66 LOG(0, 0, 0, "Can't find a free radius session! This is very bad!\n");
67 return 0;
68 }
69
70 uint16_t radiusnew(sessionidt s)
71 {
72 uint16_t r = sess_local[s].radius;
73
74 /* re-use */
75 if (r)
76 {
77 LOG(3, s, session[s].tunnel, "Re-used radius %d\n", r);
78 return r;
79 }
80
81 if (!(r = get_free_radius()))
82 {
83 LOG(1, s, session[s].tunnel, "No free RADIUS sessions\n");
84 STAT(radius_overflow);
85 return 0;
86 };
87
88 memset(&radius[r], 0, sizeof(radius[r]));
89 sess_local[s].radius = r;
90 radius[r].session = s;
91 radius[r].state = RADIUSWAIT;
92 radius[r].retry = TIME + 1200; // Wait at least 120 seconds to re-claim this.
93
94 random_data(radius[r].auth, sizeof(radius[r].auth));
95
96 LOG(3, s, session[s].tunnel, "Allocated radius %d\n", r);
97 return r;
98 }
99
100 // Send a RADIUS request
101 void radiussend(uint16_t r, uint8_t state)
102 {
103 struct sockaddr_in addr;
104 uint8_t b[4096]; // RADIUS packet
105 char pass[129];
106 int pl;
107 uint8_t *p;
108 sessionidt s;
109
110 CSTAT(radiussend);
111
112 s = radius[r].session;
113 if (!config->numradiusservers)
114 {
115 LOG(0, s, session[s].tunnel, "No RADIUS servers\n");
116 return;
117 }
118 if (!*config->radiussecret)
119 {
120 LOG(0, s, session[s].tunnel, "No RADIUS secret\n");
121 return;
122 }
123
124 if (state != RADIUSAUTH && !config->radius_accounting)
125 {
126 // Radius accounting is turned off
127 radiusclear(r, s);
128 return;
129 }
130
131 if (radius[r].state != state)
132 radius[r].try = 0;
133
134 radius[r].state = state;
135 radius[r].retry = backoff(radius[r].try++) + 20; // 3s, 4s, 6s, 10s...
136 LOG(4, s, session[s].tunnel, "Send RADIUS id %d sock %d state %s try %d\n",
137 r >> RADIUS_SHIFT, r & RADIUS_MASK,
138 radius_state(radius[r].state), radius[r].try);
139
140 if (radius[r].try > config->numradiusservers * 2)
141 {
142 if (s)
143 {
144 if (state == RADIUSAUTH)
145 sessionshutdown(s, "RADIUS timeout.", 3, 0);
146 else
147 {
148 LOG(1, s, session[s].tunnel, "RADIUS timeout, but in state %s so don't timeout session\n",
149 radius_state(state));
150 radiusclear(r, s);
151 }
152 STAT(radius_timeout);
153 }
154 else
155 {
156 STAT(radius_retries);
157 radius[r].state = RADIUSWAIT;
158 radius[r].retry = 100;
159 }
160 return;
161 }
162 // contruct RADIUS access request
163 switch (state)
164 {
165 case RADIUSAUTH:
166 b[0] = AccessRequest; // access request
167 break;
168 case RADIUSSTART:
169 case RADIUSSTOP:
170 case RADIUSINTERIM:
171 b[0] = AccountingRequest; // accounting request
172 break;
173 default:
174 LOG(0, 0, 0, "Unknown radius state %d\n", state);
175 }
176 b[1] = r >> RADIUS_SHIFT; // identifier
177 memcpy(b + 4, radius[r].auth, 16);
178 p = b + 20;
179 if (s)
180 {
181 *p = 1; // user name
182 p[1] = strlen(session[s].user) + 2;
183 strcpy(p + 2, session[s].user);
184 p += p[1];
185 }
186 if (state == RADIUSAUTH)
187 {
188 if (radius[r].chap)
189 {
190 *p = 3; // CHAP password
191 p[1] = 19; // length
192 p[2] = radius[r].id; // ID
193 memcpy(p + 3, radius[r].pass, 16); // response from CHAP request
194 p += p[1];
195 *p = 60; // CHAP Challenge
196 p[1] = 18; // length
197 memcpy(p + 2, radius[r].auth, 16);
198 p += p[1];
199 }
200 else
201 {
202 strcpy(pass, radius[r].pass);
203 pl = strlen(pass);
204 while (pl & 15)
205 pass[pl++] = 0; // pad
206 if (pl)
207 { // encrypt
208 hasht hash;
209 int p = 0;
210 while (p < pl)
211 {
212 MD5_CTX ctx;
213 MD5Init(&ctx);
214 MD5Update(&ctx, config->radiussecret, strlen(config->radiussecret));
215 if (p)
216 MD5Update(&ctx, pass + p - 16, 16);
217 else
218 MD5Update(&ctx, radius[r].auth, 16);
219 MD5Final(hash, &ctx);
220 do
221 {
222 pass[p] ^= hash[p & 15];
223 p++;
224 }
225 while (p & 15);
226 }
227 }
228 *p = 2; // password
229 p[1] = pl + 2;
230 if (pl)
231 memcpy(p + 2, pass, pl);
232 p += p[1];
233 }
234 }
235 else if (state == RADIUSSTART || state == RADIUSSTOP || state == RADIUSINTERIM)
236 { // accounting
237 *p = 40; // accounting type
238 p[1] = 6;
239 *(uint32_t *) (p + 2) = htonl(state - RADIUSSTART + 1); // start=1, stop=2, interim=3
240 p += p[1];
241 if (s)
242 {
243 *p = 44; // session ID
244 p[1] = 18;
245 sprintf(p + 2, "%08X%08X", session[s].unique_id, session[s].opened);
246 p += p[1];
247 if (state == RADIUSSTART)
248 { // start
249 *p = 41; // delay
250 p[1] = 6;
251 *(uint32_t *) (p + 2) = htonl(time(NULL) - session[s].opened);
252 p += p[1];
253 sess_local[s].last_interim = time_now; // Setup "first" Interim
254 }
255 else
256 { // stop, interim
257 *p = 42; // input octets
258 p[1] = 6;
259 *(uint32_t *) (p + 2) = htonl(session[s].cin);
260 p += p[1];
261
262 *p = 43; // output octets
263 p[1] = 6;
264 *(uint32_t *) (p + 2) = htonl(session[s].cout);
265 p += p[1];
266 if (state == RADIUSSTOP)
267 {
268 *p = 46; // session time
269 p[1] = 6;
270 *(uint32_t *) (p + 2) = htonl(time(NULL) - session[s].opened);
271 p += p[1];
272 }
273
274 *p = 47; // input packets
275 p[1] = 6;
276 *(uint32_t *) (p + 2) = htonl(session[s].pin);
277 p += p[1];
278
279 *p = 48; // output packets
280 p[1] = 6;
281 *(uint32_t *) (p + 2) = htonl(session[s].pout);
282 p += p[1];
283
284 *p = 52; // input gigawords
285 p[1] = 6;
286 *(uint32_t *) (p + 2) = htonl(session[s].cin_wrap);
287 p += p[1];
288
289 *p = 53; // output gigawords
290 p[1] = 6;
291 *(uint32_t *) (p + 2) = htonl(session[s].cout_wrap);
292 p += p[1];
293 }
294
295 if (session[s].snoop_ip && session[s].snoop_port)
296 {
297 *p = 26; // vendor-specific
298 *(uint32_t *) (p + 2) = htonl(9); // Cisco
299 p[6] = 1; // Cisco-Avpair
300 p[7] = 2 + sprintf(p + 8, "intercept=%s:%d",
301 fmtaddr(session[s].snoop_ip, 0), session[s].snoop_port);
302
303 p[1] = p[7] + 6;
304 p += p[1];
305 }
306 }
307 }
308 if (s)
309 {
310 *p = 5; // NAS-Port
311 p[1] = 6;
312 *(uint32_t *) (p + 2) = htonl(s);
313 p += p[1];
314 }
315 if (s && session[s].ip)
316 {
317 *p = 8; // Framed-IP-Address
318 p[1] = 6;
319 *(uint32_t *) (p + 2) = htonl(session[s].ip);
320 p += p[1];
321 }
322 if (*session[s].called)
323 {
324 *p = 30; // called
325 p[1] = strlen(session[s].called) + 2;
326 strcpy(p + 2, session[s].called);
327 p += p[1];
328 }
329 if (*radius[r].calling)
330 {
331 *p = 31; // calling
332 p[1] = strlen(radius[r].calling) + 2;
333 strcpy(p + 2, radius[r].calling);
334 p += p[1];
335 }
336 else if (*session[s].calling)
337 {
338 *p = 31; // calling
339 p[1] = strlen(session[s].calling) + 2;
340 strcpy(p + 2, session[s].calling);
341 p += p[1];
342 }
343 // NAS-IP-Address
344 *p = 4;
345 p[1] = 6;
346 *(uint32_t *)(p + 2) = config->bind_address;
347 p += p[1];
348
349 // All AVpairs added
350 *(uint16_t *) (b + 2) = htons(p - b);
351 if (state != RADIUSAUTH)
352 {
353 // Build auth for accounting packet
354 char z[16] = {0};
355 char hash[16] = {0};
356 MD5_CTX ctx;
357 MD5Init(&ctx);
358 MD5Update(&ctx, b, 4);
359 MD5Update(&ctx, z, 16);
360 MD5Update(&ctx, b + 20, (p - b) - 20);
361 MD5Update(&ctx, config->radiussecret, strlen(config->radiussecret));
362 MD5Final(hash, &ctx);
363 memcpy(b + 4, hash, 16);
364 memcpy(radius[r].auth, hash, 16);
365 }
366 memset(&addr, 0, sizeof(addr));
367 addr.sin_family = AF_INET;
368 *(uint32_t *) & addr.sin_addr = config->radiusserver[(radius[r].try - 1) % config->numradiusservers];
369 {
370 // get radius port
371 uint16_t port = config->radiusport[(radius[r].try - 1) % config->numradiusservers];
372 // assume RADIUS accounting port is the authentication port +1
373 addr.sin_port = htons((state == RADIUSAUTH) ? port : port+1);
374 }
375
376 LOG_HEX(5, "RADIUS Send", b, (p - b));
377 sendto(radfds[r & RADIUS_MASK], b, p - b, 0, (void *) &addr, sizeof(addr));
378 }
379
380 // process RADIUS response
381 void processrad(uint8_t *buf, int len, char socket_index)
382 {
383 uint8_t b[MAXCONTROL];
384 MD5_CTX ctx;
385 uint16_t r;
386 sessionidt s;
387 tunnelidt t = 0;
388 hasht hash;
389 uint8_t routes = 0;
390 int r_code;
391 int r_id;
392
393 CSTAT(processrad);
394
395 LOG_HEX(5, "RADIUS Response", buf, len);
396 if (len < 20 || len < ntohs(*(uint16_t *) (buf + 2)))
397 {
398 LOG(1, 0, 0, "Duff RADIUS response length %d\n", len);
399 return ;
400 }
401
402 r_code = buf[0]; // response type
403 r_id = buf[1]; // radius reply indentifier.
404
405 len = ntohs(*(uint16_t *) (buf + 2));
406 r = socket_index | (r_id << RADIUS_SHIFT);
407 s = radius[r].session;
408 LOG(3, s, session[s].tunnel, "Received %s, radius %d response for session %u (%s, id %d)\n",
409 radius_state(radius[r].state), r, s, radius_code(r_code), r_id);
410
411 if (!s && radius[r].state != RADIUSSTOP)
412 {
413 LOG(1, s, session[s].tunnel, " Unexpected RADIUS response\n");
414 return;
415 }
416 if (radius[r].state != RADIUSAUTH && radius[r].state != RADIUSSTART
417 && radius[r].state != RADIUSSTOP && radius[r].state != RADIUSINTERIM)
418 {
419 LOG(1, s, session[s].tunnel, " Unexpected RADIUS response\n");
420 return;
421 }
422 t = session[s].tunnel;
423 MD5Init(&ctx);
424 MD5Update(&ctx, buf, 4);
425 MD5Update(&ctx, radius[r].auth, 16);
426 MD5Update(&ctx, buf + 20, len - 20);
427 MD5Update(&ctx, config->radiussecret, strlen(config->radiussecret));
428 MD5Final(hash, &ctx);
429 do {
430 if (memcmp(hash, buf + 4, 16))
431 {
432 LOG(0, s, session[s].tunnel, " Incorrect auth on RADIUS response!! (wrong secret in radius config?)\n");
433 return; // Do nothing. On timeout, it will try the next radius server.
434 }
435
436 if ((radius[r].state == RADIUSAUTH && r_code != AccessAccept && r_code != AccessReject) ||
437 ((radius[r].state == RADIUSSTART || radius[r].state == RADIUSSTOP || radius[r].state == RADIUSINTERIM) && r_code != AccountingResponse))
438 {
439 LOG(1, s, session[s].tunnel, " Unexpected RADIUS response %s\n", radius_code(r_code));
440 return; // We got something we didn't expect. Let the timeouts take
441 // care off finishing the radius session if that's really correct.
442 }
443
444 if (radius[r].state == RADIUSAUTH)
445 {
446 // run post-auth plugin
447 struct param_post_auth packet = {
448 &tunnel[t],
449 &session[s],
450 session[s].user,
451 (r_code == AccessAccept),
452 radius[r].chap ? PPPCHAP : PPPPAP
453 };
454
455 run_plugins(PLUGIN_POST_AUTH, &packet);
456 r_code = packet.auth_allowed ? AccessAccept : AccessReject;
457
458 // process auth response
459 if (radius[r].chap)
460 {
461 // CHAP
462 uint8_t *p = makeppp(b, sizeof(b), 0, 0, t, s, PPPCHAP);
463 if (!p) return; // Abort!
464
465 *p = (r_code == AccessAccept) ? 3 : 4; // ack/nak
466 p[1] = radius[r].id;
467 *(uint16_t *) (p + 2) = ntohs(4); // no message
468 tunnelsend(b, (p - b) + 4, t); // send it
469
470 LOG(3, s, session[s].tunnel, " CHAP User %s authentication %s.\n", session[s].user,
471 (r_code == AccessAccept) ? "allowed" : "denied");
472 }
473 else
474 {
475 // PAP
476 uint8_t *p = makeppp(b, sizeof(b), 0, 0, t, s, PPPPAP);
477 if (!p) return; // Abort!
478
479 // ack/nak
480 *p = r_code;
481 p[1] = radius[r].id;
482 *(uint16_t *) (p + 2) = ntohs(5);
483 p[4] = 0; // no message
484 tunnelsend(b, (p - b) + 5, t); // send it
485
486 LOG(3, s, session[s].tunnel, " PAP User %s authentication %s.\n", session[s].user,
487 (r_code == AccessAccept) ? "allowed" : "denied");
488 }
489
490 if (r_code == AccessAccept)
491 {
492 // Login successful
493 // Extract IP, routes, etc
494 uint8_t *p = buf + 20;
495 uint8_t *e = buf + len;
496 for (; p + 2 <= e && p[1] && p + p[1] <= e; p += p[1])
497 {
498 if (*p == 8)
499 {
500 // Framed-IP-Address
501 if (p[1] < 6) continue;
502 session[s].ip = ntohl(*(uint32_t *) (p + 2));
503 session[s].ip_pool_index = -1;
504 LOG(3, s, session[s].tunnel, " Radius reply contains IP address %s\n",
505 fmtaddr(htonl(session[s].ip), 0));
506
507 if (session[s].ip == 0xFFFFFFFE)
508 session[s].ip = 0; // assign from pool
509 }
510 else if (*p == 135)
511 {
512 // DNS address
513 if (p[1] < 6) continue;
514 session[s].dns1 = ntohl(*(uint32_t *) (p + 2));
515 LOG(3, s, session[s].tunnel, " Radius reply contains primary DNS address %s\n",
516 fmtaddr(htonl(session[s].dns1), 0));
517 }
518 else if (*p == 136)
519 {
520 // DNS address
521 if (p[1] < 6) continue;
522 session[s].dns2 = ntohl(*(uint32_t *) (p + 2));
523 LOG(3, s, session[s].tunnel, " Radius reply contains secondary DNS address %s\n",
524 fmtaddr(htonl(session[s].dns2), 0));
525 }
526 else if (*p == 22)
527 {
528 // Framed-Route
529 in_addr_t ip = 0, mask = 0;
530 uint8_t u = 0;
531 uint8_t bits = 0;
532 uint8_t *n = p + 2;
533 uint8_t *e = p + p[1];
534 while (n < e && (isdigit(*n) || *n == '.'))
535 {
536 if (*n == '.')
537 {
538 ip = (ip << 8) + u;
539 u = 0;
540 }
541 else
542 u = u * 10 + *n - '0';
543 n++;
544 }
545 ip = (ip << 8) + u;
546 if (*n == '/')
547 {
548 n++;
549 while (n < e && isdigit(*n))
550 bits = bits * 10 + *n++ - '0';
551 mask = (( -1) << (32 - bits));
552 }
553 else if ((ip >> 24) < 128)
554 mask = 0xFF0000;
555 else if ((ip >> 24) < 192)
556 mask = 0xFFFF0000;
557 else
558 mask = 0xFFFFFF00;
559
560 if (routes == MAXROUTE)
561 {
562 LOG(1, s, session[s].tunnel, " Too many routes\n");
563 }
564 else if (ip)
565 {
566 LOG(3, s, session[s].tunnel, " Radius reply contains route for %s/%s\n",
567 fmtaddr(htonl(ip), 0), fmtaddr(htonl(mask), 1));
568
569 session[s].route[routes].ip = ip;
570 session[s].route[routes].mask = mask;
571 routes++;
572 }
573 }
574 else if (*p == 11)
575 {
576 // Filter-Id
577 char *filter = p + 2;
578 int l = p[1] - 2;
579 char *suffix;
580 uint8_t *f = 0;
581 int i;
582
583 LOG(3, s, session[s].tunnel, " Radius reply contains Filter-Id \"%.*s\"\n", l, filter);
584 if ((suffix = memchr(filter, '.', l)))
585 {
586 int b = suffix - filter;
587 if (l - b == 3 && !memcmp("in", suffix+1, 2))
588 f = &session[s].filter_in;
589 else if (l - b == 4 && !memcmp("out", suffix+1, 3))
590 f = &session[s].filter_out;
591
592 l = b;
593 }
594
595 if (!f)
596 {
597 LOG(3, s, session[s].tunnel, " Invalid filter\n");
598 continue;
599 }
600
601 for (*f = 0, i = 0; !*f && i < MAXFILTER; i++)
602 if (strlen(ip_filters[i].name) == l &&
603 !strncmp(ip_filters[i].name, filter, l))
604 *f = i + 1;
605
606 if (*f)
607 ip_filters[*f - 1].used++;
608 else
609 LOG(3, s, session[s].tunnel, " Unknown filter\n");
610
611 }
612 else if (*p == 26 && p[1] >= 7)
613 {
614 // Vendor-Specific Attribute
615 int vendor = ntohl(*(int *)(p + 2));
616 char attrib = *(p + 6);
617 int attrib_length = *(p + 7) - 2;
618 char *avpair, *value, *key, *newp;
619
620 LOG(3, s, session[s].tunnel, " Radius reply contains Vendor-Specific. Vendor=%d Attrib=%d Length=%d\n", vendor, attrib, attrib_length);
621 if (vendor != 9 || attrib != 1)
622 {
623 LOG(3, s, session[s].tunnel, " Unknown vendor-specific\n");
624 continue;
625 }
626
627 if (attrib_length < 0) continue;
628
629 avpair = key = calloc(attrib_length + 1, 1);
630 memcpy(avpair, p + 8, attrib_length);
631 LOG(3, s, session[s].tunnel, " Cisco-Avpair value: %s\n", avpair);
632 do {
633 value = strchr(key, '=');
634 if (!value) break;
635 *value++ = 0;
636
637 // Trim quotes off reply string
638 if (*value == '\'' || *value == '\"')
639 {
640 char *x;
641 value++;
642 x = value + strlen(value) - 1;
643 if (*x == '\'' || *x == '\"')
644 *x = 0;
645 }
646
647 // Run hooks
648 newp = strchr(value, ',');
649 if (newp) *newp++ = 0;
650 {
651 struct param_radius_response p = { &tunnel[session[s].tunnel], &session[s], key, value };
652 run_plugins(PLUGIN_RADIUS_RESPONSE, &p);
653 }
654 key = newp;
655 } while (newp);
656 free(avpair);
657 }
658 else if (*p == 99)
659 {
660 // Framed-IPv6-Route
661 struct in6_addr r6;
662 int prefixlen;
663 uint8_t *n = p + 2;
664 uint8_t *e = p + p[1];
665 uint8_t *m = strchr(n, '/');
666
667 *m++ = 0;
668 inet_pton(AF_INET6, n, &r6);
669
670 prefixlen = 0;
671 while (m < e && isdigit(*m)) {
672 prefixlen = prefixlen * 10 + *m++ - '0';
673 }
674
675 if (prefixlen)
676 {
677 LOG(3, s, session[s].tunnel,
678 " Radius reply contains route for %s/%d\n",
679 n, prefixlen);
680 session[s].ipv6route = r6;
681 session[s].ipv6prefixlen = prefixlen;
682 }
683 }
684 }
685 }
686 else if (r_code == AccessReject)
687 {
688 LOG(2, s, session[s].tunnel, " Authentication rejected for %s\n", session[s].user);
689 sessionkill(s, "Authentication rejected");
690 break;
691 }
692
693 if (!session[s].dns1 && config->default_dns1)
694 {
695 session[s].dns1 = htonl(config->default_dns1);
696 LOG(3, s, t, " Sending dns1 = %s\n", fmtaddr(config->default_dns1, 0));
697 }
698 if (!session[s].dns2 && config->default_dns2)
699 {
700 session[s].dns2 = htonl(config->default_dns2);
701 LOG(3, s, t, " Sending dns2 = %s\n", fmtaddr(config->default_dns2, 0));
702 }
703
704 // Valid Session, set it up
705 session[s].unique_id = 0;
706 sessionsetup(t, s);
707 }
708 else
709 {
710 // An ack for a stop or start record.
711 LOG(3, s, t, " RADIUS accounting ack recv in state %s\n", radius_state(radius[r].state));
712 break;
713 }
714 } while (0);
715
716 // finished with RADIUS
717 radiusclear(r, s);
718 }
719
720 // Send a retry for RADIUS/CHAP message
721 void radiusretry(uint16_t r)
722 {
723 sessionidt s = radius[r].session;
724 tunnelidt t = 0;
725
726 CSTAT(radiusretry);
727
728 if (s) t = session[s].tunnel;
729
730 switch (radius[r].state)
731 {
732 case RADIUSCHAP: // sending CHAP down PPP
733 sendchap(t, s);
734 break;
735 case RADIUSIPCP:
736 sendipcp(t, s); // send IPCP
737 break;
738 case RADIUSAUTH: // sending auth to RADIUS server
739 radiussend(r, RADIUSAUTH);
740 break;
741 case RADIUSSTART: // sending start accounting to RADIUS server
742 radiussend(r, RADIUSSTART);
743 break;
744 case RADIUSSTOP: // sending stop accounting to RADIUS server
745 radiussend(r, RADIUSSTOP);
746 break;
747 case RADIUSINTERIM: // sending interim accounting to RADIUS server
748 radiussend(r, RADIUSINTERIM);
749 break;
750 default:
751 case RADIUSNULL: // Not in use
752 case RADIUSWAIT: // waiting timeout before available, in case delayed reply from RADIUS server
753 // free up RADIUS task
754 radiusclear(r, s);
755 LOG(3, s, session[s].tunnel, "Freeing up radius session %d\n", r);
756 break;
757 }
758 }