Re: Which file to request SIOCGIFMAC on?



On Wednesday 21 February 2007 15:03, nocturnal wrote:
Hi

Well that's weird, is MAC defined by default at all? I tried searching
for the definition but couldn't find it.

I never thought it would be this hard just to get the ethernet address
from an ethernet interface in FreeBSD. I think i'll take a look at the
netlib source next, something tells me it will be easier to just
plagiarize their method than going through the kernel source any more.

Have you tried google? This was asked on freebsd-hackers a few months ago:

http://lists.freebsd.org/pipermail/freebsd-hackers/2006-August/017601.html

hth...
don




Med vänliga hälsningar

Stefan Midjich aka nocturnal
[Swehack] http://swehack.se

Pietro Cerutti wrote:
On 2/20/07, nocturnal <nocturnal@xxxxxxxxxx> wrote:
Hi

The original plan is to only run it on FreeBSD 5 and higher, actually
only 6 by now. It's a program i'm writing for work and at work the most
active servers run FreeBSD 6 and are updated frequently. The ones with
older versions don't run anything of interest.

I am buying a MacBook for personal use though so it would be nice to run
it on osx. I wouldn't like to start using another library just to get
the hardware address of an interface though, that seems kinda overkill
for what should be a simple task. The program is already using libpcap
but that is included in FreeBSD by default so you don't have to
install it.

Do you have any idea of why i'm getting this error from ioctl when i'm
doing what the manual says i should do? I am of course running it as
root to because the libpcap operations require it.

What might help me is to take a look at the source of that
libnet_get_hwaddr function in libnet. I'll try that, thank you very much
for the tip.

So far i've been trying to look at the source for ifconfig to figure out
how it gets the hardware address. Of course it uses SIOCGIFMAC but i
can't find the socket it opens because i can't find where it uses the
maclabel_status function.

The problem isn't with the socket type or options.
If you debug ifconfig, you'll find out that the ioctl call always
returns -1, and the program goes on to the "goto mac_free" line.

Take a look at /usr/src/sys/net/if.c, line 1258

Should we deduce that the particular ioctl isn't supported?

P.S. I'm forwarding this to freebsd-hackers@ too, so sorry for cross
posting

Med vänliga hälsningar

Stefan Midjich aka nocturnal
[Swehack] http://swehack.se

Chuck Swiger wrote:
On Feb 20, 2007, at 1:10 PM, nocturnal wrote:
I'm trying to get the ethernet address and from the manuals i
understand that i need the ifreq structure for this. So i'm trying to
request SIOCGIFMAC with ioctl on a socket of type SOCK_DGRAM.

If you're just targetting FreeBSD >= 5.x platforms, your current
approach is reasonable (assuming you can fix whatever the problem is);
if you're targetting other platforms such FreeBSD 4, Dfly, OS X, or

SysV

things like Solaris, try installing the libnet port and invoke
libnet_get_hwaddr().

---Chuck

_______________________________________________

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe@xxxxxxxxxxx"

--
Don Hinton <don.hinton at vanderbilt.edu> or <hintonda at gmail.com>
Institute for Software Integrated Systems (ISIS), Vanderbilt University
tel: 615.480.5667 or 615.870.9728

Attachment: pgp8WauAGF0WZ.pgp
Description: PGP signature



Relevant Pages

  • Re: Which file to request SIOCGIFMAC on?
    ... I never thought it would be this hard just to get the ethernet address from an ethernet interface in FreeBSD. ... Do you have any idea of why i'm getting this error from ioctl when i'm ... If you debug ifconfig, you'll find out that the ioctl call always ...
    (freebsd-questions)
  • Re: Which file to request SIOCGIFMAC on?
    ... I never thought it would be this hard just to get the ethernet address from an ethernet interface in FreeBSD. ... Do you have any idea of why i'm getting this error from ioctl when i'm ... If you debug ifconfig, you'll find out that the ioctl call always ...
    (freebsd-hackers)
  • Re: Which file to request SIOCGIFMAC on?
    ... The original plan is to only run it on FreeBSD 5 and higher, ... Do you have any idea of why i'm getting this error from ioctl when i'm ... The problem isn't with the socket type or options. ... request SIOCGIFMAC with ioctl on a socket of type SOCK_DGRAM. ...
    (freebsd-questions)
  • Re: Keylogger For FreeBSD
    ... >>all keyboard activity on my pc. ... it was 4.2) there was an ioctl that would let you spy on a tty. ... If it's not in the current source (FreeBSD source) you hopefully ... Marc Wiz ...
    (freebsd-questions)
  • Re: Which file to request SIOCGIFMAC on?
    ... It's a program i'm writing for work and at work the most active servers run FreeBSD 6 and are updated frequently. ... Of course it uses SIOCGIFMAC but i can't find the socket it opens because i can't find where it uses the maclabel_status function. ... So i'm trying to request SIOCGIFMAC with ioctl on a socket of type SOCK_DGRAM. ... approach is reasonable; if you're targetting other platforms such FreeBSD 4, Dfly, OS X, or SysV things like Solaris, try installing the libnet port and invoke libnet_get_hwaddr. ...
    (freebsd-questions)