-
Notifications
You must be signed in to change notification settings - Fork 108
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
Adding support starent attribute encoding and decoding #30
base: master
Are you sure you want to change the base?
Conversation
…te Radius attribute length. It now supports encoding and decoding of radius packet has 2 bytes radius attribute length. The library has also been tested well with starent radius dictionary (2 byte attribute length). modified: src/main/java/org/tinyradius/attribute/RadiusAttribute.java modified: src/main/java/org/tinyradius/attribute/VendorSpecificAttribute.java modified: src/main/java/org/tinyradius/dictionary/AttributeType.java modified: src/main/java/org/tinyradius/packet/RadiusPacket.java
if (attributeType < 0 || attributeType > 255) | ||
throw new IllegalArgumentException("attribute type invalid: " + attributeType); | ||
// Vendor specific attribute has values > 255 and < 1 | ||
/*if (attributeType < 0 || attributeType > 255) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer you remove the commented out code, not sure what is the purpose to leave it as commented out.
* @return attribute | ||
*/ | ||
public byte[] write2ByteAttribute() { | ||
if (getAttributeType() == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why checking for -1
?
attr[2] = (byte) (data_length >> 8 & 0x0ff); | ||
attr[3] = (byte) (data_length & 0x0ff); | ||
System.arraycopy(attributeData, 0, attr, 4, attributeData.length); | ||
return attr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see a unit test to verify previous and modified behavior?
67019ad
to
5526820
Compare
Starent radius packet attribute length is 2 byte. While testing with decoding and encoding starent radius attribute, tinyradius was going infinite loop during decoding and failed to encode in case length more than 255. With this changes it now handles starent radius dictionary.