Since you are using cBPF (classic BPF), the only way to filter a set of IP addresses is to list them all:
bpf_filter = "ip and ("
for addr in addresses[:-1]:
bpf_filter = "%shost %s or " % (bpf_filter, addr)
bpf_filter = "%shost %s)" % (bpf_filter, addresses[-1])
What for a set of IP addresses [10.0.0.1, 10.0.0.2, 10.0.0.3]will return:
ip and (host 10.0.0.1 or host 10.0.0.2 or host 10.0.0.3)
Note. You need at least one IP address in your set to work above.
cBPF?
, Scapy, - BPF. - BPF (, , ). - , .
, IP-. , - - O (1). eBPF, , , Scapy.