In Scapy, I want to compare a number of header fields between any two packets a
and b
. This list of fields is predefined, say:
fieldsToCompare = ['tos', 'id', 'len', 'proto'] #IP header
Normally I would do it individually:
if a[IP].tos == b[IP].tos:
... do stuff...
Is there any way to access those packet fields from a list of strings including what each one of them is called? Like:
for field in fieldsToCompare:
if a[IP].field == b[IP].field:
... do stuff...