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


Java PcapPacket.hasHeader方法代码示例

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


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

示例1: testScanIpv6File

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * Printing to DEV_NULL still causes entire packet structure to be decoded and
 * dumped to /dev/null while using every available header found in the packet.
 * Good stress test for Ip6 based packets.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void testScanIpv6File() throws IOException {
	TextFormatter out = new TextFormatter(OUT);
	out.setResolveAddresses(false);

	int i = 0;
	Ethernet eth = new Ethernet();
	for (PcapPacket packet : TestUtils.getIterable("tests/test-ipv6.pcap")) {

		System.out.println(packet.toDebugString());
		if (packet.hasHeader(eth)) {
			out.format(eth);
		}

		out.setFrameIndex(i++);
		out.format(packet);
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:26,代码来源:TestIpv6.java

示例2: meetCriteria

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
@Override
public Boolean meetCriteria(PcapPacket itemToCheck)
{
	if (!itemToCheck.hasHeader(Ip4.ID))
		return false;
	
	Ip4 ipHeader = new Ip4();
	ipHeader = itemToCheck.getHeader(ipHeader);
	
	if (direction == null) //direction wasn't set, so any direction
		return subnetInfo.isInRange(ipHeader.sourceToInt()) || subnetInfo.isInRange(ipHeader.destinationToInt());
	
	switch(direction)
	{
		case Incoming:	return subnetInfo.isInRange(ipHeader.sourceToInt());
		case Outgoing:	return subnetInfo.isInRange(ipHeader.destinationToInt());
		default:		return null; //doesn't get here
	}
}
 
开发者ID:ck3ck3,项目名称:WhoWhatWhere,代码行数:20,代码来源:CriteriaIP.java

示例3: meetCriteria

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
@Override
public Boolean meetCriteria(PcapPacket itemToCheck)
{
	if (!itemToCheck.hasHeader(Ethernet.ID))
		return false;

	Ethernet eth = new Ethernet();
	eth = itemToCheck.getHeader(eth);

	switch (direction)
	{
		case Incoming:
			return Arrays.equals(ownMAC, eth.destination());
		case Outgoing:
			return Arrays.equals(ownMAC, eth.source());
		default:
			return false; //doesn't get here
	}
}
 
开发者ID:ck3ck3,项目名称:WhoWhatWhere,代码行数:20,代码来源:CriteriaPacketDirection.java

示例4: testSip

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * Test sip.
 */
public void testSip() {
	Sip sip = new Sip();
	Sdp sdp = new Sdp();
	PcapPacket packet = super.getPcapPacket(SIP, 223 - 1);
	if (packet.hasHeader(sip)) {
		System.out.printf("%s", sip);

		if (packet.hasHeader(sdp)) {
			System.out.printf("%s", sdp);

		}
	} else {
		System.out.printf(packet.toString());
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:19,代码来源:TestVoip.java

示例5: SKIP_testReadEntireSuspectFile

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * SKI p_test read entire suspect file.
 */
public void SKIP_testReadEntireSuspectFile() {

	Ip4 ip = new Ip4();
	for (PcapPacket packet : TestUtils.getIterable(BUG_FILE)) {
		try {
			if (packet.getFrameNumber() == 15) {
				System.out.println(packet);
				System.out.println(packet
				    .toHexdump(packet.size(), false, false, true));
			}

			packet.hasHeader(ip);
		} catch (NullPointerException e) {
			System.out.println(packet.getState().toDebugString());
			System.out.println(packet.toHexdump());

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

示例6: handle

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * pseudonymizes the packet according to the settings and stored the
 *
 * @param packet the captured PcapPacket
 */
@Override
public void handle(PcapPacket packet) {
    // Determine if the packet is an ethernet packet first.
    if (packet.hasHeader(Ethernet.ID)){
        _packetModifier.modifyPacket(packet);
        _pseudoDumper.dump(packet);
    }
    else {
        // TODO PEF-77: don't send or nullify the packet.
        logger.warning("Non-ethernet packet found, packet is left untouched.");
    }
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:18,代码来源:JNetPcapPseudonymizeDumper.java

示例7: converge

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * 将数据包汇聚成网络流
 * @param data
 */
private void converge(List<PacketInfo> data) {
    for (PacketInfo packetInfo : data) {
        PcapPacket packet = packetInfo.getPacket();
        Ip4 ip4 = new Ip4();
        Tcp tcp = new Tcp();

        if (!packet.hasHeader(ip4) || !packet.hasHeader(tcp)) continue;

        NetFlow netFlow = find(packetInfo);
        if (tcp.flags_SYN()) {      // SYN 作为TCP建立连接的标识,创建网络流
            if (netFlow == null) {
                netFlow = new NetFlow(ip4.sourceToInt(), ip4.destinationToInt(),
                        tcp.source(), tcp.destination());
                netFlow.add(packetInfo);
                netFlows.add(netFlow);
            }
        } else if (tcp.flags_FIN()) {
            if (netFlow != null) {
                netFlow.setClosed(true);        // FIN作为TCP结束标识,关闭网络流
            }
        } else {                    // 加入到已存在的网络流中
            if (netFlow != null && !netFlow.isClosed()) {
                netFlow.add(packetInfo);
            }
        }
    }
}
 
开发者ID:whinc,项目名称:PcapAnalyzer,代码行数:32,代码来源:ClusterModule.java

示例8: contain

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * 判断数据包是否属于当前网络流
 * @param packetInfo
 * @return
 */
public boolean contain(PacketInfo packetInfo) {
    boolean b = false;

    PcapPacket packet = packetInfo.getPacket();
    Tcp tcp = new Tcp();
    Ip4 ip4 = new Ip4();
    if (packet.hasHeader(ip4)
            && packet.hasHeader(tcp) ) {
        if (ip4.sourceToInt() == srcIp
                && ip4.destinationToInt() == dstIp
                && tcp.source() == srcPort
                && tcp.destination() == dstPort) {
            packetInfo.setReversed(false);
            b = true;
        } else if (ip4.sourceToInt() == dstIp
                && ip4.destinationToInt() == srcIp
                && tcp.source() == dstPort
                && tcp.destination() == srcPort) {
            packetInfo.setReversed(true);
            b = true;
        }
    }
    return b;
}
 
开发者ID:whinc,项目名称:PcapAnalyzer,代码行数:30,代码来源:NetFlow.java

示例9: nextPacket

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
@Override
public void nextPacket(PcapPacket packet, Void nothing)
{
	if (isFirstPacket)
	{
		if (captureStartListener != null) //notify on first packet captured
			captureStartListener.captureStartedNotification();
	
		isFirstPacket = false;
	}
	
	if (packet.hasHeader(Ip4.ID) && (protocolsToCount.isEmpty() || isSelectedProtocol(packet))) //only if there's an IP layer, and if any filter is selected, filter it 
	{
		Ip4 ipHeader = new Ip4();
		ipHeader = packet.getHeader(ipHeader);

		int sourceInt = ipHeader.sourceToInt();
		int destInt = ipHeader.destinationToInt();

		int key;

		if (ownIpInt == sourceInt)
			key = destInt;
		else
			if (ownIpInt == destInt)
				key = sourceInt;
			else //not relevant to us
				return;

		Integer repeats = ipToAmountOfRepeats.get(key);

		if (repeats == null) //first time we see this ip
			ipToAmountOfRepeats.put(key, 1);
		else
			ipToAmountOfRepeats.put(key, repeats + 1);
	}
}
 
开发者ID:ck3ck3,项目名称:WhoWhatWhere,代码行数:38,代码来源:AppearanceCounterPacketHandler.java

示例10: isSelectedProtocol

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
private boolean isSelectedProtocol(PcapPacket packet)
{
	for (Integer protocolId : protocolsToCount)
		if (packet.hasHeader(protocolId))
			return true;

	return false;
}
 
开发者ID:ck3ck3,项目名称:WhoWhatWhere,代码行数:9,代码来源:AppearanceCounterPacketHandler.java

示例11: testHttpFormattingWithResolveAddressDisabled

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * Test http formatting with resolve address disabled.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void testHttpFormattingWithResolveAddressDisabled() throws IOException {
	JFormatter out = new TextFormatter(OUT);
	out.setResolveAddresses(false);

	PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

	Ip4 ip = new Ip4();
	Ethernet eth = new Ethernet();
	if (packet.hasHeader(eth)) {
		out.format(eth);
	}
	if (packet.hasHeader(ip)) {
		out.format(ip);
		out.format(ip);
	}

	out.format(packet);

	Html html = new Html();
	assertTrue("html header not found", packet.hasHeader(html));
	System.out.printf("link related tags=%s\n", Arrays.asList(html.links())
	    .toString());

	// if (true && packet.hasHeader(http)) {
	//
	// for (String e : http.fieldArray()) {
	// System.out.println(e);
	// }
	// }
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:37,代码来源:TestHttp.java

示例12: testHttpFormattingWithResolveAddressEnabled

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * Test http formatting with resolve address enabled.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
public void testHttpFormattingWithResolveAddressEnabled() throws IOException {
	JLogger.getLogger(JConfig.class).setLevel(Level.FINE);

	JLogger.getLogger(Resolver.class.getPackage()).setLevel(Level.FINER);

	JFormatter out = new TextFormatter(OUT);
	out.setResolveAddresses(true);

	PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

	Ip4 ip = new Ip4();
	Ethernet eth = new Ethernet();
	if (packet.hasHeader(eth)) {
		out.format(eth);
	}
	if (packet.hasHeader(ip)) {
		// out.format(ip);
		out.format(ip);
		System.out.println();
	}

	// out.format(packet);

	// if (true && packet.hasHeader(http)) {
	// Map<String, Http.Entry> map = http.headerFields();
	//
	// for (Entry e : map.values()) {
	// System.out.println(e.toString());
	// }
	// }

	JRegistry.shutdown();
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:40,代码来源:TestHttp.java

示例13: transp

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
public void transp() {
	
	try {
		
		// jNetPcap �ʱ�ȭ
		Pcap pcap = packetInit(btn_start);
		
		// ��Ŷ �̺�Ʈ �ڵ鷯
		PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
			
			public void nextPacket(PcapPacket packet, String user) {

				Ip4 ip = new Ip4();
				byte[] dIP = new byte[4], sIP = new byte[4];

				if (packet.hasHeader(ip)) {
					dIP = packet.getHeader(ip).destination();
					sIP = packet.getHeader(ip).source();
				} else {
					return;
				}
				
				// ����� IP
				String sourceIP = org.jnetpcap.packet.format.FormatUtils.ip(sIP);
				
				// ������ IP
				String destinationIP = org.jnetpcap.packet.format.FormatUtils.ip(dIP);
				
				/**
				 *  <pre>
				 *       << �������� >>
				 *       - ��� ��쿡���� ���� ��(��Ƽ or �δ�) ���� ������ �Է��� �޼��� ��Ŷ ������ �ݵ�� �޴´�.
				 *       - ���� ������ �޼��� ��Ŷ�� ������ ���α׷��� ���� �ִٸ� ���� ��(��Ƽor�δ�)������ �ݵ�� ������ ���޹޴´�.
				 *       - ���� Ȯ������ ������ ij���� ���� �����ϴ� ���� IP�� �� ���ڸ��� �ٸ��� �ϴ�.
				 *       - �������� 37�̰�, �����Ҵ� 39, ��ij�� 38�̴� ��Ȯ�� ��Ģ�� �˱Ⱑ ��ƴ�.
				 *  </pre>
				 */
				
				// ��Ŷ ������ �ν��Ͻ�
				PacketSniffing sniiffer = new PacketSniffing(txtMsg);

				// Ŭ�� -> ����
				sniiffer.sendPacketToServer(packet, sourceIP, destinationIP);
				
				// ���� -> Ŭ��
				sniiffer.receivePacketToClient(packet, sourceIP, destinationIP);

			}

		};
		
		// �ǽð����� ��Ŷ�� �����´�.
		pcap.loop(-1, jpacketHandler, "jNetPcap rocks!");
		pcap.close();
		
	} catch (Exception e) {
		System.out.println(e.getMessage());
	}
	
}
 
开发者ID:kimyearho,项目名称:FF14_ScraperChat,代码行数:61,代码来源:PacketSniffer.java

示例14: meetCriteria

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
@Override
public Boolean meetCriteria(PcapPacket itemToCheck)
{
	return itemToCheck.hasHeader(protocol.getValue());
}
 
开发者ID:ck3ck3,项目名称:WhoWhatWhere,代码行数:6,代码来源:CriteriaProtocol.java


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