[Chilli] Building Coova-Chilli with clang

Sevan / Venture37 venture37 at gmail.com
Fri May 9 22:53:42 UTC 2014


Hi,
The source code in its current state will not build when using the
clang, the attached diff fixes that. This work is part of getting
Coova-Chill to run on FreeBSD 10 & newer however these changes affect
all platforms not just FreeBSD so I'm posting the diff here to ask for
testing/feedback.
I'm currently unable to do propper testing as there is more prep work
that needs to be done on FreeBSD so that everything is running
correctly.
There will also be another diff coming up which fixes the network side
of things on FreeBSD.
This diff is against the latest sources in the GitHub repository.
You should test this diff if you are still using GCC as your compiler.

Sevan / Venture37
-------------- next part --------------
diff --git a/src/dhcp.c b/src/dhcp.c
index 023c1f7..53dd369 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -4131,6 +4131,64 @@ int dhcp_receive_ip(struct dhcp_ctx *ctx, uint8_t *pack, size_t len) {
 }
 
 #ifdef ENABLE_IPV6
+void check_options(int datalen, uint8_t *data, uint8_t b[256]) {
+        if (datalen > 0) {
+          uint8_t t, l;
+          int i=0;
+          while (datalen > 0) {
+            int dlen = -1;
+            t = data[i++]; datalen--;
+            if (!datalen) break;
+            l = data[i++]; datalen--;
+            if (!datalen) break;
+            switch(t) {
+            case 1: /* source link-layer address */
+            case 2: /* target link-layer address */
+              dlen = l * PKT_ETH_ALEN;
+              break;
+            default:
+              log_dbg(0, "could not parse ICMP option");
+              datalen = 0;
+              break;
+            }
+            if (dlen > 0) {
+              if (dlen <= datalen) {
+                log_dbg("ICMPv6 Option %d %d %d",(int)t,(int)l,dlen);
+                memcpy(b, data + i, dlen);
+                switch(t) {
+                case 1: /* source link-layer address */
+                case 2: /* target link-layer address */
+              dlen = l * PKT_ETH_ALEN;
+              break;
+            default:
+              log_dbg(0, "could not parse ICMP option");
+              datalen = 0;
+              break;
+            }
+            if (dlen > 0) {
+              if (dlen <= datalen) {
+                log_dbg("ICMPv6 Option %d %d %d",(int)t,(int)l,dlen);
+                memcpy(b, data + i, dlen);
+                switch(t) {
+                case 1: /* source link-layer address */
+                case 2: /* target link-layer address */
+                  log_dbg("ICMPv6 Source Link-Layer Address Option "MAC_FMT,
+                          MAC_ARG(b));
+                  break;
+                default:
+                  break;
+                }
+              }
+
+              i += dlen;
+              datalen -= dlen;
+            }
+          }
+        }
+}
+}
+}
+
 int dhcp_receive_ipv6(struct dhcp_ctx *ctx, uint8_t *pack, size_t len) {
   struct dhcp_t *this = ctx->parent;
   struct pkt_ethhdr_t *ethh = pkt_ethhdr(pack);
@@ -4151,53 +4209,13 @@ int dhcp_receive_ipv6(struct dhcp_ctx *ctx, uint8_t *pack, size_t len) {
   case ICMPv6_NEXT_HEADER:
     {
       int datalen = 0;
-      uint8_t b[256], *data;
+      uint8_t b[256], *data = NULL;
       
       struct pkt_icmphdr_t * icmphdr = 
 	(struct pkt_icmphdr_t *)
 	(((uint8_t *)iphdr) + sizeof(struct pkt_ip6hdr_t));
 
-      void check_options() {
-	if (datalen > 0) {
-	  uint8_t t, l;
-	  int i=0;
-	  while (datalen > 0) {
-	    int dlen = -1;
-	    t = data[i++]; datalen--;
-	    if (!datalen) break;
-	    l = data[i++]; datalen--;
-	    if (!datalen) break;
-	    switch(t) {
-	    case 1: /* source link-layer address */
-	    case 2: /* target link-layer address */
-	      dlen = l * PKT_ETH_ALEN;
-	      break;
-	    default:
-	      log_dbg(0, "could not parse ICMP option");
-	      datalen = 0;
-	      break;
-	    }
-	    if (dlen > 0) {
-	      if (dlen <= datalen) {
-		log_dbg("ICMPv6 Option %d %d %d",(int)t,(int)l,dlen);
-		memcpy(b, data + i, dlen);
-		switch(t) {
-		case 1: /* source link-layer address */
-		case 2: /* target link-layer address */
-		  log_dbg("ICMPv6 Source Link-Layer Address Option "MAC_FMT,
-			  MAC_ARG(b));
-		  break;
-		default:
-		  break;
-		}
-	      }
-	      
-	      i += dlen;
-	      datalen -= dlen;
-	    }
-	  }
-	}
-      }
+      check_options(datalen, data, b);
 
       data = ((uint8_t *)icmphdr) + sizeof(struct pkt_icmphdr_t);
       
@@ -4231,7 +4249,7 @@ int dhcp_receive_ipv6(struct dhcp_ctx *ctx, uint8_t *pack, size_t len) {
 
 	data += 4;
 	datalen -= 4;
-	check_options();
+	check_options(datalen, data, b);
 	
 	/*	  
 	  4.2. Router Advertisement Message Format
@@ -4388,7 +4406,7 @@ int dhcp_receive_ipv6(struct dhcp_ctx *ctx, uint8_t *pack, size_t len) {
 	  data += 16;
 	  datalen -= 16;
 
-	  check_options();
+	  check_options(datalen, data, b);
 	  
 	  memset(packet, 0, sizeof(packet));
 	  copy_ethproto(pack, packet);
diff --git a/src/garden.c b/src/garden.c
index fbc5458..65089c1 100644
--- a/src/garden.c
+++ b/src/garden.c
@@ -53,7 +53,8 @@ void garden_print_list(int fd, pass_through *ptlist, int ptcnt) {
 #endif
 		  );
     
-    if (!safe_write(fd, line, strlen(line))) /* error */;
+    if (!safe_write(fd, line, strlen(line))) /* error */
+	;
   }
 }
 
@@ -103,7 +104,8 @@ void garden_print(int fd) {
 		"static garden (%d/%d):\n",
 		_options.num_pass_throughs,
 		MAX_PASS_THROUGHS);
-  if (!safe_write(fd, line, strlen(line))) /* error */;
+  if (!safe_write(fd, line, strlen(line))) /* error */
+	;
 
 #ifdef HAVE_PATRICIA
   if (dhcp->ptree) {
@@ -118,7 +120,8 @@ void garden_print(int fd) {
 		"dynamic garden (%d/%d):\n",
 		dhcp->num_pass_throughs,
 		MAX_PASS_THROUGHS);
-  if (!safe_write(fd, line, strlen(line))) /* error */;
+  if (!safe_write(fd, line, strlen(line))) /* error */
+	;
   
 #ifdef HAVE_PATRICIA
   if (dhcp->ptree_dyn) {
diff --git a/src/ippool.c b/src/ippool.c
index 61a6243..3f2b883 100644
--- a/src/ippool.c
+++ b/src/ippool.c
@@ -501,7 +501,7 @@ int ippool_newip(struct ippool_t *this,
     /* Find in hash table */
     hash = ippool_hash4(addr) & this->hashmask;
     for (p = this->hash[hash]; p; p = p->nexthash) {
-      if ((p->addr.s_addr == addr->s_addr)) {
+      if (p->addr.s_addr == addr->s_addr) {
 	p2 = p;
 	break;
       }
diff --git a/src/md5.c b/src/md5.c
index 849e2f8..93c71af 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -140,7 +140,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
     MD5Transform(ctx->buf, (uint32_t *) ctx->in);
     byteReverse((unsigned char *) ctx->buf, 4);
     memcpy(digest, ctx->buf, 16);
-    memset(ctx, 0, sizeof(ctx));	/* In case it's sensitive */
+    memset(ctx, 0, sizeof(*ctx));	/* In case it's sensitive */
 }
 
 /* The four core functions - F1 is optimized somewhat */
diff --git a/src/redir.c b/src/redir.c
index 9d6d63e..80401bb 100644
--- a/src/redir.c
+++ b/src/redir.c
@@ -955,6 +955,26 @@ void redir_wispr1_reply (struct redir_t *redir, struct redir_conn_t *conn,
   bdestroy(bt);
 }
 
+void write_authentication_msg_header (struct redir_conn_t *conn, bstring b) {
+  if (conn->authdata.type == REDIR_AUTH_EAP) {
+    bcatcstr(b,
+             "<EAPAuthenticationReply>\r\n"
+             "<MessageType>121</MessageType>\r\n"); /* response to authentication notification */
+  } else {
+    bcatcstr(b,
+             "<AuthenticationReply>\r\n"
+             "<MessageType>120</MessageType>\r\n"); /* response to authentication notification */
+  }
+}
+
+void write_authentication_msg_footer(struct redir_conn_t *conn, bstring b) {
+  if (conn->authdata.type == REDIR_AUTH_EAP) {
+    bcatcstr(b, "</EAPAuthenticationReply>\r\n");
+  } else {
+    bcatcstr(b, "</AuthenticationReply>\r\n");
+  }
+}
+
 /* Make a WISPr 2.0 XML reply 
  * Note: This method must be called if Coova advertises the support of both 
  * WISPr 1.0 and WISPr 2.0 in the "NOTYET" phase */
@@ -964,26 +984,6 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
   bstring bt = bfromcstr("");
   char eap64str [MAX_EAP_LEN*2];
   
-  void write_authentication_msg_header () {
-    if (conn->authdata.type == REDIR_AUTH_EAP) {
-      bcatcstr(b, 
-	       "<EAPAuthenticationReply>\r\n"
-	       "<MessageType>121</MessageType>\r\n"); /* response to authentication notification */
-    } else {
-      bcatcstr(b, 
-	       "<AuthenticationReply>\r\n" 
-	       "<MessageType>120</MessageType>\r\n"); /* response to authentication notification */
-    }
-  }
-  
-  void write_authentication_msg_footer() {
-    if (conn->authdata.type == REDIR_AUTH_EAP) {
-      bcatcstr(b, "</EAPAuthenticationReply>\r\n");
-    } else {
-      bcatcstr(b, "</AuthenticationReply>\r\n");
-    }
-  }
-
   log_dbg("%s", __FUNCTION__);
   
   bcatcstr(b,
@@ -1056,7 +1056,7 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
     break;
     
   case REDIR_FAILED_REJECT:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>100</ResponseCode>\r\n"); /* login failed (Access REJECT) */
@@ -1069,33 +1069,33 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
       bcatcstr(b, "<ReplyMessage>Invalid Password</ReplyMessage>\r\n");
     }
         
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_FAILED_NOROUTE:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>105</ResponseCode>\r\n"); /* RADIUS serveur error/timeout */
     
     bcatcstr(b, "<ReplyMessage>no route for realm</ReplyMessage>\r\n");
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_FAILED_MTU:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>253</ResponseCode>\r\n"); /* MTU is too big */
     
     bcatcstr(b, "<ReplyMessage>AAA MTU is too big</ReplyMessage>\r\n");
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_FAILED_TIMEOUT:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>102</ResponseCode>\r\n"); /* RADIUS serveur timeout */
@@ -1107,11 +1107,11 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
       bcatcstr(b, "<ReplyMessage>Radius timeout</ReplyMessage>\r\n");
     }
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_ERROR_PROTOCOL:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>254</ResponseCode>\r\n"); /* WISPr 2.0 protocol error */
@@ -1123,11 +1123,11 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
       bcatcstr(b, "<ReplyMessage>WISPr 2.0 protocol error</ReplyMessage>\r\n");
     }
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_FAILED_OTHER:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>255</ResponseCode>\r\n"); /* RADIUS serveur error */
@@ -1139,7 +1139,7 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
       bcatcstr(b, "<ReplyMessage>Radius error</ReplyMessage>\r\n");
     }
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_CHALLENGE:
@@ -1167,7 +1167,7 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
     break;
     
   case REDIR_SUCCESS:
-    write_authentication_msg_header();     
+    write_authentication_msg_header(conn,b);
     
     bcatcstr(b, 
 	     "<ResponseCode>50</ResponseCode>\r\n"); 
@@ -1204,7 +1204,7 @@ void redir_wispr2_reply (struct redir_t *redir, struct redir_conn_t *conn,
       bconcat(b, bt);
     }
     
-    write_authentication_msg_footer();
+    write_authentication_msg_footer(conn,b);
     break;
     
   case REDIR_LOGOFF:
@@ -1911,6 +1918,7 @@ int redir_getparam(struct redir_t *redir, char *src, char *param, bstring dst) {
 
   return 0;
 }
+char forked;
 
 /* Read the an HTTP request from a client */
 static int redir_getreq(struct redir_t *redir, struct redir_socket_t *sock,
@@ -1930,7 +1938,7 @@ static int redir_getreq(struct redir_t *redir, struct redir_socket_t *sock,
 
   char *path = httpreq->path;
 
-  char forked = (rreq == 0);
+  forked = (rreq == 0);
 
   char wblock = 0, done = 0, eoh = 0;
 
@@ -3182,6 +3190,25 @@ pid_t redir_fork(int in, int out) {
   return pid;
 }
 
+int redir_main_exit(struct redir_socket_t *socket) {
+    /* if (httpreq->data_in) bdestroy(httpreq->data_in); */
+    /* if (!forked) return 0; XXXX*/
+#ifdef HAVE_SSL
+    if (socket.sslcon) {
+#if(_debug_ > 1)
+      log_dbg("Shutting down SSL");
+#endif
+      openssl_shutdown(socket.sslcon, 2);
+      openssl_free(socket.sslcon);
+      socket.sslcon = 0;
+      if (rreq)
+        rreq->sslcon = 0;
+    }
+#endif
+    if (forked) _redir_close_exit(socket->fd[0], socket->fd[1]);
+    return _redir_close(socket->fd[0], socket->fd[1]);
+}
+
 int redir_main(struct redir_t *redir, 
 	       int infd, int outfd, 
 	       struct sockaddr_in *address, 
@@ -3215,25 +3242,6 @@ int redir_main(struct redir_t *redir,
   int forked = (rreq == 0);
   int err;
 
-  int redir_main_exit() {
-    /* if (httpreq->data_in) bdestroy(httpreq->data_in); */
-    /* if (!forked) return 0; XXXX*/
-#ifdef HAVE_SSL
-    if (socket.sslcon) {
-#if(_debug_ > 1)
-      log_dbg("Shutting down SSL");
-#endif
-      openssl_shutdown(socket.sslcon, 2);
-      openssl_free(socket.sslcon);
-      socket.sslcon = 0;
-      if (rreq) 
-	rreq->sslcon = 0;
-    }
-#endif
-    if (forked) _redir_close_exit(socket.fd[0], socket.fd[1]);
-    return _redir_close(socket.fd[0], socket.fd[1]);
-  }
-
 
   memset(&httpreq,0,sizeof(httpreq));
   httpreq.allow_post = isui || _options.uamallowpost;
@@ -3260,7 +3268,7 @@ int redir_main(struct redir_t *redir,
   memcpy(&msg.mdata.redir, &conn.s_state.redir, sizeof(msg.mdata.redir)); \
   if (redir_send_msg(redir, &msg) < 0) { \
     log_err(errno, "write() failed! msgfd=%d type=%d len=%d", redir->msgfd, msg.mtype, sizeof(msg.mdata)); \
-    return redir_main_exit(); \
+    return redir_main_exit(&socket); \
   } 
 #else
 #define redir_msg_send(msgopt) \
@@ -3271,7 +3279,7 @@ int redir_main(struct redir_t *redir,
   memcpy(&msg.mdata.redir, &conn.s_state.redir, sizeof(msg.mdata.redir)); \
   if (msgsnd(redir->msgid, (void *)&msg, sizeof(msg.mdata), 0) < 0) { \
     log_err(errno, "msgsnd() failed! msgid=%d type=%d len=%d", redir->msgid, msg.mtype, sizeof(msg.mdata)); \
-    return redir_main_exit(); \
+    return redir_main_exit(&socket); \
   } 
 #endif
 
@@ -3291,7 +3299,7 @@ int redir_main(struct redir_t *redir,
   /*
   if (ndelay_on(socket.fd[0])) {
     log_err(errno, "fcntl() failed");
-    return redir_main_exit();
+    return redir_main_exit(&socket);
   }
   */
 
@@ -3307,7 +3315,7 @@ int redir_main(struct redir_t *redir,
 
   if (!redir->cb_getstate) { 
     log_err(0, "No cb_getstate() defined!"); 
-    return redir_main_exit();
+    return redir_main_exit(&socket);
   }
 
   /* get_state returns 0 for unauth'ed and 1 for auth'ed */
@@ -3331,7 +3339,7 @@ int redir_main(struct redir_t *redir,
     } else 
 #endif
     {
-      return redir_main_exit();
+      return redir_main_exit(&socket);
     }
   }
   
@@ -3371,7 +3379,7 @@ int redir_main(struct redir_t *redir,
 #if(_debug_ > 1)
 	log_dbg("redir error, redir_main_exit");
 #endif
-	return redir_main_exit();
+	return redir_main_exit(&socket);
       case 1:
 	if (!loop) {
 	  log_dbg("Continue... SSL pending");
@@ -3402,7 +3410,7 @@ int redir_main(struct redir_t *redir,
     return 1;
   default:
     log_dbg("Error calling get_req. Terminating %d", err);
-    return redir_main_exit();
+    return redir_main_exit(&socket);
   }
 
 #if(_debug_ > 1)
@@ -3445,7 +3453,7 @@ int redir_main(struct redir_t *redir,
 	if (isEWT) {
 	  if (!(conn.s_params.flags & ADMIN_LOGIN)) {
 	    log_warn(0, "Permission denied to EWT API");
-	    return redir_main_exit();
+	    return redir_main_exit(&socket);
 	  }
 	} else 
 #endif
@@ -3471,7 +3479,7 @@ int redir_main(struct redir_t *redir,
 	    if (*p >= '0' && *p <= '9') continue;
 	    /* invalid file name! */
 	    log_err(0, "invalid www request [%s]!", filename);
-	    return redir_main_exit();
+	    return redir_main_exit(&socket);
 	  }
 	}
 
@@ -3505,7 +3513,7 @@ int redir_main(struct redir_t *redir,
 	else { 
 	  /* we do not serve it! */
 	  log_err(0, "invalid file extension! [%s]", filename);
-	  return redir_main_exit();
+	  return redir_main_exit(&socket);
 	}
 	
 	if (!forked) {
@@ -3515,7 +3523,7 @@ int redir_main(struct redir_t *redir,
 	   */
 	  forkpid = redir_fork(infd, outfd);
 	  if (forkpid) { /* parent or error */
-	    return redir_main_exit();
+	    return redir_main_exit(&socket);
 	  }
 	}
 	
@@ -3523,7 +3531,7 @@ int redir_main(struct redir_t *redir,
 	  
 	  if (!_options.wwwbin) {
 	    log_err(0, "the 'wwwbin' setting must be configured for CGI use");
-	    return redir_main_exit();
+	    return redir_main_exit(&socket);
 	  }
 
 	  if (ndelay_off(socket.fd[0])) {
@@ -3542,14 +3550,14 @@ int redir_main(struct redir_t *redir,
 	    
 	    if (pipe(ptoc) == -1 || pipe(ctop) == -1) {
 	      log_err(errno, "pipe() failed");
-	      return redir_main_exit();
+	      return redir_main_exit(&socket);
 	    }
 	    
 	    forkpid = redir_fork(ptoc[0], ctop[1]);
 	    
 	    if (forkpid < 0) {
 	      log_err(errno, "fork() failed");
-	      return redir_main_exit();
+	      return redir_main_exit(&socket);
 	    }
 	    
 	    forked = 1;
@@ -3573,7 +3581,7 @@ int redir_main(struct redir_t *redir,
 		if ((buflen = openssl_read(socket.sslcon, buffer, rd, 0)) > 0) {
 		  if (safe_write(ptoc[1], buffer, (size_t) buflen) < 0) {
 		    log_err(errno, "error");
-		    return redir_main_exit();
+		    return redir_main_exit(&socket);
 		  }
 		  clen -= buflen;
 		}
@@ -3609,7 +3617,7 @@ int redir_main(struct redir_t *redir,
 	      safe_close(ptoc[1]);
 	      safe_close(ctop[0]);
 	      
-	      return redir_main_exit();
+	      return redir_main_exit(&socket);
 	      
 	    } else {
 	      /* child */
@@ -3691,7 +3699,7 @@ int redir_main(struct redir_t *redir,
 	    break;
 	  }
 	  
-	  return redir_main_exit();
+	  return redir_main_exit(&socket);
 	}
 	
 	if ( (_options.uid == 0 && !chroot(_options.wwwdir) && !chdir("/")) ||
@@ -3739,7 +3747,7 @@ int redir_main(struct redir_t *redir,
       }
       else log_err(0, "Required: 'wwwdir' (in chilli.conf) and 'file' query-string param"); 
       
-      return redir_main_exit();
+      return redir_main_exit(&socket);
     }
   }
 
@@ -3774,7 +3782,7 @@ int redir_main(struct redir_t *redir,
 		    (char *)conn.s_params.url, conn.hismac, 
 		    &conn.hisip, httpreq.qs);
 	
-	return redir_main_exit();
+	return redir_main_exit(&socket);
       }
     }
 
@@ -3792,7 +3800,7 @@ int redir_main(struct redir_t *redir,
 		  0, hexchal, NULL, NULL, NULL, 
 		  0, conn.hismac, &conn.hisip, httpreq.qs);
 
-      return redir_main_exit();
+      return redir_main_exit(&socket);
     }
 
     if (is_local_user(redir, &conn)) { 
@@ -3813,7 +3821,7 @@ int redir_main(struct redir_t *redir,
 	 */
 	pid_t forkpid = redir_fork(infd, outfd);
 	if (forkpid) { /* parent or error */
-	  return redir_main_exit();
+	  return redir_main_exit(&socket);
 	}
       }
 
@@ -3829,7 +3837,7 @@ int redir_main(struct redir_t *redir,
 	    flags |= modresult;
 	    switch(chilli_mod_state(modresult)) {
 	    case CHILLI_MOD_ERROR:
-	      return redir_main_exit();
+	      return redir_main_exit(&socket);
 	    default: 
 	      break;
 	    }
@@ -3905,7 +3913,7 @@ int redir_main(struct redir_t *redir,
     }    
 
     log_dbg("-->> Msg userurl=[%s]\n",conn.s_state.redir.userurl);
-    return redir_main_exit();
+    return redir_main_exit(&socket);
   }
 
   case REDIR_LOGOUT:
@@ -3919,7 +3927,7 @@ int redir_main(struct redir_t *redir,
 		  hexchal, NULL, conn.s_state.redir.userurl, NULL, 
 		  NULL, conn.hismac, &conn.hisip, httpreq.qs);
       
-      return redir_main_exit();
+      return redir_main_exit(&socket);
     }
     
   case REDIR_MACREAUTH:
@@ -3950,7 +3958,7 @@ int redir_main(struct redir_t *redir,
 		  NULL, 0, hexchal, NULL, conn.s_state.redir.userurl, NULL, 
 		  NULL, conn.hismac, &conn.hisip, httpreq.qs);
     }
-    return redir_main_exit();
+    return redir_main_exit(&socket);
 
   case REDIR_ABORT:
     if (state == 1) {
@@ -3966,12 +3974,12 @@ int redir_main(struct redir_t *redir,
 		  NULL, 0, hexchal, NULL, conn.s_state.redir.userurl, NULL, 
 		  NULL, conn.hismac, &conn.hisip, httpreq.qs);
     }
-    return redir_main_exit();
+    return redir_main_exit(&socket);
 
   case REDIR_ABOUT:
     redir_reply(redir, &socket, &conn, REDIR_ABOUT, NULL, 
 		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, httpreq.qs);
-    return redir_main_exit();
+    return redir_main_exit(&socket);
 
   case REDIR_STATUS:
     {
@@ -3998,13 +4006,13 @@ int redir_main(struct redir_t *redir,
 		  conn.s_state.redir.userurl, conn.reply, 
 		  0, conn.hismac, &conn.hisip, httpreq.qs);
       
-      return redir_main_exit();
+      return redir_main_exit(&socket);
     }
 
   case REDIR_MSDOWNLOAD:
     safe_snprintf(buffer, bufsize, "HTTP/1.0 403 Forbidden\r\n\r\n");
     redir_write(&socket, buffer, strlen(buffer));
-    return redir_main_exit();
+    return redir_main_exit(&socket);
 
 #if(0)
   {
@@ -4043,7 +4051,7 @@ int redir_main(struct redir_t *redir,
 
     safe_snprintf(buffer, bufsize, cnt);
     redir_write(&socket, buffer, strlen(buffer));
-    return redir_main_exit();
+    return redir_main_exit(&socket);
   }
 #endif
 
@@ -4223,7 +4231,7 @@ int redir_main(struct redir_t *redir,
 		NULL, conn.hismac, &conn.hisip, httpreq.qs);
   }
 
-  return redir_main_exit();
+  return redir_main_exit(&socket);
 }
 
 


More information about the Chilli mailing list