zoukankan      html  css  js  c++  java
  • lwip IP address handling 关于 IP 地址的 操作 API接口

    lwip 2.0.3  IP address handling 

    /**
    * @file
    * IP address API (common IPv4 and IPv6)
    */

    1、u32_t ipaddr_addr(const char *cp);

      把一个 字符串的 IP 地址转换成  ip4_addr_t 类型的IP。

     1 /**
     2  * Ascii internet address interpretation routine.
     3  * The value returned is in network order.
     4  *
     5  * @param cp IP address in ascii representation (e.g. "127.0.0.1")
     6  * @return ip address in network order
     7  */
     8 u32_t
     9 ipaddr_addr(const char *cp)
    10 {
    11   ip4_addr_t val;
    12 
    13   if (ip4addr_aton(cp, &val)) {
    14     return ip4_addr_get_u32(&val);
    15   }
    16   return (IPADDR_NONE);
    17 }

    2、char *ip4addr_ntoa(const ip4_addr_t *addr);

      把一个 ip4_addr_t 类型 的IP地址 转换 成 字符串形式!

     1 /**
     2  * Convert numeric IP address into decimal dotted ASCII representation.
     3  * returns ptr to static buffer; not reentrant!
     4  *
     5  * @param addr ip address in network order to convert
     6  * @return pointer to a global static (!) buffer that holds the ASCII
     7  *         representation of addr
     8  */
     9 char*
    10 ip4addr_ntoa(const ip4_addr_t *addr)
    11 {
    12   static char str[IP4ADDR_STRLEN_MAX];
    13   return ip4addr_ntoa_r(addr, str, IP4ADDR_STRLEN_MAX);
    14 }
  • 相关阅读:
    oracle性能调优
    oracle常用函数
    plsql的安装与使用
    WSAIoctl
    SQL中大概有这么几种JOIN
    如何取分组最大值记录
    having
    MSSQL—按照某一列分组后取前N条记录
    sql之left join、right join、inner join的区别
    delphi 接收心跳包怎么写
  • 原文地址:https://www.cnblogs.com/suozhang/p/8435020.html
Copyright © 2011-2022 走看看