一段C代码转C#
不懂C。。。下面代码能转成C#吗。。望指点指点。。拜谢
------
long mac_addr_sys ( u_char *addr)
{
struct ifreq ifr,*IFR;
struct ifconf ifc;
char buf[1024];
int s,i;
int ok = 0;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s==-1) {
return -1;
}
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
ioctl(s, SIOCGIFCONF, &ifc);
IFR = ifc.ifc_req;
for (i = ifc.ifc_len / sizeof(struct ifreq); --i > = 0; IFR++) {
strcpy(ifr.ifr_name, IFR-> ifr_name);
if (ioctl(s, SIOCGIFFLAGS, &ifr) == 0) {
if (! (ifr.ifr_flags & IFF_LOOPBACK)) {
if (ioctl(s, SIOCGIFHWADDR, &ifr) == 0) {
ok = 1;
break;
}
}
}
}
close(s);
if (ok) {
bcopy( ifr.ifr_hwaddr.sa_data, addr, 6);
}
else {
return -1;
}
return 0;
}
int checkserial()
{
long stat;
int i;
FILE *fp;
char password[19],new_pass[19];
u_char addr[6];
long encrypt[6];
memset(encrypt,0,sizeof(encrypt));
memset(password,0,sizeof(password));
memset(new_pass,0,sizeof(new_pass));
fp = fopen( "/usr/sbin/serial.no ", "r ");