本文整理汇总了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;
}
示例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);
}
示例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));
}
示例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());
}
示例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;
}
示例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());
}
}
示例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());
}
示例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;
}
示例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
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}