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


Java AnnotatedHeader类代码示例

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


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

示例1: lookupId

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Look's up the protocol header ID using a class name.
 * 
 * @param c
 *          class of the header
 * @return numerical ID of the protocol header
 */
public static int lookupId(Class<? extends JHeader> c) {

	if (JSubHeader.class.isAssignableFrom(c)) {
		AnnotatedHeader header =
				lookupAnnotatedSubHeader((Class<? extends JSubHeader<? extends JSubHeader<?>>>) c);

		return header.getId();
	}

	Entry e = mapByClassName.get(c.getCanonicalName());
	if (e == null) {
		e = createNewEntry(c);
	}

	return e.id;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:24,代码来源:JRegistry.java

示例2: JHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Calls on the header defintion's static annotated \@HeaderLength method to
 * get header's length. The method is given a buffer and offset as the start
 * of the header. The method invoked must be defined in the header definition
 * otherwise an exception will be thrown.
 */
public JHeader() {
	super(Type.POINTER);
	order(ByteOrder.BIG_ENDIAN); // network byte order by default
	state = new State(Type.POINTER);

	final JProtocol protocol = JProtocol.valueOf(getClass());

	AnnotatedHeader header;
	if (protocol != null) {
		this.id = protocol.getId();
		header = JRegistry.lookupAnnotatedHeader(protocol);

	} else {
		this.id = JRegistry.lookupId(getClass());
		header = JRegistry.lookupAnnotatedHeader(getClass());
	}

	initFromAnnotatedHeader(header);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:26,代码来源:JHeader.java

示例3: lookupAnnotatedHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Lookup annotated header.
 * 
 * @param c
 *          the c
 * @return the annotated header
 * @throws UnregisteredHeaderException
 *           the unregistered header exception
 */
public static AnnotatedHeader lookupAnnotatedHeader(Class<? extends JHeader> c)
		throws UnregisteredHeaderException {

	if (JSubHeader.class.isAssignableFrom(c)) {
		return lookupAnnotatedSubHeader((Class<? extends JSubHeader<? extends JSubHeader<?>>>) c);
	}

	return lookupAnnotatedHeader(lookupIdNoCreate(c));
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:19,代码来源:JRegistry.java

示例4: lookupAnnotatedSubHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Lookup annotated sub header.
 * 
 * @param c
 *          the c
 * @return the annotated header
 */
static AnnotatedHeader lookupAnnotatedSubHeader(Class<? extends JSubHeader<? extends JSubHeader<?>>> c) {
	if (mapSubsByClassName.containsKey(c.getCanonicalName()) == false) {
		throw new UnregisteredHeaderException("sub header [" + c.getName()
				+ "] not registered, most likely parent not registered as well");
	}

	return mapSubsByClassName.get(c.getCanonicalName());
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:16,代码来源:JRegistry.java

示例5: register

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Registeres a new protocol header. A new numerical ID is assigned to the
 * protocol and various mappings are recorded for this protocol.
 * 
 * @param c
 *          class of the header
 * @param errors
 *          the errors
 * @return numerical id assigned to this new protocol
 */
public static int register(Class<? extends JHeader> c,
		List<HeaderDefinitionError> errors) {

	AnnotatedHeader annotatedHeader = inspect(c, errors);
	if (errors.isEmpty() == false) {
		return -1;
	}

	Entry e = mapByClassName.get(c.getCanonicalName());
	if (e == null) {
		e = createNewEntry(c);
	}

	int id = e.id;
	e.annotatedHeader = annotatedHeader;

	scanners[id] = new JHeaderScanner(c);

	registerAnnotatedSubHeaders(annotatedHeader.getHeaders());

	JBinding[] bindings = AnnotatedBinding.inspectJHeaderClass(c, errors);
	if (errors.isEmpty() == false) {
		return -1;
	}
	addBindings(bindings);

	for (PcapDLT d : annotatedHeader.getDlt()) {
		registerDLT(d, id);
	}

	return id;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:43,代码来源:JRegistry.java

示例6: registerAnnotatedSubHeaders

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Register annotated sub headers.
 * 
 * @param subs
 *          the subs
 */
private static void registerAnnotatedSubHeaders(AnnotatedHeader[] subs) {
	for (AnnotatedHeader c : subs) {
		mapSubsByClassName.put(c.getHeaderClass().getCanonicalName(), c);

		registerAnnotatedSubHeaders(c.getHeaders());
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:JRegistry.java

示例7: initFromAnnotatedHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Initialize this header directly from annotated header definition class.
 * 
 * @param header
 *          annotation to initialize from
 */
private void initFromAnnotatedHeader(AnnotatedHeader header) {
	this.annotatedHeader = header;

	this.name = header.getName();
	this.nicname = header.getNicname();

	this.fields = AnnotatedJField.fromAnnotatedFields(header.getFields());
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:15,代码来源:JHeader.java

示例8: createHeaderInstances

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Creates the header instances.
 * 
 * @param headers
 *          the headers
 * @return the j header[]
 */
private static JHeader[] createHeaderInstances(AnnotatedHeader... headers) {
	JHeader[] h = new JHeader[headers.length];

	for (int i = 0; i < h.length; i++) {
		h[i] = createHeaderInstance(headers[i]);
	}

	return h;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:17,代码来源:JHeaderMap.java

示例9: test2

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Test2.
 */
public void test2() {

	AnnotatedHeader ah1 =
			AnnotatedHeader.inspectJHeaderClass(TestSubHeader.Sub1.Sub2.Sub3.class,
					errors);

	AnnotatedHeader ah2 =
			AnnotatedHeader.inspectJHeaderClass(TestSubHeader.Sub1.Sub2.Sub3.class,
					errors);

	assertTrue(ah1 == ah2); // Check if cached properly

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

示例10: testWithMyHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Test with my header.
 */
public void testWithMyHeader() {
	@SuppressWarnings("unused")
	AnnotatedHeader ah1 =
			AnnotatedHeader.inspectJHeaderClass(MyHeader.class, errors);

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

示例11: initFromAnnotatedHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Initialize this header directly from annotated header definition class.
 * 
 * @param header
 *          annotation to initialize from
 */
private void initFromAnnotatedHeader(AnnotatedHeader header) {
	this.annotatedHeader = header;

	this.name = header.getName();
	this.nicname = header.getNicname();

	this.fields = DefaultField.fromAnnotatedFields(header.getFields());
}
 
开发者ID:GlacialSoftware,项目名称:PCAPReader,代码行数:15,代码来源:JHeader.java

示例12: inspect

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Inspect.
 * 
 * @param c
 *          the c
 * @param errors
 *          the errors
 * @return the annotated header
 */
public static AnnotatedHeader inspect(Class<? extends JHeader> c,
		List<HeaderDefinitionError> errors) {

	return AnnotatedHeader.inspectJHeaderClass(c, errors);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:15,代码来源:JRegistry.java

示例13: getAnnotatedHeader

import org.jnetpcap.packet.structure.AnnotatedHeader; //导入依赖的package包/类
/**
 * Retrieves the cached annotation of the header definition file. The
 * AT-Header annotation is a class that contains all of the annotation
 * parameters that were set in the definition file or its defaults.
 * 
 * @return annotation class for the source header definition
 */
public AnnotatedHeader getAnnotatedHeader() {
	return this.annotatedHeader;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:11,代码来源:JHeader.java


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