Found while applying #838's ruling to raise on an unresolvable link-layer name, and it will bite the moment #838 merges.
pcapkit/toolkit/pyshark.py:87 does Enum_LinkType.get(packet.layers[0].layer_name.upper()). pyshark's layer_name is Wireshark's protocol filter name, passed through unmodified — pyshark/packet/layers/base.py:30-31 is a bare return self._layer_name, and .upper() appears only in __repr__. For a PDML capture the name comes straight from <proto name> (pyshark/tshark/output_parser/tshark_xml.py:93, XmlLayer(proto)).
Three pieces of local evidence that these are filter names, not protocol titles:
- pyshark's
Packet.__getattr__ matches layer.layer_name.lower() == item.lower(), documented as "For instance: pkt.ip", and consts.TRANSPORT_LAYERS = ['UDP', 'TCP'].
- pcapkit's own pyshark toolkit relies on exactly that:
packet.ip, packet.ipv6, packet.tcp, packet.frame_info.
- The test double in
tests/toolkit/test_pyshark_unit.py names its layers 'frame', 'ip', 'tcp', 'ipv6' — all real filter names — and then 'ethernet', which is not one. Wireshark's is eth (hence eth.src, eth.dst, and the fake's own src= field).
So layers[0].layer_name.upper() is 'ETH' for an ordinary Ethernet capture, and 'ETH' is not a LinkType member — 'ETHERNET' is. Once #838 removes the fallback, every Ethernet capture traced through this toolkit raises instead of one odd case.
Fix: map pyshark/Wireshark filter names to LinkType (at least eth → ETHERNET, ip → IPV4, ipv6 → IPV6, null/loop → NULL, raw → RAW) rather than upper-casing a display name and hoping it matches. Same question applies to pcapkit/toolkit/scapy.py:324, where (Ether()/IP()/TCP()).name.upper() happens to be 'ETHERNET' and does resolve — so scapy is correct today by coincidence of naming, not by design.
Caveat, stated plainly: there is no tshark on this host, so the eth spelling is derived from pyshark's source, its documented idiom, and the test double's own internal inconsistency — not from live PDML.
Found while applying #838's ruling to raise on an unresolvable link-layer name, and it will bite the moment #838 merges.
pcapkit/toolkit/pyshark.py:87doesEnum_LinkType.get(packet.layers[0].layer_name.upper()). pyshark'slayer_nameis Wireshark's protocol filter name, passed through unmodified —pyshark/packet/layers/base.py:30-31is a barereturn self._layer_name, and.upper()appears only in__repr__. For a PDML capture the name comes straight from<proto name>(pyshark/tshark/output_parser/tshark_xml.py:93,XmlLayer(proto)).Three pieces of local evidence that these are filter names, not protocol titles:
Packet.__getattr__matcheslayer.layer_name.lower() == item.lower(), documented as "For instance: pkt.ip", andconsts.TRANSPORT_LAYERS = ['UDP', 'TCP'].packet.ip,packet.ipv6,packet.tcp,packet.frame_info.tests/toolkit/test_pyshark_unit.pynames its layers'frame','ip','tcp','ipv6'— all real filter names — and then'ethernet', which is not one. Wireshark's iseth(henceeth.src,eth.dst, and the fake's ownsrc=field).So
layers[0].layer_name.upper()is'ETH'for an ordinary Ethernet capture, and'ETH'is not aLinkTypemember —'ETHERNET'is. Once #838 removes the fallback, every Ethernet capture traced through this toolkit raises instead of one odd case.Fix: map pyshark/Wireshark filter names to
LinkType(at leasteth→ETHERNET,ip→IPV4,ipv6→IPV6,null/loop→NULL,raw→RAW) rather than upper-casing a display name and hoping it matches. Same question applies topcapkit/toolkit/scapy.py:324, where(Ether()/IP()/TCP()).name.upper()happens to be'ETHERNET'and does resolve — so scapy is correct today by coincidence of naming, not by design.Caveat, stated plainly: there is no
tsharkon this host, so theethspelling is derived from pyshark's source, its documented idiom, and the test double's own internal inconsistency — not from live PDML.