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