SCO get MAC Address


 
Thread Tools Search this Thread
Top Forums Programming SCO get MAC Address
# 1  
Old 02-06-2007
SCO get MAC Address

Does anyone know how to get the mac address of a SCO box using c.
# 2  
Old 02-06-2007
Does arp work in SCO?

What did you try for code, ioctl?
# 3  
Old 02-06-2007
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;
}

# 4  
Old 02-06-2007
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.
# 5  
Old 02-06-2007
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
# 6  
Old 02-06-2007
SIOCGIFFLAGS works in place of SIOCGIFHWADDR
# 7  
Old 02-06-2007
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

GREP mac address

Hi, mac.txt My mac address is <Mac Address>. How can i replace <Mac Address> with the actual of my computer? I try to GREP command as below but i am unable to grep it to replace just <Mac Address>. ifconfig eth0 | grep -o -E '(]{1,2}:){5}]{1,2}' Million in Advance. Please use... (7 Replies)
Discussion started by: derrickyee81
7 Replies

3. SCO

Changing MAC address in SCO 5.0.6

Hi, For som reason i need to change MAC address of SCO Open Server 5.0.6. I have searched foe answer too much but i didn't fin any thing well.:mad: Please help me, Thx:cool::) (4 Replies)
Discussion started by: mammut3d
4 Replies

4. 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

5. SCO

MAC address

hi every one please help i want to change mac address in sco unix 5.0.6 how can i do this (3 Replies)
Discussion started by: kaydream
3 Replies

6. 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

7. Solaris

Host ID vs MAC Address

Hi, I've got a Sun Solaris machine with host ID (840f8e57) and MAC address (0:14:4f:f:8e:57), how do I: 1. Write the MAC address in standard (IEEE 802) format, i.e. xx-xx-xx-xx-xx-xx? Do I need to add 0's before or after the 'f', i.e. 00-14-4f-0f-8e-57 or 00-14-4f-f0-8e-57? 2. What is... (4 Replies)
Discussion started by: TheBlueSky
4 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Mac address

Hi Can some one help me How do find out Mac address in Tru64 Unix Thank you (1 Reply)
Discussion started by: Syed_45
1 Replies

10. Programming

Get Mac Address

:( Hi I am trying to get Mac address of of my Sun server from my C program running on the host machine. Any suggestions . (1 Reply)
Discussion started by: ss_hpov
1 Replies
Login or Register to Ask a Question