mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
Add netGetMacAddr function
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1301 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -265,3 +265,23 @@ void netGetNameserver( char *ip )
|
|||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void netGetMacAddr(char * ifname, unsigned char * mac)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
struct ifreq ifr;
|
||||||
|
|
||||||
|
|
||||||
|
memset(mac, 0, 6);
|
||||||
|
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if(fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
|
strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
|
||||||
|
|
||||||
|
if(ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
memmove(mac, ifr.ifr_hwaddr.sa_data, 6);
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ extern char *netGetHostname( void );
|
|||||||
extern void netSetHostname( char *host );
|
extern void netSetHostname( char *host );
|
||||||
extern void netSetNameserver(const char *ip);
|
extern void netSetNameserver(const char *ip);
|
||||||
extern void netGetNameserver( char *ip );
|
extern void netGetNameserver( char *ip );
|
||||||
|
extern void netGetMacAddr(char * ifname, unsigned char * mac);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user