admin 管理员组

文章数量: 1184232

/******************************************************************************

  • 名称: ipToHex

  • 描述: 192.168.1.66 表示IP地址为:c0 a8 01 42

  • 参数: [in] ip

  •   [out] 无
    
  • 返回: 无
    ****************************************************************************** /
    VIL_8
    ipToHex(unsigned char *ip)
    {

    char *pos = NULL;
    char *hear = NULL;
    VIL_8 ip_hex[4] = {0};
    VIL_8 ip_buffer[4] = {0};
    int i = 0;
    int j = 0;
    pos = ip;
    hear = pos;
    for(j = 0; j < 4; j++)/ ip有四个值 /
    {
    for(i = 0; i < 4; i++)/ 到为.的地方结束 /
    {
    if(memcmp(pos+i,".",1) == 0)
    {
    pos=pos + i + 1;
    break;
    }
    }
    if(i <= 4)
    {
    memset(ip_hex,0,sizeof(ip_hex));
    strncpy(&ip_hex[0],hear,i);
    ip_buffer[j]=atoi(&ip_hex[0]);
    }
    hear = pos;
    }
    return ip_buffer;
    }

本文标签: 系统 代码 编程