int get_ipconfig(uint *ipaddr, uint *netmask) 이 함수의 unit 는 뭘 말하는건가요?;;
글쓴이: nerkis / 작성시간: 목, 2008/05/29 - 10:38오후
수정) 질문하나더..
이거 이렇게 선언하고 해줬는데 안되네요..
뭐가 잘못된거죠?
uint *ipaddr2;
uint *netmask2;
get_ipconfig(*ipaddr2, *netmask2);
ip 얻는거 찾다가 이 소스 발견해서 쓸려고 하는데
unit 이게 뭔가요?;;
혹시나 해서 char 바꿔도 안되네요;;
int get_ipconfig(uint *ipaddr, uint *netmask) { int i, sock, ret; struct ifreq ifr; sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) { printf("socket() error\n"); return -1; } strcpy(ifr.ifr_name, "eth0"); // Get IP Adress ret = ioctl(sock, SIOCGIFADDR, &ifr); if (ret < 0) { printf("get_ipconfig(), ioctl() error\n"); close(sock); return -1; } *ipaddr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; // Get Netmask ret = ioctl(sock, SIOCGIFNETMASK, &ifr); if (ret < 0) { printf("get_ipconfig(), ioctl() error\n"); close(sock); return -1; } *netmask = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; close(sock); }
Forums:
unit이 아니라
unit이 아니라 uint겠지요 -ㅅ-;;
보통 unsigned int를 줄여서 uint로 쓰고는 합니다.
아예 uint로 나오는 언어도 있구요.
저기서 s_addr은 실제로 unsigned long라서
uint를 char로 바꾸면 당연 에러가 뜹니다 -_-;;;
ㅡ,.ㅡ
그러네요. 이거 원-_-;;;
아무튼 감사합니다..^^
댓글 달기