7

It's part of a series of functions that retrieve IP & Mac addresses from the phone.

strcpy(temp, (char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl)));

EDIT: No equivalent function needed, there were just a few missing headers.

EDIT: Added cast to LLADDR(sdl)

Orchid
  • 271
  • 6
  • 20
  • It appears to be, despite saying it's a Mac OS X manpage, it is included in the iOS Development Library. http://developer.apple.com/library/ios/#documentation/System/Conceptual/ManPages_iPhoneOS/man3/ether_ntoa.3.html – trojanfoe Jun 28 '12 at 13:08
  • Take a look at the Objective C code at this link which might help you from "amcgregor". https://gist.github.com/1265265 – Kevin Horgan Jun 28 '12 at 13:10

2 Answers2

15

As I read it, the error message isn't claiming that the function is missing, only that you don't include its declaration. (I don't know that it exists, only that the message has a different complaint.)

In case it helps, man ether_ntoa tells me:

#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
Daniel X Moore
  • 14,637
  • 17
  • 80
  • 92
Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • Looks like I was missing #include . However now I get the new error: `"Incompatible pointer types passing 'caddr_t' (aka 'char *') to parameter of type 'const struct ether_addr *'"`. I guess this is a casting-related error? – Orchid Jun 28 '12 at 13:21
  • I'm not familiar with `LLADDR` but, since the `ether_ntoa` parameter is said to be `const struct ether_addr *`, I'd guess that you're right about the cause of the problem. – Phillip Mills Jun 28 '12 at 13:30
  • 3
    Ok, the error in the comment above was a type error with the parameter passed to `ether_ntoa()`, because `LLADDR(sdl))` returns a `char *` but `ether_ntoa()` takes something else. Fixed with the cast: `ether_ntoa((const struct ether_addr *)LLADDR(sdl)))` and all appears to still be working. – Orchid Jun 28 '12 at 13:35
0

I included following header file and source code compiled successfully:

#import <arpa/inet.h>
rjobidon
  • 3,055
  • 3
  • 30
  • 36