scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Awkward FCfield API

Open redfast00 opened this issue 11 months ago • 2 comments

Brief description

How am I meant to access the to-DS field in a Dot11.FCfield in a Pythonic way? I can access for example the retry field by using fcfield.retry, but of course, fcfield.to-DS is not valid syntax. getattr(fcfield, 'to-DS') and the same with setattr works, but is very ugly. Is there a better way to read/set this bit field?

Scapy version

2.6.1

Python version

3.13.1

Operating system

Linux 6.12.6

Additional environment information

No response

How to reproduce

/

Actual result

No response

Expected result

No response

Related resources

No response

redfast00 avatar Jan 03 '25 17:01 redfast00

That's a bit crappy, you are right. I believe that you can do

if 'to-DS' in pkt.FCfield

but we probably should look into renaming this.

gpotter2 avatar Jan 03 '25 22:01 gpotter2

Good that this will be renamed :) This is not the only 'impossible' field name in the codebase, so maybe it makes sense to check the names at runtime with a regex?

Another issue I have is setting the value, but I'm using setattr in the meantime.

redfast00 avatar Jan 04 '25 01:01 redfast00