CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): knd4876 (knd)
날 짜 (Date): 2002년 11월  8일 금요일 오후 05시 21분 35초
제 목(Title): Re: MAC 어드레스 얻기


HP 리스판스 센터 (http://www.hprc.co.kr) Q&A 게시판에 아래 코드가
올라와 있네요. 근데 입력 값은 뭘줘야 하는 지 모르겠는데...
혹시 /dev/lan0를 넣으면 되나요?

#include <sys/fcntl.h>
#include <sys/netio.h>

main(int argc, char *argv[])
{
    struct fis       s_fis;
    int              lanic;
    char             ascii[6];

    if(argc < 2)
    {
        printf("Usage: %s\n", argv[0]);
        exit(1);
    }

    lanic = open(argv[1], O_RDWR);
    if(lanic < 0)
    {
        perror("Error in opening %s", argv[1]);
        perror("Error = %d", lanic);
        exit(0);
    }
    else
    {
        s_fis.reqtype = LOCAL_ADDRESS;
        s_fis.vtype = INTEGERTYPE;
        ioctl(lanic, NETSTAT, &s_fis);
        net_ntoa(ascii, (char *)s_fis.value.s, 6);
        printf("Station address of %s is %s\n", argv[1], ascii);
        s_fis.reqtype = PERMANENT_ADDRESS;
        s_fis.vtype = INTEGERTYPE;
        ioctl(lanic, NETSTAT, &s_fis);
        net_ntoa(ascii, (char *)s_fis.value.s, 6);
        printf("Permanent Station address of %s is %s\n", argv[1], ascii);

        close(lanic);
    }
}

[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.