--------------------- PatchSet 10099 Date: 2007/09/25 14:05:27 Author: adri Branch: store_copy Tag: (none) Log: Some general tidying up - remove fd_table[].ipaddr string; replace it with an in_addr for now. Use this in place and call inet_ntoa as required. Members: src/cache_manager.c:1.12->1.12.6.1 src/client_side.c:1.202.2.2->1.202.2.3 src/comm.c:1.55->1.55.2.1 src/forward.c:1.56->1.56.2.1 src/ftp.c:1.44->1.44.4.1 src/ssl.c:1.31->1.31.6.1 src/stat.c:1.42->1.42.2.1 src/structs.h:1.158.2.2->1.158.2.3 Index: squid/src/cache_manager.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_manager.c,v retrieving revision 1.12 retrieving revision 1.12.6.1 diff -u -r1.12 -r1.12.6.1 --- squid/src/cache_manager.c 26 Feb 2007 09:51:31 -0000 1.12 +++ squid/src/cache_manager.c 25 Sep 2007 14:05:27 -0000 1.12.6.1 @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.c,v 1.12 2007/02/26 09:51:31 squidadm Exp $ + * $Id: cache_manager.c,v 1.12.6.1 2007/09/25 14:05:27 adri Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -211,7 +211,7 @@ storeLockObject(entry); entry->expires = squid_curtime; debug(16, 5) ("CACHEMGR: %s requesting '%s'\n", - fd_table[fd].ipaddr, mgr->action); + inet_ntoa(fd_table[fd].remote_addr), mgr->action); /* get additional info from request headers */ cachemgrParseHeaders(mgr, request); /* Check password */ @@ -224,11 +224,11 @@ if (mgr->passwd) debug(16, 1) ("CACHEMGR: %s@%s: incorrect password for '%s'\n", mgr->user_name ? mgr->user_name : "", - fd_table[fd].ipaddr, mgr->action); + inet_ntoa(fd_table[fd].remote_addr), mgr->action); else debug(16, 1) ("CACHEMGR: %s@%s: password needed for '%s'\n", mgr->user_name ? mgr->user_name : "", - fd_table[fd].ipaddr, mgr->action); + inet_ntoa(fd_table[fd].remote_addr), mgr->action); rep = errorBuildReply(err); errorStateFree(err); /* @@ -245,7 +245,7 @@ } debug(16, 1) ("CACHEMGR: %s@%s requesting '%s'\n", mgr->user_name ? mgr->user_name : "", - fd_table[fd].ipaddr, mgr->action); + inet_ntoa(fd_table[fd].remote_addr), mgr->action); /* retrieve object requested */ a = cachemgrFindAction(mgr->action); assert(a != NULL); Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.2 retrieving revision 1.202.2.3 diff -u -r1.202.2.2 -r1.202.2.3 --- squid/src/client_side.c 25 Sep 2007 01:53:31 -0000 1.202.2.2 +++ squid/src/client_side.c 25 Sep 2007 14:05:28 -0000 1.202.2.3 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.2 2007/09/25 01:53:31 adri Exp $ + * $Id: client_side.c,v 1.202.2.3 2007/09/25 14:05:28 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -3785,7 +3785,7 @@ conn->nrequests++; commSetTimeout(fd, Config.Timeout.lifetime, clientLifetimeTimeout, http); if (parser_return_code < 0) { - debug(33, 1) ("clientReadRequest: FD %d (%s:%d) Invalid Request\n", fd, fd_table[fd].ipaddr, fd_table[fd].remote_port); + debug(33, 1) ("clientReadRequest: FD %d (%s:%d) Invalid Request\n", fd, inet_ntoa(fd_table[fd].remote_addr), fd_table[fd].remote_port); err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST, NULL); err->src_addr = conn->peer.sin_addr; err->request_hdrs = xstrdup(conn->in.buf); @@ -4439,7 +4439,7 @@ break; } F = &fd_table[fd]; - debug(33, 4) ("httpAccept: FD %d: accepted port %d client %s:%d\n", fd, F->local_port, F->ipaddr, F->remote_port); + debug(33, 4) ("httpAccept: FD %d: accepted port %d client %s:%d\n", fd, F->local_port, inet_ntoa(F->remote_addr), F->remote_port); fd_note_static(fd, "client http connect"); connState = cbdataAlloc(ConnStateData); connState->port = s; @@ -4961,7 +4961,7 @@ conn->pinning.auth = auth; f = &fd_table[conn->fd]; snprintf(desc, FD_DESC_SZ, "%s pinned connection for %s:%d (%d)", - (auth || !peer) ? host : peer->name, f->ipaddr, (int) f->remote_port, conn->fd); + (auth || !peer) ? host : peer->name, inet_ntoa(f->remote_addr), (int) f->remote_port, conn->fd); fd_note(fd, desc); comm_add_close_handler(fd, clientPinnedConnectionClosed, conn); } Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -u -r1.55 -r1.55.2.1 --- squid/src/comm.c 21 Sep 2007 14:52:48 -0000 1.55 +++ squid/src/comm.c 25 Sep 2007 14:05:30 -0000 1.55.2.1 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.55 2007/09/21 14:52:48 squidadm Exp $ + * $Id: comm.c,v 1.55.2.1 2007/09/25 14:05:30 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -584,11 +584,11 @@ status = COMM_INPROGRESS; else return COMM_ERROR; - xstrncpy(F->ipaddr, xinet_ntoa(address->sin_addr), 16); + F->remote_addr = address->sin_addr; F->remote_port = ntohs(address->sin_port); if (status == COMM_OK) { debug(5, 10) ("comm_connect_addr: FD %d connected to %s:%d\n", - sock, F->ipaddr, F->remote_port); + sock, inet_ntoa(F->remote_addr), F->remote_port); } else if (status == COMM_INPROGRESS) { debug(5, 10) ("comm_connect_addr: FD %d connection pending\n", sock); } @@ -630,7 +630,7 @@ /* fdstat update */ fd_open(sock, FD_SOCKET, "HTTP Request"); F = &fd_table[sock]; - xstrncpy(F->ipaddr, xinet_ntoa(P.sin_addr), 16); + F->remote_addr = P.sin_addr; F->remote_port = htons(P.sin_port); F->local_port = htons(M.sin_port); commSetNonBlocking(sock); Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.56 retrieving revision 1.56.2.1 diff -u -r1.56 -r1.56.2.1 --- squid/src/forward.c 5 Sep 2007 20:52:51 -0000 1.56 +++ squid/src/forward.c 25 Sep 2007 14:05:30 -0000 1.56.2.1 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.56 2007/09/05 20:52:51 squidadm Exp $ + * $Id: forward.c,v 1.56.2.1 2007/09/25 14:05:30 adri Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -333,7 +333,7 @@ request_t *request = fwdState->request; assert(fwdState->server_fd == server_fd); if (Config.onoff.log_ip_on_direct && status != COMM_ERR_DNS && fs->code == HIER_DIRECT) - hierarchyNote(&fwdState->request->hier, fs->code, fd_table[server_fd].ipaddr); + hierarchyNote(&fwdState->request->hier, fs->code, inet_ntoa(fd_table[server_fd].remote_addr)); if (status == COMM_ERR_DNS) { /* * Only set the dont_retry flag if the DNS lookup fails on @@ -381,8 +381,8 @@ ErrorState *err; debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, storeUrl(entry)); assert(fd == fwdState->server_fd); - if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT && fd_table[fd].ipaddr[0]) - hierarchyNote(&fwdState->request->hier, fs->code, fd_table[fd].ipaddr); + if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT && fd_table[fd].remote_addr.s_addr != INADDR_ANY) + hierarchyNote(&fwdState->request->hier, fs->code, inet_ntoa(fd_table[fd].remote_addr)); if (entry->mem_obj->inmem_hi == 0) { err = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, fwdState->request); err->xerrno = ETIMEDOUT; @@ -605,7 +605,7 @@ if (fs->peer) hierarchyNote(&fwdState->request->hier, fs->code, fs->peer->name); else if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT) - hierarchyNote(&fwdState->request->hier, fs->code, fd_table[fd].ipaddr); + hierarchyNote(&fwdState->request->hier, fs->code, inet_ntoa(fd_table[fd].remote_addr)); else hierarchyNote(&fwdState->request->hier, fs->code, name); if (fs->peer && idle >= 0 && idle < fs->peer->idle) { Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.44 retrieving revision 1.44.4.1 diff -u -r1.44 -r1.44.4.1 --- squid/src/ftp.c 13 Aug 2007 02:52:38 -0000 1.44 +++ squid/src/ftp.c 25 Sep 2007 14:05:31 -0000 1.44.4.1 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.44 2007/08/13 02:52:38 squidadm Exp $ + * $Id: ftp.c,v 1.44.4.1 2007/09/25 14:05:31 adri Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1817,32 +1817,32 @@ buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "0123456789"); n = sscanf(buf, "%d,%d,%d,%d,%d,%d", &h1, &h2, &h3, &h4, &p1, &p2); if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255) { - debug(9, 1) ("Odd PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debug(9, 1) ("Odd PASV reply from %s: %s\n", inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr), ftpState->ctrl.last_reply); ftpSendPort(ftpState); return; } snprintf(ipaddr, 1024, "%d.%d.%d.%d", h1, h2, h3, h4); if (!safe_inet_addr(ipaddr, NULL)) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debug(9, 1) ("Unsafe PASV reply from %s: %s\n", inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr), ftpState->ctrl.last_reply); ftpSendPort(ftpState); return; } port = ((p1 << 8) + p2); if (0 == port) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debug(9, 1) ("Unsafe PASV reply from %s: %s\n", inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr), ftpState->ctrl.last_reply); ftpSendPort(ftpState); return; } if (Config.Ftp.sanitycheck) { if (port < 1024) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debug(9, 1) ("Unsafe PASV reply from %s: %s\n", inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr), ftpState->ctrl.last_reply); ftpSendPort(ftpState); return; } } ftpState->data.port = port; if (Config.Ftp.sanitycheck) - ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.fd].ipaddr); + ftpState->data.host = xstrdup(inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr)); else ftpState->data.host = xstrdup(ipaddr); safe_free(ftpState->ctrl.last_command); @@ -1978,8 +1978,8 @@ fd = comm_accept(fd, &my_peer, &me); if (Config.Ftp.sanitycheck) { char *ipaddr = inet_ntoa(my_peer.sin_addr); - if (strcmp(fd_table[ftpState->ctrl.fd].ipaddr, ipaddr) != 0) { - debug(9, 1) ("FTP data connection from unexpected server (%s:%d), expecting %s\n", ipaddr, (int) ntohs(my_peer.sin_port), fd_table[ftpState->ctrl.fd].ipaddr); + if (strcmp(inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr), ipaddr) != 0) { + debug(9, 1) ("FTP data connection from unexpected server (%s:%d), expecting %s\n", ipaddr, (int) ntohs(my_peer.sin_port), inet_ntoa(fd_table[ftpState->ctrl.fd].remote_addr)); comm_close(fd); commSetSelect(ftpState->data.fd, COMM_SELECT_READ, Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v retrieving revision 1.31 retrieving revision 1.31.6.1 diff -u -r1.31 -r1.31.6.1 --- squid/src/ssl.c 15 Jul 2007 06:51:53 -0000 1.31 +++ squid/src/ssl.c 25 Sep 2007 14:05:31 -0000 1.31.6.1 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.31 2007/07/15 06:51:53 squidadm Exp $ + * $Id: ssl.c,v 1.31.6.1 2007/09/25 14:05:31 adri Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -417,7 +417,7 @@ sslState->servers->peer->name); else if (Config.onoff.log_ip_on_direct) hierarchyNote(&sslState->request->hier, sslState->servers->code, - fd_table[sslState->server.fd].ipaddr); + inet_ntoa(fd_table[sslState->server.fd].remote_addr)); else hierarchyNote(&sslState->request->hier, sslState->servers->code, sslState->host); @@ -465,7 +465,7 @@ sslState->servers->peer->name); else if (Config.onoff.log_ip_on_direct) hierarchyNote(&sslState->request->hier, sslState->servers->code, - fd_table[sslState->server.fd].ipaddr); + inet_ntoa(fd_table[sslState->server.fd].remote_addr)); else hierarchyNote(&sslState->request->hier, sslState->servers->code, sslState->host); Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.42 retrieving revision 1.42.2.1 diff -u -r1.42 -r1.42.2.1 --- squid/src/stat.c 20 Sep 2007 20:53:11 -0000 1.42 +++ squid/src/stat.c 25 Sep 2007 14:05:31 -0000 1.42.2.1 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.42 2007/09/20 20:53:11 squidadm Exp $ + * $Id: stat.c,v 1.42.2.1 2007/09/25 14:05:31 adri Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -421,7 +421,7 @@ LOCAL_ARRAY(char, buf, 32); if (f->type != FD_SOCKET) return null_string; - snprintf(buf, 32, "%s.%d", f->ipaddr, (int) f->remote_port); + snprintf(buf, 32, "%s.%d", inet_ntoa(f->remote_addr), (int) f->remote_port); return buf; } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.158.2.2 retrieving revision 1.158.2.3 diff -u -r1.158.2.2 -r1.158.2.3 --- squid/src/structs.h 25 Sep 2007 00:29:27 -0000 1.158.2.2 +++ squid/src/structs.h 25 Sep 2007 14:05:32 -0000 1.158.2.3 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.158.2.2 2007/09/25 00:29:27 adri Exp $ + * $Id: structs.h,v 1.158.2.3 2007/09/25 14:05:32 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -873,8 +873,8 @@ u_short local_port; u_short remote_port; struct in_addr local_addr; + struct in_addr remote_addr; unsigned char tos; - char ipaddr[16]; /* dotted decimal address of peer */ const char *desc; char descbuf[FD_DESC_SZ]; struct {