Obtain the MAC address of the NIC by programming in SCO
Source: Internet
Author: User
Article title: obtain the MAC address of the NIC by programming under SCO. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
# Include
# Include
# Include
# Include
# Include
# Include
Int main (int argc, char * argv [])
{
Struct strioctl strioc;
U_char ether_addr [6];
Int s;
If (argc! = 2 ){
Fprintf (stderr, "usage: % s deviceFile \ n", argv [0]);
Exit (1 );
}
Printf ("% s is using address % 02x: % 02x: % 02x: % 02x: % 02x: % 02x \ n ",
Argv [1],
Ether_addr [0], ether_addr [1], ether_addr [2],
Ether_addr [3], ether_addr [4], ether_addr [5]
);
Exit (0 );
}
/********************************** End **** *****************************/
Note:
The execution method is as follows (assume that the compiled execution file is getmac ):
./Getmac/dev/net0
MDI (MAC Driver Interface)
MACIOC_GETADDR
Send a request to the MDI driver to obtain the current MAC address of the network adapter );
MACIOC_GETRADDR
Send a request to the MDI driver to obtain the MAC address of the NIC vendor (the factory MAC address );
This program is applicable to SCO OpenServer and UnixWare and passed the test on OpenServer 5.06.
When I try to use MACIOC_GETRADDR, an invalid parameter is Prompted. I guess it may be related to the implementation not provided in the driver, because the copyright information I accidentally saw is
/*
* Copyright (C) The Santa Cruz Operation, 1993-1995.
* This Module contains Proprietary Information
* The Santa Cruz Operation and shoshould be treated
* As Confidential.
*/
In the AT-2500TX driver source code, the corresponding part only contains the MACIOC_GETADDR implementation, without MACIOC_GETRADDR.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.