3 from abc import abstractmethod, ABCMeta
4 from cStringIO import StringIO
7 def ppp(headline, packet):
8 """ Return string containing the output of scapy packet.show() call. """
10 old_stdout = sys.stdout
14 sys.stdout = old_stdout
18 def ppc(headline, capture, limit=10):
19 """ Return string containing ppp() printout for a capture.
21 :param headline: printed as first line of output
22 :param capture: packets to print
23 :param limit: limit the print to # of packets
27 result = headline + "\n"
30 result.append(ppp("Packet #%s:" % count, p))
34 if limit < len(capture):
36 "Capture contains %s packets in total, of which %s were printed" %
37 (len(capture), limit))
40 class NumericConstant(object):
41 __metaclass__ = ABCMeta
46 def __init__(self, value):
56 if self._value in self.desc_dict:
57 return self.desc_dict[self._value]
62 """ Generic test host "connected" to VPPs interface. """
77 return socket.inet_pton(socket.AF_INET, self._ip4)
84 def __init__(self, mac=None, ip4=None, ip6=None):