acl/lib_acl/include/net/acl_sane_inet.h

60 lines
1.4 KiB
C
Raw Normal View History

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}
* @return {int} 0: <EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD>
*/
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 <EFBFBD><EFBFBD>ʽ
* @param addr {const char*} IP <EFBFBD><EFBFBD>ַ
* @return {int} 1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_ipv4_valid(const char *addr);
/**
* <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