Sponsored Content
Top Forums Programming How do I find the MAC address in C on different UNIX platforms? Post 302452760 by Pug on Monday 13th of September 2010 03:19:16 AM
Old 09-13-2010
Power How do I find the MAC address in C on different UNIX platforms?

I need to find the MAC address of the ethernet cards on the host machine from the C language. I have found a way to do this on Linux using socket(), ioctl() and the ifreq structure. But this does not seem to work on AIX, HP/UX and probably the others I need (Solaris, SCO, Alpha etc).

Is there a standard way to do this in UNIX?
Why do the UNIX ifreq structures not have a MAC address field like Linux?
Or and I missing something here? It would be fine with me if I need to to it differently for each platform, if I have to. I just need to know what calls to use for each type of UNIX.

Please help!

Thank you.
 

10 More Discussions You Might Find Interesting

1. IP Networking

Mac address - what is line command to find and active new card

How do you find mac address and active new card. (1 Reply)
Discussion started by: wmetz
1 Replies

2. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

3. UNIX for Advanced & Expert Users

Find IP Address of a Printer Q in Hp-Unix

Could anyone help me to identify the IP address of a printer queue with its printer queue name information . (1 Reply)
Discussion started by: lenin1985
1 Replies

4. UNIX for Dummies Questions & Answers

Unix Platforms

Hi. Where can i learn, Which Unix platform specific for what? Properties? (1 Reply)
Discussion started by: Enrgy
1 Replies

5. Solaris

Get ip address from mac address

I have following message in my messages file on solaris 10 WARNING: e1000g3712000:3 has duplicate address 010.022.196.011 (in use by 00:50:56:85:25:ef); disabled Now is there any way i can find which server has 00:50:56:85:25:ef mac address either IP or Hostname ? (6 Replies)
Discussion started by: fugitive
6 Replies

6. UNIX and Linux Applications

Platforms using Unix

Hi ;) Which hardware platforms/machine types use the Operating System Unix? A list of all would be appreaciated Thx Megadrink :cool: (2 Replies)
Discussion started by: Megadrink
2 Replies

7. UNIX for Dummies Questions & Answers

Is there a unix command to find ALL hostnames for an ip address?

I am trying to determine if there are several url/host names for an IP address. Is there a UNIX command to find ALL host names for an IP address? Thank you in advance. (3 Replies)
Discussion started by: rukasu
3 Replies

8. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

9. Shell Programming and Scripting

Multichecks across all unix platforms

Can somebody refer me following multicheck to perform across most of unix platform like AIX, HP-UX, solaris, Linux. CPU utilization above X% Check IO above X% Swap usage check above X% Memory utilization above X% ... (3 Replies)
Discussion started by: sendtoshailesh
3 Replies

10. IP Networking

MAC Address - Four Interfaces with the same MAC Address

four interfaces with ifconfig all interfaces have the same mac. If is not set for unique. but it still works. what difference does it make to have all macs the same or different? (4 Replies)
Discussion started by: rrodgers
4 Replies
xna(7)							 Miscellaneous Information Manual						    xna(7)

NAME
xna - The DEMNA Ethernet interfaces SYNOPSIS
config_driver xna DESCRIPTION
The xna driver provides access to a 10-MB Ethernet network through the DEMNA adapter. The DEMNA is an Ethernet-to-XMI adapter. The host's Internet address is specified at boot time with an SIOCSIFADDR ioctl. The xna driver employs the Address Resolution Protocol, as described in arp(7), to map dynamically between Internet and Ethernet addresses on the local network. The SIOCSPHYSADDR ioctl can be used to change the physical address of the adapter and SIOCRPHYSADDR can be used to read its physical address. SIOCADDMULTI and SIOCDELMULTI can be used to add or delete multicast addresses. The xna driver supports a maximum of 12 multi- cast addresses. The argument to the latter ioctls is a pointer to an ``ifreq'' structure found in <net/if.h>. SIOCRDCTRS and SIOCRDZCTRS ioctls can be used to read or read and clear network counters. The argument to the latter two ioctls is a pointer to a counter structure ``ctrreq'' found in <net/if.h>. The ioctls SIOCENABLBACK and SIOCDISABLBACK can be used to enable and disable the interface loopback mode. RESTRICTIONS
The PUP protocol family is not supported. EXAMPLES
To obtain the physical address of the adapter, use the SIOCRPHYSADDR ioctl as in the following program example: #include <stdio.h> /* standard I/O */ #include <errno.h> /* error numbers */ #include <sys/socket.h> /* socket definitions */ #include <sys/ioctl.h> /* ioctls */ #include <net/if.h> /* generic interface structures */ main() { int s,i; static struct ifdevea devea; /* Get a socket */ s = socket(AF_INET,SOCK_DGRAM,0); if (s < 0) { perror("socket"); exit(1); } strcpy(devea.ifr_name,"xna0"); if (ioctl(s,SIOCRPHYSADDR,&devea) < 0) { perror(&devea.ifr_name[0]); exit(1); } printf("Address is "); for (i = 0; i < 6; i++) printf("%X ", devea.default_pa[i] & 0xff); printf(" "); close(s); } To enable external loopback, use the SIOCENABLEBACK ioctl as in the following program example: #include <stdio.h> /* standard I/O */ #include <errno.h> /* error numbers */ #include <sys/socket.h> /* socket definitions */ #include <sys/ioctl.h> /* ioctls */ #include <net/if.h> /* generic interface structures */ main() { int s; struct ifreq data; /* Get a socket */ s = socket(AF_INET,SOCK_DGRAM,0); if (s < 0) { perror("socket"); exit(1); } strcpy(data.ifr_name,"xna0"); if (ioctl(s,SIOCENABLEBACK,&data) < 0) { perror("SIOCENABLEBACK:"); exit(1); } close(s); } ERRORS
The DEMNA errors are coded as follows: Adapter did not pass the power-up self-test during autoconfiguration time. The port attachment fails. The xna driver was unable to allocate memory for adapter data structures. The port attachment fails. The xna driver was unable to map memory for adapter data structures. The port attachment fails. The xna driver was unable to bring the adapter into the initialized state. The port attachment fails. The xna driver failed to prepare the adapter for run-time use. The xna driver was unable to bring the adapter into the initialized state during a port reset. The adapter port command failed. The error code gives reason for failure. Too many multicast requests have been made. RELATED INFORMATION
Files: arp(7), inet(7), intro(4), netstat(1) delim off xna(7)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy