--------------------- PatchSet 5291 Date: 2002/10/08 01:46:15 Author: rbcollins Branch: rbcollins_cxxtest Tag: (none) Log: extract method - icpAccessAllowed Members: src/icp_v2.cc:1.1.2.10->1.1.2.11 src/icp_v3.cc:1.1.2.10->1.1.2.11 src/protos.h:1.63.2.14->1.63.2.15 Index: squid/src/icp_v2.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icp_v2.cc,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/icp_v2.cc 8 Oct 2002 00:51:35 -0000 1.1.2.10 +++ squid/src/icp_v2.cc 8 Oct 2002 01:46:15 -0000 1.1.2.11 @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.cc,v 1.1.2.10 2002/10/08 00:51:35 rbcollins Exp $ + * $Id: icp_v2.cc,v 1.1.2.11 2002/10/08 01:46:15 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -244,12 +244,21 @@ } } +int +icpAccessAllowed(struct sockaddr_in *from, request_t *icp_request) +{ + aclCheck_t checklist; + memset(&checklist, '\0', sizeof(checklist)); + checklist.src_addr = from->sin_addr; + checklist.my_addr = no_addr; + checklist.request = icp_request; + return aclCheckFast(Config.accessList.icp, &checklist); +} + static void doV2Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header) { request_t *icp_request = NULL; - aclCheck_t checklist; - int allow = 0; int rtt = 0; int hops = 0; int src_rtt = 0; @@ -265,12 +274,7 @@ icpCreateAndSend(ICP_ERR, 0, url, header.reqnum, 0, fd, &from); return; } - memset(&checklist, '\0', sizeof(checklist)); - checklist.src_addr = from.sin_addr; - checklist.my_addr = no_addr; - checklist.request = icp_request; - allow = aclCheckFast(Config.accessList.icp, &checklist); - if (!allow) { + if (!icpAccessAllowed(&from, icp_request)) { icpDenyAccess (&from, url, header.reqnum, fd); requestDestroy(icp_request); return; Index: squid/src/icp_v3.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icp_v3.cc,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/icp_v3.cc 8 Oct 2002 00:51:35 -0000 1.1.2.10 +++ squid/src/icp_v3.cc 8 Oct 2002 01:46:15 -0000 1.1.2.11 @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.1.2.10 2002/10/08 00:51:35 rbcollins Exp $ + * $Id: icp_v3.cc,v 1.1.2.11 2002/10/08 01:46:15 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -53,8 +53,6 @@ doV3Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header) { request_t *icp_request = NULL; - aclCheck_t checklist; - int allow = 0; /* We have a valid packet */ char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t); if (strpbrk(url, w_space)) { @@ -66,12 +64,7 @@ icpCreateAndSend (ICP_ERR,0,url,header.reqnum,0,fd,&from); return; } - memset(&checklist, '\0', sizeof(checklist)); - checklist.src_addr = from.sin_addr; - checklist.my_addr = no_addr; - checklist.request = icp_request; - allow = aclCheckFast(Config.accessList.icp, &checklist); - if (!allow) { + if (!icpAccessAllowed(&from, icp_request)) { icpDenyAccess (&from, url, header.reqnum, fd); requestDestroy(icp_request); return; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.63.2.14 retrieving revision 1.63.2.15 diff -u -r1.63.2.14 -r1.63.2.15 --- squid/src/protos.h 8 Oct 2002 00:51:35 -0000 1.63.2.14 +++ squid/src/protos.h 8 Oct 2002 01:46:15 -0000 1.63.2.15 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.63.2.14 2002/10/08 00:51:35 rbcollins Exp $ + * $Id: protos.h,v 1.63.2.15 2002/10/08 01:46:15 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -531,6 +531,7 @@ SQUIDCEXTERN void icmpSourcePing(struct in_addr to, const icp_common_t *, const char *url); SQUIDCEXTERN void icmpDomainPing(struct in_addr to, const char *domain); +int icpAccessAllowed(struct sockaddr_in *from, request_t *icp_request); SQUIDCEXTERN void *icpCreateMessage(icp_opcode opcode, int flags, const char *url,