本文整理汇总了Java中org.jnetpcap.nio.JBuffer.getByte方法的典型用法代码示例。如果您正苦于以下问题:Java JBuffer.getByte方法的具体用法?Java JBuffer.getByte怎么用?Java JBuffer.getByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.nio.JBuffer
的用法示例。
在下文中一共展示了JBuffer.getByte方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: headerLength
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
* Determines the length of the header in octets. The value is calculated by
* adding to the length of the static part of the header the length of the
* CSRC table. The CC field contains number of 32-bit entries within the
* table.
*
* @param buffer
* buffer containing the header data
* @param offset
* offset within the buffer of the start of the header
* @return length of the header in bytes
*/
@HeaderLength
public static int headerLength(final JBuffer buffer, final int offset) {
final int rtpBaseHeader = baseHeaderLength(buffer, offset);
if ((buffer.getByte(offset) & EXTENSION_MASK) > 0) {
return rtpBaseHeader
+ Rtp.Extension.headerLength(buffer, offset + rtpBaseHeader);
} else {
return rtpBaseHeader;
}
}
示例2: compareJBuffer
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
* Compare j buffer.
*
* @param b1
* the b1
* @param b2
* the b2
* @return true, if successful
*/
private boolean compareJBuffer(JBuffer b1, JBuffer b2) {
if (b1.size() != b2.size()) {
return false;
}
for (int i = 0; i < b1.size(); i++) {
if (b1.getByte(i) != b2.getByte(i)) {
return false;
}
}
return true;
}
示例3: decodeData
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
public void decodeData(JBuffer payload)
{
int currentBuffPosition = 0;
// We walk through the payload to decode each data entry
for (int currentEntry = 0; currentEntry < numEntries; currentEntry++)
{
// We decode the current data entry
this.data[currentEntry].decode(payload, currentBuffPosition);
currentBuffPosition++;
// We read the current data entry length
currentBuffPosition += (payload.getByte(currentBuffPosition) +1);
}
}
示例4: decode
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
protected void decode(JBuffer currentEntry, int offset)
{
// The first byte is the data type
this.dataType = IEC61850_GOOSE_MMS_DataType.get(currentEntry.getUByte(offset));
// The second byte is the data length
this.length = currentEntry.getUByte(offset+1);
switch (this.dataType)
{
/*
case array:
case structure:
// The array and structure code could not be tested
// The number of elements in the structure or array
nbOfElements = getNumberOfElements(currentEntry,offset+2,this.length);
// Add code to read data
break;
*/
case booln:
if (this.length == 1)
value = new Boolean(currentEntry.getUByte(offset+2) != 0);
else
throw new UnsupportedOperationException("In IEC61850_GOOSE_Data_Element::decode Cannot read boolean on more than 1 byte");
break;
case integer:
if (this.length == 1)
value = new Byte(currentEntry.getByte(offset+2));
else if (this.length == 2)
value = new Short(currentEntry.getShort(offset+2));
else if (this.length == 4)
value = new Integer(currentEntry.getInt(offset+2));
else if (this.length == 8)
value = new Long(currentEntry.getLong(offset+2));
else
throw new UnsupportedOperationException("In IEC61850_GOOSE_Data_Element::decode Cannot read integer on 3 bytes");
break;
case unsign:
if (this.length == 1)
value = new Integer(currentEntry.getUByte(offset+2));
else if (this.length == 2)
value = new Integer(currentEntry.getUShort(offset+2));
else if (this.length == 4)
value = new Long(currentEntry.getUInt(offset+2));
else
throw new UnsupportedOperationException("In IEC61850_GOOSE_Data_Element::decode Cannot read unsigned integer on 3 bytes");
break;
case float_point:
if (this.length == 4)
//TODO test this
value = new Float(currentEntry.getFloat(offset+2));
else if (this.length == 8)
//TODO test this
value = new Double(currentEntry.getDouble(offset+2));
else
throw new UnsupportedOperationException("In IEC61850_GOOSE_Data_Element::decode Cannot read float on other than 4 or 8 bytes");
break;
default:
throw new UnsupportedOperationException("In IEC61850_GOOSE_Data_Element::decode Unsupported data type");
}
}
示例5: baseHeaderLength
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
* Calculate the base header length (Rtp header without an extension).
*
* @param buffer
* buffer with rtp header
* @param offset
* offset into the buffer
* @return dynamic length of the header with extension ignored
*/
private static int baseHeaderLength(final JBuffer buffer, final int offset) {
final byte b0 = buffer.getByte(offset);
final int cc = (b0 & CC_MASK) >> CC_OFFSET;
return Rtp.STATIC_HEADER_LENGTH + (cc * CSRC_LENGTH);
}
示例6: postfixLength
import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
* Determines the length of Rtp padding if the header has been padded. If the
* Rtp.P bit is set, that means that last byte within the frame contains the
* number of bytes that were used to pad after the payload following this
* header.
*
* @param buffer
* buffer to read options and padding information from
* @param offset
* offset to the start of the header
* @return number of bytes padding rtp payload or 0 if no padding bytes
*/
@HeaderLength(HeaderLength.Type.POSTFIX)
public static int postfixLength(final JBuffer buffer, final int offset) {
if ((buffer.getByte(offset) & PADDING_MASK) > 0) {
return buffer.getUByte(buffer.size() - 1);
} else {
return 5;
}
}