Sponsored Content
Top Forums Programming How do I find the MAC address in C on different UNIX platforms? Post 302459150 by Pug on Monday 4th of October 2010 12:35:44 AM
Old 10-04-2010
Thank you for your help.

I did what you did, but on my platform. I did ldd libsocket.so to see the list in my context. It was different but I continued.

I tried what you said and linked with
/lib/libsocket.a and /lib/libnsl.a
then I had only a few left and they seemed related to lindl so I tried linking to libdl.a too but discovered there was no libdl.a only a lindl.so so I tried linking to this in hopes that it would resolve the static linkage but then find libdl.so and link dynamically at run time. As I mentioned, I normally avoid .so files to avoid run time linkage issues, but I tried it.

The executable linked but when I ran it all the calls to ioctl returned -1 (error). Keep in mind that when I make these same calls (or similar) on Linux they work. I suspect the linkage more than the calling code. All I am doing at the point I get the error is calling ioctl() with
a handle value of 8, SIOCGIFADDR and IfReq.ifr_name set to "eth0"
The handle is from a call to
socket(AF_INET, SOCK_DGRAM, IP_PROTOIP)

Any other ideas?

Can you tell me in a nutshell how the so system works. For example, when I link with a .so file, does it resolve the static linkage issue and the at runtime go out looking for the same .so file to dynamically link to it?
If this is the case, then what are the rules for finding the .so file (in case the location of the .so file on my compiling platform is different that the end users platform)?
Could I have inked with libsocket.so directly? Is this any better? Or is it just a matter of preference?
My concern is of course two things:
- why did it link and the fail to run properly (assuming my code is OK)?
- how can I be sure my code will run reliably using .so files if I do get it to work?

Thank you for your insights.
 

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
libdl(3LIB)							Interface Libraries						       libdl(3LIB)

NAME
libdl - dynamic linking library SYNOPSIS
cc [ flag... ] file... -ldl [ library... ] DESCRIPTION
Historically, functions in libdl provided for dynamic linking support. This functionality now resides in libc(3LIB). This library is maintained to provide backward compatibility for both runtime and compilation environments. The shared object is imple- mented as a filter on the runtime linker. See ld.so.1(1). New application development need not specify -ldl. INTERFACES
The shared object libdl.so.1 provides the following public interfaces. See intro(3) for additional information on shared object interfaces. dladdr dladdr1 dlclose dldump dlerror dlinfo dlmopen dlopen dlsym FILES
/lib/libdl.so.1 shared object /lib/64/libdl.so.1 64-bit shared object ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsl (32-bit) | +-----------------------------+-----------------------------+ | |SUNWcslx (64-bit) | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
ld.so.1(1), pvs(1), intro(3), libc(3LIB), attributes(5) SunOS 5.10 24 Mar 2004 libdl(3LIB)
All times are GMT -4. The time now is 11:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy