diff --git a/HISTORY b/HISTORY index 8d108bd..4e2c206 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,8 @@ -Version 1.22 2015-09-15 +Version 1.22 2015-10-09 * export php function: fastcommon_get_first_local_ip + * add function is_private_ip + * add function get_next_local_ip Version 1.21 2015-09-14 * ini_file_reader support annotation function diff --git a/src/local_ip_func.c b/src/local_ip_func.c index ecb17aa..068ec5a 100644 --- a/src/local_ip_func.c +++ b/src/local_ip_func.c @@ -134,26 +134,49 @@ void print_local_host_ip_addrs() printf("\n"); } -const char *get_first_local_ip() +const char *get_next_local_ip(const char *previous_ip) { char *p; char *pEnd; + bool found; if (g_local_host_ip_count == 0) { load_local_host_ip_addrs(); } + found = (previous_ip == NULL); pEnd = g_local_host_ip_addrs + \ IP_ADDRESS_SIZE * g_local_host_ip_count; for (p=g_local_host_ip_addrs; p= 16 && b < 32) + { + return true; + } + } + + return false; +} + diff --git a/src/shared_func.h b/src/shared_func.h index e88d90b..b9ee212 100644 --- a/src/shared_func.h +++ b/src/shared_func.h @@ -515,6 +515,11 @@ int ignore_signal_pipe(); double get_line_distance_km(const double lat1, const double lon1, const double lat2, const double lon2); +/** is private ip address for IPv4 + * return: true for private ip, otherwise false + */ +bool is_private_ip(const char* ip); + #ifdef __cplusplus } #endif