More replace vp->lvalue with vp->vp_*
authoraland <aland>
Tue, 17 Apr 2007 07:58:50 +0000 (07:58 +0000)
committeraland <aland>
Tue, 17 Apr 2007 07:58:50 +0000 (07:58 +0000)
src/main/acct.c
src/main/auth.c
src/main/event.c
src/main/listen.c
src/main/radclient.c
src/main/session.c
src/main/valuepair.c
src/main/xlat.c

index 367f118..f31c092 100644 (file)
@@ -80,7 +80,7 @@ int rad_accounting(REQUEST *request)
                vp = pairfind(request->config_items, PW_ACCT_TYPE);
                if (vp) {
                        DEBUG2("  Found Acct-Type %s", vp->vp_strvalue);
-                       acct_type = vp->lvalue;
+                       acct_type = vp->vp_integer;
                }
                result = module_accounting(acct_type, request);
                switch (result) {
index d76c756..90438ad 100644 (file)
@@ -43,7 +43,7 @@ char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli) {
        if ((cli = pairfind(request->packet->vps, PW_CALLING_STATION_ID)) == NULL)
                do_cli = 0;
        if ((pair = pairfind(request->packet->vps, PW_NAS_PORT)) != NULL)
-               port = pair->lvalue;
+               port = pair->vp_integer;
 
        snprintf(buf, buflen, "from client %.128s port %u%s%.128s",
                        client_name_old(&request->packet->src_ipaddr), port,
@@ -162,7 +162,7 @@ static int rad_check_password(REQUEST *request)
         */
        cur_config_item = request->config_items;
        while(((auth_type_pair = pairfind(cur_config_item, PW_AUTH_TYPE))) != NULL) {
-               auth_type = auth_type_pair->lvalue;
+               auth_type = auth_type_pair->vp_integer;
                auth_type_count++;
 
                DEBUG2("  rad_check_password:  Found Auth-Type %s",
@@ -394,7 +394,7 @@ int rad_postauth(REQUEST *request)
        vp = pairfind(request->config_items, PW_POST_AUTH_TYPE);
        if (vp) {
                DEBUG2("  Found Post-Auth-Type %s", vp->vp_strvalue);
-               postauth_type = vp->lvalue;
+               postauth_type = vp->vp_integer;
        }
        result = module_post_auth(postauth_type, request);
        switch (result) {
@@ -467,7 +467,7 @@ int rad_authenticate(REQUEST *request)
                                radlog(L_ERR|L_CONS, "Not enough memory");
                                exit(1);
                        }
-                       tmp->lvalue = PW_AUTHTYPE_ACCEPT;
+                       tmp->vp_integer = PW_AUTHTYPE_ACCEPT;
                        pairadd(&request->config_items, tmp);
                        break;
                /*
@@ -567,7 +567,7 @@ autz_redo:
                tmp = pairfind(request->config_items, PW_AUTZ_TYPE);
                if (tmp) {
                        DEBUG2("  Found Autz-Type %s", tmp->vp_strvalue);
-                       autz_type = tmp->lvalue;
+                       autz_type = tmp->vp_integer;
                        autz_retry = 1;
                        goto autz_redo;
                }
@@ -659,7 +659,7 @@ autz_redo:
                tmp = pairfind(request->config_items, PW_SESSION_TYPE);
                if (tmp) {
                        DEBUG2("  Found Session-Type %s", tmp->vp_strvalue);
-                       session_type = tmp->lvalue;
+                       session_type = tmp->vp_integer;
                }
 
                /*
@@ -667,7 +667,7 @@ autz_redo:
                 *      for the Simultaneous-Use parameter.
                 */
                if (namepair &&
-                   (r = module_checksimul(session_type, request, check_item->lvalue)) != 0) {
+                   (r = module_checksimul(session_type, request, check_item->vp_integer)) != 0) {
                        char mpp_ok = 0;
 
                        if (r == 2){
@@ -675,16 +675,16 @@ autz_redo:
                                VALUE_PAIR *port_limit;
 
                                if ((port_limit = pairfind(request->reply->vps, PW_PORT_LIMIT)) != NULL &&
-                                       port_limit->lvalue > check_item->lvalue){
+                                       port_limit->vp_integer > check_item->vp_integer){
                                        DEBUG2("main auth: MPP is OK");
                                        mpp_ok = 1;
                                }
                        }
                        if (!mpp_ok){
-                               if (check_item->lvalue > 1) {
+                               if (check_item->vp_integer > 1) {
                                snprintf(umsg, sizeof(umsg),
                                                        "\r\nYou are already logged in %d times  - access denied\r\n\n",
-                                                       (int)check_item->lvalue);
+                                                       (int)check_item->vp_integer);
                                        user_msg = umsg;
                                } else {
                                        user_msg = "\r\nYou are already logged in - access denied\r\n\n";
@@ -701,7 +701,7 @@ autz_redo:
                                request->reply->vps = tmp;
 
                                snprintf(logstr, sizeof(logstr), "Multiple logins (max %d) %s",
-                                       check_item->lvalue,
+                                       check_item->vp_integer,
                                        r == 2 ? "[MPP attempt]" : "");
                                rad_authlog(logstr, request, 1);
 
@@ -741,10 +741,10 @@ autz_redo:
                 */
                if ((vpPortId = pairfind(request->packet->vps,
                                         PW_NAS_PORT)) != NULL) {
-                 unsigned long tvalue = ntohl(tmp->lvalue);
-                 tmp->lvalue = htonl(tvalue + vpPortId->lvalue);
+                 unsigned long tvalue = ntohl(tmp->vp_integer);
+                 tmp->vp_integer = htonl(tvalue + vpPortId->vp_integer);
                  tmp->flags.addport = 0;
-                 ip_ntoa(tmp->vp_strvalue, tmp->lvalue);
+                 ip_ntoa(tmp->vp_strvalue, tmp->vp_integer);
                } else {
                        DEBUG2("WARNING: No NAS-Port attribute in request.  CANNOT return a Framed-IP-Address + NAS-Port.\n");
                        pairdelete(&request->reply->vps, PW_FRAMED_IP_ADDRESS);
index 34ea484..177a377 100644 (file)
@@ -97,8 +97,6 @@ static void snmp_inc_client_responses(RADCLIENT *client,
 {
        if (!mainconfig.do_snmp) return;
 
-       if (!client) return;
-
        /*
         *      Update the SNMP statistics.
         *
@@ -111,24 +109,24 @@ static void snmp_inc_client_responses(RADCLIENT *client,
        case PW_AUTHENTICATION_ACK:
                rad_snmp.auth.total_responses++;
                rad_snmp.auth.total_access_accepts++;
-               client->auth->accepts++;
+               if (client) client->auth->accepts++;
                break;
 
        case PW_AUTHENTICATION_REJECT:
                rad_snmp.auth.total_responses++;
                rad_snmp.auth.total_access_rejects++;
-               client->auth->rejects++;
+               if (client) client->auth->rejects++;
                break;
                
        case PW_ACCESS_CHALLENGE:
                rad_snmp.auth.total_responses++;
                rad_snmp.auth.total_access_challenges++;
-               client->auth->challenges++;
+               if (client) client->auth->challenges++;
                break;
                
        case PW_ACCOUNTING_RESPONSE:
                rad_snmp.acct.total_responses++;
-               client->auth->responses++;
+               if (client) client->auth->responses++;
                break;
 
                /*
@@ -138,7 +136,7 @@ static void snmp_inc_client_responses(RADCLIENT *client,
        case 0:
                if (request->packet->code == PW_AUTHENTICATION_REQUEST) {
                        rad_snmp.auth.total_bad_authenticators++;
-                       client->auth->bad_authenticators++;
+                       if (client) client->auth->bad_authenticators++;
                }
                break;
                
@@ -875,7 +873,7 @@ static int request_pre_handler(REQUEST *request)
                vp = pairfind(request->config_items, PW_POST_PROXY_TYPE);
                if (vp) {
                        DEBUG2("  Found Post-Proxy-Type %s", vp->vp_strvalue);
-                       post_proxy_type = vp->lvalue;
+                       post_proxy_type = vp->vp_integer;
                }
                rcode = module_post_proxy(post_proxy_type, request);
                
@@ -1135,7 +1133,7 @@ static int successfully_proxied_request(REQUEST *request)
        vp = pairfind(request->config_items, PW_PRE_PROXY_TYPE);
        if (vp) {
                DEBUG2("  Found Pre-Proxy-Type %s", vp->vp_strvalue);
-               pre_proxy_type = vp->lvalue;
+               pre_proxy_type = vp->vp_integer;
        }
        rcode = module_pre_proxy(pre_proxy_type, request);
        switch (rcode) {
@@ -1235,7 +1233,7 @@ static void request_post_handler(REQUEST *request)
 
        if ((request->reply->code == 0) &&
            ((vp = pairfind(request->config_items, PW_AUTH_TYPE)) != NULL) &&
-           (vp->lvalue == PW_AUTHTYPE_REJECT)) {
+           (vp->vp_integer == PW_AUTHTYPE_REJECT)) {
                request->reply->code = PW_AUTHENTICATION_REJECT;
        }
 
index 9ce2dcb..cdbb1a9 100644 (file)
@@ -1008,7 +1008,7 @@ static int detail_recv(rad_listen_t *listener,
                rad_assert(vp != NULL);
        }
        if (data->timestamp != 0) {
-               vp->lvalue += time(NULL) - data->timestamp;
+               vp->vp_integer += time(NULL) - data->timestamp;
        }
 
        /*
@@ -1022,7 +1022,7 @@ static int detail_recv(rad_listen_t *listener,
        vp = pairfind(packet->vps, PW_PACKET_SRC_IP_ADDRESS);
        if (vp) {
                packet->src_ipaddr.af = AF_INET;
-               packet->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+               packet->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
        } else {
                vp = pairfind(packet->vps, PW_PACKET_SRC_IPV6_ADDRESS);
                if (vp) {
@@ -1035,7 +1035,7 @@ static int detail_recv(rad_listen_t *listener,
        vp = pairfind(packet->vps, PW_PACKET_DST_IP_ADDRESS);
        if (vp) {
                packet->dst_ipaddr.af = AF_INET;
-               packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+               packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
        } else {
                vp = pairfind(packet->vps, PW_PACKET_DST_IPV6_ADDRESS);
                if (vp) {
index 581aa6c..bf4c950 100644 (file)
@@ -230,16 +230,16 @@ static radclient_t *radclient_init(const char *filename)
                                 *      the attributes read from the file.
                                 */
                        case PW_PACKET_TYPE:
-                               radclient->request->code = vp->lvalue;
+                               radclient->request->code = vp->vp_integer;
                                break;
 
                        case PW_PACKET_DST_PORT:
-                               radclient->request->dst_port = (vp->lvalue & 0xffff);
+                               radclient->request->dst_port = (vp->vp_integer & 0xffff);
                                break;
 
                        case PW_PACKET_DST_IP_ADDRESS:
                                radclient->request->dst_ipaddr.af = AF_INET;
-                               radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+                               radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
                                break;
 
                        case PW_PACKET_DST_IPV6_ADDRESS:
@@ -248,12 +248,12 @@ static radclient_t *radclient_init(const char *filename)
                                break;
 
                        case PW_PACKET_SRC_PORT:
-                               radclient->request->src_port = (vp->lvalue & 0xffff);
+                               radclient->request->src_port = (vp->vp_integer & 0xffff);
                                break;
 
                        case PW_PACKET_SRC_IP_ADDRESS:
                                radclient->request->src_ipaddr.af = AF_INET;
-                               radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+                               radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
                                break;
 
                        case PW_PACKET_SRC_IPV6_ADDRESS:
index 51f0657..3f08a1e 100644 (file)
@@ -26,8 +26,9 @@ RCSID("$Id$")
 #include       <freeradius-devel/radiusd.h>
 #include       <freeradius-devel/rad_assert.h>
 
-#include       <signal.h>
+#ifdef HAVE_SYS_WAIT_H
 #include       <sys/wait.h>
+#endif
 
 /*
  *     End a session by faking a Stop packet to all accounting modules.
@@ -55,8 +56,8 @@ int session_zap(REQUEST *request, uint32_t nasaddr, unsigned int port,
                vp->e = v; \
                pairadd(&(stopreq->packet->vps), vp); \
        } while(0)
-#define INTPAIR(n,v) PAIR(n,v,PW_TYPE_INTEGER,lvalue)
-#define IPPAIR(n,v) PAIR(n,v,PW_TYPE_IPADDR,lvalue)
+#define INTPAIR(n,v) PAIR(n,v,PW_TYPE_INTEGER,vp_integer)
+#define IPPAIR(n,v) PAIR(n,v,PW_TYPE_IPADDR,vp_ipaddr)
 #define STRINGPAIR(n,v) do { \
        if(!(vp = paircreate(n, PW_TYPE_STRING))) { \
                radlog(L_ERR|L_CONS, "no memory"); \
index 065ea0f..982400e 100644 (file)
@@ -189,9 +189,13 @@ int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
                                             (char *)check->vp_strvalue);
                        }
                        break;
+               case PW_TYPE_BYTE:
+               case PW_TYPE_SHORT:
                case PW_TYPE_INTEGER:
+                       ret = vp->vp_integer - check->vp_integer;
+                       break;
                case PW_TYPE_DATE:
-                       ret = vp->lvalue - check->lvalue;
+                       ret = vp->vp_date - check->vp_date;
                        break;
                case PW_TYPE_IPADDR:
                        ret = ntohl(vp->vp_ipaddr) - ntohl(check->vp_ipaddr);
index a740f86..633a28e 100644 (file)
@@ -255,7 +255,7 @@ static int xlat_packet(void *instance, REQUEST *request,
                                        return 0;
                                }
                                localvp.attribute = da->attr;
-                               localvp.lvalue = packet->src_ipaddr.ipaddr.ip4addr.s_addr;
+                               localvp.vp_ipaddr = packet->src_ipaddr.ipaddr.ip4addr.s_addr;
                                break;
                        
                        case PW_PACKET_DST_IP_ADDRESS:
@@ -263,17 +263,17 @@ static int xlat_packet(void *instance, REQUEST *request,
                                        return 0;
                                }
                                localvp.attribute = da->attr;
-                               localvp.lvalue = packet->dst_ipaddr.ipaddr.ip4addr.s_addr;
+                               localvp.vp_ipaddr = packet->dst_ipaddr.ipaddr.ip4addr.s_addr;
                                break;
                        
                        case PW_PACKET_SRC_PORT:
                                localvp.attribute = da->attr;
-                               localvp.lvalue = packet->src_port;
+                               localvp.vp_integer = packet->src_port;
                                break;
                        
                        case PW_PACKET_DST_PORT:
                                localvp.attribute = da->attr;
-                               localvp.lvalue = packet->dst_port;
+                               localvp.vp_integer = packet->dst_port;
                                break;
 
                        case PW_PACKET_AUTHENTICATION_VECTOR: