Пример #1
0
    def prettyprint(self):
        """
    Looks something like this:

CURRENT FLOW TABLE:                            okay  drop mod/frg pend t/rx prot
111.222.233.244:12345 > 244.233.222.211:78901 343004 10000 100001 1000/2331 icmp
(192.168.1.100:54343)   (192.168.33.212:2333) opening_hash: 
                      <                       
    """
        pub_src, pub_dest = map(s.inet_ntoa, self.m_tuple[0:2])
        o_hash = self.m_tuple[2]
        # the other side is the only reliable indicator of each side's
        # public port number
        try:
            pub_src += ":" + ` util.bin2int(self.dest_flow[1]) `
            pub_dest += ":" + ` util.bin2int(self.src_flow[3]) `
        except:
            log.error("Weird error caused by flow %s (%s, %s)" % (`self.flow`, \
                      `self.dest_flow`, `self.src_flow`))
            log.error(traceback.format_exc())

        line1 = pub_src.center(21) + " > " + pub_dest.center(21)

        # 19 = len("192.168.1.100:65535") -- this should be okay unless
        # the private addresses & ports are rather unusual
        priv_src = priv_dest = "not firewalled".center(19)
        if self.src_links[0][0].alice_firewalled:
            priv_src = self.src_links[0][0].peers_private_ip
            priv_src += ":" + ` util.bin2int(self.src_flow[1]) `
        if self.dest_links[0][0].alice_firewalled:  # here, alice means bob :)
            priv_dest = self.dest_links[0][0].peers_private_ip
            priv_dest += ":" + ` util.bin2int(self.dest_flow[3]) `

        line2 = "(%19s)   (%19s)" % (priv_src, priv_dest)

        line1+= " %6g %5g %6g %4g/%4g " % (self.okay_packets, self.dropped_packets,\
          self.forged_packets, len(self.sent_packets), len(self.recd_packets))
        line1 += util.prot_name(util.bin2int(self.flow[4]))
        return line1 + "\n" + line2
Пример #2
0
  def prettyprint(self):
    """
    Looks something like this:

CURRENT FLOW TABLE:                            okay  drop mod/frg pend t/rx prot
111.222.233.244:12345 > 244.233.222.211:78901 343004 10000 100001 1000/2331 icmp
(192.168.1.100:54343)   (192.168.33.212:2333) opening_hash: 
                      <                       
    """
    pub_src,pub_dest = map(s.inet_ntoa, self.m_tuple[0:2])
    o_hash = self.m_tuple[2]
    # the other side is the only reliable indicator of each side's
    # public port number
    try:
      pub_src += ":" + `util.bin2int(self.dest_flow[1])`
      pub_dest += ":" + `util.bin2int(self.src_flow[3])`
    except:
      log.error("Weird error caused by flow %s (%s, %s)" % (`self.flow`, \
                `self.dest_flow`, `self.src_flow`))
      log.error(traceback.format_exc())

    line1 = pub_src.center(21) + " > " + pub_dest.center(21)

    # 19 = len("192.168.1.100:65535") -- this should be okay unless
    # the private addresses & ports are rather unusual
    priv_src = priv_dest = "not firewalled".center(19)
    if self.src_links[0][0].alice_firewalled:
      priv_src = self.src_links[0][0].peers_private_ip
      priv_src += ":" + `util.bin2int(self.src_flow[1])`
    if self.dest_links[0][0].alice_firewalled: # here, alice means bob :)
      priv_dest = self.dest_links[0][0].peers_private_ip
      priv_dest += ":" + `util.bin2int(self.dest_flow[3])`

    line2 = "(%19s)   (%19s)" % (priv_src, priv_dest)

    line1+= " %6g %5g %6g %4g/%4g " % (self.okay_packets, self.dropped_packets,\
      self.forged_packets, len(self.sent_packets), len(self.recd_packets))
    line1 += util.prot_name(util.bin2int(self.flow[4]))
    return line1 + "\n" + line2
Пример #3
0
def print_flow_tuple(f):
    """Pretty print the raw binary flow."""

    return (s.inet_ntoa(f[0]),bin2int(f[1]), s.inet_ntoa(f[2]), bin2int(f[3]),\
           util.prot_name(bin2int(f[4])))
Пример #4
0
def print_flow_tuple(f):
    """Pretty print the raw binary flow."""

    return (s.inet_ntoa(f[0]),bin2int(f[1]), s.inet_ntoa(f[2]), bin2int(f[3]),\
           util.prot_name(bin2int(f[4])))
Пример #5
0
def parse_version(str):
    "Read a 32 bit binary string, return the int it encodes"
    assert (len(str) == 2), "length should be 2, not " + ` len(str) `
    # yuck!
    return util.bin2int(str)
Пример #6
0
def parse_version(str):
  "Read a 32 bit binary string, return the int it encodes"
  assert (len(str) == 2), "length should be 2, not " + `len(str)`
  # yuck!
  return util.bin2int(str)