The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Achive IP address through MAC(Ethernet) address krishnacins IP Networking 3 08-29-2005 05:45 PM
ce0 and ce1 have the same mac address BG_JrAdmin SUN Solaris 2 07-08-2005 04:30 PM
network address and broadcast address? pnxi UNIX for Dummies Questions & Answers 7 11-10-2003 07:29 PM
IP address krishna UNIX for Advanced & Expert Users 10 03-20-2002 01:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2007
Registered User
 

Join Date: Feb 2007
Posts: 11
Stumble this Post!
SCO get MAC Address

Does anyone know how to get the mac address of a SCO box using c.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,849
Stumble this Post!
Does arp work in SCO?

What did you try for code, ioctl?
Reply With Quote
  #3 (permalink)  
Old 02-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,849
Stumble this Post!
does this work?
Code:
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>


int main( int argc, char *argv[] )
{
	int s;
		
	struct ifreq buffer;
	s = socket(PF_INET, SOCK_DGRAM, 0);
	memset(&buffer, 0x00, sizeof(buffer));
	strcpy(buffer.ifr_name, "eth0");
	ioctl(s, SIOCGIFHWADDR, &buffer);
	close(s);	
	for( s = 0; s < 6; s++ )
	{
		printf("%.2X ", (unsigned char)buffer.ifr_hwaddr.sa_data[s]);
	}
	printf("\n");

	return 0;
}
Reply With Quote
  #4 (permalink)  
Old 02-06-2007
Registered User
 

Join Date: Feb 2007
Posts: 11
Stumble this Post!
I am a newbie, to doing this on the SCO. I got it to work with the AIX. From the documentation that I read arp is supposed to work. Acutally a coding sample or two with arp would really really be appreciated.

Thanks.
Reply With Quote
  #5 (permalink)  
Old 02-06-2007
Registered User
 

Join Date: Feb 2007
Posts: 11
Stumble this Post!
These are the errors I got:


"sco.c", line 16: error: undefined symbol: SIOCGIFHWADDR
"sco.c", line 20: error: undefined struct/union member: ifr_hwaddr
"sco.c", line 20: warning: left operand of "." must be struct/union object
"sco.c", line 20: error: cannot access member of non-struct/union object
"sco.c", line 25: warning: newline not last character in file
Reply With Quote
  #6 (permalink)  
Old 02-06-2007
Registered User
 

Join Date: Feb 2007
Posts: 11
Stumble this Post!
SIOCGIFFLAGS works in place of SIOCGIFHWADDR
Reply With Quote
  #7 (permalink)  
Old 02-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,849
Stumble this Post!
Code:
#include <stdio.h>

int main()
{
   
   FILE *cmd=popen("arp kcsdev | awk '{print $4}'", "r");
   char tmp[80]={0x0};
   
   while(fgets( tmp, sizeof(tmp), cmd)!=NULL)
   {
         printf("%s\n", tmp);
    }
   pclose(cmd);
   return 0;
}
kcsdev = node this was tested on. Change it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0