2014-11-19 00:25:21 +08:00
|
|
|
|
#ifndef ACL_SANE_INET_INCLUDE_H
|
|
|
|
|
#define ACL_SANE_INET_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "stdlib/acl_define.h"
|
|
|
|
|
#ifdef ACL_UNIX
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param src {const unsigned char*} struct in_addr in.s_addr <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
* @param dst {char *} <EFBFBD>洢ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} dst <EFBFBD>Ŀռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @return {const char*} NULL: error; !NULL: ok
|
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_inet_ntop4(const unsigned char *src, char *dst, size_t size);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param in {struct in_addr}
|
|
|
|
|
* @param dst {char *} <EFBFBD>洢ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} dst <EFBFBD>Ŀռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @return {const char*} NULL: error; !NULL: ok
|
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_inet_ntoa(struct in_addr in, char *dst, size_t size);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>жϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD> ip <EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @param ip {const char *ip}
|
2017-04-11 23:14:39 +08:00
|
|
|
|
* @return {int} != 0: <EFBFBD><EFBFBD>; == 0: <EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_is_ip(const char *ip);
|
2017-04-07 20:13:08 +08:00
|
|
|
|
ACL_API int acl_is_ipv4(const char *ip);
|
|
|
|
|
ACL_API int acl_is_ipv6(const char *ip);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ip <EFBFBD><EFBFBD>ַ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xxx.xxx.xxx.xxx:port <EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param addr {const char*} IP:PORT <EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @return {int} 1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_ipv4_addr_valid(const char *addr);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|