00001 /********************************************************************\ 00002 * This program is free software; you can redistribute it and/or * 00003 * modify it under the terms of the GNU General Public License as * 00004 * published by the Free Software Foundation; either version 2 of * 00005 * the License, or (at your option) any later version. * 00006 * * 00007 * This program is distributed in the hope that it will be useful, * 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00010 * GNU General Public License for more details. * 00011 * * 00012 * You should have received a copy of the GNU General Public License* 00013 * along with this program; if not, contact: * 00014 * * 00015 * Free Software Foundation Voice: +1-617-542-5942 * 00016 * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * 00017 * Boston, MA 02111-1307, USA gnu@gnu.org * 00018 * * 00019 \********************************************************************/ 00020 00021 /* $Id: util.h 1373 2008-09-30 09:27:40Z wichert $ */ 00027 #ifndef _UTIL_H_ 00028 #define _UTIL_H_ 00029 00030 #define STATUS_BUF_SIZ 16384 00031 00034 int execute(char *cmd_line, int quiet); 00035 struct in_addr *wd_gethostbyname(const char *name); 00036 00037 /* @brief Get IP address of an interface */ 00038 char *get_iface_ip(const char *ifname); 00039 00040 /* @brief Get MAC address of an interface */ 00041 char *get_iface_mac(const char *ifname); 00042 00043 /* @brief Get interface name of default gateway */ 00044 char *get_ext_iface (void); 00045 00046 /* @brief Sets hint that an online action (dns/connect/etc using WAN) succeeded */ 00047 void mark_online(); 00048 /* @brief Sets hint that an online action (dns/connect/etc using WAN) failed */ 00049 void mark_offline(); 00050 /* @brief Returns a guess (true or false) on whether we're online or not based on previous calls to mark_online and mark_offline */ 00051 int is_online(); 00052 00053 /* @brief Sets hint that an auth server online action succeeded */ 00054 void mark_auth_online(); 00055 /* @brief Sets hint that an auth server online action failed */ 00056 void mark_auth_offline(); 00057 /* @brief Returns a guess (true or false) on whether we're an auth server is online or not based on previous calls to mark_auth_online and mark_auth_offline */ 00058 int is_auth_online(); 00059 00060 /* 00061 * @brief Creates a human-readable paragraph of the status of wifidog 00062 */ 00063 char * get_status_text(); 00064 00065 #define LOCK_GHBN() do { \ 00066 debug(LOG_DEBUG, "Locking wd_gethostbyname()"); \ 00067 pthread_mutex_lock(&ghbn_mutex); \ 00068 debug(LOG_DEBUG, "wd_gethostbyname() locked"); \ 00069 } while (0) 00070 00071 #define UNLOCK_GHBN() do { \ 00072 debug(LOG_DEBUG, "Unlocking wd_gethostbyname()"); \ 00073 pthread_mutex_unlock(&ghbn_mutex); \ 00074 debug(LOG_DEBUG, "wd_gethostbyname() unlocked"); \ 00075 } while (0) 00076 00077 #endif /* _UTIL_H_ */ 00078