help-gnu-radius
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnu-radius] Problem with filters


From: Sergey Poznyakoff
Subject: Re: [Help-gnu-radius] Problem with filters
Date: Thu, 09 Oct 2003 12:34:09 +0300

Hi Roger,

>         Ascend-Call-Filter = "generic out drop 28 ffff 0453",
>          Ascend-Call-Filter = "generic out forward 0 0 0",
> 
> When I add these to a profile I get the following errors:
> Oct 07 16:35:50 Main.error: /usr/local/etc/raddb/users:93: attribute 
> Ascend-Call-Filter: Unexpected end of string

This is a bug in generic filter handling that appeared due to my misreading
the Ascend manual :^) Please find attached a patch that fixes it.

Regards,
Sergey

Index: lib/ascend.c
===================================================================
RCS file: /cvsroot/radius/radius/lib/ascend.c,v
retrieving revision 1.5
diff -p -u -r1.5 ascend.c
--- lib/ascend.c        3 Jun 2003 14:17:27 -0000       1.5
+++ lib/ascend.c        9 Oct 2003 09:27:59 -0000
@@ -262,7 +262,7 @@ _get_hex_string(struct ascend_parse_buf 
 
 /* Generic filter is:
 
-  "generic" dir action offset mask value {"=="|"!="} [ "more" ]
+  "generic" dir action offset mask ["=="|"!="] value [ "more" ]
   where dir    is {"in"|"out"}
         action is {"forward"|"drop"}
        offset is number
@@ -289,6 +289,18 @@ _ascend_parse_generic(struct ascend_pars
                return 1;
        pb->flt->v.generic.len = htons(len);
 
+       tok = _lookahead(pb);
+       if (!tok) 
+               return 1;
+
+       if (strcmp(tok, "==") == 0) {
+               pb->flt->v.generic.neq = 0;
+               _get_token(pb, 1);
+       } else if (strcmp(tok, "!=") == 0) {
+               pb->flt->v.generic.neq = 1;
+               _get_token(pb, 1);
+       }
+       
        if ((num = _get_hex_string(pb, pb->flt->v.generic.value)) < 0)
                return 1;
        if (num != len) {
@@ -297,19 +309,6 @@ _ascend_parse_generic(struct ascend_pars
                return 1;
        }
        
-       tok = _get_token(pb, 1);
-       if (!tok)
-               return 1;
-       if (strcmp(tok, "==") == 0)
-               pb->flt->v.generic.neq = 0;
-       else if (strcmp(tok, "!=") == 0)
-               pb->flt->v.generic.neq = 1;
-       else {
-               asprintf(pb->errmsg, "%s: %s",
-                        _("Bad operator"), tok);
-               return 1;
-       }
-
        tok = _get_token(pb, 0);
        if (!tok)
                return 0;
@@ -645,6 +644,8 @@ _ascend_parse_filter(const char *input, 
        pb.errmsg = errp;
        rc = _ascend_parse(&pb);
        argcv_free(pb.tokc, pb.tokv);
+       if (rc && !*errp) 
+               asprintf(errp, _("Malformed attribute value"));
        return rc;
 }
 
@@ -653,7 +654,7 @@ ascend_parse_filter(VALUE_PAIR *pair, ch
 {
        ASCEND_FILTER flt;
        
-       if (_ascend_parse_filter(pair->avp_strvalue, &flt, errp))
+       if (_ascend_parse_filter(pair->avp_strvalue, &flt, errp)) 
                return 1;
        efree(pair->avp_strvalue);
        pair->avp_strlength = sizeof(flt);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]