connect_request_tunneling() raise ValueError
theobarrague opened this issue · 3 comments
When I try to establish a tunnel to the KNX router I get this error :
(knx) knx@knx-Virtual-Machine:~/knx$ python main.py
/home/knx/knx/lib/python3.7/site-packages/scapy/base_classes.py:324: SyntaxWarning: Packet 'LcEMI' has a duplicated 'reserved' field ! If you are using several ConditionalFields, have a look at MultipleTypeField instead ! This will become a SyntaxError in a future version of Scapy !
warnings.warn(war_msg, SyntaxWarning)
Traceback (most recent call last):
File "main.py", line 6, in <module>
channel, knx_source = connect_request_tunneling(knxnet)
File "/home/knx/knx/bof/layers/knx/knx_feature.py", line 259, in connect_request_tunneling
return response.communication_channel_id, knx_source
File "/home/knx/knx/bof/packet.py", line 114, in __getattr__
_, value, _ = self._get_field(attr)
File "/home/knx/knx/bof/packet.py", line 342, in _get_field
field_and_val = parent.getfield_and_val(name)
File "/home/knx/knx/lib/python3.7/site-packages/scapy/packet.py", line 423, in getfield_and_val
raise ValueError
ValueError
I attach a Wireshark capture and Python script : resources.zip
After investigation, it seems to come from knx_feature.py
:
# FIX: we can't access knx_individual_address directly
knx_source = response.scapy_pkt.connection_response_data_block.connection_data.knx_individual_address
I don't know how to fix this for now
Hi,
Thanks for the fix.
Actually this is a change in Scapy 2.4.5 where getfield_and_val now raises a ValueError if no condition was met (file scapy/packet.py). In BOF's current code, we rely on getfield_and_val not returning anything to know how to act (tested with Scapy 2.4.3).
To close this issue, we have to check every call to getfield_and_val in BOF to handle ValueError exceptions. I'm on it :p
Fixed with release 1.0.2
Thanks again for reporting this issue and submitting a fix!