Changeset 451
- Timestamp:
- 02/12/05 15:53:11 (8 years ago)
- Location:
- trunk/wifidog/src
- Files:
-
- 3 modified
-
firewall.c (modified) (2 diffs)
-
ping_thread.c (modified) (1 diff)
-
util.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/firewall.c
r449 r451 110 110 { 111 111 FILE *proc; 112 char *ip, *mac; 112 char ip[16]; 113 char mac[18]; 113 114 char * reply; 114 115 … … 116 117 return NULL; 117 118 } 118 if (!(ip = malloc(16))) {119 debug(LOG_CRIT, "Cannot allocate 16 bytes of memory for IP, Banzai!");120 exit(1);121 }122 if (!(mac = malloc(18))) {123 debug(LOG_CRIT, "Cannot allocate 18 bytes of memory for MAC, Banzai!");124 exit(1);125 }126 119 127 120 /* Skip first line */ 128 121 while (!feof(proc) && fgetc(proc) != '\n'); 129 122 130 /* Find ip, putmac in reply */123 /* Find ip, copy mac in reply */ 131 124 reply = NULL; 132 125 while (!feof(proc) && (fscanf(proc, " %15[0-9.] %*s %*s %17[A-F0-9:] %*s %*s", ip, mac) == 2)) { 133 126 if (strcmp(ip, req_ip) == 0) { 134 reply = mac;127 reply = strdup(mac); 135 128 break; 136 129 } 137 130 } 138 139 free(ip);140 if (!reply)141 free(mac);142 131 143 132 fclose(proc); -
trunk/wifidog/src/ping_thread.c
r450 r451 193 193 } 194 194 if ((fh = fopen("/proc/loadavg", "r"))) { 195 fscanf(fh, "% *s %f", &sys_load);195 fscanf(fh, "%f", &sys_load); 196 196 fclose(fh); 197 197 } 198 198 199 snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s&sys_uptime=%lu&sys_memfree=%u&sys_load=%f HTTP/1.0\n" 199 /* 200 * Prep & send request 201 */ 202 snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s&sys_uptime=%lu&sys_memfree=%u&sys_load=%.2f HTTP/1.0\n" 200 203 "User-Agent: WiFiDog %s\n" 201 204 "Host: %s\n" -
trunk/wifidog/src/util.c
r426 r451 103 103 h_addr = (struct in_addr *)malloc(sizeof(struct in_addr)); 104 104 105 if (h_addr == NULL) 106 return NULL; 105 if (h_addr == NULL) { 106 debug(LOG_CRIT, "Failed to allocate memory for in_addr"); 107 exit(1); 108 } 107 109 108 110 LOCK_GHBN();
