Skip to content

'scapy.all' has no attribute 'get_if_raw_hwaddr' #3

@TechTheGuy

Description

@TechTheGuy

Hey everybody, I first of all want to let you all know how awesome this module is!!
Anyways, I had to work a bit to get it working.
I am using python 3.9.5 with scapy 2.6.0 and, when running the first example in the readme, it fails.
Here's the code:

from ESPythoNOW import *
import time

def callback(from_mac, to_mac, msg):
  print("ESP-NOW message from %s to %s: %s" % (from_mac, to_mac, msg))

espnow = ESPythoNow(interface="wlan0mon", callback=callback)
espnow.start()

while True:
  msg=b'\x01'
  espnow.send("FF:FF:FF:FF:FF:FF", msg)
  time.sleep(3)

And, when ran with sudo python test.py, it fails with:

Traceback (most recent call last):
  File "/home/mindyourbusiness/fix_espnow/ESPythoNOW/test.py", line 7, in <module>
    espnow = ESPythoNow(interface="wlan0mon", callback=callback)
  File "/home/mindyourbusiness/fix_espnow/ESPythoNOW/ESPythoNOW.py", line 38, in __init__
    self.local_hw_mac        = self.hw_mac_as_str(self.interface)        # Interface's actual HW MAC
  File "/home/mindyourbusiness/fix_espnow/ESPythoNOW/ESPythoNOW.py", line 248, in hw_mac_as_str
    return ("%02X:" * 6)[:-1] % tuple(scapy.orb(x) for x in scapy.get_if_raw_hwaddr(self.l2_socket.iface)[1])
AttributeError: module 'scapy.all' has no attribute 'get_if_raw_hwaddr'

I think I got it to work with my pull request:
Line 247 defines the function hw_mac_as_str in a pretty weird way (it's got an unused argument(interface) and reconstructs the string version of the interface's mac address. What's the point of that if there's scapy's get_if_hwaddr function for it?

I fixed it (now there are no errors and Wireshark detects the packets) and am about to open a PR, once I figure out how to upload the fix...
Give me a few minutes so I can feel the glory of publishing my first PR please :-)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions