📄 jpcap.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Sep 14 11:15:58 JST 2000 --><TITLE>: Class Jpcap</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../jpcap/IPv6Option.html"><B>PREV CLASS</B></A> <A HREF="../jpcap/Jpcap.JpcapInfo.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Jpcap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">jpcap</FONT><BR>Class Jpcap</H2><PRE>java.lang.Object | +--<B>jpcap.Jpcap</B></PRE><HR><DL><DT>public class <B>Jpcap</B><DT>extends java.lang.Object</DL><P>Main class of package jpcap.<BR> Capturing and Sending packets are done through the instance of this class.<P> Sample tcpdump-like capturing program.<BR> <PRE> import jpcap.*; class Tcpdump implements JpcapHandler { public void handlePacket(Packet packet){ System.out.println(packet); } public static void main(String[] args) throws java.io.IOException{ Jpcap jpcap=new Jpcap(args[0],1000,true,20); jpcap.processPacket(-1,new Tcpdump()); } } </PRE><P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> class</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.JpcapInfo.html">Jpcap.JpcapInfo</A></B></CODE><BR> Class for keeping capture info.</TD></TR></TABLE> <!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#dropped_packets">dropped_packets</A></B></CODE><BR> Number of packets dropped</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#received_packets">received_packets</A></B></CODE><BR> Number of packets received</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../jpcap/Jpcap.html#Jpcap(java.lang.String)">Jpcap</A></B>(java.lang.String filename)</CODE><BR> Opens the dump file created by tcpdump and creates the instance of this class.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../jpcap/Jpcap.html#Jpcap(java.lang.String, int, boolean, int)">Jpcap</A></B>(java.lang.String device, int snaplen, boolean promisc, int to_ms)</CODE><BR> Initializes the specified network interface and creates the instance of this class.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#close()">close</A></B>()</CODE><BR> Close the interface or dump file which is currently opened.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#getErrorMessage()">getErrorMessage</A></B>()</CODE><BR> Returns the error message which was caused by the error while capturing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../jpcap/Jpcap.JpcapInfo.html">Jpcap.JpcapInfo</A></CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#getJpcapInfo()">getJpcapInfo</A></B>()</CODE><BR> Return JpcapInfo of this Jpcap instance.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../jpcap/Packet.html">Packet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#getPacket()">getPacket</A></B>()</CODE><BR> Captures one packet.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#lookupDevice()">lookupDevice</A></B>()</CODE><BR> Returns the name of the device which can be used for capturing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#openRawSocket()">openRawSocket</A></B>()</CODE><BR> Initializes the sending socket.<BR> This method must be called before sending packets.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#processPacket(int, jpcap.JpcapHandler)">processPacket</A></B>(int count, <A HREF="../jpcap/JpcapHandler.html">JpcapHandler</A> handler)</CODE><BR> Captures the specified number of packets consecutively.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#sendPacket(jpcap.IPPacket)">sendPacket</A></B>(<A HREF="../jpcap/IPPacket.html">IPPacket</A> packet)</CODE><BR> Sends a IP packet.<BR> <BR> Currently only TCP/UDP/ICMP over IPv4 are supported.<BR> For ICMP, only echo packets can be sent.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../jpcap/Jpcap.html#setFilter(java.lang.String, boolean)">setFilter</A></B>(java.lang.String condition, boolean optimize)</CODE><BR> Sets up the capturing filter.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -