Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,13 @@ $ zigpy ota dump-firmware 10047227-1.2-TRADFRI-cv-cct-unified-2.3.050.ota.ota.si
| grep 'Ember Version'
Ember Version: 6.3.1.1
```


# PCAP
Re-calculate the FCS on a packet capture due to a bug in current EmberZNet SDK releases:
```console
$ # Fix an existing capture
$ zigpy pcap fix-fcs input.pcap fixed.pcap
$ # Fix a capture from stdin and send it to stdout
$ bellows -d /dev/cu.GoControl_zigbee dump -w /dev/stdout | zigpy pcap fix-fcs - - | wireshark -k -S -i -
```
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"zigpy",
"click",
"coloredlogs",
"scapy",
],
extras_require={
# [all] pulls in all radio libraries
Expand Down
1 change: 1 addition & 0 deletions zigpy_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import zigpy_cli.ota # noqa: F401
import zigpy_cli.pcap # noqa: F401
import zigpy_cli.radio # noqa: F401
from zigpy_cli.cli import cli # noqa: F401
31 changes: 31 additions & 0 deletions zigpy_cli/pcap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

import logging

import click
from scapy.utils import PcapReader, PcapWriter
from scapy.config import conf as scapy_conf
from scapy.layers.dot15d4 import Dot15d4 # NOQA: F401

from zigpy_cli.cli import cli

scapy_conf.dot15d4_protocol = "zigbee"

LOGGER = logging.getLogger(__name__)


@cli.group()
def pcap():
pass


@pcap.command()
@click.argument("input", type=click.File("rb"))
@click.argument("output", type=click.File("wb"))
def fix_fcs(input, output):
reader = PcapReader(input.raw)
writer = PcapWriter(output.raw)

for packet in reader:
packet.fcs = None
writer.write(packet)