]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Okumoto suggested changes. perl script to generate string arrays
authorwessels <>
Thu, 20 Nov 1997 13:25:24 +0000 (13:25 +0000)
committerwessels <>
Thu, 20 Nov 1997 13:25:24 +0000 (13:25 +0000)
from enums.
protoStart() can be static and should use a switch() instead of
if-else-else

12 files changed:
src/Makefile.in
src/access_log.cc
src/enums.h
src/errorpage.cc
src/globals.h
src/icp_v2.cc
src/icp_v3.cc
src/neighbors.cc
src/peer_select.cc
src/protos.h
src/stat.cc
src/structs.h

index aac45bb78d81abaea21d0071620b11adedfaf12c..aa39e3ff3abe3500e912836af98dbd032de69f58 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.95 1997/11/13 05:25:47 wessels Exp $
+#  $Id: Makefile.in,v 1.96 1997/11/20 06:25:24 wessels Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -131,6 +131,7 @@ OBJS                = \
                store_dir.o \
                store_key_sha.o \
                store_key_url.o \
+               string_arrays.o \
                tools.o \
                unlinkd.o \
                url.o \
@@ -154,6 +155,9 @@ globals.o: globals.c Makefile
 globals.c: globals.h mk-globals-c.pl
        $(PERL) mk-globals-c.pl < globals.h > $@
 
+string_arrays.c: enums.h mk-string-arrays.pl
+       $(PERL) mk-string-arrays.pl < enums.h > $@
+
 client:        client.o
        $(CC) -o $@ $(LDFLAGS) $@.o $(CLIENT_LIBS)
 
index 439b76936effda46b0b4fb700b0f60f7f2b09231..a2ddb2cfdb397986d6cd0461d9d3261783f006f4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.10 1997/11/12 23:36:20 wessels Exp $
+ * $Id: access_log.cc,v 1.11 1997/11/20 06:25:25 wessels Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -195,7 +195,7 @@ accessLogLog(AccessLogEntry * al)
     if (!al->cache.ident || *al->cache.ident == '\0')
        al->cache.ident = dash_str;
     if (al->icp.opcode)
-       al->private.method_str = IcpOpcodeStr[al->icp.opcode];
+       al->private.method_str = icp_opcode_str[al->icp.opcode];
     else
        al->private.method_str = RequestMethodStr[al->http.method];
     if (al->hier.host[0] == '\0')
index 8f199515f4c4673a2286641a26e52167e7e0cf86..4b53f3d3beca5651fe82e8d7eb2c63bc1523a371 100644 (file)
@@ -173,31 +173,31 @@ typedef enum {
 } hier_code;
 
 typedef enum {
-    ICP_OP_INVALID,            /* 00 to insure 0 doesn't get accidently interpreted. */
-    ICP_OP_QUERY,              /* 01 query opcode (cl->sv) */
-    ICP_OP_HIT,                        /* 02 hit (cl<-sv) */
-    ICP_OP_MISS,               /* 03 miss (cl<-sv) */
-    ICP_OP_ERR,                        /* 04 error (cl<-sv) */
-    ICP_OP_SEND,               /* 05 send object non-auth (cl->sv) */
-    ICP_OP_SENDA,              /* 06 send object authoritative (cl->sv) */
-    ICP_OP_DATABEG,            /* 07 first data, but not last (sv<-cl) */
-    ICP_OP_DATA,               /* 08 data middle of stream (sv<-cl) */
-    ICP_OP_DATAEND,            /* 09 last data (sv<-cl) */
-    ICP_OP_SECHO,              /* 10 echo from source (sv<-os) */
-    ICP_OP_DECHO,              /* 11 echo from dumb cache (sv<-dc) */
-    ICP_OP_UNUSED0,            /* 12 */
-    ICP_OP_UNUSED1,            /* 13 */
-    ICP_OP_UNUSED2,            /* 14 */
-    ICP_OP_UNUSED3,            /* 15 */
-    ICP_OP_UNUSED4,            /* 16 */
-    ICP_OP_UNUSED5,            /* 17 */
-    ICP_OP_UNUSED6,            /* 18 */
-    ICP_OP_UNUSED7,            /* 19 */
-    ICP_OP_UNUSED8,            /* 20 */
-    ICP_OP_MISS_NOFETCH,       /* 21 access denied while reloading */
-    ICP_OP_DENIED,             /* 22 access denied (cl<-sv) */
-    ICP_OP_HIT_OBJ,            /* 23 hit with object data (cl<-sv) */
-    ICP_OP_END                 /* 24 marks end of opcodes */
+    ICP_INVALID,
+    ICP_QUERY,
+    ICP_HIT,
+    ICP_MISS,
+    ICP_ERR,
+    ICP_SEND,
+    ICP_SENDA,
+    ICP_DATABEG,
+    ICP_DATA,
+    ICP_DATAEND,
+    ICP_SECHO,
+    ICP_DECHO,
+    ICP_UNUSED12,
+    ICP_UNUSED13,
+    ICP_UNUSED14,
+    ICP_UNUSED15,
+    ICP_UNUSED16,
+    ICP_UNUSED17,
+    ICP_UNUSED18,
+    ICP_UNUSED19,
+    ICP_UNUSED20,
+    ICP_MISS_NOFETCH,
+    ICP_DENIED,        
+    ICP_HIT_OBJ,
+    ICP_END
 } icp_opcode;
 
 enum {
index b1151595ca1324b22936f8ce85ea276b15775c9d..c0dd929b2c1530167942ef6ccb5f6f4e83d954b4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.101 1997/11/12 00:08:49 wessels Exp $
+ * $Id: errorpage.cc,v 1.102 1997/11/20 06:25:26 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
 
 #include "squid.h"
 
-static const char *err_string[] =
-{
-    "ERR_NONE",
-    "ERR_READ_TIMEOUT",
-    "ERR_LIFETIME_EXP",
-    "ERR_READ_ERROR",
-    "ERR_WRITE_ERROR",
-    "ERR_CLIENT_ABORT",
-    "ERR_CONNECT_FAIL",
-    "ERR_INVALID_REQ",
-    "ERR_UNSUP_REQ",
-    "ERR_INVALID_URL",
-    "ERR_SOCKET_FAILURE",
-    "ERR_DNS_FAIL",
-    "ERR_CANNOT_FORWARD",
-    "ERR_NO_RELAY",
-    "ERR_ZERO_SIZE_OBJECT",
-    "ERR_FTP_DISABLED",
-    "ERR_FTP_FAILURE",
-    "ERR_ACCESS_DENIED",
-    "ERR_MAX"
-};
-
 static char *error_text[ERR_MAX];
 
 static void errorStateFree(ErrorState * err);
@@ -84,10 +61,9 @@ errorInitialize(void)
     int fd;
     char path[MAXPATHLEN];
     struct stat sb;
-    assert(sizeof(err_string) == (ERR_MAX + 1) * sizeof(char *));
     for (i = ERR_NONE + 1; i < ERR_MAX; i++) {
        snprintf(path, MAXPATHLEN, "%s/%s",
-           Config.errorDirectory, err_string[i]);
+           Config.errorDirectory, err_type_str[i]);
        fd = file_open(path, O_RDONLY, NULL, NULL);
        if (fd < 0) {
            debug(4, 0) ("errorInitialize: %s: %s\n", path, xstrerror());
index 37892dbe5e8744501a99e6c7cec9074c506c4c15..10143abc16cfc43085fea4d1027075e40028e073 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.18 1997/11/15 00:14:48 wessels Exp $
+ * $Id: globals.h,v 1.19 1997/11/20 06:25:26 wessels Exp $
  */
 
 extern FILE *debug_log;                /* NULL */
@@ -94,6 +94,8 @@ extern icpUdpData *UdpQueueHead;      /* NULL */
 extern icpUdpData *UdpQueueTail;       /* NULL */
 extern time_t hit_only_mode_until;     /* 0 */
 extern StatCounters Counter;
+extern char *err_type_str[];
+extern char *icp_opcode_str[];
 
 #ifdef HAVE_SYSLOG
 extern int _db_level;
index 54d12edb950719a4e742e58b54a203d137ae47e9..9a93f8462eb6df0a76749e0ffb2ac3241560301d 100644 (file)
@@ -19,7 +19,7 @@ icpLogIcp(icpUdpData * queue)
     if (!Config.onoff.log_udp)
        return;
     memset(&al, '\0', sizeof(AccessLogEntry));
-    al.icp.opcode = ICP_OP_QUERY;
+    al.icp.opcode = ICP_QUERY;
     al.url = url;
     al.cache.caddr = queue->address.sin_addr;
     al.cache.size = queue->len;
@@ -78,7 +78,7 @@ icpCreateMessage(
     char *urloffset = NULL;
     int buf_len;
     buf_len = sizeof(icp_common_t) + strlen(url) + 1;
-    if (opcode == ICP_OP_QUERY)
+    if (opcode == ICP_QUERY)
        buf_len += sizeof(u_num32);
     buf = xcalloc(buf_len, 1);
     headerp = (icp_common_t *) (void *) buf;
@@ -90,7 +90,7 @@ icpCreateMessage(
     headerp->pad = htonl(pad);
     headerp->shostid = htonl(theOutICPAddr.s_addr);
     urloffset = buf + sizeof(icp_common_t);
-    if (opcode == ICP_OP_QUERY)
+    if (opcode == ICP_QUERY)
        urloffset += sizeof(u_num32);
     xmemcpy(urloffset, url, strlen(url));
     return buf;
@@ -116,7 +116,7 @@ icpCreateHitObjMessage(
     MemObject *m = entry->mem_obj;
     assert(m != NULL);
     buf_len = sizeof(icp_common_t) + strlen(url) + 1 + 2 + entry->object_len;
-    if (opcode == ICP_OP_QUERY)
+    if (opcode == ICP_QUERY)
        buf_len += sizeof(u_num32);
     buf = xcalloc(buf_len, 1);
     headerp = (icp_common_t *) (void *) buf;
@@ -154,7 +154,7 @@ icpUdpSend(int fd,
 {
     icpUdpData *data = xcalloc(1, sizeof(icpUdpData));
     debug(12, 4) ("icpUdpSend: Queueing %s for %s\n",
-       IcpOpcodeStr[msg->opcode],
+       icp_opcode_str[msg->opcode],
        inet_ntoa(to->sin_addr));
     data->address = *to;
     data->msg = msg;
@@ -233,11 +233,11 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
     header.pad = ntohl(headerp->pad);
 
     switch (header.opcode) {
-    case ICP_OP_QUERY:
+    case ICP_QUERY:
        /* We have a valid packet */
        url = buf + sizeof(header) + sizeof(u_num32);
        if ((icp_request = urlParse(METHOD_GET, url)) == NULL) {
-           reply = icpCreateMessage(ICP_OP_ERR, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE);
            break;
        }
@@ -248,7 +248,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
            debug(12, 2) ("icpHandleIcpV2: Access Denied for %s by %s.\n",
                inet_ntoa(from.sin_addr), AclMatchedName);
            if (clientdbDeniedPercent(from.sin_addr) < 95) {
-               reply = icpCreateMessage(ICP_OP_DENIED, 0, url, header.reqnum, 0);
+               reply = icpCreateMessage(ICP_DENIED, 0, url, header.reqnum, 0);
                icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, icp_request->protocol);
            }
            break;
@@ -263,12 +263,12 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
        /* The peer is allowed to use this cache */
        key = storeKeyPublic(url, METHOD_GET);
        entry = storeGet(key);
-       debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", IcpOpcodeStr[header.opcode]);
+       debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
            pkt_len = sizeof(icp_common_t) + strlen(url) + 1 + 2 + entry->object_len;
 #if USE_ICP_HIT_OBJ
            if (icpCheckUdpHitObj(entry, icp_request, &header, pkt_len)) {
-               reply = icpCreateHitObjMessage(ICP_OP_HIT_OBJ,
+               reply = icpCreateHitObjMessage(ICP_HIT_OBJ,
                    flags,
                    url,
                    header.reqnum,
@@ -278,7 +278,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
                break;
            } else {
 #endif
-               reply = icpCreateMessage(ICP_OP_HIT, flags, url, header.reqnum, src_rtt);
+               reply = icpCreateMessage(ICP_HIT, flags, url, header.reqnum, src_rtt);
                icpUdpSend(fd, &from, reply, LOG_UDP_HIT, icp_request->protocol);
                break;
 #if USE_ICP_HIT_OBJ
@@ -287,24 +287,24 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
        }
        /* if store is rebuilding, return a UDP_HIT, but not a MISS */
        if (store_rebuilding && opt_reload_hit_only) {
-           reply = icpCreateMessage(ICP_OP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
+           reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol);
        } else if (hit_only_mode_until > squid_curtime) {
-           reply = icpCreateMessage(ICP_OP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
+           reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol);
        } else {
-           reply = icpCreateMessage(ICP_OP_MISS, flags, url, header.reqnum, src_rtt);
+           reply = icpCreateMessage(ICP_MISS, flags, url, header.reqnum, src_rtt);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS, icp_request->protocol);
        }
        break;
 
-    case ICP_OP_HIT_OBJ:
-    case ICP_OP_HIT:
-    case ICP_OP_SECHO:
-    case ICP_OP_DECHO:
-    case ICP_OP_MISS:
-    case ICP_OP_DENIED:
-    case ICP_OP_MISS_NOFETCH:
+    case ICP_HIT_OBJ:
+    case ICP_HIT:
+    case ICP_SECHO:
+    case ICP_DECHO:
+    case ICP_MISS:
+    case ICP_DENIED:
+    case ICP_MISS_NOFETCH:
        if (neighbors_do_private_keys && header.reqnum == 0) {
            debug(12, 0) ("icpHandleIcpV2: Neighbor %s returned reqnum = 0\n",
                inet_ntoa(from.sin_addr));
@@ -312,18 +312,18 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
            neighbors_do_private_keys = 0;
        }
        url = buf + sizeof(header);
-       if (header.opcode == ICP_OP_HIT_OBJ) {
+       if (header.opcode == ICP_HIT_OBJ) {
            data = url + strlen(url) + 1;
            xmemcpy((char *) &u, data, sizeof(u_short));
            data += sizeof(u_short);
            data_sz = ntohs(u);
            if ((int) data_sz > (len - (data - buf))) {
-               debug(12, 0) ("icpHandleIcpV2: ICP_OP_HIT_OBJ object too small\n");
+               debug(12, 0) ("icpHandleIcpV2: ICP_HIT_OBJ object too small\n");
                break;
            }
        }
        debug(12, 3) ("icpHandleIcpV2: %s from %s for '%s'\n",
-           IcpOpcodeStr[header.opcode],
+           icp_opcode_str[header.opcode],
            inet_ntoa(from.sin_addr),
            url);
        if (neighbors_do_private_keys && header.reqnum)
@@ -334,15 +334,15 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
            storeKeyText(key));
        if ((entry = storeGet(key)) == NULL) {
            debug(12, 3) ("icpHandleIcpV2: Ignoring %s for NULL Entry.\n",
-               IcpOpcodeStr[header.opcode]);
+               icp_opcode_str[header.opcode]);
        } else {
            /* call neighborsUdpAck even if ping_status != PING_WAITING */
            neighborsUdpAck(url, &header, &from, entry);
        }
        break;
 
-    case ICP_OP_INVALID:
-    case ICP_OP_ERR:
+    case ICP_INVALID:
+    case ICP_ERR:
        break;
 
     default:
@@ -362,7 +362,7 @@ icpPktDump(icp_common_t * pkt)
 
     debug(12, 9) ("opcode:     %3d %s\n",
        (int) pkt->opcode,
-       IcpOpcodeStr[pkt->opcode]);
+       icp_opcode_str[pkt->opcode]);
     debug(12, 9) ("version: %-8d\n", (int) pkt->version);
     debug(12, 9) ("length:  %-8d\n", (int) ntohs(pkt->length));
     debug(12, 9) ("reqnum:  %-8d\n", ntohl(pkt->reqnum));
index 4b957d382682eb0f6a1e6b1874178c58f13684b4..7c8f4342447a5cb08e2a37d1272eb989a477060f 100644 (file)
@@ -25,11 +25,11 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
     header.shostid = ntohl(headerp->shostid);
 
     switch (header.opcode) {
-    case ICP_OP_QUERY:
+    case ICP_QUERY:
        /* We have a valid packet */
        url = buf + sizeof(header) + sizeof(u_num32);
        if ((icp_request = urlParse(METHOD_GET, url)) == NULL) {
-           reply = icpCreateMessage(ICP_OP_ERR, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE);
            break;
        }
@@ -40,7 +40,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
            debug(12, 2) ("icpHandleIcpV3: Access Denied for %s by %s.\n",
                inet_ntoa(from.sin_addr), AclMatchedName);
            if (clientdbDeniedPercent(from.sin_addr) < 95) {
-               reply = icpCreateMessage(ICP_OP_DENIED, 0, url, header.reqnum, 0);
+               reply = icpCreateMessage(ICP_DENIED, 0, url, header.reqnum, 0);
                icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, icp_request->protocol);
            }
            break;
@@ -49,32 +49,32 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
        key = storeKeyPublic(url, METHOD_GET);
        entry = storeGet(key);
        debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n",
-           IcpOpcodeStr[header.opcode]);
+           icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
-           reply = icpCreateMessage(ICP_OP_HIT, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_HIT, icp_request->protocol);
            break;
        }
        /* if store is rebuilding, return a UDP_HIT, but not a MISS */
        if (opt_reload_hit_only && store_rebuilding) {
-           reply = icpCreateMessage(ICP_OP_MISS_NOFETCH, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol);
        } else if (hit_only_mode_until > squid_curtime) {
-           reply = icpCreateMessage(ICP_OP_MISS_NOFETCH, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol);
        } else {
-           reply = icpCreateMessage(ICP_OP_MISS, 0, url, header.reqnum, 0);
+           reply = icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0);
            icpUdpSend(fd, &from, reply, LOG_UDP_MISS, icp_request->protocol);
        }
        break;
 
-    case ICP_OP_HIT_OBJ:
-    case ICP_OP_HIT:
-    case ICP_OP_SECHO:
-    case ICP_OP_DECHO:
-    case ICP_OP_MISS:
-    case ICP_OP_DENIED:
-    case ICP_OP_MISS_NOFETCH:
+    case ICP_HIT_OBJ:
+    case ICP_HIT:
+    case ICP_SECHO:
+    case ICP_DECHO:
+    case ICP_MISS:
+    case ICP_DENIED:
+    case ICP_MISS_NOFETCH:
        if (neighbors_do_private_keys && header.reqnum == 0) {
            debug(12, 0) ("icpHandleIcpV3: Neighbor %s returned reqnum = 0\n",
                inet_ntoa(from.sin_addr));
@@ -82,18 +82,18 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
            neighbors_do_private_keys = 0;
        }
        url = buf + sizeof(header);
-       if (header.opcode == ICP_OP_HIT_OBJ) {
+       if (header.opcode == ICP_HIT_OBJ) {
            data = url + strlen(url) + 1;
            xmemcpy((char *) &u, data, sizeof(u_short));
            data += sizeof(u_short);
            data_sz = ntohs(u);
            if ((int) data_sz > (len - (data - buf))) {
-               debug(12, 0) ("icpHandleIcpV3: ICP_OP_HIT_OBJ object too small\n");
+               debug(12, 0) ("icpHandleIcpV3: ICP_HIT_OBJ object too small\n");
                break;
            }
        }
        debug(12, 3) ("icpHandleIcpV3: %s from %s for '%s'\n",
-           IcpOpcodeStr[header.opcode],
+           icp_opcode_str[header.opcode],
            inet_ntoa(from.sin_addr),
            url);
        if (neighbors_do_private_keys && header.reqnum)
@@ -104,15 +104,15 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
            storeKeyText(key));
        if ((entry = storeGet(key)) == NULL) {
            debug(12, 3) ("icpHandleIcpV3: Ignoring %s for NULL Entry.\n",
-               IcpOpcodeStr[header.opcode]);
+               icp_opcode_str[header.opcode]);
        } else {
            /* call neighborsUdpAck even if ping_status != PING_WAITING */
            neighborsUdpAck(url, &header, &from, entry);
        }
        break;
 
-    case ICP_OP_INVALID:
-    case ICP_OP_ERR:
+    case ICP_INVALID:
+    case ICP_ERR:
        break;
 
     default:
index 6f8bb3d52d170da7ddd221ebeb65826bd53a8abf..4374dd5ab1daf0ab9e61c853add1a425acb0162b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: neighbors.cc,v 1.168 1997/11/12 23:47:39 wessels Exp $
+ * $Id: neighbors.cc,v 1.169 1997/11/20 06:25:28 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -377,7 +377,7 @@ neighbors_open(int fd)
        debug(15, 1) ("getsockname(%d,%p,%p) failed.\n", fd, &name, &len);
     peerRefreshDNS(NULL);
     if (0 == echo_hdr.opcode) {
-       echo_hdr.opcode = ICP_OP_SECHO;
+       echo_hdr.opcode = ICP_SECHO;
        echo_hdr.version = ICP_VERSION_CURRENT;
        echo_hdr.length = 0;
        echo_hdr.reqnum = 0;
@@ -437,7 +437,7 @@ neighborsUdpPing(request_t * request,
        if (p->icp_port == echo_port) {
            debug(15, 4) ("neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n");
            echo_hdr.reqnum = reqnum;
-           query = icpCreateMessage(ICP_OP_DECHO, 0, url, reqnum, 0);
+           query = icpCreateMessage(ICP_DECHO, 0, url, reqnum, 0);
            icpUdpSend(theOutIcpConnection,
                &p->in_addr,
                query,
@@ -453,7 +453,7 @@ neighborsUdpPing(request_t * request,
            if (Config.onoff.query_icmp)
                if (p->icp_version == ICP_VERSION_2)
                    flags |= ICP_FLAG_SRC_RTT;
-           query = icpCreateMessage(ICP_OP_QUERY, flags, url, reqnum, 0);
+           query = icpCreateMessage(ICP_QUERY, flags, url, reqnum, 0);
            icpUdpSend(theOutIcpConnection,
                &p->in_addr,
                query,
@@ -499,7 +499,7 @@ neighborsUdpPing(request_t * request,
                to_addr.sin_family = AF_INET;
                to_addr.sin_addr = ia->in_addrs[ia->cur];
                to_addr.sin_port = htons(echo_port);
-               query = icpCreateMessage(ICP_OP_SECHO, 0, url, reqnum, 0);
+               query = icpCreateMessage(ICP_SECHO, 0, url, reqnum, 0);
                icpUdpSend(theOutIcpConnection,
                    &to_addr,
                    query,
@@ -531,7 +531,7 @@ neighborAlive(peer * p, const MemObject * mem, const icp_common_t * header)
     }
     p->stats.ack_deficit = 0;
     n = ++p->stats.pings_acked;
-    if ((icp_opcode) header->opcode <= ICP_OP_END)
+    if ((icp_opcode) header->opcode <= ICP_END)
        p->stats.counts[header->opcode]++;
     if (mem) {
        rtt = tvSubMsec(mem->start_ping, current_time);
@@ -624,9 +624,9 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
     debug(15, 6) ("neighborsUdpAck: opcode %d '%s'\n", (int) opcode, url);
     if ((p = whichPeer(from)))
        neighborAlive(p, mem, header);
-    if (opcode > ICP_OP_END)
+    if (opcode > ICP_END)
        return;
-    opcode_d = IcpOpcodeStr[opcode];
+    opcode_d = icp_opcode_str[opcode];
     /* check if someone is already fetching it */
     if (EBIT_TEST(entry->flag, ENTRY_DISPATCHED)) {
        debug(15, 3) ("neighborsUdpAck: '%s' already being fetched.\n", url);
@@ -654,7 +654,7 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
        ntype = neighborType(p, mem->request);
     if (ignoreMulticastReply(p, mem)) {
        neighborCountIgnored(p, opcode);
-    } else if (opcode == ICP_OP_SECHO) {
+    } else if (opcode == ICP_SECHO) {
        /* Received source-ping reply */
        if (p) {
            debug(15, 1) ("Ignoring SECHO from neighbor %s\n", p->host);
@@ -665,7 +665,7 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
            debug(15, 6) ("Source is the first to respond.\n");
            mem->icp_reply_callback(NULL, ntype, header, mem->ircb_data);
        }
-    } else if (opcode == ICP_OP_MISS) {
+    } else if (opcode == ICP_MISS) {
        if (p == NULL) {
            neighborIgnoreNonPeer(from, opcode);
        } else if (ntype != PEER_PARENT) {
@@ -673,14 +673,14 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
        } else {
            mem->icp_reply_callback(p, ntype, header, mem->ircb_data);
        }
-    } else if (opcode == ICP_OP_HIT || opcode == ICP_OP_HIT_OBJ) {
+    } else if (opcode == ICP_HIT || opcode == ICP_HIT_OBJ) {
        if (p == NULL) {
            neighborIgnoreNonPeer(from, opcode);
        } else {
-           header->opcode = ICP_OP_HIT;
+           header->opcode = ICP_HIT;
            mem->icp_reply_callback(p, ntype, header, mem->ircb_data);
        }
-    } else if (opcode == ICP_OP_DECHO) {
+    } else if (opcode == ICP_DECHO) {
        if (p == NULL) {
            neighborIgnoreNonPeer(from, opcode);
        } else if (ntype == PEER_SIBLING) {
@@ -689,7 +689,7 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
        } else {
            mem->icp_reply_callback(p, ntype, header, mem->ircb_data);
        }
-    } else if (opcode == ICP_OP_SECHO) {
+    } else if (opcode == ICP_SECHO) {
        if (p) {
            debug(15, 1) ("Ignoring SECHO from neighbor %s\n", p->host);
            neighborCountIgnored(p, opcode);
@@ -698,11 +698,11 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
        } else {
            mem->icp_reply_callback(NULL, ntype, header, mem->ircb_data);
        }
-    } else if (opcode == ICP_OP_DENIED) {
+    } else if (opcode == ICP_DENIED) {
        if (p == NULL) {
            neighborIgnoreNonPeer(from, opcode);
        } else if (p->stats.pings_acked > 100) {
-           if (100 * p->stats.counts[ICP_OP_DENIED] / p->stats.pings_acked > 95) {
+           if (100 * p->stats.counts[ICP_DENIED] / p->stats.pings_acked > 95) {
                debug(15, 0) ("95%% of replies from '%s' are UDP_DENIED\n", p->host);
                debug(15, 0) ("Disabling '%s', please check your configuration.\n", p->host);
                neighborRemove(p);
@@ -711,7 +711,7 @@ neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in
                neighborCountIgnored(p, opcode);
            }
        }
-    } else if (opcode == ICP_OP_MISS_NOFETCH) {
+    } else if (opcode == ICP_MISS_NOFETCH) {
        mem->icp_reply_callback(p, ntype, header, mem->ircb_data);
     } else {
        debug(15, 0) ("neighborsUdpAck: Unexpected ICP reply: %s\n", opcode_d);
@@ -912,7 +912,7 @@ peerCountMcastPeersStart(void *data)
     mem->ircb_data = psstate;
     mcastSetTtl(theOutIcpConnection, p->mcast.ttl);
     p->mcast.reqnum = mem->reqnum;
-    query = icpCreateMessage(ICP_OP_QUERY, 0, url, p->mcast.reqnum, 0);
+    query = icpCreateMessage(ICP_QUERY, 0, url, p->mcast.reqnum, 0);
     icpUdpSend(theOutIcpConnection,
        &p->in_addr,
        query,
index 6c19fcc0ed83ff3e4914f538809278375e3256c4..edc59b83fe46639928d1a858ccb8298fad1bf770 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.32 1997/11/12 00:09:01 wessels Exp $
+ * $Id: peer_select.cc,v 1.33 1997/11/20 06:25:29 wessels Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -385,20 +385,20 @@ peerHandleIcpReply(peer * p, peer_t type, icp_common_t * header, void *data)
     icp_opcode op = header->opcode;
     request_t *request = psstate->request;
     debug(44, 3) ("peerHandleIcpReply: %s %s\n",
-       IcpOpcodeStr[op],
+       icp_opcode_str[op],
        storeUrl(psstate->entry));
     psstate->icp.n_recv++;
-    if (op == ICP_OP_MISS || op == ICP_OP_DECHO) {
+    if (op == ICP_MISS || op == ICP_DECHO) {
        if (type == PEER_PARENT)
            peerIcpParentMiss(p, header, psstate);
-    } else if (op == ICP_OP_HIT || op == ICP_OP_HIT_OBJ) {
+    } else if (op == ICP_HIT || op == ICP_HIT_OBJ) {
        hierarchyNote(&request->hier,
            type == PEER_PARENT ? PARENT_HIT : SIBLING_HIT,
            &psstate->icp,
            p->host);
        peerSelectCallback(psstate, p);
        return;
-    } else if (op == ICP_OP_SECHO) {
+    } else if (op == ICP_SECHO) {
        hierarchyNote(&request->hier,
            SOURCE_FASTEST,
            &psstate->icp,
index 200471252d1a151b0230e4b38facdab2799433d8..8997b51da239809b8a3ebcef0ac28e3c6cb7ba17 100644 (file)
@@ -329,7 +329,6 @@ extern void peerSelectInit(void);
 extern void protoDispatch(int, StoreEntry *, request_t *);
 
 extern int protoUnregister(StoreEntry *, request_t *);
-extern void protoStart(int, StoreEntry *, peer *, request_t *);
 extern int protoAbortFetch(StoreEntry * entry);
 extern DEFER protoCheckDeferRead;
 
index 911cf7ec0bc029efb39b7d557fe5752f0286203f..6430442a70ecc0db70997526a23f3be135fbd2ae 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.174 1997/11/18 01:02:40 wessels Exp $
+ * $Id: stat.cc,v 1.175 1997/11/20 06:25:31 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -418,11 +418,11 @@ dump_peers(StoreEntry * sentry, peer * peers)
            e->stats.ignored_replies,
            percent(e->stats.ignored_replies, e->stats.pings_acked));
        storeAppendPrintf(sentry, "{Histogram of PINGS ACKED:}\n");
-       for (op = ICP_OP_INVALID; op < ICP_OP_END; op++) {
+       for (op = ICP_INVALID; op < ICP_END; op++) {
            if (e->stats.counts[op] == 0)
                continue;
            storeAppendPrintf(sentry, "{    %12.12s : %8d %3d%%}\n",
-               IcpOpcodeStr[op],
+               icp_opcode_str[op],
                e->stats.counts[op],
                percent(e->stats.counts[op], e->stats.pings_acked));
        }
index 9d18e7c8970878a17d57f05d51dac733dc7b77a5..38a85e70792287dfae167221cebb2cbf51d581cc 100644 (file)
@@ -550,7 +550,7 @@ struct _peer {
        int ack_deficit;
        int fetches;
        int rtt;
-       int counts[ICP_OP_END];
+       int counts[ICP_END];
        int ignored_replies;
        int n_keepalives_sent;
        int n_keepalives_recv;