(self)
| 463 | libpcap = True |
| 464 | |
| 465 | def load(self): |
| 466 | # type: () -> Dict[str, NetworkInterface] |
| 467 | if not conf.use_pcap or WINDOWS: |
| 468 | return {} |
| 469 | if not conf.cache_pcapiflist: |
| 470 | load_winpcapy() |
| 471 | data = {} |
| 472 | i = 0 |
| 473 | for ifname, dat in conf.cache_pcapiflist.items(): |
| 474 | description, ips, flags, mac, itype = dat |
| 475 | i += 1 |
| 476 | if LINUX or BSD or SOLARIS and not mac: |
| 477 | from scapy.arch.unix import get_if_raw_hwaddr |
| 478 | try: |
| 479 | itype, _mac = get_if_raw_hwaddr(ifname) |
| 480 | mac = str2mac(_mac) |
| 481 | except Exception: |
| 482 | # There are at least 3 different possible exceptions |
| 483 | mac = "00:00:00:00:00:00" |
| 484 | if_data = { |
| 485 | 'name': ifname, |
| 486 | 'description': description or ifname, |
| 487 | 'network_name': ifname, |
| 488 | 'index': i, |
| 489 | 'mac': mac, |
| 490 | 'type': itype, |
| 491 | 'ips': ips, |
| 492 | 'flags': flags |
| 493 | } |
| 494 | data[ifname] = NetworkInterface(self, if_data) |
| 495 | return data |
| 496 | |
| 497 | def reload(self): |
| 498 | # type: () -> Dict[str, NetworkInterface] |
no test coverage detected