Collaboration diagram for IP Cache API:


 IP Cache Internals


class  ipcache_entry


void ipcache_purgelru (void *)
void ipcache_nbgethostbyname (const char *name, IPH *handler, void *handlerData)
void ipcache_init (void)
const ipcache_addrsipcache_gethostbyname (const char *name, int flags)
void ipcacheInvalidate (const char *name)
void ipcacheInvalidateNegative (const char *name)
static const Dns::CachedIpsipcacheCheckNumeric (const char *name)
void ipcacheMarkGoodAddr (const char *name, const Ip::Address &addr)
void ipcacheFreeMemory (void)
void ipcache_restart (void)
int ipcacheAddEntryFromHosts (const char *name, const char *ipaddr)
variable_listsnmp_netIpFn (variable_list *Var, snint *ErrP)

Detailed Description


The IP cache is a built-in component of squid providing Hostname to IP-Number translation functionality and managing the involved data-structures. Efficiency concerns require mechanisms that allow non-blocking access to these mappings. The IP cache usually doesn't block on a request except for special cases where this is desired (see below).
IP Cache should have its own API *.h header file.

Function Documentation

const ipcache_addrs* ipcache_gethostbyname ( const char *  name,
int  flags 

Is different from ipcache_nbgethostbyname in that it only checks if an entry exists in the cache and does not by default contact the DNS, unless this is requested, by setting the flags.

nameHost name to resolve.
flagsDefault is NULL, set to IP_LOOKUP_IF_MISS to explicitly perform DNS lookups.
Return values
NULLAn error occured during lookup
NULLNo results available in cache and no lookup specified
*Pointer to the ipcahce_addrs structure containing the lookup results

Definition at line 720 of file

Referenced by ACLDestinationASNStrategy::match(), ACLDestinationIP::match(), and netdbClosestParent().

void ipcache_init ( void  )

Initialize the ipcache. Is called from mainInitialize() after disk initialization and prior to the reverse FQDNCache initialization

Definition at line 687 of file

Referenced by mainInitialize().

void ipcache_nbgethostbyname ( const char *  name,
IPH handler,
void *  handlerData 
nameHost to resolve.
handlerPointer to the function to be called when the reply from the IP cache (or the DNS if the IP cache misses)
handlerDataInformation that is passed to the handler and does not affect the IP cache.

XXX: on hits and some errors, the handler is called immediately instead of scheduling an async call. This reentrant behavior means that the user job must be extra careful after calling ipcache_nbgethostbyname, especially if the handler destroys the job. Moreover, the job has no way of knowing whether the reentrant call happened. Comm::Connection setup usually protects the job by scheduling an async call, but some user code calls ipcache_nbgethostbyname directly.

Definition at line 600 of file

Referenced by DestinationIPLookup::checkForAsync(), ClientRequestContext::hostHeaderVerify(), icpIncomingConnectionOpened(), ipcache_gethostbyname(), netdbPingSite(), Adaptation::Icap::Xaction::openConnection(), peerConnectSucceded(), peerRefreshDNS(), and start_announce().

void ipcache_purgelru ( void *  )

Definition at line 351 of file

Referenced by ipcache_purgelru(), and mainInitialize().

void ipcache_restart ( void  )

Recalculate IP cache size upon reconfigure. Is called to clear the IPCache's data structures, cancel all pending requests.

Definition at line 1103 of file

Referenced by mainReconfigureFinish().

int ipcacheAddEntryFromHosts ( const char *  name,
const char *  ipaddr 

Adds a "static" entry from /etc/hosts

nameHostname to be linked with IP
ipaddrIP Address to be cached.
Return values
1IP address is invalid or other error.

Definition at line 1124 of file

Referenced by parseEtcHosts().

static const Dns::CachedIps * ipcacheCheckNumeric ( const char *  name)
void ipcacheFreeMemory ( void  )

Definition at line 1088 of file

Referenced by SquidShutdown().

void ipcacheInvalidate ( const char *  name)

Definition at line 856 of file

Referenced by clientReplyContext::purgeRequest().

void ipcacheInvalidateNegative ( const char *  name)

Definition at line 873 of file

Referenced by clientReplyContext::identifyFoundObject().

void ipcacheMarkGoodAddr ( const char *  name,
const Ip::Address addr 

Definition at line 1066 of file

Referenced by Comm::ConnOpener::sendAnswer().






Web Site Translations