sarg
2.4.0
About: SARG ia a Squid Analysis Report Generator. Fossies Dox: sarg-2.4.0.tar.gz ("unofficial" and yet experimental doxygen-generated source code documentation) 
|
Go to the documentation of this file.
66 if (
debug)
debuga(__FILE__,__LINE__,
_(
"Chaining IP resolving module \"%s\"\n"),Module->
Name);
71 debuga(__FILE__,__LINE__,
_(
"Ignoring duplicate module \"%s\" to resolve an IP address\n"),Module->
Name);
92 const char *candidate;
98 while (*candidate && (
unsigned char)*candidate<=
' ') candidate++;
99 for (length=0 ; (
unsigned char)candidate[length]>
' ' ; length++);
109 debuga(__FILE__,__LINE__,
_(
"Unknown module \"%.*s\" to resolve the IP addresses\n"),length,candidate);
112 list=candidate+length;
125 unsigned int ModuleIdx;
127 for (length=0 ;
module[length] && (
unsigned char)
module[length]>
' ' ; length++);
136 while (
module[length] && (
unsigned char)
module[length]<=
' ') length++;
189 debuga(__FILE__,__LINE__,
_(
"No known module to resolve an IP address using the DNS\n"));
195 for (Chain=
FirstModule ; Chain && Chain!=DnsModule ; Chain=Chain->
Next) {
198 if (
debug)
debuga(__FILE__,__LINE__,
_(
"Chaining IP resolving module \"%s\"\n"),DnsModule->
Name);
200 Last->
Next=DnsModule;
226 debuga(__FILE__,__LINE__,
_(
"Not enough memory to store the names corresponding to the IP address\n"));
240 Status=Module->
Resolve(ip,ip_len);
258 #ifdef HAVE_GETADDRINFO
261 struct addrinfo *res=NULL;
266 port=strchr(
name,
']');
272 port=strchr(
name,
':');
273 if (port) *port=
'\0';
276 error=getaddrinfo(
addr,NULL,NULL,&res);
278 if (res) freeaddrinfo(res);
279 debuga(__FILE__,__LINE__,
_(
"Cannot resolve host name \"%s\": %s\n"),
name,gai_strerror(error));
281 if (res->ai_family==AF_INET) {
282 struct sockaddr_in *s4=(
struct sockaddr_in *)res->ai_addr;
283 struct in_addr *sa=&s4->sin_addr;
284 if (res->ai_addrlen<
sizeof(*s4)) {
285 debuga(__FILE__,__LINE__,
_(
"Short structure returned by getaddrinfo for an IPv4 address: %d bytes instead of %d\n"),res->ai_addrlen,(
int)
sizeof(*s4));
288 inet_ntop(res->ai_family,sa,
name,name_size);
289 }
else if (res->ai_family==AF_INET6) {
290 struct sockaddr_in6 *s6=(
struct sockaddr_in6 *)res->ai_addr;
291 struct in6_addr *sa6=&s6->sin6_addr;
292 if (res->ai_addrlen<
sizeof(*s6)) {
293 debuga(__FILE__,__LINE__,
_(
"Short structure returned by getaddrinfo for an IPv6 address: %d bytes instead of %d\n"),res->ai_addrlen,(
int)
sizeof(*s6));
296 inet_ntop(res->ai_family,sa6,
name,name_size);
298 debuga(__FILE__,__LINE__,
_(
"Invalid address type %d returned when resolving host name \"%s\"\n"),res->ai_family,
name);
312 port=strchr(
name,
':');
313 if (port) *port=
'\0';
315 if ((hp=gethostbyname(
name))==NULL)
318 memcpy(&ia.s_addr,hp->h_addr_list[0],
sizeof(ia.s_addr));
319 ia.s_addr=ntohl(ia.s_addr);
321 if (
getword(n4,
sizeof(n4),&gwarea,
'.')<0 ||
getword(n3,
sizeof(n3),&gwarea,
'.')<0 ||
322 getword(n2,
sizeof(n2),&gwarea,
'.')<0 ||
getword(n1,
sizeof(n1),&gwarea,0)<0) {
323 debuga(__FILE__,__LINE__,
_(
"Invalid IPv4 address \"%s\"\n"),gwarea.
beginning);
326 snprintf(
name,name_size,
"%s.%s.%s.%s",n1,n2,n3,n4);
void name2ip(char *name, int name_size)
if( $written !=strlen( $url))
@ INRC_Found
A match was found.
Entry points of the ip2name modules.
void getword_start(struct getwordstruct *gwarea, const char *line)
void debuga(const char *File, int Line, const char *msg,...)
const char * Dichotomic_Search(DichotomicObject Obj, const char *key)
static void ip2name_chainmodule(struct Ip2NameProcess *Module)
Associate a name or alias to a module.
struct Ip2NameProcess * Process
The structure to access the module functions.
struct Ip2NameProcess * Next
The link to the next module to try if this one fails.
void Dichotomic_Destroy(DichotomicObject *ObjPtr)
static const struct Ip2NameModules ModulesList[]
The list of the modules available to resolve an IP address into a name.
void ip2name_cleanup(void)
struct Ip2NameProcess Ip2NameExec
The functions to resolve an IP address using an external executable.
enum ip2name_retcode(* Resolve)(char *ip, int ip_len)
Function to resolve an IP address into a name.
static void ip2name_buildmoduleslist(const char *list)
struct Ip2NameProcess Ip2NameDns
The functions to resolve an IP address through tne dns.
int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
static DichotomicObject KnownIp
The list of the names found so far.
Include headers and define global variables. */.
void ip2name_forcedns(void)
static void ip2name_configmodule(const char *module)
void ip2name(char *ip, int ip_len)
ip2name_retcode
The possible return code of ip2name subfunctions.
DichotomicObject Dichotomic_Create(void)
const char * Name
The real name of the module.
const char * Name
The name of the module.
static struct Ip2NameProcess * FirstModule
The chain of the configured modules to try to resolve an IP.
void safe_strcpy(char *dest, const char *src, int length)
Declaration of the structures and functions.
int ip2name_config(const char *param)
bool Dichotomic_Insert(DichotomicObject Obj, const char *key, const char *value)
void(* Configure)(const char *name, const char *param)
The function to configure the module.