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)  

ip2name.c File Reference
#include "include/conf.h"
#include "include/defs.h"
#include "include/ip2name.h"
#include "include/dichotomic.h"
Include dependency graph for ip2name.c:

Go to the source code of this file.

Data Structures

struct  Ip2NameModules
 Associate a name or alias to a module. More...
 

Functions

static void ip2name_chainmodule (struct Ip2NameProcess *Module)
 
static void ip2name_buildmoduleslist (const char *list)
 
static void ip2name_configmodule (const char *module)
 
int ip2name_config (const char *param)
 
void ip2name_forcedns (void)
 
void ip2name (char *ip, int ip_len)
 
void ip2name_cleanup (void)
 
void name2ip (char *name, int name_size)
 

Variables

struct Ip2NameProcess Ip2NameDns
 The functions to resolve an IP address through tne dns. More...
 
struct Ip2NameProcess Ip2NameExec
 The functions to resolve an IP address using an external executable. More...
 
static const struct Ip2NameModules ModulesList []
 The list of the modules available to resolve an IP address into a name. More...
 
static struct Ip2NameProcessFirstModule =NULL
 The chain of the configured modules to try to resolve an IP. More...
 
static DichotomicObject KnownIp =NULL
 The list of the names found so far. More...
 

Function Documentation

◆ ip2name()

void ip2name ( char *  ip,
int  ip_len 
)

Convert an IP address into a name.

Parameters
ipThe IP address. It is replaced by the corresponding name if one can be found.
ip_lenThe length of the ip buffer.

The function does nothing if no module are configured.

Definition at line 216 of file ip2name.c.

References _, debuga(), Dichotomic_Create(), Dichotomic_Insert(), Dichotomic_Search(), FirstModule, INRC_Found, KnownIp, Ip2NameProcess::Name, Ip2NameProcess::Next, Ip2NameProcess::Resolve, and safe_strcpy().

Referenced by dansguardian_report(), data_file(), datashow(), gerarel(), parse_log(), redirector_report(), and UserAgent().

Here is the caller graph for this function:

◆ ip2name_buildmoduleslist()

static void ip2name_buildmoduleslist ( const char *  list)
static

Add a new module to the list of the configured modules.

Parameters
listThe list of the modules name to chain.

Definition at line 90 of file ip2name.c.

References _, debuga(), ip2name_chainmodule(), ModulesList, Ip2NameProcess::Name, and Ip2NameModules::Name.

Referenced by ip2name_config().

Here is the caller graph for this function:

◆ ip2name_chainmodule()

static void ip2name_chainmodule ( struct Ip2NameProcess Module)
static

Add a new module to the list of the configured modules.

Definition at line 61 of file ip2name.c.

References _, debug, debuga(), FirstModule, Ip2Name, Ip2NameProcess::Name, and Ip2NameProcess::Next.

Referenced by ip2name_buildmoduleslist().

Here is the caller graph for this function:

◆ ip2name_cleanup()

void ip2name_cleanup ( void  )

Release the memory allocated to resolve the IP addresses into names.

Definition at line 251 of file ip2name.c.

References Dichotomic_Destroy(), and KnownIp.

Referenced by main().

Here is the caller graph for this function:

◆ ip2name_config()

int ip2name_config ( const char *  param)

Configure a module to resolve an IP address into a name.

Parameters
paramThe parameter found in the configuration file. It always begins after the "resolv_ip".
Return values
1Parameter processed.
0Parameter ignored.

Definition at line 153 of file ip2name.c.

References ip2name_buildmoduleslist(), and ip2name_configmodule().

Referenced by parmtest().

Here is the caller graph for this function:

◆ ip2name_configmodule()

static void ip2name_configmodule ( const char *  module)
static

Configure a module whose name is given as an argument. The parameters to configure follow the module name after one or more space or tabs.

Parameters
moduleThe name of the module, a space and the configuration options.

Definition at line 122 of file ip2name.c.

References _, Ip2NameProcess::Configure, debuga(), module, ModulesList, Ip2NameProcess::Name, Ip2NameModules::Name, and Ip2NameModules::Process.

Referenced by ip2name_config().

Here is the caller graph for this function:

◆ ip2name_forcedns()

void ip2name_forcedns ( void  )

Require the use of the DNS to resolve the IP addresses.

Definition at line 173 of file ip2name.c.

References _, debug, debuga(), FirstModule, Ip2Name, ModulesList, Ip2NameProcess::Name, Ip2NameProcess::Next, and Ip2NameModules::Process.

Referenced by main().

Here is the caller graph for this function:

◆ name2ip()

void name2ip ( char *  name,
int  name_size 
)

Definition at line 256 of file ip2name.c.

References _, addr, getwordstruct::beginning, debuga(), getword(), getword_start(), if, and name.

Referenced by saverecs().

Here is the caller graph for this function:

Variable Documentation

◆ FirstModule

struct Ip2NameProcess* FirstModule =NULL
static

The chain of the configured modules to try to resolve an IP.

Definition at line 54 of file ip2name.c.

Referenced by ip2name(), ip2name_chainmodule(), and ip2name_forcedns().

◆ Ip2NameDns

struct Ip2NameProcess Ip2NameDns

The functions to resolve an IP address through tne dns.

Definition at line 37 of file ip2name_dns.c.

◆ Ip2NameExec

struct Ip2NameProcess Ip2NameExec

The functions to resolve an IP address using an external executable.

Definition at line 38 of file ip2name_exec.c.

◆ KnownIp

DichotomicObject KnownIp =NULL
static

The list of the names found so far.

Definition at line 56 of file ip2name.c.

Referenced by ip2name(), and ip2name_cleanup().

◆ ModulesList

const struct Ip2NameModules ModulesList[]
static
Initial value:
=
{
{"dns",&Ip2NameDns},
{"exec",&Ip2NameExec},
{"yes",&Ip2NameDns},
{"no",NULL},
}

The list of the modules available to resolve an IP address into a name.

Definition at line 45 of file ip2name.c.

Referenced by ip2name_buildmoduleslist(), ip2name_configmodule(), and ip2name_forcedns().

Ip2NameExec
struct Ip2NameProcess Ip2NameExec
The functions to resolve an IP address using an external executable.
Definition: ip2name_exec.c:38
Ip2NameDns
struct Ip2NameProcess Ip2NameDns
The functions to resolve an IP address through tne dns.
Definition: ip2name_dns.c:37