'Analyze a list of packets for interesting traffic when the host is
unknown.'

def _analyze_packets_no_host(self, packets):

    from scapy.all import get_if_addr
    from scapy.all import IP
    from scapy.all import TCP
    from scapy.all import UDP
    possible_packets = []
    possible_hosts = {}
    good_ports = []
    good_hosts = []
    for p in packets:
        if (p.haslayer(TCP) and (p[TCP].dport in self._tcp_ports) and (p[IP].dst in get_if_addr(self._iface)) and (p[TCP].flags == 2)):
            possible_packets.append(p)
            if (p[IP].src in possible_hosts):
                possible_hosts[p[IP].src] += 1
            else:
                possible_hosts[p[IP].src] = 1
        if (p.haslayer(UDP) and (p[UDP].dport in self._udp_ports) and (p[IP].dst in get_if_addr(self._iface))):
            possible_packets.append(p)
            if (p[IP].src in possible_hosts):
                possible_hosts[p[IP].src] += 1
            else:
                possible_hosts[p[IP].src] = 1
    for p in possible_packets:
        om.out.debug(('[extrusionServer]    Possible    packet:    ' + p.summary()))
    def sortfunc(x, y):
        return cmp(x[1], y[1])
    items = possible_hosts.items()
    items.sort(sortfunc)
    i = 0
    while ((i < len(items)) and (items[0][1] == items[i][1])):
        good_hosts.append(items[i][0])
        i += 1
    for p in possible_packets:
        if (p[IP].src in good_hosts):
            if p.haslayer(TCP):
                _tuple = (p[IP].src, p[TCP].dport, 'TCP')
                if (_tuple not in good_ports):
                    good_ports.append(_tuple)
                    om.out.debug(('[extrusionServer]    Adding    ' + str(_tuple)))
            if p.haslayer(UDP):
                _tuple = (p[IP].src, p[UDP].dport, 'UDP')
                if (_tuple not in good_ports):
                    good_ports.append(_tuple)
                    om.out.debug(('[extrusionServer]    Adding    ' + str(_tuple)))
    return good_ports
