#include "MemBuf.h"
#include "http.h"
#include "icmp/net_db.h"
+#include "AccessLogEntry.h"
typedef struct _Countstr Countstr;
static void htcpHandleMsg(char *buf, int sz, IpAddress &from);
+static void htcpLogHtcp(IpAddress &, int, log_type, const char *);
static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, IpAddress &from);
static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, IpAddress &from);
static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, IpAddress &from);
static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+
static void htcpRecv(int fd, void *data);
static void htcpSend(const char *buf, int len, IpAddress &to);
/* s is a new object */
s = htcpUnpackSpecifier(buf, sz);
- s->setFrom (from);
+ s->setFrom(from);
- s->setDataHeader (dhdr);
+ s->setDataHeader(dhdr);
if (NULL == s) {
debugs(31, 2, "htcpHandleTstRequest: htcpUnpackSpecifier failed");
+ htcpLogHtcp(from, dhdr->opcode, LOG_UDP_INVALID, dash_str);
return;
}
if (!s->request) {
debugs(31, 2, "htcpHandleTstRequest: failed to parse request");
+ htcpLogHtcp(from, dhdr->opcode, LOG_UDP_INVALID, dash_str);
htcpFreeSpecifier(s);
return;
}
if (!htcpAccessCheck(Config.accessList.htcp, s, from)) {
debugs(31, 2, "htcpHandleTstRequest: Access denied");
+ htcpLogHtcp(from, dhdr->opcode, LOG_UDP_DENIED, s->uri);
htcpFreeSpecifier(s);
return;
}
void
htcpSpecifier::checkedHit(StoreEntry *e)
{
- if (e)
+ if (e) {
htcpTstReply(dhdr, e, this, from); /* hit */
- else
+ htcpLogHtcp(from, dhdr->opcode, LOG_UDP_HIT, uri);
+ } else {
htcpTstReply(dhdr, NULL, NULL, from); /* cache miss */
+ htcpLogHtcp(from, dhdr->opcode, LOG_UDP_MISS, uri);
+ }
htcpFreeSpecifier(this);
}
}
static void
-
htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
{
htcpSpecifier *s;
if (sz == 0) {
debugs(31, 4, "htcpHandleClr: nothing to do");
+ htcpLogHtcp(from, hdr->opcode, LOG_UDP_INVALID, dash_str);
return;
}
if (NULL == s) {
debugs(31, 3, "htcpHandleClr: htcpUnpackSpecifier failed");
+ htcpLogHtcp(from, hdr->opcode, LOG_UDP_INVALID, dash_str);
return;
}
if (!htcpAccessCheck(Config.accessList.htcp_clr, s, from)) {
debugs(31, 2, "htcpHandleClr: Access denied");
+ htcpLogHtcp(from, hdr->opcode, LOG_UDP_DENIED, s->uri);
htcpFreeSpecifier(s);
return;
}
case 1:
htcpClrReply(hdr, 1, from); /* hit */
+ htcpLogHtcp(from, hdr->opcode, LOG_UDP_HIT, s->uri);
break;
case 0:
htcpClrReply(hdr, 0, from); /* miss */
+ htcpLogHtcp(from, hdr->opcode, LOG_UDP_MISS, s->uri);
break;
default:
htcpOutSocket = -1;
}
}
+
+static void
+htcpLogHtcp(IpAddress &caddr, int opcode, log_type logcode, const char *url)
+{
+ AccessLogEntry al;
+ if (LOG_TAG_NONE == logcode)
+ return;
+ if (!Config.onoff.log_udp)
+ return;
+ al.htcp.opcode = htcpOpcodeStr[opcode];
+ al.url = url;
+ al.cache.caddr = caddr;
+ al.cache.code = logcode;
+ al.cache.msec = 0;
+ accessLogLog(&al, NULL);
+}