Changeset 22
- Timestamp:
- 03/13/04 18:06:02 (5 years ago)
- Files:
-
- branches/incorporate_libhttpd/wifidog/src/Makefile.am (modified) (2 diffs)
- branches/incorporate_libhttpd/wifidog/src/centralserver.c (added)
- branches/incorporate_libhttpd/wifidog/src/centralserver.h (added)
- branches/incorporate_libhttpd/wifidog/src/common.h (modified) (1 diff)
- branches/incorporate_libhttpd/wifidog/src/firewall.c (modified) (1 diff)
- branches/incorporate_libhttpd/wifidog/src/http.c (modified) (2 diffs)
- branches/incorporate_libhttpd/wifidog/src/http.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/incorporate_libhttpd/wifidog/src/Makefile.am
r9 r22 15 15 firewall.c \ 16 16 gateway.c \ 17 centralserver.c \ 17 18 http.c 18 19 … … 24 25 firewall.h \ 25 26 gateway.h \ 27 centralserver.h \ 26 28 http.h 27 29 branches/incorporate_libhttpd/wifidog/src/common.h
r20 r22 51 51 #include "cgi.h" 52 52 #include "http.h" 53 #include "centralserver.h" 53 54 54 55 #include "httpd.h" branches/incorporate_libhttpd/wifidog/src/firewall.c
r18 r22 196 196 } else { 197 197 p1->counter = counter; 198 if ((profile = auth (p1->ip, p1->mac, p1->token, p1->counter)) == -1) {198 if ((profile = authenticate(p1->ip, p1->mac, p1->token, p1->counter)) == -1) { 199 199 /* User has to be kicked out */ 200 200 } branches/incorporate_libhttpd/wifidog/src/http.c
r20 r22 88 88 http_body(body, "I could not find your hardware address for your IP address %s, please report this error to the systems administrator", ip); 89 89 } else { 90 if ((profile = auth (ip, mac, token, 0)) != -1) {90 if ((profile = authenticate(ip, mac, token, 0)) != -1) { 91 91 /* Authentication succesful */ 92 92 if (profile == 0) { … … 195 195 } 196 196 197 int198 auth(char *ip, char *mac, char *token, long int stats)199 {200 int sockfd, numbytes;201 char buf[MAX_BUF];202 struct hostent *he;203 struct sockaddr_in their_addr;204 int profile;205 char *p1;206 207 if ((he = gethostbyname(config.authserv_hostname)) == NULL) {208 debug(D_LOG_ERR, "gethostbyname(): %s", strerror(errno));209 exit(1);210 }211 212 if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {213 debug(D_LOG_ERR, "socket(): %s", strerror(errno));214 exit(1);215 }216 217 their_addr.sin_family = AF_INET;218 their_addr.sin_port = htons(config.authserv_port);219 their_addr.sin_addr = *((struct in_addr *)he->h_addr);220 memset(&(their_addr.sin_zero), '\0', 8);221 222 debug(D_LOG_DEBUG, "Connecting to auth server %s on port %d", config.authserv_hostname, config.authserv_port);223 224 if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) {225 debug(D_LOG_ERR, "connect(): %s", strerror(errno));226 exit(1);227 }228 229 sprintf(buf, "GET %s?ip=%s&mac=%s&token=%s&stats=%ld HTTP/1.1\nHost: %s\n\n", config.authserv_path, ip, mac, token, stats, config.authserv_hostname);230 sock_send(sockfd, buf);231 232 debug(D_LOG_DEBUG, "Sending HTTP request:\n#####\n%s\n#####", buf);233 234 if ((numbytes = recv(sockfd, buf, MAX_BUF - 1, 0)) == -1) {235 debug(D_LOG_ERR, "recv(): %s", strerror(errno));236 exit(1);237 }238 239 buf[numbytes] = '\0';240 241 close(sockfd);242 243 if ((p1 = strstr(buf, "Profile: "))) {244 if (sscanf(p1, "Profile: %d", &profile) == 1) {245 debug(D_LOG_DEBUG, "Auth server returned profile %d", profile);246 return(profile);247 } else {248 debug(D_LOG_DEBUG, "Auth server did not return expected information");249 return(-1);250 }251 } else {252 return(-1);253 }254 255 close(sockfd);256 257 return(-1);258 }259 branches/incorporate_libhttpd/wifidog/src/http.h
r9 r22 33 33 void sock_send(int sockfd, char *buffer); 34 34 char *gmtdate(); 35 int auth(char *ip, char *mac, char *token, long int stats);36 35 37 36 #endif /* _HTTP_H_ */
