get mac address via c++ program - ifreq (hwaddr) and ioctl



Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

get mac address via c++ program - ifreq (hwaddr) and ioctl

Postby tdzs » Tue Dec 24, 2013 6:28 am

I am working on a sample c++ program to get mac address for a v1.13 system. The same program worked on other *nix OSes. My question was - what I am am missing here to be able to port same functionality to z/os env. The compilation(xlC) issue I am facing is w.r.t (1) missing member ifr_hwaddr for structure ifreq (present on other *nix platforms) in header under /usr/include . (2) Also, I am unable to find SIOCGIFHWADDR in ioctl header (present on other *nix platforms) under /usr/include for which I am getting compilation error.

The sample program basically loops through available interfaces and uses SIOCGIFHWADDR to be able to get mac address - ignoring any loopback address while iterating.

This leads me to believe that there is different route to obtain mac address via c++ program for z/os. Can somebody please point to any z/os specific macros or markers that I am missing here - or point me to a z/os compatible route - via c++ calls. Thanks...
tdzs
 
Posts: 4
Joined: Tue Dec 17, 2013 5:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: get mac address via c++ program - ifreq (hwaddr) and ioc

Postby enrico-sorichetti » Tue Dec 24, 2013 11:41 am

googling with zos communication server mac address
will return the links to the IBM REDBOOKS dealing with some of the internals of the communication server TCP/IP component
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: get mac address via c++ program - ifreq (hwaddr) and ioc

Postby enrico-sorichetti » Tue Dec 24, 2013 12:23 pm

follow on ...
and start looking at the XL C/C++ manuals starting from
http://publibz.boulder.ibm.com/cgi-bin/ ... s/CBCBS1D0
proceeding to the
z/OS V1R13.0 XL C/C++ Programming Guide
( which unfortunately gives an error)

here the same roadmap for zOS 1.12
http://publibz.boulder.ibm.com/cgi-bin/ ... s/cbcbs1b0
http://publibz.boulder.ibm.com/cgi-bin/ ... 0625173249
and chapter 4.9 which deals with TCP/IP
http://publibz.boulder.ibm.com/cgi-bin/ ... 0625173249
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: get mac address via c++ program - ifreq (hwaddr) and ioc

Postby tdzs » Tue Dec 24, 2013 1:33 pm

Hi Enrico

Thanks for your reply as well as mentioning various URLs. Yes, ibm doc. has been immensely helpful previously to work with sockets on z/os. I have been relying on comm. server ip sockets api guide and reference under http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.halx001%2Ff1a1d3b1.htm n/w communications section under http://pic.dhe.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.cbcpx01/cbcpg1a0.htm , header file sections under http://pic.dhe.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.bpxbd00/edclb1a0.htm. I will also look at URLs you mentioned.

However, with the limited reading i have done w.r.t this issue in general until now, i haven't come across a clear path specially in 1st url(where i expected to get some info). Some of the non-prg (as in admin guides) mention about osa interface to display mac address - however, i am not sure if that is the right route to take to get mac address via a c++ program and if it is - i am not sure on how do i interface with those commands or if it is possible via c++ program through spawn or exec etc and if that is the preferred route.
tdzs
 
Posts: 4
Joined: Tue Dec 17, 2013 5:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: get mac address via c++ program - ifreq (hwaddr) and ioc

Postby enrico-sorichetti » Tue Dec 24, 2013 2:05 pm

in the *nix world configure.ac after having been processed by the auto tool chain is used to check if a facility is available
if a SIOC****** is not declared in some header then the functionality/facility is not available

AC_CHECK_DECLS( SIOCGIFHWADDR, [hc_cv_have_siocgifhwaddr=yes], [hc_cv_have_siocgifhwaddr=no], [#include <sys/sockio.h>] )
the header where the SIOC**** are defined depends on the *nix flavor ( the above works on APPLE )

on the other side seems that the MAC address of the OSA interface is available only the the HMC or thru some OSA management commands

for some details see here
http://pic.dhe.ibm.com/infocenter/zos/v ... 0/maca.htm

I got there googling for ibm zseries mac address

I guess that You cannot have programmatically what You are looking for
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: get mac address via c++ program - ifreq (hwaddr) and ioc

Postby tdzs » Wed Dec 25, 2013 1:42 am

Enrico - Thanks for the link on osa. Not having that capability via a prg.- that might be an issue - i will check if i can spawn these commands - not sure if its gonna work or if that is the preferred/only route. On other hand certain(as an alternative to SIOCGIFHWADDR) alternate BSD based calls/structure getifaddrs , sockaddr_dl seems to be also not present/missing-certain-members in headers under /usr/include
tdzs
 
Posts: 4
Joined: Tue Dec 17, 2013 5:33 am
Has thanked: 0 time
Been thanked: 0 time


Return to C, C++

 


  • Related topics
    Replies
    Views
    Last post