本文整理汇总了Java中org.jnetpcap.packet.JScan类的典型用法代码示例。如果您正苦于以下问题:Java JScan类的具体用法?Java JScan怎么用?Java JScan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JScan类属于org.jnetpcap.packet包,在下文中一共展示了JScan类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSignature
import org.jnetpcap.packet.JScan; //导入依赖的package包/类
/**
* Validate signature.
*
* @param method
* the method
* @see org.jnetpcap.packet.structure.AnnotatedMethod#validateSignature(java.lang.reflect.Method)
*/
@Override
protected void validateSignature(Method method) {
final Class<?> declaringClass = method.getDeclaringClass();
if (method.isAnnotationPresent(Scanner.class) == false) {
throw new AnnotatedMethodException(declaringClass,
"@Scanner annotation missing for " + method.getName() + "()");
}
/*
* Now make sure it has the right signature of: <code>static int
* name(JBuffer, int)</code.
*/
final Class<?>[] sig = method.getParameterTypes();
if (sig.length != 1 || sig[0] != JScan.class) {
throw new AnnotatedMethodException(declaringClass,
"Invalid signature for " + method.getName() + "()");
}
if (object == null && (method.getModifiers() & Modifier.STATIC) == 0) {
throw new AnnotatedMethodException(declaringClass, method.getName()
+ "()" + " must be declared static");
}
}
示例2: scanner
import org.jnetpcap.packet.JScan; //导入依赖的package包/类
/**
* Scanner.
*
* @param scan
* the scan
*/
@Scanner
public static void scanner(JScan scan) {
/*
* Packet extends JBuffer. The packet object is the one that is already
* created for the scanner in the Pcap.loop call and is already peered. This
* is better approach than getting the buffer with: JBuffer b = new
* JBuffer(Type.POINTER); scan.scan_buf(b);
*/
JPacket packet = scan.scan_packet();
/*
* Thats good
*/
int offset = scan.scan_offset();
/*
* Should put this outside the method body as a private field. Do it once
* everytime the header is created.
*/
@SuppressWarnings("unused")
int id = JRegistry.lookupId(IEEE802dot11_RADIOTAP.class);
// JRegistry.lookupId(IEEE802dot11.class);
/*
* Good. Exactly why @HeaderLength methods are static
*/
scan.scan_length(getHeaderLength(packet, offset));
/*
* Now here the scan_id is already set, otherwise this @Scanner method would
* not be getting called. What you want to set is the next_id which is the
* ID of the next header or leave next at PAYLOAD_ID which will force the
* JHeaderScanner that called this @Scanner method to also check the reverse
* bindings. If you set the next_id to anything other than PAYLOAD or
* JScan.END_OF_HEADERS_ID, that id will be used as the next protocol in the
* header (another iteration of the loop will make it the current id)
*/
// scan.scan_id(id);
// scan.scan_next_id(next_id);
}