Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

HeaderF
Class IPHeader  view IPHeader download IPHeader.java

java.lang.Object
  extended byHeaderF.Header
      extended byHeaderF.IPHeader

public class IPHeader
extends Header


Field Summary
private  boolean contains_icmp
           
private  boolean contains_igmp
           
private  boolean contains_pimv2
           
private  boolean contains_tcp
           
private  boolean contains_udp
           
private  int datasize
           
private  long dest
           
static int DONT_FRAGMENT
           
private  java.lang.String feedback
           
private  int fragment_flags
           
private  int hchecksum
           
private  int header_length
           
private  int headerlen
           
static int ICMP_PROTOCOL
           
private  int id
           
static int IGMP_PROTOCOL
           
static int MORE_FRAGMENTS
           
private  int offset
           
private  Misc.MultiByte options
           
private  int payloadlen
           
private  int protocol
           
private  java.lang.String ptcol
           
private  int servicetype
           
private  long source
           
static int TCP_PROTOCOL
           
private  int timetolive
           
private  int total_length
           
static int UDP_PROTOCOL
           
private  int version
           
 
Constructor Summary
IPHeader(java.io.BufferedInputStream src, Misc.Counter ct)
          Creates a new instance of IPHeader
IPHeader(int protocol, int total_length)
          creates a new instance of IPHeader - default
 
Method Summary
 void calculateChecksum()
          Calculate IP checksum from Stevens, 1990
 boolean containsICMP()
           
 boolean containsIGMP()
           
 boolean containsPIMv2()
           
 boolean containsTCP()
           
 boolean containsUDP()
           
 java.lang.String getChecksum()
          Returns the header checksum
 int getFragmentFlags()
          Returns the fragment flags
 int getFragmentOffset()
          Returns the fragment offset
 int getHeaderLength()
          Returns the header length
 int getId()
          Returns the id
 javax.swing.tree.DefaultMutableTreeNode getInfoTree()
           
 java.lang.String getIPDest()
          method to retrieve the IP Dest address
 java.lang.String getIPSource()
          method to retrieve the IP Source address
 int getLength()
          Returns the total length
 java.lang.String getProtocol()
          Returns the protocol that is encapsulated
 int getTimeToLive()
          Returns the time to live
 int getTypeOfService()
          Returns the type of service
 int getVersion()
          Returns the ip version
private  java.lang.String ipHexToString(long ipaddress)
          auxiliary method to convert an hexadecimal ip address into the text form
static boolean isIP(java.io.BufferedInputStream src, Misc.Counter ct)
           
 void setChecksum(int hchecksum)
          Sets the header checksum
 void setDestIP(long dest)
          Sets the destination ip address
 void setFragmentFlags(int fragment_flags)
          Sets the fragment flags
 void setFragmentOffset(int offset)
          Sets the fragment offset
 void setHeaderLength(int header_length)
          Sets the header length
 void setId(int id)
          Sets the id
 void setProtocol(int protocol)
          Sets the protocol that is encapsulated
 void setSourceIP(long source)
          Sets the source ip address
 void setTimeToLive(int timetolive)
          Sets the time to live
 void setTotalLength(int total_length)
          Sets the total length
 void setTypeOfService(int servicetype)
          Sets the type of service
 void setVersion(int version)
          sets the ip version
 byte[] toByteArray()
          writes the ip header to an array of bytes toByteArray()
 java.lang.String toString()
          Generate string with contents describing this IP packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UDP_PROTOCOL

public static final int UDP_PROTOCOL
See Also:
Constant Field Values

TCP_PROTOCOL

public static final int TCP_PROTOCOL
See Also:
Constant Field Values

ICMP_PROTOCOL

public static final int ICMP_PROTOCOL
See Also:
Constant Field Values

IGMP_PROTOCOL

public static final int IGMP_PROTOCOL
See Also:
Constant Field Values

DONT_FRAGMENT

public static final int DONT_FRAGMENT
See Also:
Constant Field Values

MORE_FRAGMENTS

public static final int MORE_FRAGMENTS
See Also:
Constant Field Values

contains_icmp

private boolean contains_icmp

contains_igmp

private boolean contains_igmp

contains_tcp

private boolean contains_tcp

contains_udp

private boolean contains_udp

contains_pimv2

private boolean contains_pimv2

version

private int version

servicetype

private int servicetype

total_length

private int total_length

header_length

private int header_length

id

private int id

fragment_flags

private int fragment_flags

offset

private int offset

timetolive

private int timetolive

protocol

private int protocol

hchecksum

private int hchecksum

source

private long source

dest

private long dest

options

private Misc.MultiByte options

payloadlen

private int payloadlen

headerlen

private int headerlen

datasize

private int datasize

ptcol

private java.lang.String ptcol

feedback

private java.lang.String feedback
Constructor Detail

IPHeader

public IPHeader(int protocol,
                int total_length)
creates a new instance of IPHeader - default


IPHeader

public IPHeader(java.io.BufferedInputStream src,
                Misc.Counter ct)
         throws java.io.IOException,
                Exceptions.InvalidTcpdumpFileException
Creates a new instance of IPHeader

Method Detail

containsICMP

public boolean containsICMP()

containsIGMP

public boolean containsIGMP()

containsTCP

public boolean containsTCP()

containsUDP

public boolean containsUDP()

containsPIMv2

public boolean containsPIMv2()

getIPSource

public java.lang.String getIPSource()
method to retrieve the IP Source address


getIPDest

public java.lang.String getIPDest()
method to retrieve the IP Dest address


setSourceIP

public void setSourceIP(long source)
Sets the source ip address


setDestIP

public void setDestIP(long dest)
Sets the destination ip address


ipHexToString

private java.lang.String ipHexToString(long ipaddress)
auxiliary method to convert an hexadecimal ip address into the text form


isIP

public static boolean isIP(java.io.BufferedInputStream src,
                           Misc.Counter ct)
                    throws java.io.IOException

toString

public java.lang.String toString()
Generate string with contents describing this IP packet.


getInfoTree

public javax.swing.tree.DefaultMutableTreeNode getInfoTree()

getVersion

public int getVersion()
Returns the ip version


setVersion

public void setVersion(int version)
sets the ip version


getHeaderLength

public int getHeaderLength()
Returns the header length


setHeaderLength

public void setHeaderLength(int header_length)
Sets the header length


getTypeOfService

public int getTypeOfService()
Returns the type of service


setTypeOfService

public void setTypeOfService(int servicetype)
Sets the type of service


getLength

public int getLength()
Returns the total length


setTotalLength

public void setTotalLength(int total_length)
Sets the total length


getId

public int getId()
Returns the id


setId

public void setId(int id)
Sets the id


getProtocol

public java.lang.String getProtocol()
Returns the protocol that is encapsulated


setProtocol

public void setProtocol(int protocol)
Sets the protocol that is encapsulated


getChecksum

public java.lang.String getChecksum()
Returns the header checksum


setChecksum

public void setChecksum(int hchecksum)
Sets the header checksum


calculateChecksum

public void calculateChecksum()
Calculate IP checksum from Stevens, 1990


getFragmentFlags

public int getFragmentFlags()
Returns the fragment flags


setFragmentFlags

public void setFragmentFlags(int fragment_flags)
Sets the fragment flags


getFragmentOffset

public int getFragmentOffset()
Returns the fragment offset


setFragmentOffset

public void setFragmentOffset(int offset)
Sets the fragment offset


getTimeToLive

public int getTimeToLive()
Returns the time to live


setTimeToLive

public void setTimeToLive(int timetolive)
Sets the time to live


toByteArray

public byte[] toByteArray()
                   throws java.io.IOException
writes the ip header to an array of bytes toByteArray()