Miracle of miracles... it seems to work
authorAlan T. DeKok <aland@freeradius.org>
Mon, 5 Oct 2009 10:32:36 +0000 (12:32 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 31 May 2010 08:16:15 +0000 (10:16 +0200)
14 files changed:
src/lib/dict.c
src/lib/valuepair.c
src/main/acct.c
src/main/auth.c
src/main/client.c
src/main/detail.c
src/main/evaluate.c
src/main/event.c
src/main/listen.c
src/main/modules.c
src/main/session.c
src/main/stats.c
src/main/valuepair.c
src/main/xlat.c

index a08c67b..99d98da 100644 (file)
@@ -192,6 +192,7 @@ static uint32_t dict_value_name_hash(const void *data)
        const DICT_VALUE *dval = data;
 
        hash = dict_hashname(dval->name);
+       hash = fr_hash_update(&dval->vendor, sizeof(dval->vendor), hash);
        return fr_hash_update(&dval->attr, sizeof(dval->attr), hash);
 }
 
@@ -204,6 +205,9 @@ static int dict_value_name_cmp(const void *one, const void *two)
        rcode = a->attr - b->attr;
        if (rcode != 0) return rcode;
 
+       rcode = a->vendor - b->vendor;
+       if (rcode != 0) return rcode;
+
        return strcasecmp(a->name, b->name);
 }
 
@@ -213,6 +217,7 @@ static uint32_t dict_value_value_hash(const void *data)
        const DICT_VALUE *dval = data;
 
        hash = fr_hash(&dval->attr, sizeof(dval->attr));
+       hash = fr_hash_update(&dval->vendor, sizeof(dval->vendor), hash);
        return fr_hash_update(&dval->value, sizeof(dval->value), hash);
 }
 
@@ -222,6 +227,9 @@ static int dict_value_value_cmp(const void *one, const void *two)
        const DICT_VALUE *a = one;
        const DICT_VALUE *b = two;
 
+       if (a->vendor < b->vendor) return -1;
+       if (a->vendor > b->vendor) return +1;
+
        rcode = a->attr - b->attr;
        if (rcode != 0) return rcode;
 
@@ -708,6 +716,7 @@ int dict_addvalue(const char *namestr, const char *attrstr, int value)
                }
 
                dval->attr = dattr->attr;
+               dval->vendor = dattr->vendor;
 
                /*
                 *      Enforce valid values
@@ -1120,6 +1129,7 @@ static int process_value_alias(const char* fn, const int line, char **argv,
 
        dval->name[0] = '\0';   /* empty name */
        dval->attr = my_da->attr;
+       dval->vendor = my_da->vendor;
        dval->value = da->attr;
 
        if (!fr_hash_table_insert(values_byname, dval)) {
index 350fb35..f302005 100644 (file)
@@ -208,9 +208,14 @@ void pairfree(VALUE_PAIR **pair_ptr)
  */
 VALUE_PAIR * pairfind(VALUE_PAIR *first, int attr, int vendor)
 {
-       while(first && (first->attribute != attr) && (first->vendor != vendor))
+       while (first) {
+               if ((first->attribute == attr) && (first->vendor == vendor)) {
+                       return first;
+               }
                first = first->next;
-       return first;
+       }
+
+       return NULL;
 }
 
 
index 0ba6a5c..09b129f 100644 (file)
@@ -132,7 +132,7 @@ int rad_accounting(REQUEST *request)
                        realm = realm_find2(vp->vp_strvalue);
                        if (realm && !realm->acct_pool) {
                                DEBUG("rad_accounting: Cancelling proxy to realm %s, as it is a LOCAL realm.", realm->name);
-                               pairdelete(&request->config_items, PW_PROXY_TO_REALM);
+                               pairdelete(&request->config_items, PW_PROXY_TO_REALM, 0);
                        } else {
                                /*
                                 *      Don't reply to the NAS now because
index 7fd4cab..54f5992 100644 (file)
@@ -102,7 +102,7 @@ static int rad_authlog(const char *msg, REQUEST *request, int goodpass)
                        VALUE_PAIR *auth_type;
 
                        auth_type = pairfind(request->config_items,
-                                            PW_AUTH_TYPE);
+                                            PW_AUTH_TYPE, 0);
                        if (auth_type && (auth_type->vp_strvalue[0] != '\0')) {
                                snprintf(clean_password, sizeof(clean_password),
                                         "<via Auth-Type = %s>",
@@ -178,7 +178,7 @@ static int rad_check_password(REQUEST *request)
                auth_type = auth_type_pair->vp_integer;
                auth_type_count++;
                DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute,
-                                               auth_type_pair->vp_integer);
+                                               auth_type_pair->vp_integer, 0);
 
                RDEBUG2("Found Auth-Type = %s",
                        (dv != NULL) ? dv->name : "?");
@@ -213,7 +213,7 @@ static int rad_check_password(REQUEST *request)
        password_pair =  pairfind(request->config_items, PW_USER_PASSWORD, 0);
        if (password_pair &&
            pairfind(request->config_items, PW_CLEARTEXT_PASSWORD, 0)) {
-               pairdelete(&request->config_items, PW_USER_PASSWORD);
+         pairdelete(&request->config_items, PW_USER_PASSWORD, 0);
                password_pair = NULL;
        }
 
@@ -227,7 +227,7 @@ static int rad_check_password(REQUEST *request)
                RDEBUG("!!! clear text password is in Cleartext-Password, and not in User-Password. !!!");
                RDEBUG("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                password_pair->attribute = PW_CLEARTEXT_PASSWORD;
-               da = dict_attrbyvalue(PW_CLEARTEXT_PASSWORD);
+               da = dict_attrbyvalue(PW_CLEARTEXT_PASSWORD, 0);
                if (!da) {
                        radlog_request(L_ERR, 0, request, "FATAL: You broke the dictionaries.  Please use the default dictionaries!");
                        _exit(1);
@@ -311,7 +311,7 @@ static int rad_check_password(REQUEST *request)
                        auth_item = request->password;
                        if (!auth_item)
                                auth_item = pairfind(request->packet->vps,
-                                                    PW_CHAP_PASSWORD);
+                                                    PW_CHAP_PASSWORD, 0);
                        if (!auth_item) {
                                RDEBUG2("No User-Password or CHAP-Password attribute in the request.");
                                RDEBUG2("Cannot perform authentication.");
@@ -486,7 +486,7 @@ int rad_authenticate(REQUEST *request)
                case PW_AUTHENTICATION_ACK:
                        tmp = radius_paircreate(request,
                                                &request->config_items,
-                                               PW_AUTH_TYPE, PW_TYPE_INTEGER);
+                                               PW_AUTH_TYPE, 0, PW_TYPE_INTEGER);
                        if (tmp) tmp->vp_integer = PW_AUTHTYPE_ACCEPT;
                        goto authenticate;
 
@@ -531,7 +531,7 @@ int rad_authenticate(REQUEST *request)
         */
        if (!request->password) {
                request->password = pairfind(request->packet->vps,
-                                            PW_USER_PASSWORD);
+                                            PW_USER_PASSWORD, 0);
        }
 
        /*
@@ -546,7 +546,7 @@ int rad_authenticate(REQUEST *request)
                 *      Maybe there's a CHAP-Password?
                 */
                if ((auth_item = pairfind(request->packet->vps,
-                                         PW_CHAP_PASSWORD)) != NULL) {
+                                         PW_CHAP_PASSWORD, 0)) != NULL) {
                        password = "<CHAP-PASSWORD>";
 
                } else {
@@ -577,7 +577,7 @@ autz_redo:
                case RLM_MODULE_USERLOCK:
                default:
                        if ((module_msg = pairfind(request->packet->vps,
-                                       PW_MODULE_FAILURE_MESSAGE)) != NULL) {
+                                                  PW_MODULE_FAILURE_MESSAGE, 0)) != NULL) {
                                char msg[MAX_STRING_LEN + 16];
                                snprintf(msg, sizeof(msg), "Invalid user (%s)",
                                         module_msg->vp_strvalue);
@@ -769,7 +769,7 @@ autz_redo:
         *      vp->addport is set.
         */
        if (((tmp = pairfind(request->reply->vps,
-                            PW_FRAMED_IP_ADDRESS)) != NULL) &&
+                            PW_FRAMED_IP_ADDRESS, 0)) != NULL) &&
            (tmp->flags.addport != 0)) {
                VALUE_PAIR *vpPortId;
 
@@ -777,14 +777,14 @@ autz_redo:
                 *  Find the NAS port ID.
                 */
                if ((vpPortId = pairfind(request->packet->vps,
-                                        PW_NAS_PORT)) != NULL) {
+                                        PW_NAS_PORT, 0)) != NULL) {
                  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->vp_integer);
                } else {
                        RDEBUG2("WARNING: No NAS-Port attribute in request.  CANNOT return a Framed-IP-Address + NAS-Port.\n");
-                       pairdelete(&request->reply->vps, PW_FRAMED_IP_ADDRESS);
+                       pairdelete(&request->reply->vps, PW_FRAMED_IP_ADDRESS, 0);
                }
        }
 
index bd825db..433c5e5 100644 (file)
@@ -1065,7 +1065,7 @@ RADCLIENT *client_create(RADCLIENT_LIST *clients, REQUEST *request)
                        return NULL;
                }
 
-               vp = pairfind(request->config_items, da->attr);
+               vp = pairfind(request->config_items, da->attr, da->vendor);
                if (!vp) {
                        /*
                         *      Not required.  Skip it.
index 995dca0..f03933c 100644 (file)
@@ -539,7 +539,7 @@ int detail_recv(rad_listen_t *listener,
                if (!strcasecmp(key, "Timestamp")) {
                        data->timestamp = atoi(value);
 
-                       vp = paircreate(PW_PACKET_ORIGINAL_TIMESTAMP,
+                       vp = paircreate(PW_PACKET_ORIGINAL_TIMESTAMP, 0,
                                        PW_TYPE_DATE);
                        if (vp) {
                                vp->vp_date = (uint32_t) data->timestamp;
@@ -683,7 +683,7 @@ int detail_recv(rad_listen_t *listener,
         */
        vp = pairfind(packet->vps, PW_ACCT_DELAY_TIME, 0);
        if (!vp) {
-               vp = paircreate(PW_ACCT_DELAY_TIME, PW_TYPE_INTEGER);
+               vp = paircreate(PW_ACCT_DELAY_TIME, 0, PW_TYPE_INTEGER);
                rad_assert(vp != NULL);
                pairadd(&packet->vps, vp);
        }
index 6fae2be..2313320 100644 (file)
@@ -289,7 +289,7 @@ int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p)
        /*
         *      May not may not be found, but it *is* a known name.
         */
-       *vp_p = pairfind(vps, da->attr);
+       *vp_p = pairfind(vps, da->attr, da->vendor);
        return TRUE;
 }
 
@@ -355,7 +355,7 @@ static int radius_do_cmp(REQUEST *request, int *presult,
                                 *      If so, try looking for it.
                                 */
                                da = dict_attrbyname(pleft);
-                               if (da && radius_find_compare(da->attr)) {
+                               if (da && (da->vendor == 0) && radius_find_compare(da->attr)) {
                                        VALUE_PAIR *check = pairmake(pleft, pright, token);
                                        *presult = (radius_callback_compare(request, NULL, check, NULL, NULL) == 0);
                                        RDEBUG3("  Callback returns %d",
index b8fe65c..9a62b21 100644 (file)
@@ -953,10 +953,10 @@ static int setup_post_proxy_fail(REQUEST *request)
        request->child_state = REQUEST_RUNNING;
 
        if (request->packet->code == PW_AUTHENTICATION_REQUEST) {
-               dval = dict_valbyname(PW_POST_PROXY_TYPE, "Fail-Authentication");
+         dval = dict_valbyname(PW_POST_PROXY_TYPE, 0, "Fail-Authentication");
 
        } else if (request->packet->code == PW_ACCOUNTING_REQUEST) {
-               dval = dict_valbyname(PW_POST_PROXY_TYPE, "Fail-Accounting");
+               dval = dict_valbyname(PW_POST_PROXY_TYPE, 0, "Fail-Accounting");
 
 #ifdef WITH_COA
                /*
@@ -966,10 +966,10 @@ static int setup_post_proxy_fail(REQUEST *request)
                request->packet->code &= 0xff; /* restore it */
 
                if (request->proxy->code == PW_COA_REQUEST) {
-                       dval = dict_valbyname(PW_POST_PROXY_TYPE, "Fail-CoA");
+                       dval = dict_valbyname(PW_POST_PROXY_TYPE, 0, "Fail-CoA");
 
                } else if (request->proxy->code == PW_DISCONNECT_REQUEST) {
-                       dval = dict_valbyname(PW_POST_PROXY_TYPE, "Fail-Disconnect");
+                       dval = dict_valbyname(PW_POST_PROXY_TYPE, 0, "Fail-Disconnect");
                } else {
                        return 0;
                }
@@ -979,16 +979,16 @@ static int setup_post_proxy_fail(REQUEST *request)
                return 0;
        }
 
-       if (!dval) dval = dict_valbyname(PW_POST_PROXY_TYPE, "Fail");
+       if (!dval) dval = dict_valbyname(PW_POST_PROXY_TYPE, 0, "Fail");
 
        if (!dval) {
-               pairdelete(&request->config_items, PW_POST_PROXY_TYPE);
+               pairdelete(&request->config_items, PW_POST_PROXY_TYPE, 0);
                return 0;
        }
 
        vp = pairfind(request->config_items, PW_POST_PROXY_TYPE, 0);
        if (!vp) vp = radius_paircreate(request, &request->config_items,
-                                       PW_POST_PROXY_TYPE, PW_TYPE_INTEGER);
+                                       PW_POST_PROXY_TYPE, 0, PW_TYPE_INTEGER);
        vp->vp_integer = dval->value;
 
        rad_assert(request->proxy_reply == NULL);
@@ -1553,12 +1553,12 @@ static int originated_coa_request(REQUEST *request)
                ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
 
        } else if ((vp = pairfind(coa->proxy->vps,
-                                 PW_PACKET_DST_IPV6_ADDRESS)) != NULL) {
+                                 PW_PACKET_DST_IPV6_ADDRESS, 0)) != NULL) {
                ipaddr.af = AF_INET6;
                ipaddr.ipaddr.ip6addr = vp->vp_ipv6addr;
                
        } else if ((vp = pairfind(coa->proxy->vps,
-                                 PW_HOME_SERVER_POOL)) != NULL) {
+                                 PW_HOME_SERVER_POOL, 0)) != NULL) {
                coa->home_pool = home_pool_byname(vp->vp_strvalue,
                                                  HOME_TYPE_COA);
                if (!coa->home_pool) {
@@ -1802,7 +1802,7 @@ static int process_proxy_reply(REQUEST *request)
                 *      the reply.  These include Proxy-State
                 *      attributes from us and remote server.
                 */
-               pairdelete(&request->proxy_reply->vps, PW_PROXY_STATE);
+               pairdelete(&request->proxy_reply->vps, PW_PROXY_STATE, 0);
                
                /*
                 *      Add the attributes left in the proxy
@@ -1851,9 +1851,9 @@ static int request_pre_handler(REQUEST *request)
         */
        if (request->packet->dst_port == 0) {
                request->username = pairfind(request->packet->vps,
-                                            PW_USER_NAME);
+                                            PW_USER_NAME, 0);
                request->password = pairfind(request->packet->vps,
-                                            PW_USER_PASSWORD);
+                                            PW_USER_PASSWORD, 0);
                return 1;
        }
 
@@ -1906,7 +1906,7 @@ static int request_pre_handler(REQUEST *request)
 
        if (!request->username) {
                request->username = pairfind(request->packet->vps,
-                                            PW_USER_NAME);
+                                            PW_USER_NAME, 0);
        }
 
 #ifdef WITH_PROXY
@@ -2211,7 +2211,7 @@ found_pool:
                vp = pairfind(request->proxy->vps, PW_USER_NAME, 0);
                if (!vp) {
                        vp = radius_paircreate(request, NULL,
-                                              PW_USER_NAME, PW_TYPE_STRING);
+                                              PW_USER_NAME, 0, PW_TYPE_STRING);
                        rad_assert(vp != NULL); /* handled by above function */
                        /* Insert at the START of the list */
                        vp->next = request->proxy->vps;
@@ -2236,7 +2236,7 @@ found_pool:
            pairfind(request->proxy->vps, PW_CHAP_PASSWORD, 0) &&
            pairfind(request->proxy->vps, PW_CHAP_CHALLENGE, 0) == NULL) {
                vp = radius_paircreate(request, &request->proxy->vps,
-                                      PW_CHAP_CHALLENGE, PW_TYPE_OCTETS);
+                                      PW_CHAP_CHALLENGE, 0, PW_TYPE_OCTETS);
                vp->length = AUTH_VECTOR_LEN;
                memcpy(vp->vp_strvalue, request->packet->vector, AUTH_VECTOR_LEN);
        }
@@ -2246,7 +2246,7 @@ found_pool:
         *      doesn't need it.
         */
        vp = radius_paircreate(request, &request->proxy->vps,
-                              PW_PROXY_STATE, PW_TYPE_OCTETS);
+                              PW_PROXY_STATE, 0, PW_TYPE_OCTETS);
        snprintf(vp->vp_strvalue, sizeof(vp->vp_strvalue), "%d",
                 request->packet->id);
        vp->length = strlen(vp->vp_strvalue);
@@ -2427,7 +2427,7 @@ static void request_post_handler(REQUEST *request)
        /*
         *      Copy Proxy-State from the request to the reply.
         */
-       vp = paircopy2(request->packet->vps, PW_PROXY_STATE);
+       vp = paircopy2(request->packet->vps, PW_PROXY_STATE, 0);
        if (vp) pairadd(&request->reply->vps, vp);
 #endif
 
@@ -2443,7 +2443,7 @@ static void request_post_handler(REQUEST *request)
                         *      Check if the lack of response is intentional.
                         */
                        vp = pairfind(request->config_items,
-                                     PW_RESPONSE_PACKET_TYPE);
+                                     PW_RESPONSE_PACKET_TYPE, 0);
                        if (!vp) {
                                RDEBUG2("There was no response configured: rejecting request");
                                request->reply->code = PW_AUTHENTICATION_REJECT;
@@ -2472,7 +2472,7 @@ static void request_post_handler(REQUEST *request)
                 *      Post-Auth-Type = Reject
                 */
                if (request->reply->code == PW_AUTHENTICATION_REJECT) {
-                       pairdelete(&request->config_items, PW_POST_AUTH_TYPE);
+                       pairdelete(&request->config_items, PW_POST_AUTH_TYPE, 0);
                        vp = radius_pairmake(request, &request->config_items,
                                             "Post-Auth-Type", "Reject",
                                             T_OP_SET);
index e0a1882..c28d415 100644 (file)
@@ -293,7 +293,7 @@ static int rad_status_server(REQUEST *request)
        case RAD_LISTEN_NONE:
 #endif
        case RAD_LISTEN_AUTH:
-               dval = dict_valbyname(PW_AUTZ_TYPE, "Status-Server");
+               dval = dict_valbyname(PW_AUTZ_TYPE, 0, "Status-Server");
                if (dval) {
                        rcode = module_authorize(dval->value, request);
                } else {
@@ -320,7 +320,7 @@ static int rad_status_server(REQUEST *request)
 
 #ifdef WITH_ACCOUNTING
        case RAD_LISTEN_ACCT:
-               dval = dict_valbyname(PW_ACCT_TYPE, "Status-Server");
+               dval = dict_valbyname(PW_ACCT_TYPE, 0, "Status-Server");
                if (dval) {
                        rcode = module_accounting(dval->value, request);
                } else {
@@ -347,7 +347,7 @@ static int rad_status_server(REQUEST *request)
                 *      the WG.  We like it, so it goes in here.
                 */
        case RAD_LISTEN_COA:
-               dval = dict_valbyname(PW_RECV_COA_TYPE, "Status-Server");
+               dval = dict_valbyname(PW_RECV_COA_TYPE, 0, "Status-Server");
                if (dval) {
                        rcode = module_recv_coa(dval->value, request);
                } else {
@@ -1436,7 +1436,7 @@ static int rad_coa_recv(REQUEST *request)
         *      Copy State from the request to the reply.
         *      See RFC 5176 Section 3.3.
         */
-       vp = paircopy2(request->packet->vps, PW_STATE);
+       vp = paircopy2(request->packet->vps, PW_STATE, 0);
        if (vp) pairadd(&request->reply->vps, vp);
 
        /*
index e15ee76..32fffa1 100644 (file)
@@ -759,7 +759,7 @@ static int load_subcomponent_section(modcallable *parent, CONF_SECTION *cs,
         *      automatically.  If it isn't found, it's a serious
         *      error.
         */
-       dval = dict_valbyname(attr, name2);
+       dval = dict_valbyname(attr, 0, name2);
        if (!dval) {
                cf_log_err(cf_sectiontoitem(cs),
                           "%s %s Not previously configured",
@@ -787,7 +787,7 @@ static int define_type(const DICT_ATTR *dattr, const char *name)
         *      If the value already exists, don't
         *      create it again.
         */
-       dval = dict_valbyname(dattr->attr, name);
+       dval = dict_valbyname(dattr->attr, dattr->vendor, name);
        if (dval) return 1;
 
        /*
@@ -799,7 +799,7 @@ static int define_type(const DICT_ATTR *dattr, const char *name)
         */
        do {
                value = fr_rand() & 0x00ffffff;
-       } while (dict_valbyattr(dattr->attr, value));
+       } while (dict_valbyattr(dattr->attr, dattr->vendor, value));
 
        if (dict_addvalue(name, dattr->name, value) < 0) {
                radlog(L_ERR, "%s", fr_strerror());
@@ -823,7 +823,7 @@ static int load_component_section(CONF_SECTION *cs,
        /*
         *      Find the attribute used to store VALUEs for this section.
         */
-       dattr = dict_attrbyvalue(section_type_value[comp].attr);
+       dattr = dict_attrbyvalue(section_type_value[comp].attr, 0);
        if (!dattr) {
                cf_log_err(cf_sectiontoitem(cs),
                           "No such attribute %s",
@@ -902,7 +902,7 @@ static int load_component_section(CONF_SECTION *cs,
                                }
                        }
 
-                       dval = dict_valbyname(PW_AUTH_TYPE, modrefname);
+                       dval = dict_valbyname(PW_AUTH_TYPE, 0, modrefname);
                        if (!dval) {
                                /*
                                 *      It's a section, but nothing we
@@ -987,7 +987,7 @@ static int load_byserver(CONF_SECTION *cs)
                /*
                 *      Find the attribute used to store VALUEs for this section.
                 */
-               dattr = dict_attrbyvalue(section_type_value[comp].attr);
+               dattr = dict_attrbyvalue(section_type_value[comp].attr, 0);
                if (!dattr) {
                        cf_log_err(cf_sectiontoitem(subcs),
                                   "No such attribute %s",
index 5d49861..a8f7826 100644 (file)
@@ -51,7 +51,7 @@ int session_zap(REQUEST *request, uint32_t nasaddr, unsigned int port,
 
        /* Hold your breath */
 #define PAIR(n,v,t,e) do { \
-               if(!(vp = paircreate(n, t))) { \
+               if(!(vp = paircreate(n, 0, t))) {       \
                        request_free(&stopreq); \
                        radlog(L_ERR|L_CONS, "no memory"); \
                        pairfree(&(stopreq->packet->vps)); \
@@ -63,7 +63,7 @@ int session_zap(REQUEST *request, uint32_t nasaddr, unsigned int port,
 #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))) { \
+       if(!(vp = paircreate(n, 0, PW_TYPE_STRING))) {  \
                request_free(&stopreq); \
                radlog(L_ERR|L_CONS, "no memory"); \
                pairfree(&(stopreq->packet->vps)); \
index de5300e..85afcf8 100644 (file)
@@ -282,8 +282,6 @@ static fr_stats2vp client_acctvp[] = {
 };
 #endif
 
-#define FR2ATTR(x) ((11344 << 16) | (x))
-
 static void request_stats_addvp(REQUEST *request,
                                fr_stats2vp *table, fr_stats_t *stats)
 {
@@ -292,7 +290,7 @@ static void request_stats_addvp(REQUEST *request,
 
        for (i = 0; table[i].attribute != 0; i++) {
                vp = radius_paircreate(request, &request->reply->vps,
-                                      FR2ATTR(table[i].attribute),
+                                      table[i].attribute, VENDORPEC_FREERADIUS,
                                       PW_TYPE_INTEGER);
                if (!vp) continue;
 
@@ -311,7 +309,7 @@ void request_stats_reply(REQUEST *request)
        rad_assert(request->packet->code == PW_STATUS_SERVER);
        rad_assert(request->listener->type == RAD_LISTEN_NONE);
                
-       flag = pairfind(request->packet->vps, FR2ATTR(127));
+       flag = pairfind(request->packet->vps, 127, VENDORPEC_FREERADIUS);
        if (!flag || (flag->vp_integer == 0)) return;
 
        /*
@@ -357,10 +355,10 @@ void request_stats_reply(REQUEST *request)
         */
        if ((flag->vp_integer & 0x10) != 0) {
                vp = radius_paircreate(request, &request->reply->vps,
-                                      FR2ATTR(176), PW_TYPE_DATE);
+                                      176, VENDORPEC_FREERADIUS, PW_TYPE_DATE);
                if (vp) vp->vp_date = start_time.tv_sec;
                vp = radius_paircreate(request, &request->reply->vps,
-                                      FR2ATTR(177), PW_TYPE_DATE);
+                                      177, VENDORPEC_FREERADIUS, PW_TYPE_DATE);
                if (vp) vp->vp_date = hup_time.tv_sec;
                
 #ifdef HAVE_PTHREAD_H
@@ -370,7 +368,7 @@ void request_stats_reply(REQUEST *request)
 
                for (i = 0; i <= RAD_LISTEN_DETAIL; i++) {
                        vp = radius_paircreate(request, &request->reply->vps,
-                                              FR2ATTR(162 + i),
+                                              162 + i, VENDORPEC_FREERADIUS,
                                               PW_TYPE_INTEGER);
                        
                        if (!vp) continue;
@@ -392,10 +390,10 @@ void request_stats_reply(REQUEST *request)
                 *      See if we need to look up the client by server
                 *      socket.
                 */
-               server_ip = pairfind(request->packet->vps, FR2ATTR(170));
+               server_ip = pairfind(request->packet->vps, 170, VENDORPEC_FREERADIUS);
                if (server_ip) {
                        server_port = pairfind(request->packet->vps,
-                                              FR2ATTR(171));
+                                              171, VENDORPEC_FREERADIUS);
 
                        if (server_port) {
                                ipaddr.af = AF_INET;
@@ -410,7 +408,7 @@ void request_stats_reply(REQUEST *request)
                }
 
 
-               vp = pairfind(request->packet->vps, FR2ATTR(167));
+               vp = pairfind(request->packet->vps, 167, VENDORPEC_FREERADIUS);
                if (vp) {
                        ipaddr.af = AF_INET;
                        ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
@@ -425,7 +423,7 @@ void request_stats_reply(REQUEST *request)
                         *      Else look it up by number.
                         */
                } else if ((vp = pairfind(request->packet->vps,
-                                          FR2ATTR(168))) != NULL) {
+                                          168, VENDORPEC_FREERADIUS)) != NULL) {
                        client = client_findbynumber(cl, vp->vp_integer);
                }
 
@@ -444,7 +442,7 @@ void request_stats_reply(REQUEST *request)
                            (client->ipaddr.af == AF_INET)) {
                                vp = radius_paircreate(request,
                                                       &request->reply->vps,
-                                                      FR2ATTR(167),
+                                                      167, VENDORPEC_FREERADIUS,
                                                       PW_TYPE_IPADDR);
                                if (vp) {
                                        vp->vp_ipaddr = client->ipaddr.ipaddr.ip4addr.s_addr;
@@ -453,7 +451,7 @@ void request_stats_reply(REQUEST *request)
                                if (client->prefix != 32) {
                                        vp = radius_paircreate(request,
                                                               &request->reply->vps,
-                                                              FR2ATTR(169),
+                                                              169, VENDORPEC_FREERADIUS,
                                                               PW_TYPE_INTEGER);
                                        if (vp) {
                                                vp->vp_integer = client->prefix;
@@ -496,11 +494,11 @@ void request_stats_reply(REQUEST *request)
                 *      See if we need to look up the server by socket
                 *      socket.
                 */
-               server_ip = pairfind(request->packet->vps, FR2ATTR(170));
+               server_ip = pairfind(request->packet->vps, 170, VENDORPEC_FREERADIUS);
                if (!server_ip) return;
 
                server_port = pairfind(request->packet->vps,
-                                      FR2ATTR(171));
+                                      171, VENDORPEC_FREERADIUS);
                if (!server_port) return;
                
                ipaddr.af = AF_INET;
@@ -547,11 +545,11 @@ void request_stats_reply(REQUEST *request)
                 *      See if we need to look up the server by socket
                 *      socket.
                 */
-               server_ip = pairfind(request->packet->vps, FR2ATTR(170));
+               server_ip = pairfind(request->packet->vps, 170, VENDORPEC_FREERADIUS);
                if (!server_ip) return;
 
                server_port = pairfind(request->packet->vps,
-                                      FR2ATTR(171));
+                                      171, VENDORPEC_FREERADIUS);
                if (!server_port) return;
                
                ipaddr.af = AF_INET;
@@ -570,17 +568,17 @@ void request_stats_reply(REQUEST *request)
                        paircopyvp(server_port));
 
                vp = radius_paircreate(request, &request->reply->vps,
-                                      FR2ATTR(172), PW_TYPE_INTEGER);
+                                      172, VENDORPEC_FREERADIUS, PW_TYPE_INTEGER);
                if (vp) vp->vp_integer = home->currently_outstanding;
 
                vp = radius_paircreate(request, &request->reply->vps,
-                                      FR2ATTR(173), PW_TYPE_INTEGER);
+                                      173, VENDORPEC_FREERADIUS, PW_TYPE_INTEGER);
                if (vp) vp->vp_integer = home->state;
 
                if ((home->state == HOME_STATE_ALIVE) &&
                    (home->revive_time.tv_sec != 0)) {
                        vp = radius_paircreate(request, &request->reply->vps,
-                                              FR2ATTR(175), PW_TYPE_DATE);
+                                              175, VENDORPEC_FREERADIUS, PW_TYPE_DATE);
                        if (vp) vp->vp_date = home->revive_time.tv_sec;
                }
 
@@ -588,17 +586,17 @@ void request_stats_reply(REQUEST *request)
                    (home->ema.window > 0)) {
                                vp = radius_paircreate(request,
                                                       &request->reply->vps,
-                                                      FR2ATTR(178),
+                                                      178, VENDORPEC_FREERADIUS,
                                                       PW_TYPE_INTEGER);
                                if (vp) vp->vp_integer = home->ema.window;
                                vp = radius_paircreate(request,
                                                       &request->reply->vps,
-                                                      FR2ATTR(179),
+                                                      179, VENDORPEC_FREERADIUS,
                                                       PW_TYPE_INTEGER);
                                if (vp) vp->vp_integer = home->ema.ema1 / EMA_SCALE;
                                vp = radius_paircreate(request,
                                                       &request->reply->vps,
-                                                      FR2ATTR(180),
+                                                      180, VENDORPEC_FREERADIUS,
                                                       PW_TYPE_INTEGER);
                                if (vp) vp->vp_integer = home->ema.ema10 / EMA_SCALE;
 
@@ -606,7 +604,7 @@ void request_stats_reply(REQUEST *request)
 
                if (home->state == HOME_STATE_IS_DEAD) {
                        vp = radius_paircreate(request, &request->reply->vps,
-                                              FR2ATTR(174), PW_TYPE_DATE);
+                                              174, VENDORPEC_FREERADIUS, PW_TYPE_DATE);
                        if (vp) vp->vp_date = home->zombie_period_start.tv_sec + home->zombie_period;
                }
 
index d334488..5e5011d 100644 (file)
@@ -266,7 +266,8 @@ int radius_callback_compare(REQUEST *req, VALUE_PAIR *request,
         *      FIXME: use new RB-Tree code.
         */
        for (c = cmp; c; c = c->next)
-               if (c->attribute == check->attribute) {
+               if ((c->attribute == check->attribute) &&
+                   (check->vendor == 0)) {
                        return (c->compare)(c->instance, req, request, check,
                                check_pairs, reply_pairs);
                }
@@ -594,7 +595,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                        pairparsevalue(i, buffer);
                }
 
-               found = pairfind(*to, i->attribute);
+               found = pairfind(*to, i->attribute, i->vendor);
                switch (i->operator) {
 
                        /*
@@ -606,7 +607,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                                if (!i->vp_strvalue[0] ||
                                    (strcmp((char *)found->vp_strvalue,
                                            (char *)i->vp_strvalue) == 0)){
-                                       pairdelete(to, found->attribute);
+                                 pairdelete(to, found->attribute, found->vendor);
 
                                        /*
                                         *      'tailto' may have been
@@ -692,13 +693,13 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
  *     it causes the server to exit!
  */
 VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
-                             int attribute, int type)
+                             int attribute, int vendor, int type)
 {
        VALUE_PAIR *vp;
 
        request = request;      /* -Wunused */
 
-       vp = paircreate(attribute, type);
+       vp = paircreate(attribute, vendor, type);
        if (!vp) {
                radlog(L_ERR, "No memory!");
                rad_assert("No memory" == NULL);
index cf675df..4ceece1 100644 (file)
@@ -204,9 +204,9 @@ static size_t xlat_packet(void *instance, REQUEST *request,
                if ((p[1] == '#') && (p[2] == ']')) {
                        count = 0;
 
-                       for (vp = pairfind(vps, da->attr);
+                       for (vp = pairfind(vps, da->attr, da->vendor);
                             vp != NULL;
-                            vp = pairfind(vp->next, da->attr)) {
+                            vp = pairfind(vp->next, da->attr, da->vendor)) {
                                count++;
                        }
                        snprintf(out, outlen, "%d", (int) count);
@@ -220,9 +220,9 @@ static size_t xlat_packet(void *instance, REQUEST *request,
                if ((p[1] == '*') && (p[2] == ']')) {
                        int total = 0;
 
-                       for (vp = pairfind(vps, da->attr);
+                       for (vp = pairfind(vps, da->attr, da->vendor);
                             vp != NULL;
-                            vp = pairfind(vp->next, da->attr)) {
+                            vp = pairfind(vp->next, da->attr, da->vendor)) {
                                count = valuepair2str(out, outlen - 1, vp, da->type, func);
                                rad_assert(count <= outlen);
                                total += count + 1;
@@ -252,9 +252,9 @@ static size_t xlat_packet(void *instance, REQUEST *request,
                /*
                 *      Find the N'th value.
                 */
-               for (vp = pairfind(vps, da->attr);
+               for (vp = pairfind(vps, da->attr, da->vendor);
                     vp != NULL;
-                    vp = pairfind(vp->next, da->attr)) {
+                    vp = pairfind(vp->next, da->attr, da->vendor)) {
                        if (count == 0) break;
                        count--;
                }
@@ -267,7 +267,7 @@ static size_t xlat_packet(void *instance, REQUEST *request,
                return valuepair2str(out, outlen, vp, da->type, func);
        }
 
-       vp = pairfind(vps, da->attr);
+       vp = pairfind(vps, da->attr, da->vendor);
        if (!vp) {
                /*
                 *      Some "magic" handlers, which are never in VP's, but
@@ -286,7 +286,7 @@ static size_t xlat_packet(void *instance, REQUEST *request,
                        {
                                DICT_VALUE *dval;
 
-                               dval = dict_valbyattr(da->attr, packet->code);
+                               dval = dict_valbyattr(da->attr, da->vendor, packet->code);
                                if (dval) {
                                        snprintf(out, outlen, "%s", dval->name);
                                } else {