/[radius]/radius/radiusd/proxy.c
ViewVC logotype

Diff of /radius/radiusd/proxy.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.44 by gray, Fri Apr 25 22:48:55 2003 UTC revision 1.45 by gray, Mon Apr 28 12:09:11 2003 UTC
# Line 1  Line 1 
1  /* This file is part of GNU RADIUS.  /* This file is part of GNU Radius.
2     Copyright (C) 2000, Sergey Poznyakoff     Copyright (C) 2000,2002,2003 Sergey Poznyakoff
3        
4     This program is free software; you can redistribute it and/or modify     GNU Radius is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.     (at your option) any later version.
8        
9     This program is distributed in the hope that it will be useful,     GNU Radius is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.     GNU General Public License for more details.
13        
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software Foundation,     along with GNU Radius; if not, write to the Free Software Foundation,
16     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17    
18  /*FIXME!FIXME!FIXME! server timeout is not used */  /*FIXME!FIXME!FIXME! server timeout is not used */
19    
20  #define RADIUS_MODULE_PROXY_C  #define RADIUS_MODULE_PROXY_C
 #ifndef lint  
 static char rcsid[] =  
 "@(#) $Id$";  
 #endif  
21    
22  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
23  # include <config.h>  # include <config.h>
# Line 43  static char rcsid[] = Line 39  static char rcsid[] =
39    
40  #include <radiusd.h>  #include <radiusd.h>
41    
 static PROXY_ID *proxy_id;  
   
42  /* ************************************************************************* */  /* ************************************************************************* */
43  /* Functions local to this module */  /* Functions local to this module */
44    
# Line 144  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r) Line 138  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r)
138  }  }
139    
140  /* ************************************************************************* */  /* ************************************************************************* */
 /* Proxy-Id functions */  
 /* We try to keep a separate proxy_id per remote server so that if we happen  
  * to have a lot of proxy requests the proxy id wouldn't wrap around too  
  * fast.  
  * From the other hand, we can't keep the proxy id in the client struct since  
  * it would be reset to zero after each reload of configuration files.  
  * This approach has two drawbacks:  
  *   1. Linear search. If we have too many clients, its performance will  
  *      degradate.  
  *   2. Suppose we delete a client and then do a reload. In that case this  
  *      client's proxy_id record will hang around just wasting memory. Hence,  
  *      the need of proxy_cleanup function.  
  */  
   
 /* next_proxy_id(): return next proxy id for the given client's IP address.  
  * If we don't have one, create it and initialize to zero.  
  */  
 u_char  
 next_proxy_id(UINT4 ipaddr)  
 {  
         PROXY_ID *p;  
           
         for (p = proxy_id; p; p = p->next)  
                 if (p->ipaddr == ipaddr)  
                         break;  
         if (!p) {  
                 p = mem_alloc(sizeof *p);  
                 p->ipaddr = ipaddr;  
                 p->id = 0;  
                 p->next = proxy_id;  
                 proxy_id = p;  
         }  
         return p->id++;  
 }  
   
 /* Delete any proxy_id's that do not correspond to existing clients  
  */  
 void  
 proxy_cleanup()  
 {  
         PROXY_ID *p, *prev, *next;  
   
         prev = NULL;  
         for (p = proxy_id; p; ) {  
                 next = p->next;  
                 if (!client_lookup_ip(p->ipaddr)) {  
                         if (prev)  
                                 prev->next = next;  
                         else  
                                 proxy_id = next;  
                         mem_free(p);  
                 }  
                 p = next;  
         }  
 }  
   
 /* ************************************************************************* */  
141  /* Reply functions. Possibly these should go to libclient? */  /* Reply functions. Possibly these should go to libclient? */
142    
143  int  int
# Line 353  proxy_send(REQUEST *req) Line 290  proxy_send(REQUEST *req)
290    
291          radreq->server = realm->queue->first_server;          radreq->server = realm->queue->first_server;
292          radreq->attempt_no = 0;          radreq->attempt_no = 0;
293          radreq->server_id = next_proxy_id(radreq->server->addr);          radreq->server_id = rad_clt_message_id(radreq->server);
294          radreq->remote_user = string_create(username);          radreq->remote_user = string_create(username);
295    
296          req->update_size = sizeof(*upd) + strlen(realm->realm);          req->update_size = sizeof(*upd) + strlen(realm->realm);

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26