Build a per byte hexadecimal representation Example: >>> chexdump(IP()) 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 :param p: a Packet :param dump: print the view if False :retu
(p, dump=False)
| 358 | |
| 359 | @conf.commands.register |
| 360 | def chexdump(p, dump=False): |
| 361 | # type: (Union[Packet, AnyStr], bool) -> Optional[str] |
| 362 | """Build a per byte hexadecimal representation |
| 363 | |
| 364 | Example: |
| 365 | >>> chexdump(IP()) |
| 366 | 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 |
| 367 | |
| 368 | :param p: a Packet |
| 369 | :param dump: print the view if False |
| 370 | :return: a String only if dump=True |
| 371 | """ |
| 372 | x = bytes_encode(p) |
| 373 | s = ", ".join("%#04x" % orb(x) for x in x) |
| 374 | if dump: |
| 375 | return s |
| 376 | else: |
| 377 | print(s) |
| 378 | return None |
| 379 | |
| 380 | |
| 381 | @conf.commands.register |
nothing calls this directly
no test coverage detected