[Jradius-users] Fix for missed possible values in VSAs

wlan at mac.com wlan at mac.com
Thu Sep 13 15:02:29 UTC 2007


Hi,

Thanks for that!.. I've committed the changes to my current repo (and  
cc'ed the new mailing list):
http://dev.coova.org/svn/cjradius/

Actually, you will find that I rearranged how the dictionary works  
internally, but the interface is roughly the same.

Cheers,
David

On Sep 13, 2007, at 3:40 PM, Marcel.Natz at swisscom.com wrote:

> Hi
>
> We created our own vendor specific attributes in a new dictionary.
> Unfortunately the values didnt show up in the created Java-classes.
> Because none of the other VSA did have possible values I had a look  
> into
> the code. I'm not sure if omitting this values was a bug or a  
> feature. A
> feature because there are some troubles with variable naming.
>
> Because I like to have this human readable values I adapted the  
> code and
> I don't want to detain it in case somebody else is interested in it:
>
> The reason why the values didn't show up was found in the method
> "readline()" at the following part:
>
>
> else if (upperLine.startsWith("VALUE"))
> {
>     String parts[] = line.split("[\t ]+");
>     String attrName = null;
>     String attrValueName = null;
>     String attrValueNum = null;
>     for (int i = 1; i < parts.length; i++)
>     {
>         String p = parts[i].trim();
>         if (p.length() == 0) continue;
>         if (attrName == null) attrName = p;
>         else if (attrValueName == null) attrValueName = p;
>         else if (attrValueNum == null) attrValueNum = p;
>     }
>     if (attrName != null && attrValueNum != null && attrValueName !=
> null)
>     {
>         AttrDesc desc = (AttrDesc)attrMap.get(attrName);
>
>
>         // NEW CODE
>         if(desc == null) {
>         	VendorDesc vendorDesc = (VendorDesc)
> vendorMap.get(cVendor);
>         	desc = (AttrDesc) vendorDesc.attrMap.get(attrName);
>         }
>         // END NEW CODE
>
>
>         if (desc != null)
>         {
>             AttrValueDesc avd;
>             if (desc.values == null) desc.values = new LinkedHashMap 
> ();
>             if ((avd = (AttrValueDesc)desc.values.get 
> (attrValueNum)) ==
> null)
>                 desc.values.put(attrValueNum, new
> AttrValueDesc(attrValueName, attrValueNum));
>             else
>                 avd.addName(attrValueName);
>         }
>     }
> }
>
>
> Now the values show up in the code but now there are some problems  
> with
> generated variable names starting with a digit. The following  
> change in
> the mertho clean() fixed it:
>
> private String clean(String s)
> {
>     s = s.replaceAll("[^a-zA-Z0-9]", "");
>
>     // NEW CODE
>     if(Character.isDigit(s.charAt(0))) {
>     	s = "_" + s;
>     }
>     // END NEW CODE
>
>     return s;
> }
>
> And finally there is a "L" required where new Long() are created (in
> method writeAttrMap()) because the compile said that the integer is to
> large or out of range:
>
>
> while (iter2.hasNext())
> {
>     AttrValueDesc vdesc = (AttrValueDesc)iter2.next();
>     for (Iterator i = vdesc.names.iterator(); i.hasNext(); )
>     {
>         // The last one defined is the one used for number to String
> lookups!
>         String name = (String)i.next();
>
>         // NEW: "L" added after vdesc.num the declare a long  
> instead of
> a int
>         writer.println("        valueMap.put(new Long(" + vdesc.num +
> "L), " + clean(name) + ");");
>         writer.println("        valueMap.put(" + clean(name) + ", new
> Long(" + vdesc.num + "L));");
>     }
> }
>
> Thats it. Well, almost. The dictonary "karlnet" produces so many lines
> of code the the java compiler just said "code to large". Comment it in
> the root dictionary file and everything works fine.
>
> Have fun with JRadius!
>
> Marcel
>
> Sorry, that I can't provide a patch. Eclipse can't create a patch  
> from a
> compare-editor or I just do not know how ;-).
>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Jradius-users mailing list
> Jradius-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jradius-users




More information about the Jradius mailing list