Changeset 492
- Timestamp:
- 03/11/05 11:15:06 (8 years ago)
- Location:
- trunk/wifidog
- Files:
-
- 5 modified
-
ChangeLog (modified) (1 diff)
-
src/fw_iptables.c (modified) (4 diffs)
-
src/gateway.c (modified) (1 diff)
-
src/util.c (modified) (2 diffs)
-
src/util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/ChangeLog
r490 r492 1 1 # $Header$ 2 3 2005-03-11 Mina Naguib <mina@ilesansfil.org> 4 * If external interface was unspecified in the conf file, try to determine 5 it from the default route 6 * If external interface is known, specify it in the trigger rule in 7 nat.PREROUTING to prevent the rule from matching traffic inbound to the 8 router itself. This should fix the issue raised by Philippe and Pascal on 9 the mailing list 2 10 3 11 2005-03-07 Mina Naguib <mina@ilesansfil.org> -
trunk/wifidog/src/fw_iptables.c
r490 r492 183 183 s_config *config; 184 184 char * gw_interface = NULL; 185 char * external_interface = NULL; 185 186 int gw_port = 0; 186 187 … … 191 192 gw_interface = safe_strdup(config->gw_interface); 192 193 gw_port = config->gw_port; 194 if (config->external_interface) 195 external_interface = safe_strdup(config->external_interface); 193 196 UNLOCK_CONFIG(); 194 197 … … 219 222 220 223 /* Assign links and rules to these new chains */ 221 iptables_do_command("-t nat -I PREROUTING 1 -i %s -j " TABLE_WIFIDOG_WIFI_TO_INTERNET, gw_interface); 224 if (external_interface) 225 iptables_do_command("-t nat -I PREROUTING 1 -i %s -o %s -j " TABLE_WIFIDOG_WIFI_TO_INTERNET, gw_interface, external_interface); 226 else 227 iptables_do_command("-t nat -I PREROUTING 1 -i %s -j " TABLE_WIFIDOG_WIFI_TO_INTERNET, gw_interface); 222 228 iptables_do_command("-t nat -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -m mark --mark 0x%u -j RETURN", FW_MARK_KNOWN); 223 229 iptables_do_command("-t nat -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -m mark --mark 0x%u -j RETURN", FW_MARK_PROBATION); … … 264 270 265 271 free(gw_interface); 272 if (external_interface) 273 free(external_interface); 266 274 267 275 return 1; -
trunk/wifidog/src/gateway.c
r488 r492 179 179 debug(LOG_DEBUG, "%s = %s", config->gw_interface, config->gw_address); 180 180 } 181 /* If we don't have the external interface, try to get it */ 182 if (!config->external_interface) { 183 config->external_interface = get_default_iface(); 184 if (!config->external_interface) { 185 debug(LOG_CRIT, "Failed to determine external interface. The firewall rules will not be up to par"); 186 } 187 } 188 181 189 182 190 /* Initializes the web server */ -
trunk/wifidog/src/util.c
r488 r492 49 49 #include <netdb.h> 50 50 51 #include "common.h" 51 52 #include "client_list.h" 52 53 #include "safe.h" … … 137 138 } 138 139 140 /* 141 * @return Interface name or NULL if it cannot be determined - must be free()ed by caller when no longer needed 142 */ 143 char * get_default_iface() { 144 FILE * fh; 145 char * retval = NULL; 146 char buffer[MAX_BUF]; 147 char ifname[MAX_BUF]; 148 char mask[MAX_BUF]; 149 debug(LOG_INFO, "Trying to determine the default interface"); 150 151 if ((fh = fopen("/proc/net/route", "r"))) { 152 while (!feof(fh) && fgets(buffer, sizeof(buffer), fh)) { 153 if (sscanf(buffer, "%s %s", ifname, mask) == 2 && strcmp(mask, "00000000") == 0) { 154 /* Found it */ 155 retval = safe_strdup(ifname); 156 debug(LOG_INFO, "Determined default interface [%s]", retval); 157 break; 158 } 159 } 160 fclose(fh); 161 } 162 else { 163 debug(LOG_ERR, "Failed to open /proc/net/route"); 164 } 165 166 if (!retval) 167 debug(LOG_ERR, "Failed to determine default interface"); 168 169 return retval; 170 } 171 139 172 char *get_iface_ip(char *ifname) { 140 173 #ifdef __linux__ -
trunk/wifidog/src/util.h
r479 r492 38 38 char *get_iface_ip(char *ifname); 39 39 40 /* @Brief get the interface name used by the default route */ 41 char * get_default_iface(); 42 40 43 /* @brief Sets hint that an online action (dns/connect/etc using WAN) succeeded */ 41 44 void mark_online();
