当前位置: 首页>>代码示例>>Java>>正文


Java JBuffer.getUShort方法代码示例

本文整理汇总了Java中org.jnetpcap.nio.JBuffer.getUShort方法的典型用法代码示例。如果您正苦于以下问题:Java JBuffer.getUShort方法的具体用法?Java JBuffer.getUShort怎么用?Java JBuffer.getUShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jnetpcap.nio.JBuffer的用法示例。


在下文中一共展示了JBuffer.getUShort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: headerLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
 * Header length.
 * 
 * @param buffer
 *          the buffer
 * @param offset
 *          the offset
 * @return the int
 */
@HeaderLength
public static int headerLength(JBuffer buffer, int offset) {
	int flags = buffer.getUShort(0);
	int len = 6;
	if ((flags & FLAG_L) != 0) {
		len += 2;
	}

	if ((flags & FLAG_S) != 0) {
		len += 4;
	}

	if ((flags & FLAG_O) != 0) {
		len += 4;
	}

	return len;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:28,代码来源:L2TP.java

示例2: getHeaderLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
@HeaderLength
public static int getHeaderLength(JBuffer buffer, int offset) {
	int len = buffer.getUShort(offset + 2);
	return len + (4 - len % 4) & 3;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:6,代码来源:SctpChunk.java

示例3: create

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
public static TLV create(JBuffer buffer, int offset) {
	int type = buffer.getUShort(offset);
	int length = buffer.getUShort(offset + 2);

	switch (type) {
		case 5 : // Ip4
			return new Ip4TLV(buffer, offset, length);

		case 6 : // Ip6
			return new Ip6TLV(buffer, offset, length);

		case 7 : // State Cookie
			return new StateCookieTLV(buffer, offset, length);

		case 8 : // Unrecognized Parameters
			return new UnrecognizedParametersTLV(buffer, offset, length);

		case 9 : // Cookie Preservative
			return new CookieTLV(buffer, offset, length);

		case 11 : // Host Name Address (11)
			return new HostnameTLV(buffer, offset, length);

		case 12 : // Supported Address Types (12)
			return new AddressTypeTLV(buffer, offset, length);

		case ECN_TLV : // Supported Address Types (12)
			return new TLV("ECN", buffer, offset, length);

		case FORWARD_TSN_TLV : // Supported Address Types (12)
			return new TLV("Forward TSN Supported", buffer, offset,
					length);

		case ADAPTATION_LAYER_TLV : // Supported Address Types (12)
			long indication = buffer.getUInt(offset + 4);
			return new TLV(String.format(
					"Adaptation Layer Indication: 0x%08X", indication),
					buffer, offset, length);

		default :
			return new TLV(String.format(
					"Unrecognized type=%04X, length=%d", type, length),
					buffer, offset, length);
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:46,代码来源:SctpInitBaseclass.java

示例4: readTLVS

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
static TLV[] readTLVS(JBuffer buffer, int length) {
	final List<TLV> list = new ArrayList<TLV>();

	for (int offset = 20; offset < length;) {
		TLV tlv = TLV.create(buffer, offset);

		list.add(tlv);

		int tlvLen = buffer.getUShort(offset + 2);
		tlvLen = tlvLen + ((4 - tlvLen % 4) & 3);

		offset += tlvLen;
	}

	return list.toArray(new TLV[list.size()]);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:17,代码来源:SctpInitBaseclass.java

示例5: headerLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
@HeaderLength()
public static int headerLength(JBuffer buffer, int offset) {
	return buffer.getUShort(16);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:5,代码来源:Radius.java

示例6: 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");
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:81,代码来源:IEC61850_GOOSE_Data_Element.java

示例7: headerLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
 * Header length.
 * 
 * @param buffer
 *          the buffer
 * @param offset
 *          the offset
 * @return the int
 */
@HeaderLength
public static int headerLength(JBuffer buffer, int offset) {
	return ((buffer.getUShort(offset + 2) & 0x3) == 0x3) ? 4 : 5;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:IEEE802dot2.java

示例8: headerLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
 * Determines the length of the header in octets. The value is calculated by
 * use of a 16-bit length field that counts the number of 32-bit words in
 * the extension.
 * 
 * @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) {
	return (buffer.getUShort(2) * 4) + STATIC_HEADER_LENGTH;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:16,代码来源:Rtp.java

示例9: getHeaderLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
 * Gets the header length.
 * 
 * @param buffer
 *          the buffer
 * @param offset
 *          the offset
 * @return the header length
 */
@HeaderLength
public static int getHeaderLength(JBuffer buffer, int offset) {
	return buffer.getUShort(offset + 2); // len
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:IEEE802dot11_RADIOTAP.java


注:本文中的org.jnetpcap.nio.JBuffer.getUShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。