public abstract class Format extends Object
| Modifier and Type | Class and Description |
|---|---|
protected class |
Format.AttributeParseContext |
| Constructor and Description |
|---|
Format() |
| Modifier and Type | Method and Description |
|---|---|
static short |
getUnsignedByte(ByteBuffer bb) |
static short |
getUnsignedByte(ByteBuffer bb,
int position) |
static long |
getUnsignedInt(ByteBuffer bb) |
static long |
getUnsignedInt(ByteBuffer bb,
int position) |
static int |
getUnsignedShort(ByteBuffer bb) |
static int |
getUnsignedShort(ByteBuffer bb,
int position) |
abstract void |
packAttribute(ByteBuffer buffer,
RadiusAttribute a) |
void |
packAttributeList(AttributeList attrs,
ByteBuffer buffer,
boolean onWire)
Packs an AttributeList into a byte array
|
void |
packAttributes(ByteBuffer buffer,
List<VSAttribute> list) |
static void |
putUnsignedByte(ByteBuffer bb,
int value) |
static void |
putUnsignedByte(ByteBuffer bb,
int position,
int value) |
static void |
putUnsignedInt(ByteBuffer bb,
int position,
long value) |
static void |
putUnsignedInt(ByteBuffer bb,
long value) |
static void |
putUnsignedShort(ByteBuffer bb,
int value) |
static void |
putUnsignedShort(ByteBuffer bb,
int position,
int value) |
static int |
readUnsignedByte(InputStream in) |
static long |
readUnsignedInt(InputStream in) |
static int |
readUnsignedShort(InputStream in) |
abstract void |
unpackAttributeHeader(ByteBuffer buffer,
Format.AttributeParseContext ctx) |
void |
unpackAttributes(AttributeList attrs,
ByteBuffer buffer,
int length,
boolean pool)
Unpacks RadiusAttributes from a byte array into an AttributeList
|
static void |
writeUnsignedByte(OutputStream out,
int b) |
static void |
writeUnsignedInt(OutputStream out,
long i) |
static void |
writeUnsignedShort(OutputStream out,
int s) |
public abstract void packAttribute(ByteBuffer buffer, RadiusAttribute a)
public void packAttributes(ByteBuffer buffer, List<VSAttribute> list)
public abstract void unpackAttributeHeader(ByteBuffer buffer, Format.AttributeParseContext ctx) throws IOException
IOExceptionpublic void packAttributeList(AttributeList attrs, ByteBuffer buffer, boolean onWire)
attrs - The AttributeList to packpublic void unpackAttributes(AttributeList attrs, ByteBuffer buffer, int length, boolean pool)
attrs - The AttributeList to put unpacked attributesbytes - The bytes to be unpackedbLength - The length of the bytes to be unpacked
public void unpackAttributes(AttributeList attrs, byte[] bytes, int bOffset, int bLength)
{
InputStream attributeInput = new ByteArrayInputStream(bytes, bOffset, bLength);
try
{
for (int pos = 0; pos < bLength; )
{
AttributeParseContext ctx = new AttributeParseContext();
pos += unpackAttributeHeader(attributeInput, ctx);
RadiusAttribute attribute = null;
ctx.attributeValue = new byte[(int)(ctx.attributeLength - ctx.headerLength)];
attributeInput.read(ctx.attributeValue, 0, (int)(ctx.attributeLength - ctx.headerLength));
attribute = AttributeFactory.newAttribute(ctx.vendorNumber, ctx.attributeType, ctx.attributeValue, (int) ctx.attributeOp);
if (attribute == null)
{
RadiusLog.warn("Unknown attribute with type = " + ctx.attributeType);
}
else
{
attrs._add(attribute, false);
}
if (ctx.padding > 0)
{
pos += ctx.padding;
while (ctx.padding-- > 0)
{
readUnsignedByte(attributeInput);
}
}
pos += ctx.attributeLength;
}
attributeInput.close();
}
catch (IOException e)
{
RadiusLog.warn(e.getMessage(), e);
}
}public static long readUnsignedInt(InputStream in) throws IOException
IOExceptionpublic static int readUnsignedShort(InputStream in) throws IOException
IOExceptionpublic static int readUnsignedByte(InputStream in) throws IOException
IOExceptionpublic static void writeUnsignedByte(OutputStream out, int b) throws IOException
IOExceptionpublic static void writeUnsignedShort(OutputStream out, int s) throws IOException
IOExceptionpublic static void writeUnsignedInt(OutputStream out, long i) throws IOException
IOExceptionpublic static short getUnsignedByte(ByteBuffer bb)
public static void putUnsignedByte(ByteBuffer bb, int value)
public static short getUnsignedByte(ByteBuffer bb, int position)
public static void putUnsignedByte(ByteBuffer bb, int position, int value)
public static int getUnsignedShort(ByteBuffer bb)
public static void putUnsignedShort(ByteBuffer bb, int value)
public static int getUnsignedShort(ByteBuffer bb, int position)
public static void putUnsignedShort(ByteBuffer bb, int position, int value)
public static long getUnsignedInt(ByteBuffer bb)
public static void putUnsignedInt(ByteBuffer bb, long value)
public static long getUnsignedInt(ByteBuffer bb, int position)
public static void putUnsignedInt(ByteBuffer bb, int position, long value)
Copyright © 2017. All rights reserved.