objects.gui.traceDisplayDialog.traceDisplayDialog Class Reference

Code generated by "Boa Constructor". More...

List of all members.

Public Member Functions

def __init__
def initControlsFromResultSet
 This method will display a ResultSet as a viewable list onto the window.
def OnListCtrlPacketsListItemDeselected
 Not implemented.
def OnListCtrlPacketsListItemSelected
 This handler is called whenever a packet is selected from the "Packet List".
def displayProtocolStack
 Updates the "Protocol Stack" window in response to a change in the "Packet List" control.
def displayIPHeader
 Helper function used to display the details of the IP Header.
def displayTCPHeader
 Helper function used to display the details of the TCP Header.
def displayUDPHeader
 Helper function used to display the details of the UDP Header.
def displayICMPHeader
 Helper function used to display the details of the ICMP Header.
def displayIGMPHeader
 Helper function used to display the details of the IGMP Header.
def displayPayload
 Displays the application payload as a String.

Public Attributes

 listCtrlPackets
 treeCtrlProtStack
 staticTextData
 staticTextProtStack
 staticTextPacketList
 richTextCtrlPayloadTxt
 richTextCtrlPayloadHex
 staticTextPacketText
 packetDict
 treeFrameRoot


Detailed Description

Code generated by "Boa Constructor".

This class should be edited using the Boa Constructor IDE. Minimal inline documentation will be provided for this class as it may interfere with the automatic code generation.

The traceDisplayDialog class represents the applications's 'Display Trace' window.

Definition at line 53 of file traceDisplayDialog.py.


Member Function Documentation

def objects.gui.traceDisplayDialog.traceDisplayDialog.__init__ (   self,
  parent,
  foreignIP,
  srcPort,
  dstPort 
)

Definition at line 163 of file traceDisplayDialog.py.

00163                                                            :
00164         self._init_ctrls(parent)
00165         
00166         self.packetDict = dict()
00167         storageImpl = sqlite3Impl(globalStrings.traceStoragePath)
00168         storageImpl.open()
00169         
00170         try:
00171             resultset = storageImpl.query(foreignIP, srcPort, dstPort)
00172         except Exception, ex:
00173             strErr = "Could not retrieve trace information: %s" % str(ex)
00174             dlg = wx.MessageDialog(None, strErr, 'Error', wx.ICON_ERROR)
00175             result = dlg.ShowModal()
00176             dlg.Destroy()
00177         else:
00178             self.initControlsFromResultSet(resultset)
00179         finally:
00180             storageImpl.close()
00181             #relinquish memory right away
00182             del resultset
00183             
    ## This method will display a ResultSet as a viewable list onto the window

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayICMPHeader (   self,
  xptHdr 
)

Helper function used to display the details of the ICMP Header.

Parameters:
xptHdr Raw Transport Header

Definition at line 424 of file traceDisplayDialog.py.

00424                                        :
00425         ICMPHeader = ICMP(xptHdr)
00426         
00427         type         = "Type: %s" % ICMPHeader.get_type_name(ICMPHeader.get_icmp_type())
00428         code         = "Code: %s" % ICMPHeader.get_code_name(ICMPHeader.get_icmp_type(), ICMPHeader.get_icmp_code())
00429         checksum     = "Checksum: %d" % ICMPHeader.get_icmp_cksum()        
00430         id           = "ID: %d" % ICMPHeader.get_icmp_id()
00431         sequence     = "Sequence: %d" % ICMPHeader.get_icmp_seq()
00432                 
00433         hdrString = "ICMP Header -- (%d bytes)" % ICMPHeader.get_header_size()
00434         
00435         xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, hdrString)
00436         
00437         self.treeCtrlProtStack.AppendItem(xportRoot, type)
00438         self.treeCtrlProtStack.AppendItem(xportRoot, code)
00439         self.treeCtrlProtStack.AppendItem(xportRoot, checksum)
00440         self.treeCtrlProtStack.AppendItem(xportRoot, id)
00441         self.treeCtrlProtStack.AppendItem(xportRoot, sequence)
00442         
00443     
    ## Helper function used to display the details of the IGMP Header

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayIGMPHeader (   self,
  xptHdr 
)

Helper function used to display the details of the IGMP Header.

Parameters:
xptHdr Raw Transport Header

Definition at line 446 of file traceDisplayDialog.py.

00446                                        :
00447         IGMPHeader = IGMP(xptHdr)
00448         
00449         type         = "Type: %s" % IGMPHeader.get_type_name(IGMPHeader.get_igmp_type())
00450         code         = "Code: %s" % IGMPHeader.get_igmp_code()
00451         checksum     = "Checksum: %d" % IGMPHeader.get_igmp_cksum()        
00452         groupAddr    = "Group Address: %s" % self.__IPnumToString(IGMPHeader.get_igmp_group())
00453         
00454                 
00455         hdrString = "IGMP Header -- (%d bytes)" % IGMPHeader.get_header_size()
00456         
00457         xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, hdrString)
00458         
00459         self.treeCtrlProtStack.AppendItem(xportRoot, type)
00460         self.treeCtrlProtStack.AppendItem(xportRoot, code)
00461         self.treeCtrlProtStack.AppendItem(xportRoot, checksum)
00462         self.treeCtrlProtStack.AppendItem(xportRoot, groupAddr)
00463         
00464     
00465     
    ## Formats a 32 Bit Decimal IP address as a string

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayIPHeader (   self,
  netHdr,
  xportProtocol 
)

Helper function used to display the details of the IP Header.

Parameters:
netHdr Raw IP Header
xportProtocol Raw UDP/TCP Packet

Definition at line 280 of file traceDisplayDialog.py.

00280                                                     :
00281         
00282         try:
00283             IPHeader = IP(netHdr)
00284         except ImpactPacketException, ex:
00285             logger.log(__name__ + ": Could not display IP packet. (bad IP packet) -- " + str(ex) )
00286             netRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "IP Header -- (Could not parse...)")
00287             return
00288             
00289         #display all various attributes
00290         ipv     = "IP Version: %d" % IPHeader.get_ip_v()
00291         ihl     = "Internet Header Length: %d Bytes" % (IPHeader.get_ip_hl() * 4)
00292         tos     = "Type of Service: %d" % IPHeader.get_ip_tos()
00293         totlen  = "Total Length: %d" % IPHeader.get_ip_len()
00294         ident   = "Identification: %d" % IPHeader.get_ip_id()
00295                     
00296         if IPHeader.get_ip_df() > 0:
00297             df = 1
00298         else:
00299             df = 0
00300             
00301         if IPHeader.get_ip_mf() > 0:
00302             mf = 1
00303         else:
00304             mf = 0
00305                                             
00306         flags   = "Flags: (DF:%d, MF:%d)" % (df, mf)
00307         fragoff = "Fragment Offset: %d" % IPHeader.get_ip_off()
00308         ttl     = "Time To Live: %d" % IPHeader.get_ip_ttl()
00309         prot    = "Protocol: %d (%s)" % (IPHeader.get_ip_p(), xportProtocol)
00310         check   = "Checksum: %d" % IPHeader.get_ip_sum() 
00311         srcip   = "Source IP: %s" % IPHeader.get_ip_src()
00312         dstip   = "Dest IP: %s" % IPHeader.get_ip_dst()
00313         
00314         IPhdrString = "IP Header -- (%d Bytes)" % (IPHeader.get_ip_hl() * 4)
00315         
00316         
00317         netRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, IPhdrString)
00318         
00319         
00320         self.treeCtrlProtStack.AppendItem(netRoot, ipv)
00321         self.treeCtrlProtStack.AppendItem(netRoot, ihl)
00322         self.treeCtrlProtStack.AppendItem(netRoot, tos)            
00323         self.treeCtrlProtStack.AppendItem(netRoot, totlen)
00324         self.treeCtrlProtStack.AppendItem(netRoot, ident)
00325         self.treeCtrlProtStack.AppendItem(netRoot, flags)
00326         self.treeCtrlProtStack.AppendItem(netRoot, fragoff)
00327         self.treeCtrlProtStack.AppendItem(netRoot, ttl)            
00328         self.treeCtrlProtStack.AppendItem(netRoot, prot)
00329         self.treeCtrlProtStack.AppendItem(netRoot, check)
00330         self.treeCtrlProtStack.AppendItem(netRoot, srcip)
00331         self.treeCtrlProtStack.AppendItem(netRoot, dstip)
00332         opt = self.treeCtrlProtStack.AppendItem(netRoot, "Options")
00333         self.treeCtrlProtStack.AppendItem(opt, "...")
00334                 
00335     
00336     
    ## Helper function used to display the details of the TCP Header

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayPayload (   self,
  payload 
)

Displays the application payload as a String.

Parameters:
payload Raw Payload data

Definition at line 483 of file traceDisplayDialog.py.

00483                                      :
00484         try:
00485             self.richTextCtrlPayloadTxt.WriteText(conversionUtil.removeNonASCIICharaters(payload, "."))
00486         except Exception, ex:
00487             print "could not encode text"
00488         
00489         self.richTextCtrlPayloadHex.WriteText(self.__toFormattedHex(payload))
00490     
00491     
    ## formats a string into a new formatted Hex like string.

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayProtocolStack (   self,
  inetp,
  xportp,
  netHdr,
  xptHdr 
)

Updates the "Protocol Stack" window in response to a change in the "Packet List" control.

Parameters:
inetp Raw IP Packet data
xportp Raw UDP/TCP Packet data
netHdr Raw IP Header
xptHdr Raw UDP/TCP Header

Definition at line 245 of file traceDisplayDialog.py.

00245                                                                  :
00246         self.treeCtrlProtStack.DeleteAllItems()
00247         packetDec = packetDecoder()
00248         
00249         # display protocol stack
00250         netProtocol = "%s" % packetDec.getNetProtocolString(inetp)
00251         xportProtocol = "%s" % packetDec.getXportProtocolString(xportp)
00252         
00253         self.treeFrameRoot = self.treeCtrlProtStack.AddRoot("Ethernet Frame")
00254         self.treeCtrlProtStack.Expand(self.treeFrameRoot)
00255         
00256         # first deal with the network layer
00257         if netProtocol == "IP":
00258             self.displayIPHeader(netHdr, xportProtocol)        
00259         else:
00260             netRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "Unknown Network Protocol")
00261             
00262         # now deal with the transport layer
00263         if xportProtocol == "TCP":
00264             self.displayTCPHeader(xptHdr)            
00265         elif xportProtocol == "UDP":
00266             self.displayUDPHeader(xptHdr)            
00267         elif xportProtocol == "ICMP":
00268             self.displayICMPHeader(xptHdr)
00269         elif xportProtocol == "IGMP":
00270             self.displayIGMPHeader(xptHdr)
00271         else:
00272             xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "Unknown Transport Protocol")
00273             
00274         self.treeCtrlProtStack.Expand(self.treeFrameRoot)
00275             
00276     
    ## Helper function used to display the details of the IP Header

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayTCPHeader (   self,
  xptHdr 
)

Helper function used to display the details of the TCP Header.

Parameters:
xptHdr Raw Transport Header

Definition at line 339 of file traceDisplayDialog.py.

00339                                       :
00340         
00341         try:
00342             TCPHeader = TCP(xptHdr)
00343         except ImpactPacketException, ex:
00344             logger.log(__name__ + ": Could not display TCP packet. (bad TCP packet) -- " + str(ex) )
00345             xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "TCP Header -- (Could not Parse)")
00346             return
00347         
00348         srcPort = "Src Port: %d" % TCPHeader.get_th_sport()
00349         dstPort = "Dst Port: %d" % TCPHeader.get_th_dport()
00350         seq     = "Sequence #: %d" % (TCPHeader.get_th_seq() % 4294967296)
00351         ack     = "Ack #: %d" % (TCPHeader.get_th_ack() % 4294967296)    
00352         hdrSize = "Header Size: %d Bytes" % TCPHeader.get_header_size()
00353         
00354         ##Options
00355         ctlURG = "URG: %d" % TCPHeader.get_URG()
00356         ctlACK = "ACK: %d" % TCPHeader.get_ACK()
00357         ctlPSH = "PSH: %d" % TCPHeader.get_PSH()
00358         ctlRST = "RST: %d" % TCPHeader.get_RST()
00359         ctlSYN = "SYN: %d" % TCPHeader.get_SYN()
00360         ctlFIN = "FIN: %d" % TCPHeader.get_FIN()
00361         
00362         window   = "Window: %d" % TCPHeader.get_th_win()
00363         checksum = "CheckSum: %d" % TCPHeader.get_th_sum()
00364         urp      = "Urgent Prt: %d" % TCPHeader.get_th_urp()        
00365         
00366         hdrString = "TCP Header -- (%d Bytes)" % TCPHeader.get_header_size()
00367         xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, hdrString)
00368         
00369         self.treeCtrlProtStack.AppendItem(xportRoot, srcPort)
00370         self.treeCtrlProtStack.AppendItem(xportRoot, dstPort)
00371         self.treeCtrlProtStack.AppendItem(xportRoot, seq)
00372         self.treeCtrlProtStack.AppendItem(xportRoot, ack)
00373         self.treeCtrlProtStack.AppendItem(xportRoot, hdrSize)
00374         ctrl = self.treeCtrlProtStack.AppendItem(xportRoot, "Control Flags")
00375         self.treeCtrlProtStack.AppendItem(ctrl, ctlURG)        
00376         self.treeCtrlProtStack.AppendItem(ctrl, ctlACK)
00377         self.treeCtrlProtStack.AppendItem(ctrl, ctlPSH)
00378         self.treeCtrlProtStack.AppendItem(ctrl, ctlRST)
00379         self.treeCtrlProtStack.AppendItem(ctrl, ctlSYN)
00380         self.treeCtrlProtStack.AppendItem(ctrl, ctlFIN)
00381         
00382         self.treeCtrlProtStack.AppendItem(xportRoot, window)
00383         self.treeCtrlProtStack.AppendItem(xportRoot, checksum)
00384         self.treeCtrlProtStack.AppendItem(xportRoot, urp)
00385         
00386         opts = self.treeCtrlProtStack.AppendItem(xportRoot, "Options")
00387         if (TCPHeader.get_header_size() > 20):            
00388             for opt in TCPHeader.get_options():
00389                 stropt = str(opt)
00390                 stropt = stropt.replace("\tTCP Option: ", "")
00391                 self.treeCtrlProtStack.AppendItem(opts, stropt)
00392         else:
00393             self.treeCtrlProtStack.AppendItem(opts, "None")
00394             
00395             
00396             
    ## Helper function used to display the details of the UDP Header

def objects.gui.traceDisplayDialog.traceDisplayDialog.displayUDPHeader (   self,
  xptHdr 
)

Helper function used to display the details of the UDP Header.

Parameters:
xptHdr Raw Transport Header

Definition at line 399 of file traceDisplayDialog.py.

00399                                       :
00400         
00401         try:
00402             UDPHeader = UDP(xptHdr)
00403         except ImpactPacketException, ex:
00404             logger.log(__name__ + ": Could not display UDP packet. (bad UDP packet) -- " + str(ex) )
00405             xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "UDP Header -- (Could not Parse)")
00406             return
00407                 
00408         
00409         srcPort      = "Src Port: %d" % UDPHeader.get_uh_sport()
00410         dstPort      = "Dst Port: %d" % UDPHeader.get_uh_dport()        
00411         datagramSize = "Datagram Size: %d Bytes" % UDPHeader.get_uh_ulen()
00412         checksum     = "Checksum: %d" % UDPHeader.get_uh_sum()
00413         
00414         xportRoot = self.treeCtrlProtStack.AppendItem(self.treeFrameRoot, "UDP Header -- (8 Bytes)")
00415         
00416         self.treeCtrlProtStack.AppendItem(xportRoot, srcPort)
00417         self.treeCtrlProtStack.AppendItem(xportRoot, dstPort)
00418         self.treeCtrlProtStack.AppendItem(xportRoot, datagramSize)
00419         self.treeCtrlProtStack.AppendItem(xportRoot, checksum)
00420     
00421     
    ## Helper function used to display the details of the ICMP Header

def objects.gui.traceDisplayDialog.traceDisplayDialog.initControlsFromResultSet (   self,
  resultset 
)

This method will display a ResultSet as a viewable list onto the window.

Parameters:
resultset list of Tuples retrieved from the sqlLite storage. Each Tuple comes in the form of (ts, srcip, dstip, srcprt, dstprt, inetp, xportp, netHdr, xptHdr, payload)

Definition at line 187 of file traceDisplayDialog.py.

00187                                                   :
00188         
00189         packetDec = packetDecoder()
00190         
00191         if resultset is not None:
00192             for ts, srcip, dstip, srcprt, dstprt, inetp, xportp, netHdr, xptHdr, payload in resultset:
00193                                                                                 
00194                 netHdrArr = array('B', netHdr)
00195                 xptHrdArr = array('B', xptHdr)
00196                 
00197                 infoString = self.__getInfo(netHdr, xportp, xptHdr)
00198                 
00199                 protocolString = "%s/%s" % (packetDec.getXportProtocolString(xportp), packetDec.getNetProtocolString(inetp))        
00200                 
00201                 index = self.listCtrlPackets.InsertStringItem(sys.maxint, timeUtil.formatDateTime(ts))
00202                 self.listCtrlPackets.SetStringItem(index, 1, srcip)
00203                 self.listCtrlPackets.SetStringItem(index, 2, dstip)
00204                 self.listCtrlPackets.SetStringItem(index, 3, str(srcprt))
00205                 self.listCtrlPackets.SetStringItem(index, 4, str(dstprt))
00206                 self.listCtrlPackets.SetStringItem(index, 5, protocolString)
00207                 self.listCtrlPackets.SetStringItem(index, 6, infoString)
00208                                 
00209                 
00210                 self.packetDict[index] = (srcprt, dstprt, inetp, xportp, netHdr, xptHdr, payload)        
00211 
00212 
00213 
    ## Not implemented

def objects.gui.traceDisplayDialog.traceDisplayDialog.OnListCtrlPacketsListItemDeselected (   self,
  event 
)

Not implemented.

Parameters:
event Standard wx.Button event

Definition at line 216 of file traceDisplayDialog.py.

00216                                                         :
00217         pass
00218 
00219 
    ## This handler is called whenever a packet is selected from the "Packet List".

def objects.gui.traceDisplayDialog.traceDisplayDialog.OnListCtrlPacketsListItemSelected (   self,
  event 
)

This handler is called whenever a packet is selected from the "Packet List".

It simply updates the other controls in the window (Protocol Stack, Payload (Hex), Payload (Text) )

Parameters:
event Standard event

Definition at line 223 of file traceDisplayDialog.py.

00223                                                       :
00224         # display the payload...
00225         item = event.GetItem()        
00226         srcprt, dstprt, inetp, xportp, netHdr, xptHdr, payload = self.packetDict[item.GetId()]
00227         
00228         self.displayProtocolStack(inetp, xportp, netHdr, xptHdr)
00229             
00230                 
00231         # display payload into window
00232         self.richTextCtrlPayloadTxt.Clear()
00233         self.richTextCtrlPayloadHex.Clear()
00234             
00235         if payload is not None:                                    
00236             self.displayPayload(payload)            
00237     
00238     
00239     
    ## Updates the "Protocol Stack" window in response to a change in the "Packet List" control.


Member Data Documentation

Definition at line 85 of file traceDisplayDialog.py.

Definition at line 166 of file traceDisplayDialog.py.

Definition at line 143 of file traceDisplayDialog.py.

Definition at line 132 of file traceDisplayDialog.py.

Definition at line 111 of file traceDisplayDialog.py.

Definition at line 125 of file traceDisplayDialog.py.

Definition at line 155 of file traceDisplayDialog.py.

Definition at line 118 of file traceDisplayDialog.py.

Definition at line 101 of file traceDisplayDialog.py.

Definition at line 253 of file traceDisplayDialog.py.


The documentation for this class was generated from the following file:

Generated on Mon Mar 30 00:26:33 2009 for EyeSpy by  doxygen 1.5.8