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


Java JField类代码示例

本文整理汇总了Java中org.jnetpcap.packet.structure.JField的典型用法代码示例。如果您正苦于以下问题:Java JField类的具体用法?Java JField怎么用?Java JField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fieldAfter

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/** 
 * @param header
 * @param field
 * @param detail
 * @throws IOException
 * @see org.jnetpcap.packet.format.JFormatter#fieldAfter(org.jnetpcap.packet.JHeader, org.jnetpcap.packet.structure.JField, org.jnetpcap.packet.format.JFormatter.Detail)
 */
@Override
protected void fieldAfter(JHeader header, JField field, Detail detail)
		throws IOException {

	if (field.getStyle() == Style.BYTE_ARRAY_HEX_DUMP) {
		decLevel();
		pad().format(LT + "/hexdump" + GT + "\n");
	} /*
		 * else if (false && field.hasSubFields()) { final String v =
		 * stylizeSingleLine(header, field, field.getValue(header));
		 * 
		 * pad().format(LT + "/field" + GT);
		 * 
		 * }
		 */else if (field.getStyle() == Style.INT_BITS) {
	}

	decLevel();
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:27,代码来源:XmlFormatter.java

示例2: format

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Format.
 * 
 * @param header
 *            the header
 * @param field
 *            the field
 * @param detail
 *            the detail
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public void format(JHeader header, JField field, Detail detail)
		throws IOException {

	if (header == null) {
		headerNull(header, detail);
		return;
	}

	if (field == null) {
		fieldNull(header, field, detail);
		return;
	}

	fieldBefore(header, field, detail);

	if (field.hasSubFields()) {
		for (JField sub : field.getSubFields()) {
			format(header, sub, detail);
		}
	}

	fieldAfter(header, field, detail);

}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:37,代码来源:JFormatter.java

示例3: format

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Format.
 * 
 * @param header
 *          the header
 * @param field
 *          the field
 * @param detail
 *          the detail
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void format(JHeader header, JField field, Detail detail)
		throws IOException {

	if (header == null) {
		headerNull(header, detail);
		return;
	}

	if (field == null) {
		fieldNull(header, field, detail);
		return;
	}

	fieldBefore(header, field, detail);

	if (field.hasSubFields()) {
		for (JField sub : field.getSubFields()) {
			format(header, sub, detail);
		}
	}

	fieldAfter(header, field, detail);

}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:37,代码来源:JFormatter.java

示例4: getFields

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * @return
 * @see org.jnetpcap.packet.JHeader#getFields()
 */
@Override
public JField[] getFields() {
	if (avps.isEmpty()) {
		decodeHeaderToAVPFields();
	}

	return avps.toArray(new JField[avps.size()]);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:13,代码来源:Radius.java

示例5: stylizeMultiLine

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize multi line.
 * 
 * @param header
 *            the header
 * @param field
 *            the field
 * @param style
 *            the style
 * @param value
 *            the value
 * @return the string[]
 */
protected String[] stylizeMultiLine(JHeader header, JField field,
		Style style, Object value) {

	switch (style) {
		case BYTE_ARRAY_HEX_DUMP :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, true, true, true);

		case BYTE_ARRAY_HEX_DUMP_NO_TEXT :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, true, false, true);

		case BYTE_ARRAY_HEX_DUMP_NO_TEXT_ADDRESS :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, false, false, true);

		case BYTE_ARRAY_HEX_DUMP_NO_ADDRESS :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, false, true, true);

		case BYTE_ARRAY_HEX_DUMP_ADDRESS :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, true, false, false);

		case BYTE_ARRAY_HEX_DUMP_TEXT :
			return FormatUtils.hexdump((byte[]) value, header.getOffset(),
					0, false, true, false);

		case STRING_TEXT_DUMP :
			return ((String) value).split("\r\n");

		default :
			return new String[]{stylizeSingleLine(header, field, value)};
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:49,代码来源:JFormatter.java

示例6: stylizeSingleLine

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize single line.
 * 
 * @param header
 *          the header
 * @param field
 *          the field
 * @param value
 *          the value
 * @return the string
 */
protected String stylizeSingleLine(JHeader header, JField field, Object value) {

	final Style style = field.getStyle();

	switch (style) {
	case BYTE_ARRAY_DASH_ADDRESS:
		return FormatUtils.asString((byte[]) value, '-').toUpperCase();

	case BYTE_ARRAY_COLON_ADDRESS:
		return formatMacAddress((byte[]) value);

	case BYTE_ARRAY_DOT_ADDRESS:
		return FormatUtils.asString((byte[]) value, '.').toUpperCase();

	case BYTE_ARRAY_ARRAY_IP4_ADDRESS:
	case BYTE_ARRAY_IP4_ADDRESS:
	case BYTE_ARRAY_IP6_ADDRESS:
		return formatIpAddress((byte[]) value);

	case INT_BITS:
		return stylizeBitField(header, field, value);

	case INT_RADIX_16:
		return Long.toHexString(((Number) value).longValue()).toUpperCase();

	case INT_HEX:
		return "0x"
				+ Long.toHexString(((Number) value).longValue()).toUpperCase() + " ("
				+ value.toString() + ")";

	case LONG_HEX:
		return "0x" + Long.toHexString((long) (Long) value).toUpperCase() + " ("
				+ value.toString() + ")";

	default:
		return value.toString();
	}
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:50,代码来源:JFormatter.java

示例7: analyzeFields

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
public int analyzeFields(JHeader header, JField[] fields, int level){
	if (fields==null){
		return 0;
	}
	
	int maxLevel=level;
	int actualFieldsCount=0;
	for (JField field : fields){
		if (field==null){
			continue;
		}
		
		try {
			format(header,field);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		String line = getCurrentString();
		if (line=="" || line==null){
			continue;
		}
		add(line,level);
		actualFieldsCount++;
		
		if (field.hasSubFields()){
			int depth=analyzeFields(header, field.getSubFields(), level+1);
			if (depth>maxLevel){
				maxLevel=depth;
			}
		}
	}
	if (actualFieldsCount==0){
		return 0;
	}
	return maxLevel;
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:38,代码来源:PacketFormatter.java

示例8: format

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
@Override
public void format(JHeader header, JField field, Detail detail)
		throws IOException {

	fieldBefore(header, field, detail);
	fieldAfter(header, field, detail);
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:8,代码来源:PacketFormatter.java

示例9: stylizeBitField

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize bit field.
 * 
 * @param header
 *            the header
 * @param field
 *            the field
 * @param value
 *            the value
 * @return the string
 */
private String stylizeBitField(JHeader header, JField field, Object value) {
	StringBuilder b = new StringBuilder();
	final JField parent = field.getParent();
	final int plen = parent.getLength(header);
	// final int p = parent.getValue(int.class, header);
	final long pmask = parent.getMask(header);
	long v = field.longValue(header);

	final int offset = field.getOffset(header);
	final int length = field.getLength(header);

	final int end = (offset + length);
	final int start = offset;

	for (int i = plen; i > end; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}

		b.append(((i - 1) % 4) == 0 ? ". " : '.');
	}

	for (int i = end; i > start; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}

		if ((v & (1L << (i - start - 1))) == 0) {
			b.append('0');
		} else {
			b.append('1');
		}

		if (((i - 1) % 4) == 0) {
			b.append(' ');
		}
	}

	for (int i = start; i > 0; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}
		b.append(((i - 1) % 4) == 0 ? ". " : '.');
	}

	/*
	 * Hack since we always append 1 too many ' ' chars.
	 */
	b.setLength(b.length() - 1);

	// for (int i = plen - 1; i >= 0; i--) {
	//
	// if (i >= start && i < end) {
	// b.append('0');
	// } else {
	// b.append('.');
	// }
	//
	// if ((i % 4) == 0) {
	// b.append(' ');
	// }
	// }

	return b.toString();
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:77,代码来源:JFormatter.java

示例10: stylizeSingleLine

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize single line.
 * 
 * @param header
 *            the header
 * @param field
 *            the field
 * @param value
 *            the value
 * @return the string
 */
protected String stylizeSingleLine(JHeader header, JField field,
		Object value) {

	final Style style = field.getStyle();

	switch (style) {
		case BYTE_ARRAY_DASH_ADDRESS :
			return FormatUtils.asString((byte[]) value, '-').toUpperCase();

		case BYTE_ARRAY_COLON_ADDRESS :
			return formatMacAddress((byte[]) value);

		case BYTE_ARRAY_DOT_ADDRESS :
			return FormatUtils.asString((byte[]) value, '.').toUpperCase();

		case BYTE_ARRAY_ARRAY_IP4_ADDRESS :
		case BYTE_ARRAY_IP4_ADDRESS :
		case BYTE_ARRAY_IP6_ADDRESS :
			return formatIpAddress((byte[]) value);

		case BYTE_ARRAY_OCTET_STREAM :
			return FormatUtils.hexLineStream((byte[]) value, 0);

		case INT_BITS :
			return stylizeBitField(header, field, value);

		case INT_RADIX_16 :
			return Long.toHexString(((Number) value).longValue())
					.toUpperCase();

		case INT_HEX :
			long v = (value instanceof Long)
					? ((Number) value).longValue()
					: toUInt(((Number) value).intValue());
			return "0x" + Long.toHexString(v).toUpperCase() + " ("
					+ ((Long) v).toString() + ")";

		case LONG_HEX :
			return "0x" + Long.toHexString((Long) value).toUpperCase()
					+ " (" + value.toString() + ")";

		case TIMESTAMP :
			return new Timestamp((Long) value).toString();

		case TIMESTAMP_SECONDS :
			return new Timestamp(((Long) value) * 1000).toString();

		default :
			return String.valueOf(value);
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:63,代码来源:JFormatter.java

示例11: stylizeBitField

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize bit field.
 * 
 * @param header
 *          the header
 * @param field
 *          the field
 * @param value
 *          the value
 * @return the string
 */
private String stylizeBitField(JHeader header, JField field, Object value) {
	StringBuilder b = new StringBuilder();
	final JField parent = field.getParent();
	final int plen = parent.getLength(header);
	// final int p = parent.getValue(int.class, header);
	final long pmask = parent.getMask(header);
	long v = field.longValue(header);

	final int offset = field.getOffset(header);
	final int length = field.getLength(header);

	final int end = (offset + length);
	final int start = offset;

	for (int i = plen; i > end; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}

		b.append(((i - 1) % 4) == 0 ? ". " : '.');
	}

	for (int i = end; i > start; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}

		if ((v & (1L << (i - start - 1))) == 0) {
			b.append('0');
		} else {
			b.append('1');
		}

		if (((i - 1) % 4) == 0) {
			b.append(' ');
		}
	}

	for (int i = start; i > 0; i--) {
		if ((pmask & (1L << (i - 1))) == 0) {
			continue;
		}
		b.append(((i - 1) % 4) == 0 ? ". " : '.');
	}

	/*
	 * Hack since we always append 1 too many ' ' chars.
	 */
	b.setLength(b.length() - 1);

	// for (int i = plen - 1; i >= 0; i--) {
	//
	// if (i >= start && i < end) {
	// b.append('0');
	// } else {
	// b.append('.');
	// }
	//
	// if ((i % 4) == 0) {
	// b.append(' ');
	// }
	// }

	return b.toString();
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:77,代码来源:JFormatter.java

示例12: stylizeMultiLine

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Stylize multi line.
 * 
 * @param header
 *          the header
 * @param field
 *          the field
 * @param style
 *          the style
 * @param value
 *          the value
 * @return the string[]
 */
protected String[] stylizeMultiLine(JHeader header,
		JField field,
		Style style,
		Object value) {

	switch (style) {
	case BYTE_ARRAY_HEX_DUMP:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				true,
				true,
				true);

	case BYTE_ARRAY_HEX_DUMP_NO_TEXT:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				true,
				false,
				true);

	case BYTE_ARRAY_HEX_DUMP_NO_TEXT_ADDRESS:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				false,
				false,
				true);

	case BYTE_ARRAY_HEX_DUMP_NO_ADDRESS:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				false,
				true,
				true);

	case BYTE_ARRAY_HEX_DUMP_ADDRESS:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				true,
				false,
				false);

	case BYTE_ARRAY_HEX_DUMP_TEXT:
		return FormatUtils.hexdump((byte[]) value,
				header.getOffset(),
				0,
				false,
				true,
				false);

	case STRING_TEXT_DUMP:
		return ((String) value).split("\r\n");

	default:
		return new String[] { stylizeSingleLine(header, field, value)
		};
	}
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:76,代码来源:JFormatter.java

示例13: JHeader

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Constructs a header and initializes its static fields.
 * 
 * @param id
 *          numerical ID of the protocol
 * @param fields
 *          fields usd by the formatter to reformat the packet for output
 * @param name
 *          comprehensive name of the protocol
 * @param nicname
 *          a short name for the protocol
 */
public JHeader(int id, JField[] fields, String name, String nicname) {
	super(Type.POINTER);
	this.fields = fields;

	this.id = id;
	this.name = name;
	this.nicname = nicname;
	this.state = new State(Type.POINTER);
	super.order(ByteOrder.nativeOrder());

}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:24,代码来源:JHeader.java

示例14: JHeaderMap

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Instantiates a new j header map.
 * 
 * @param id
 *          the id
 * @param fields
 *          the fields
 * @param name
 *          the name
 * @param nicname
 *          the nicname
 * @param unordered
 *          the unordered
 */
public JHeaderMap(int id, JField[] fields, String name, String nicname,
    JHeader[] unordered) {
	super(id, fields, name, nicname);

	reorderAndSave(unordered);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:21,代码来源:JHeaderMap.java

示例15: fieldAfter

import org.jnetpcap.packet.structure.JField; //导入依赖的package包/类
/**
 * Field after.
 * 
 * @param header
 *            the header
 * @param field
 *            the field
 * @param detail
 *            the detail
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @see org.jnetpcap.packet.format.JFormatter#fieldAfter(org.jnetpcap.packet.JHeader,
 *      org.jnetpcap.packet.structure.JField,
 *      org.jnetpcap.packet.format.JFormatter.Detail)
 */
@Override
protected void fieldAfter(JHeader header, JField field, Detail detail)
		throws IOException {

	if (field.getStyle() == Style.INT_BITS) {

	} else if (field.hasSubFields()) {
		decLevel();
	} else if (field.getStyle() != Style.BYTE_ARRAY_HEX_DUMP
			&& field.getStyle() != Style.STRING_TEXT_DUMP) {
		decLevel();
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:29,代码来源:TextFormatter.java


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