![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
SCO get MAC Address
Does anyone know how to get the mac address of a SCO box using c.
|
| Forum Sponsor | ||
|
|
|
|||
|
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;
}
|
|
|||
|
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 |
|
|||
|
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;
}
|
|||
| Google The UNIX and Linux Forums |