-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vendors for the dictionary #10
Comments
I ended up writing a new Is there any reason those files wouldn't work in your system? Here is my source if you want to see. using Flexinets.Radius.Core;
using log4net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace InfinitWifi.RadiusServer
{
public class RadiusDictionary : IRadiusDictionary
{
private readonly List<DictionaryVendorAttribute> vendorSpecificAttributes = new List<DictionaryVendorAttribute>();
private readonly Dictionary<byte, DictionaryAttribute> attributes = new Dictionary<byte, DictionaryAttribute>();
private readonly Dictionary<string, DictionaryAttribute> attributeNames = new Dictionary<string, DictionaryAttribute>();
private readonly ILog log = LogManager.GetLogger(typeof(RadiusDictionary));
public RadiusDictionary(string dictionaryFilePath)
{
ParseFile(dictionaryFilePath);
log.Info($"Parsed {attributes.Count} attributes and {vendorSpecificAttributes.Count} vendor attributes from file");
}
public DictionaryAttribute GetAttribute(byte code) => attributes[code];
public DictionaryAttribute GetAttribute(string name)
{
attributeNames.TryGetValue(name, out var attributeType);
return attributeType;
}
public DictionaryVendorAttribute GetVendorAttribute(uint vendorId, byte vendorCode) =>
vendorSpecificAttributes.FirstOrDefault(a => a.VendorId == vendorId && a.VendorCode == vendorCode);
private void ParseFile(string dictionaryFilePath)
{
using (var reader = new StreamReader(dictionaryFilePath))
{
var vendorName = string.Empty;
uint vendorId = 0;
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.StartsWith("$INCLUDE"))
{
var lineParts = SplitLine(line);
var fileName = lineParts[1];
var filePath = Path.Combine(Path.GetDirectoryName(dictionaryFilePath), fileName);
ParseFile(filePath);
}
else if (line.StartsWith("VENDOR"))
{
var lineParts = SplitLine(line);
vendorName = lineParts[1];
vendorId = Convert.ToUInt32(lineParts[2]);
}
else if (line.StartsWith("END-VENDOR"))
{
vendorName = string.Empty;
vendorId = 0;
}
else if (line.StartsWith("ATTRIBUTE"))
{
var lineParts = SplitLine(line);
if (vendorId == 0)
{
var name = lineParts[1];
if (!byte.TryParse(lineParts[2], out var code))
{
continue;
}
var type = lineParts[3];
var attribute = new DictionaryAttribute(name, code, type);
attributes[code] = attribute;
attributeNames[name] = attribute;
}
else
{
var name = lineParts[1];
if (!uint.TryParse(lineParts[2], out var code))
{
continue;
}
var type = lineParts[3];
var attribute = new DictionaryVendorAttribute(vendorId, name, code, type);
vendorSpecificAttributes.Add(attribute);
}
}
}
}
}
private string[] SplitLine(string line)
{
return line.Split(new char[] { '\t', '\x20' }, StringSplitOptions.RemoveEmptyEntries);
}
}
} |
Hi, The current dictionary is actually based on the format Radiator uses. So it looks a bit like FreeRADIUS, but not quite. |
I'll probably do a PR. This will parse the 202 FreeRADIUS files that come with Wireshark seemingly fine. I'll write up some tests. |
Do you want me to add all the files for FreeRADIUS so they can be tested and used if someone wants to grab them? |
I guess it would be nice to have the dictionaries, however I havent checked license compatibility. Im not sure if a radius dictionary actually is something that can be copyrighted in the first place though. cheers, |
Yes, sorry. I forked the core project and am doing the work there. |
I'm seeing some types that the Here is a list of them. Do you see any others that need to be handled/added?
|
Could you explain your vendor format? I'm looking to add some vendors to my file, but I'm seeing differences from the files I have. I'm using ones from WireShark, but they look like they came from FreeRadius. I'm looking at Cisco vendor 9 as an example. Not everything is included in your file. Some of the names match up and some have cisco- in front when it doesn't in the freeradius file. Casing is different. Are values not put in your file?
To me, this looks to be the format:
This is the file I want to use.
The text was updated successfully, but these errors were encountered: