after looking at this some more, it's pretty clear that a different version of 
the icmp module was used for this code.   the following diff _kind of_ 
works...it still has a number of problems but at least the scanned systems that 
respond get discovered.

NOTE: Do not just apply this diff, do it by hand because the 'orig' isn't 
really 'orig'. :P


Code:

*** Ping.py.orig        2007-08-01 02:15:18.000000000 +0000
--- Ping.py.new 2007-08-01 03:39:49.000000000 +0000
***************
*** 78,83 ****
--- 78,84 ----
          self.tries = tries
          self.timeout = timeout
          self.chunkSize = chunkSize
+       ### this overflows the chr() function in icmp.py, need <256
          self.procId = os.getpid()
          self.jobqueue = {}
          self.pingsocket = None
***************
*** 136,148 ****
          """Take a pingjob and send an ICMP packet for it"""
          #### sockets with bad addresses fail
          try:
!             pkt = icmp.Packet(icmp.ICMP_ECHO, self.procId)
              pkt.seq = pingJob.sent
              pkt.data = self.pktdata
!             buf = pkt.assemble()
              pingJob.start = time.time()
              plog.debug("send icmp to '%s'", pingJob.ipaddr)
-             plog.error("send icmp to '%s'", pingJob.ipaddr)
              self.pingsocket.sendto(buf, (pingJob.ipaddr, 0))
              pingJob.sent += 1
              self.jobqueue[pingJob.ipaddr] = pingJob
--- 137,150 ----
          """Take a pingjob and send an ICMP packet for it"""
          #### sockets with bad addresses fail
          try:
!             ### '128' is an arbitrary number < 256 to satisfy the icmp module
!             ### the old self.procId overflowed the chr() function used
!             pkt = icmp.Echo(icmp.ICMP_ECHO, 128)
              pkt.seq = pingJob.sent
              pkt.data = self.pktdata
!             buf = icmp.assemble(pkt)
              pingJob.start = time.time()
              plog.debug("send icmp to '%s'", pingJob.ipaddr)
              self.pingsocket.sendto(buf, (pingJob.ipaddr, 0))
              pingJob.sent += 1
              self.jobqueue[pingJob.ipaddr] = pingJob
***************
*** 150,156 ****
          except Exception, e:
              pingJob.rtt = -1
              pingJob.message = "%s sendto error %s" % (pingJob.ipaddr, e)
-             print "%s sendto error %s" % (pingJob.ipaddr, e)
              if hasattr(self, "reportPingJob"):
                  self.reportPingJob(pingJob)

--- 152,157 ----
***************
*** 164,177 ****
                  ipreply = ip.disassemble(data)
                  icmppkt = icmp.disassemble(ipreply.data)
                  sip =  ipreply.src
!                 if (icmppkt.get_type() == icmp.ICMP_ECHOREPLY and
!                     icmppkt.get_code() == self.procId and 
self.jobqueue.has_key(sip)):
                      plog.debug("echo reply pkt %s %s", sip, icmppkt)
                      self.pingJobSucceed(self.jobqueue[sip])
                  elif icmppkt.get_type() == icmp.ICMP_UNREACH:
                      plog.debug("host unreachable pkt %s %s", sip, icmppkt)
                      try:
!                         origpkt = ip.disassemble(icmppkt.data)
                          origicmp = icmp.disassemble(origpkt.data)
                          dip = origpkt.dst
                          if (origicmp.data == self.pktdata
--- 165,182 ----
                  ipreply = ip.disassemble(data)
                  icmppkt = icmp.disassemble(ipreply.data)
                  sip =  ipreply.src
!                 if (icmppkt.get_type() == icmp.ICMP_ECHOREPLY):
!               ###Removing the following conditions make it possible
!               ###for spurious packets to be incorrectly recorded, but i
!               ###don't care about that right now...
!                 ###    icmppkt.get_code() == 128 and 
self.jobqueue.has_key(sip)):
                      plog.debug("echo reply pkt %s %s", sip, icmppkt)
                      self.pingJobSucceed(self.jobqueue[sip])
                  elif icmppkt.get_type() == icmp.ICMP_UNREACH:
                      plog.debug("host unreachable pkt %s %s", sip, icmppkt)
                      try:
!                         ##origpkt = ip.disassemble(icmppkt.data)
!                         origpkt = ip.disassemble(icmppkt.get_data())
                          origicmp = icmp.disassemble(origpkt.data)
                          dip = origpkt.dst
                          if (origicmp.data == self.pktdata





------------------------
 J Cims




-------------------- m2f --------------------

Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=9408#9408

-------------------- m2f --------------------



_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to