Move tag out of "flags" struct.
authorAlan T. DeKok <aland@freeradius.org>
Sat, 16 Feb 2013 19:00:49 +0000 (14:00 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 16 Feb 2013 19:00:49 +0000 (14:00 -0500)
The VP's shouldn't have flags, and the DICT_ATTRs shouldn't
have tags.

Edit libradius.h, followed by:

$ replace 'flags.tag' tag $(find src/ -name "*.c" -print)

src/include/libradius.h
src/lib/print.c
src/lib/radius.c
src/lib/valuepair.c
src/main/valuepair.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_python/rlm_python.c
src/modules/rlm_ruby/rlm_ruby.c

index 140dc78..139122e 100644 (file)
@@ -126,8 +126,6 @@ typedef struct attr_flags {
        unsigned int    evs : 1;                //!< Extended VSA.
        unsigned int    wimax: 1;               //!< WiMAX format=1,1,c.
 
-       int8_t          tag;                    //!< Tag for tunneled.
-                                               //!< Attributes.
        uint8_t         encrypt;                //!< Ecryption method.
        uint8_t         length;
 } ATTR_FLAGS;
@@ -202,6 +200,9 @@ typedef struct value_pair {
                                                //!< moving or inserting 
                                                //!< valuepair into a list.
                                                
+       int8_t                  tag;            //!< Tag for tunneled.
+                                               //!< Attributes.
+
         ATTR_FLAGS              flags;
 
        size_t                  length; /* of data field */
index de0ab82..c077487 100644 (file)
@@ -615,7 +615,7 @@ int vp_prints(char *out, size_t outlen, const VALUE_PAIR *vp)
 
        if(vp->da->flags.has_tag) {
                snprintf(out, outlen, "%s:%d %s ",
-                        vp->da->name, vp->flags.tag, token);
+                        vp->da->name, vp->tag, token);
 
                len = strlen(out);
                vp_prints_value(out + len, outlen - len, vp, 1);
index 1b55522..ce965fe 100644 (file)
@@ -983,7 +983,7 @@ static ssize_t vp2data_any(const RADIUS_PACKET *packet,
                                return -1;
                        }
 
-                       if (lvalue) ptr[0] = vp->flags.tag;
+                       if (lvalue) ptr[0] = vp->tag;
                        make_tunnel_passwd(ptr + lvalue, &len, data, len,
                                           room - lvalue,
                                           secret, original->vector);
@@ -991,7 +991,7 @@ static ssize_t vp2data_any(const RADIUS_PACKET *packet,
                case PW_ACCOUNTING_REQUEST:
                case PW_DISCONNECT_REQUEST:
                case PW_COA_REQUEST:
-                       ptr[0] = vp->flags.tag;
+                       ptr[0] = vp->tag;
                        make_tunnel_passwd(ptr + 1, &len, data, len - 1, room,
                                           secret, packet->vector);
                        break;
@@ -1009,13 +1009,13 @@ static ssize_t vp2data_any(const RADIUS_PACKET *packet,
 
 
        default:
-               if (vp->da->flags.has_tag && TAG_VALID(vp->flags.tag)) {
+               if (vp->da->flags.has_tag && TAG_VALID(vp->tag)) {
                        if (vp->da->type == PW_TYPE_STRING) {
                                if (len > ((ssize_t) (room - 1))) len = room - 1;
-                               ptr[0] = vp->flags.tag;
+                               ptr[0] = vp->tag;
                                ptr++;
                        } else if (vp->da->type == PW_TYPE_INTEGER) {
-                               array[0] = vp->flags.tag;
+                               array[0] = vp->tag;
                        } /* else it can't be any other type */
                }
                memcpy(ptr, data, len);
@@ -2965,7 +2965,7 @@ static ssize_t data2vp_any(const RADIUS_PACKET *packet,
                         *      Tunnel passwords REQUIRE a tag, even
                         *      if don't have a valid tag.
                         */
-                       vp->flags.tag = data[0];
+                       vp->tag = data[0];
 
                        if ((vp->type == PW_TYPE_STRING) ||
                            (vp->type == PW_TYPE_OCTETS)) {
index 557558a..f68dc1a 100644 (file)
@@ -245,7 +245,7 @@ VALUE_PAIR * pairfind(VALUE_PAIR *first, unsigned int attr, unsigned int vendor,
        while (first) {
                if ((first->attribute == attr) && (first->vendor == vendor)
                    && ((tag == TAG_ANY) ||
-                       (first->flags.has_tag && (first->flags.tag == tag)))) {
+                       (first->flags.has_tag && (first->tag == tag)))) {
                        return first;
                }
                first = first->next;
@@ -274,7 +274,7 @@ void pairdelete(VALUE_PAIR **first, unsigned int attr, unsigned int vendor,
                next = i->next;
                if ((i->da->attr == attr) && (i->da->vendor == vendor) &&
                    ((tag == TAG_ANY) ||
-                    (i->da->flags.has_tag && (i->flags.tag == tag)))) {
+                    (i->da->flags.has_tag && (i->tag == tag)))) {
                        *last = next;
                        pairbasicfree(i);
                } else {
@@ -339,7 +339,7 @@ void pairreplace(VALUE_PAIR **first, VALUE_PAIR *replace)
                 *      and return.
                 */
                if ((i->da == replace->da) &&
-                   (!i->da->flags.has_tag || (i->flags.tag == replace->flags.tag))
+                   (!i->da->flags.has_tag || (i->tag == replace->tag))
                ) {
                        *prev = replace;
 
@@ -471,7 +471,7 @@ VALUE_PAIR *paircopy2(VALUE_PAIR *vp, unsigned int attr, unsigned int vendor,
                        goto skip;
                        
                if ((tag != TAG_ANY) && vp->da->flags.has_tag &&
-                   (vp->flags.tag != tag)) {
+                   (vp->tag != tag)) {
                        goto skip;
                }
 
@@ -733,7 +733,7 @@ void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, unsigned int attr,
                next = i->next;
 
                if ((tag != TAG_ANY) && i->da->flags.has_tag &&
-                   (i->flags.tag != tag)) {
+                   (i->tag != tag)) {
                        continue;
                }
                
@@ -1791,7 +1791,7 @@ VALUE_PAIR *pairmake(const char *attribute, const char *value, FR_TOKEN op)
        }
 
        if (found_tag) {
-         vp->flags.tag = tag;
+         vp->tag = tag;
        }
 
        switch (vp->op) {
index 0917e1f..c173201 100644 (file)
@@ -230,7 +230,7 @@ int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
         *      tag AND value match.
         */
        if (check->da->flags.has_tag) {
-               ret = ((int) vp->flags.tag) - ((int) check->flags.tag);
+               ret = ((int) vp->tag) - ((int) check->tag);
                if (ret != 0) return ret;
        }
 
@@ -715,7 +715,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
                                                    (char *)i->vp_strvalue) == 0)) {
                                                pairdelete(to, found->da->attr,
                                                        found->da->vendor,
-                                                       found->flags.tag);
+                                                       found->tag);
 
                                        /*
                                         *      'tailto' may have been
index fa94fce..3322060 100644 (file)
@@ -567,9 +567,9 @@ static void perl_store_vps(VALUE_PAIR *vp, HV *rad_hv)
                 *      <attribute>:<tag>, others just use the normal attribute
                 *      name as the key.
                 */
-               if (nvp->da->flags.has_tag && (nvp->flags.tag != 0)) {
+               if (nvp->da->flags.has_tag && (nvp->tag != 0)) {
                        snprintf(namebuf, sizeof(namebuf), "%s:%d",
-                                nvp->da->name, nvp->flags.tag);
+                                nvp->da->name, nvp->tag);
                        name = namebuf;
                } else {
                        name = nvp->da->name;
@@ -579,7 +579,7 @@ static void perl_store_vps(VALUE_PAIR *vp, HV *rad_hv)
                 *      Create a new list with all the attributes like this one
                 *      which are in the same tag group.
                 */
-               vpa = paircopy2(nvp, nvp->da->attr, nvp->da->vendor, nvp->flags.tag);
+               vpa = paircopy2(nvp, nvp->da->attr, nvp->da->vendor, nvp->tag);
 
                /*
                 *      Attribute has multiple values
@@ -609,7 +609,7 @@ static void perl_store_vps(VALUE_PAIR *vp, HV *rad_hv)
                 *      Finally remove all the VPs we processed from our copy
                 *      of the list.
                 */
-               pairdelete(&nvp, nvp->da->attr, nvp->da->vendor, nvp->flags.tag);
+               pairdelete(&nvp, nvp->da->attr, nvp->da->vendor, nvp->tag);
        }
 
        pairfree(&nvp);         /* shouldn't be necessary, but hey... */
index 22580bf..2ac817f 100644 (file)
@@ -335,7 +335,7 @@ static int python_populate_vptuple(PyObject *pPair, VALUE_PAIR *vp)
        /* Look at the vp_print_name? */
        
        if (vp->da->flags.has_tag)
-               pStr = PyString_FromFormat("%s:%d", vp->da->name, vp->flags.tag);
+               pStr = PyString_FromFormat("%s:%d", vp->da->name, vp->tag);
        else
                pStr = PyString_FromString(vp->da->name);
        
index f376f09..780ba86 100644 (file)
@@ -231,7 +231,7 @@ static int ruby_function(REQUEST *request, int func, VALUE module, const char *f
 
             /* The name. logic from vp_prints, lib/print.c */
             if (vp->da->flags.has_tag) {
-                snprintf(buf, BUF_SIZE, "%s:%d", vp->da->name, vp->flags.tag);
+                snprintf(buf, BUF_SIZE, "%s:%d", vp->da->name, vp->tag);
             } else {
                 strcpy(buf, vp->da->name);
             }