Revision: 14737
Author: adrian.chadd
Date: Mon Jul 12 01:12:05 2010
Log:
Migrate the AccessLogEntry IP address fields (caddr, out_ip) to use
IPv6-aware
versions.
http://code.google.com/p/lusca-cache/source/detail?r=14737
Modified:
/playpen/LUSCA_HEAD_ipv6/src/access_log.c
/playpen/LUSCA_HEAD_ipv6/src/structs.h
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/access_log.c Sun Jul 11 16:49:18 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/access_log.c Mon Jul 12 01:12:05 2010
@@ -450,6 +450,7 @@
static MemBuf mb = MemBufNULL;
char tmp[1024];
String sb = StringNull;
+ LOCAL_ARRAY(char, cbuf, MAX_IPSTRLEN);
memBufReset(&mb);
@@ -469,13 +470,16 @@
out = fmt->data.string;
break;
case LFT_CLIENT_IP_ADDRESS:
- out = inet_ntoa(al->cache.caddr);
+ (void) sqinet_ntoa(&al->cache.caddr2, cbuf, sizeof(cbuf),
SQADDR_NONE);
+ out = cbuf;
break;
case LFT_CLIENT_FQDN:
- out = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS);
- if (!out)
- out = inet_ntoa(al->cache.caddr);
+ out = fqdncache_gethostbyaddr6(&al->cache.caddr2,
FQDN_LOOKUP_IF_MISS);
+ if (!out) {
+ (void) sqinet_ntoa(&al->cache.caddr2, cbuf, sizeof(cbuf),
SQADDR_NONE);
+ out = cbuf;
+ }
break;
case LFT_CLIENT_PORT:
@@ -491,7 +495,8 @@
out = al->hier.host;
break;
case LFT_OUTGOING_IP:
- out = xstrdup(inet_ntoa(al->cache.out_ip));
+ (void) sqinet_ntoa(&al->cache.out_ip2, cbuf, sizeof(cbuf),
SQADDR_NONE);
+ out = cbuf;
break;
/* case LFT_SERVER_PORT: */
@@ -1059,12 +1064,15 @@
static void
accessLogSquid(AccessLogEntry * al, Logfile * logfile)
{
+ LOCAL_ARRAY(char, cbuf, MAX_IPSTRLEN);
const char *client = NULL;
const char *user = NULL;
if (Config.onoff.log_fqdn)
- client = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS);
- if (client == NULL)
- client = inet_ntoa(al->cache.caddr);
+ client = fqdncache_gethostbyaddr6(&al->cache.caddr2,
FQDN_LOOKUP_IF_MISS);
+ if (client == NULL) {
+ (void) sqinet_ntoa(&al->cache.caddr2, cbuf, sizeof(cbuf),
SQADDR_NONE);
+ client = cbuf;
+ }
user = accessLogFormatName(al->cache.authuser);
if (!user)
user = accessLogFormatName(al->cache.rfc931);
@@ -1119,12 +1127,15 @@
static void
accessLogCommon(AccessLogEntry * al, Logfile * logfile)
{
+ LOCAL_ARRAY(char, buf, MAX_IPSTRLEN);
const char *client = NULL;
char *user1 = NULL, *user2 = NULL;
if (Config.onoff.log_fqdn)
- client = fqdncache_gethostbyaddr(al->cache.caddr, 0);
- if (client == NULL)
- client = inet_ntoa(al->cache.caddr);
+ client = fqdncache_gethostbyaddr6(&al->cache.caddr2, 0);
+ if (client == NULL) {
+ (void) sqinet_ntoa(&al->cache.caddr2, buf, sizeof(buf),
SQADDR_NONE);
+ client = buf;
+ }
user1 = accessLogFormatName(al->cache.authuser);
user2 = accessLogFormatName(al->cache.rfc931);
if (al->icp.opcode)
@@ -1502,6 +1513,8 @@
accessLogEntryInit(AccessLogEntry *al)
{
memset(al, '\0', sizeof(*al));
+ sqinet_init(&al->cache.caddr2);
+ sqinet_init(&al->cache.out_ip2);
}
/*
@@ -1541,6 +1554,9 @@
al->reply = NULL; /* This is just a pointer! No reference
counting */
/* al->hier is a local copy and should be separately free()'d here when
the time comes */
+
+ sqinet_done(&al->cache.caddr2);
+ sqinet_done(&al->cache.out_ip2);
}
void
@@ -1553,24 +1569,24 @@
void
accessLogEntrySetClientAddr(AccessLogEntry *al, sqaddr_t *addr)
{
- al->cache.caddr = sqinet_get_v4_inaddr(addr, SQADDR_ASSERT_IS_V4);
+ sqinet_copy(&al->cache.caddr2, addr);
}
void
accessLogEntrySetClientAddr4(AccessLogEntry *al, struct in_addr addr)
{
- al->cache.caddr = addr;
+ sqinet_set_v4_inaddr(&al->cache.caddr2, &addr);
}
void
accessLogEntrySetOutAddr(AccessLogEntry *al, sqaddr_t *addr)
{
- al->cache.out_ip = sqinet_get_v4_inaddr(addr, SQADDR_ASSERT_IS_V4);
+ sqinet_copy(&al->cache.out_ip2, addr);
}
void
accessLogEntrySetOutAddr4(AccessLogEntry *al, struct in_addr addr)
{
- al->cache.out_ip = addr;
+ sqinet_set_v4_inaddr(&al->cache.out_ip2, &addr);
}
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/structs.h Sun Jul 11 03:07:35 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/structs.h Mon Jul 12 01:12:05 2010
@@ -939,8 +939,8 @@
icp_opcode opcode;
} icp;
struct {
- struct in_addr caddr;
- struct in_addr out_ip;
+ sqaddr_t caddr2;
+ sqaddr_t out_ip2;
squid_off_t size;
size_t rq_size;
log_type code;
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.