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


Java JBuffer.getUByte方法代码示例

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


在下文中一共展示了JBuffer.getUByte方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
	switch (buffer.getUByte(offset)) {
	case 0: // EchoReply
	case 8: // EchoRequest
		return buffer.size() - offset - 4;

	case 4: // SourceQuench
	case 5: // Redirect
	case 11: // Timestamp
	default:
		return 4;
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:24,代码来源:Icmp.java

示例2: 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) {
	switch (buffer.getUByte(offset)) {
		case 0: // EchoReply
		case 8: // EchoRequest
			return buffer.size() - offset - 4;

		case 4: // SourceQuench
		case 5: // Redirect
		case 11: // Timestamp
		default:
			return 4;
	}
}
 
开发者ID:universsky,项目名称:diddler,代码行数:24,代码来源:Icmp.java

示例3: readLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
public static int readLength(JBuffer buffer, int offset) {
	return buffer.getUByte(offset + 1);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:4,代码来源:RtcpSDES.java

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

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

示例6: 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) {
	final int hlen = buffer.getUByte(offset + 4);
	final int plen = buffer.getUByte(offset + 5);

	return (hlen + plen) * 2 + 8;
}
 
开发者ID:universsky,项目名称:diddler,代码行数:17,代码来源:Arp.java

示例7: headerLength

import org.jnetpcap.nio.JBuffer; //导入方法依赖的package包/类
/**
 * Calculates the length of a tcp header.
 * 
 * @param buffer
 *          buffer containing packet and/or tcp header data
 * @param offset
 *          offset into the buffer where tcp header start (in bytes)
 * @return number of bytes occupied by the tcp header, including any tcp
 *         options
 */
@HeaderLength
public static int headerLength(final JBuffer buffer, final int offset) {
	final int hlen = (buffer.getUByte(offset + 12) & 0xF0) >> 4;
	return hlen * 4;
}
 
开发者ID:universsky,项目名称:diddler,代码行数:16,代码来源:Tcp.java

示例8: 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.getUByte(1);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:Ip4.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.getUByte(offset) & 0x0F) * 4;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:Ip4.java

示例10: 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.getUByte(1);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:MyHeader.java

示例11: 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.getUByte(offset) & 0x0F) * 4;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:MyHeader.java

示例12: 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.getUByte(offset) & 0x0F) * 4;
	}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:14,代码来源:Ip4.java


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