博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

ip4转数字ntop

Posted on 2019-07-30 17:55  PorkerFace  阅读(136)  评论(0)    收藏  举报
 1 #include<arpa/inet.h>
 2 
 3 uint32_t ip_ntop(const char *ip)
 4 {
 5         struct in_addr s;
 6         uint32_t ret = 0;
 7 
 8         memset(&s, 0x00,sizeof(s));
 9         if (ip != NULL)
10         {
11                 inet_pton(AF_INET, ip, &s);
12                 ret = ntohl(s.s_addr);
13         }
14         return ret;
15 }