0

How exactly would one go about creating a raw socket on the MAC layer in Micropython?

The UNIX equivalent is:

eth_p_all=3
netif='wlan0'
s=socket.socket(socket.AF_PACKET,socket.SOCK_RAW,socket.htons(eth_p_all))
s.bind((netif,0))

For one, it is not clear how to get the interface name, and there is no socket.AF_PACKET or socket.htons.

So, if there is no way to do this with the stock libraries or firmware, which libraries should I choose, or if firmware modification is required, how exactly should I modify the firmware?

zx485
  • 28,498
  • 28
  • 50
  • 59
user8079
  • 23
  • 4

1 Answers1

0

There have no raw socket implementation at current upy firmware. Yo can check the following line. The raw socket dispatch has been removed from modlwip.c

https://github.com/micropython/micropython/blob/68a5d6fe7746850ce049b8bf295bfce1382383f3/extmod/modlwip.c#L712

If you want to modify firmware by your self, you can follow the steps.

  • Check your platform's origin SDK support raw socket or not. (for example, cc3200 use TI's cc3200 SDK and it support raw socket)
  • Modify modlwip.c

There's an unofficial port(realtek's ameba series) support raw socket. You could start from this one.

https://github.com/wylinks/micropython-ameba/blob/ameba/ports/ameba/mphelper/mods/modlwip.c

YuSheng
  • 191
  • 1
  • 4