Return string containing ppp() printout for a capture. :param headline: printed as first line of output :param capture: packets to print :param limit: limit the print to # of packets
(headline, capture, limit=10)
| 90 | |
| 91 | |
| 92 | def ppc(headline, capture, limit=10): |
| 93 | """Return string containing ppp() printout for a capture. |
| 94 | |
| 95 | :param headline: printed as first line of output |
| 96 | :param capture: packets to print |
| 97 | :param limit: limit the print to # of packets |
| 98 | """ |
| 99 | if not capture: |
| 100 | return headline |
| 101 | tail = "" |
| 102 | if limit < len(capture): |
| 103 | tail = "\nPrint limit reached, %s out of %s packets printed" % ( |
| 104 | limit, |
| 105 | len(capture), |
| 106 | ) |
| 107 | body = "".join( |
| 108 | [ |
| 109 | str(ppp("Packet #%s:" % count, p)) |
| 110 | for count, p in zip(range(0, limit), capture) |
| 111 | ] |
| 112 | ) |
| 113 | return "%s\n%s%s" % (headline, body, tail) |
| 114 | |
| 115 | |
| 116 | def ip4_range(ip4, s, e): |