Dynamically change the BPF to allow processing of data transfer channels.
(self)
| 54 | ) |
| 55 | |
| 56 | def __update_bpf(self): |
| 57 | """ |
| 58 | Dynamically change the BPF to allow processing of data transfer |
| 59 | channels. |
| 60 | """ |
| 61 | dynfilters = [] |
| 62 | for conn, metadata in self.conns.items(): |
| 63 | try: |
| 64 | dynfilters += ["(host %s and host %s)" % metadata["tempippair"]] |
| 65 | except (KeyError, TypeError): |
| 66 | continue |
| 67 | for a, p in self.data_channel_map.keys(): |
| 68 | dynfilters += ["(host %s and port %d)" % (a, p)] |
| 69 | self.bpf = "(%s) and ((%s)%s)" % ( |
| 70 | self.original_bpf, |
| 71 | " or ".join( "port %d" % p for p in self.control_ports ), |
| 72 | " or " + " or ".join(dynfilters) if dynfilters else "" |
| 73 | ) |
| 74 | self.recompile_bpf() |
| 75 | |
| 76 | def premodule(self): |
| 77 | # dictionary containing metadata for connections |
no test coverage detected