Page 1 of 1

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

PostPosted: Tue Dec 24, 2013 6:28 am
by tdzs
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...

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

PostPosted: Tue Dec 24, 2013 11:41 am
by enrico-sorichetti
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

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

PostPosted: Tue Dec 24, 2013 12:23 pm
by enrico-sorichetti
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

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

PostPosted: Tue Dec 24, 2013 1:33 pm
by tdzs
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.

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

PostPosted: Tue Dec 24, 2013 2:05 pm
by enrico-sorichetti
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

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

PostPosted: Wed Dec 25, 2013 1:42 am
by tdzs
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