Skip to content

Commit 5f6c2af

Browse files
authored
Merge pull request #1 from puddly/puddly/fix-pcap-fcs
Add tool to recalculate PCAP frame checksums
2 parents 46d201b + 76113e6 commit 5f6c2af

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,13 @@ $ zigpy ota dump-firmware 10047227-1.2-TRADFRI-cv-cct-unified-2.3.050.ota.ota.si
8585
| grep 'Ember Version'
8686
Ember Version: 6.3.1.1
8787
```
88+
89+
90+
# PCAP
91+
Re-calculate the FCS on a packet capture due to a bug in current EmberZNet SDK releases:
92+
```console
93+
$ # Fix an existing capture
94+
$ zigpy pcap fix-fcs input.pcap fixed.pcap
95+
$ # Fix a capture from stdin and send it to stdout
96+
$ bellows -d /dev/cu.GoControl_zigbee dump -w /dev/stdout | zigpy pcap fix-fcs - - | wireshark -k -S -i -
97+
```

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"zigpy",
2222
"click",
2323
"coloredlogs",
24+
"scapy",
2425
],
2526
extras_require={
2627
# [all] pulls in all radio libraries

zigpy_cli/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import zigpy_cli.ota # noqa: F401
2+
import zigpy_cli.pcap # noqa: F401
23
import zigpy_cli.radio # noqa: F401
34
from zigpy_cli.cli import cli # noqa: F401

zigpy_cli/pcap.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import annotations
2+
3+
import logging
4+
5+
import click
6+
from scapy.utils import PcapReader, PcapWriter
7+
from scapy.config import conf as scapy_conf
8+
from scapy.layers.dot15d4 import Dot15d4 # NOQA: F401
9+
10+
from zigpy_cli.cli import cli
11+
12+
scapy_conf.dot15d4_protocol = "zigbee"
13+
14+
LOGGER = logging.getLogger(__name__)
15+
16+
17+
@cli.group()
18+
def pcap():
19+
pass
20+
21+
22+
@pcap.command()
23+
@click.argument("input", type=click.File("rb"))
24+
@click.argument("output", type=click.File("wb"))
25+
def fix_fcs(input, output):
26+
reader = PcapReader(input.raw)
27+
writer = PcapWriter(output.raw)
28+
29+
for packet in reader:
30+
packet.fcs = None
31+
writer.write(packet)

0 commit comments

Comments
 (0)