/[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.49 by gray, Thu Jun 5 11:10:24 2003 UTC revision 1.50 by gray, Thu Jun 5 17:29:01 2003 UTC
# Line 40  Line 40 
40  /* ************************************************************************* */  /* ************************************************************************* */
41  /* Functions local to this module */  /* Functions local to this module */
42    
 static UINT4  
 get_socket_addr(int fd)  
 {  
         struct sockaddr_in sin;  
         int len = sizeof(sin);  
         UINT4 ip = 0;  
   
         if (getsockname(fd, (struct sockaddr*)&sin, &len) == 0)  
                 ip = sin.sin_addr.s_addr;  
   
         if (ip == INADDR_ANY)  
                 ip = ref_ip;  
         return ip;  
 }  
   
   
43  /*  /*
44   *      Decode a password and encode it again.   *      Decode a password and encode it again.
45   */   */
# Line 63  static void Line 47  static void
47  passwd_recode(VALUE_PAIR *pass_pair, char *new_secret, char *new_vector,  passwd_recode(VALUE_PAIR *pass_pair, char *new_secret, char *new_vector,
48                RADIUS_REQ *req)                RADIUS_REQ *req)
49  {  {
50          char    password[AUTH_STRING_LEN+1];          char password[AUTH_STRING_LEN+1];
51          req_decrypt_password(password, req, pass_pair);          req_decrypt_password(password, req, pass_pair);
52          efree(pass_pair->avp_strvalue);          efree(pass_pair->avp_strvalue);
53          encrypt_password(pass_pair, password, new_vector, new_secret);          encrypt_password(pass_pair, password, new_vector, new_secret);
# Line 79  int Line 63  int
63  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r)  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r)
64  {  {
65          VALUE_PAIR *p, *proxy_state_pair = NULL;          VALUE_PAIR *p, *proxy_state_pair = NULL;
         PROXY_STATE *state;  
66          RADIUS_SERVER *server;          RADIUS_SERVER *server;
67                    
68          if (!qr->realm) {          if (!qr->realm) {
# Line 97  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r) Line 80  proxy_cmp(RADIUS_REQ *qr, RADIUS_REQ *r)
80                  if (p->attribute == DA_PROXY_STATE)                  if (p->attribute == DA_PROXY_STATE)
81                          proxy_state_pair = p;                          proxy_state_pair = p;
82          }          }
83    
84            if (proxy_state_pair
85                && proxy_state_pair->avp_strlength == sizeof(PROXY_STATE)) {
86                    PROXY_STATE *state;
87    
88                    state = (PROXY_STATE *)proxy_state_pair->avp_strvalue;
89                    
         state = proxy_state_pair ?  
                    (PROXY_STATE *)proxy_state_pair->avp_strvalue : NULL;  
           
         if (state) {  
90                  debug(1,                  debug(1,
91                        ("state: ipaddr %08x, id %u, proxy_id %u, rem_ipaddr %08x",                        ("state: ipaddr %08x, id %u, proxy_id %u, remote_ip %08x",
92                         state->ipaddr,                         state->client_ip,
93                         state->id,                         state->id,
94                         state->proxy_id,                         state->proxy_id,
95                         state->rem_ipaddr));                         state->remote_ip));
96                                    
97                  if (state->proxy_id == r->id                  if (state->ref_ip == ref_ip
98                      && state->rem_ipaddr == r->ipaddr) {                      && state->proxy_id == r->id
99                        && state->remote_ip == r->ipaddr) {
100                          debug(10, ("(old=data) id %d %d, ipaddr %#8x %#8x, proxy_id %d %d, server_addr %#8x %#8x",                          debug(10, ("(old=data) id %d %d, ipaddr %#8x %#8x, proxy_id %d %d, server_addr %#8x %#8x",
101                                     qr->id, state->id,                                     qr->id, state->id,
102                                     qr->ipaddr, state->ipaddr,                                     qr->ipaddr, state->client_ip,
103                                     qr->server_id, state->proxy_id,                                     qr->server_id, state->proxy_id,
104                                     server->addr, state->rem_ipaddr));                                     server->addr, state->remote_ip));
105                    
106                          if (state->ipaddr == qr->ipaddr                          if (state->client_ip == qr->ipaddr
107                              && state->id  == qr->id                              && state->id  == qr->id
108                              && state->proxy_id == qr->server_id                              && state->proxy_id == qr->server_id
109                              && state->rem_ipaddr == server->addr) {                              && state->remote_ip == server->addr) {
110                                  debug(1,("EQUAL!!!"));                                  debug(1,("EQUAL!!!"));
111                                  return 0;                                  return 0;
112                          }                          }
# Line 183  proxy_send_request(int fd, RADIUS_REQ *r Line 169  proxy_send_request(int fd, RADIUS_REQ *r
169          p->avp_strvalue = emalloc(p->avp_strlength);          p->avp_strvalue = emalloc(p->avp_strlength);
170                    
171          proxy_state = (PROXY_STATE *)p->avp_strvalue;          proxy_state = (PROXY_STATE *)p->avp_strvalue;
172                  
173          proxy_state->ipaddr = radreq->ipaddr; /*FIXME: get_socket_addr(fd);*/          proxy_state->ref_ip = ref_ip;
174            proxy_state->client_ip = radreq->ipaddr;
175          proxy_state->id = radreq->id;          proxy_state->id = radreq->id;
176          proxy_state->proxy_id = radreq->server_id;          proxy_state->proxy_id = radreq->server_id;
177          proxy_state->rem_ipaddr = server->addr;          proxy_state->remote_ip = server->addr;
178    
179          avl_add_pair(&plist, p);          avl_add_pair(&plist, p);
180    

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

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