/** * Copyright (C) 2008 Happy Fish / YuQing * * FastDFS may be copied only under the terms of the GNU General * Public License V3, which may be found in the FastDFS source kit. * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. **/ #include #include #include #include "logger.h" #include "sockopt.h" #include "shared_func.h" #include "local_ip_func.h" int g_local_host_ip_count = 0; char g_local_host_ip_addrs[FAST_MAX_LOCAL_IP_ADDRS * \ IP_ADDRESS_SIZE]; char g_if_alias_prefix[FAST_IF_ALIAS_PREFIX_MAX_SIZE] = {0}; bool is_local_host_ip(const char *client_ip) { char *p; char *pEnd; pEnd = g_local_host_ip_addrs + \ IP_ADDRESS_SIZE * g_local_host_ip_count; for (p=g_local_host_ip_addrs; p= FAST_MAX_LOCAL_IP_ADDRS) { return -1; } strcpy(g_local_host_ip_addrs + \ IP_ADDRESS_SIZE * g_local_host_ip_count, \ client_ip); g_local_host_ip_count++; return 1; } static void log_local_host_ip_addrs() { char *p; char *pEnd; char buff[512]; int len; len = sprintf(buff, "local_host_ip_count: %d,", g_local_host_ip_count); pEnd = g_local_host_ip_addrs + \ IP_ADDRESS_SIZE * g_local_host_ip_count; for (p=g_local_host_ip_addrs; p