GNAT.Sockets obtain MAC Address

376 Views Asked by At

Is there a way to obtain a MAC address with GNAT.Sockets?

I've read the .ads file several times and seen nothing that looks like it would yield a MAC address.

Ads here

2

There are 2 best solutions below

11
On

Get your local socket address with Get_Socket_Name and match that to the address of one of your network interfaces.

0
On

While googling for your problem, I found a C solution here you could interface to. One advantage of this compared to calling system command is that you don't rely on parsing the output of the command and thus to its format. One drawback is that you have to use Interfacing annex of Ada but as it's standard, it's easy.

Hope this will help.