/* * Copyright (c) 2020 YuQing <384681@qq.com> * * This program is free software: you can use, redistribute, and/or modify * it under the terms of the Lesser GNU General Public License, version 3 * or later ("LGPL"), as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the Lesser GNU General Public License * along with this program. If not, see . */ #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; } const char *local_host_ip_addrs_to_string(char *buff, const int size) { char *p; char *pEnd; int len; len = snprintf(buff, size, "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