tcpdump  4.99.1
About: tcpdump is a tool for network monitoring and data acquisition.
  Fossies Dox: tcpdump-4.99.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

addrtoname.c File Reference
#include "netdissect-stdinc.h"
#include <pcap.h>
#include <pcap-namedb.h>
#include <getservent.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "netdissect.h"
#include "addrtoname.h"
#include "addrtostr.h"
#include "ethertype.h"
#include "llc.h"
#include "extract.h"
#include "oui.h"
Include dependency graph for addrtoname.c:

Go to the source code of this file.

Data Structures

struct  hnamemem
 
struct  h6namemem
 
struct  enamemem
 
struct  bsnamemem
 
struct  protoidmem
 
struct  eproto
 
struct  protoidlist
 
struct  etherlist
 
struct  ipxsap_ent
 

Macros

#define HASHNAMESIZE   4096
 
#define ISONSAP_MAX_LENGTH   20
 

Functions

const char * intoa (uint32_t addr)
 
const char * ipaddr_string (netdissect_options *ndo, const u_char *ap)
 
const char * ip6addr_string (netdissect_options *ndo, const u_char *ap)
 
static char * octet_to_hex (char *cp, uint8_t octet)
 
static struct enamememlookup_emem (netdissect_options *ndo, const u_char *ep)
 
static struct bsnamememlookup_bytestring (netdissect_options *ndo, const u_char *bs, const unsigned int nlen)
 
static struct enamememlookup_nsap (netdissect_options *ndo, const u_char *nsap, u_int nsap_length)
 
static struct protoidmemlookup_protoid (netdissect_options *ndo, const u_char *pi)
 
const char * etheraddr_string (netdissect_options *ndo, const uint8_t *ep)
 
const char * le64addr_string (netdissect_options *ndo, const uint8_t *ep)
 
const char * linkaddr_string (netdissect_options *ndo, const uint8_t *ep, const unsigned int type, const unsigned int len)
 
const char * isonsap_string (netdissect_options *ndo, const uint8_t *nsap, u_int nsap_length)
 
const char * tcpport_string (netdissect_options *ndo, u_short port)
 
const char * udpport_string (netdissect_options *ndo, u_short port)
 
const char * ipxsap_string (netdissect_options *ndo, u_short port)
 
static void init_servarray (netdissect_options *ndo)
 
static void init_eprotoarray (netdissect_options *ndo)
 
static void init_protoidarray (netdissect_options *ndo)
 
static void init_etherarray (netdissect_options *ndo)
 
static void init_ipxsaparray (netdissect_options *ndo)
 
void init_addrtoname (netdissect_options *ndo, uint32_t localnet, uint32_t mask)
 
const char * dnaddr_string (netdissect_options *ndo, u_short dnaddr)
 
struct hnamememnewhnamemem (netdissect_options *ndo)
 
struct h6namememnewh6namemem (netdissect_options *ndo)
 
const char * ieee8021q_tci_string (const uint16_t tci)
 

Variables

static struct hnamemem hnametable [4096]
 
static struct hnamemem tporttable [4096]
 
static struct hnamemem uporttable [4096]
 
static struct hnamemem eprototable [4096]
 
static struct hnamemem dnaddrtable [4096]
 
static struct hnamemem ipxsaptable [4096]
 
static struct h6namemem h6nametable [4096]
 
static struct enamemem enametable [4096]
 
static struct enamemem nsaptable [4096]
 
static struct bsnamemem bytestringtable [4096]
 
static struct protoidmem protoidtable [4096]
 
static uint32_t f_netmask
 
static uint32_t f_localnet
 
static const char hex [16]
 
static const struct eproto eproto_db []
 
static const struct protoidlist protoidlist []
 
static const struct etherlist etherlist []
 
static const struct ipxsap_ent ipxsap_db []
 

Macro Definition Documentation

◆ HASHNAMESIZE

#define HASHNAMESIZE   4096

Definition at line 125 of file addrtoname.c.

◆ ISONSAP_MAX_LENGTH

#define ISONSAP_MAX_LENGTH   20

Definition at line 706 of file addrtoname.c.

Function Documentation

◆ dnaddr_string()

const char* dnaddr_string ( netdissect_options ndo,
u_short  dnaddr 
)

◆ etheraddr_string()

◆ ieee8021q_tci_string()

const char* ieee8021q_tci_string ( const uint16_t  tci)

Definition at line 1325 of file addrtoname.c.

References snprintf().

Referenced by ether_common_print(), of10_bsn_actions_print(), sll2_if_print(), and sll_if_print().

◆ init_addrtoname()

void init_addrtoname ( netdissect_options ndo,
uint32_t  localnet,
uint32_t  mask 
)

◆ init_eprotoarray()

static void init_eprotoarray ( netdissect_options ndo)
static

◆ init_etherarray()

◆ init_ipxsaparray()

static void init_ipxsaparray ( netdissect_options ndo)
static

◆ init_protoidarray()

◆ init_servarray()

◆ intoa()

const char* intoa ( uint32_t  addr)

◆ ip6addr_string()

◆ ipaddr_string()

◆ ipxsap_string()

const char* ipxsap_string ( netdissect_options ndo,
u_short  port 
)

◆ isonsap_string()

const char* isonsap_string ( netdissect_options ndo,
const uint8_t *  nsap,
u_int  nsap_length 
)

◆ le64addr_string()

const char* le64addr_string ( netdissect_options ndo,
const uint8_t *  ep 
)

◆ linkaddr_string()

const char* linkaddr_string ( netdissect_options ndo,
const uint8_t *  ep,
const unsigned int  type,
const unsigned int  len 
)

◆ lookup_bytestring()

static struct bsnamemem* lookup_bytestring ( netdissect_options ndo,
const u_char *  bs,
const unsigned int  nlen 
)
static

◆ lookup_emem()

static struct enamemem* lookup_emem ( netdissect_options ndo,
const u_char *  ep 
)
static

◆ lookup_nsap()

static struct enamemem* lookup_nsap ( netdissect_options ndo,
const u_char *  nsap,
u_int  nsap_length 
)
static

◆ lookup_protoid()

static struct protoidmem* lookup_protoid ( netdissect_options ndo,
const u_char *  pi 
)
static

◆ newh6namemem()

struct h6namemem* newh6namemem ( netdissect_options ndo)

Definition at line 1305 of file addrtoname.c.

References netdissect_options::ndo_error, and S_ERR_ND_MEM_ALLOC.

Referenced by ip6addr_string().

◆ newhnamemem()

◆ octet_to_hex()

static char* octet_to_hex ( char *  cp,
uint8_t  octet 
)
inlinestatic

Definition at line 427 of file addrtoname.c.

References hex.

Referenced by etheraddr_string(), isonsap_string(), le64addr_string(), and linkaddr_string().

◆ tcpport_string()

const char* tcpport_string ( netdissect_options ndo,
u_short  port 
)

◆ udpport_string()

const char* udpport_string ( netdissect_options ndo,
u_short  port 
)

Variable Documentation

◆ bytestringtable

struct bsnamemem bytestringtable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by lookup_bytestring().

◆ dnaddrtable

struct hnamemem dnaddrtable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by dnaddr_string().

◆ enametable

struct enamemem enametable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by lookup_emem().

◆ eproto_db

const struct eproto eproto_db[]
static
Initial value:
= {
{ "aarp", 0x80f3 },
{ "arp", 0x0806 },
{ "atalk", 0x809b },
{ "decnet", 0x6003 },
{ "ip", 0x0800 },
{ "ip6", 0x86dd },
{ "lat", 0x6004 },
{ "loopback", 0x9000 },
{ "mopdl", 0x6001 },
{ "moprc", 0x6002 },
{ "rarp", 0x8035 },
{ "sca", 0x6007 },
{ (char *)0, 0 }
}

Referenced by init_eprotoarray(), and init_protoidarray().

◆ eprototable

struct hnamemem eprototable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by init_eprotoarray().

◆ etherlist

const struct etherlist etherlist[]
static
Initial value:
= {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL }
}

◆ f_localnet

uint32_t f_localnet
static

Definition at line 255 of file addrtoname.c.

Referenced by init_addrtoname(), and ipaddr_string().

◆ f_netmask

uint32_t f_netmask
static

Definition at line 254 of file addrtoname.c.

Referenced by init_addrtoname(), and ipaddr_string().

◆ h6nametable

struct h6namemem h6nametable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by ip6addr_string().

◆ hex

const char hex[16]
static
Initial value:
= {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
}

Definition at line 397 of file addrtoname.c.

Referenced by ipxsap_string(), octet_to_hex(), and print_field().

◆ hnametable

struct hnamemem hnametable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by ipaddr_string().

◆ ipxsap_db

const struct ipxsap_ent ipxsap_db[]
static

Referenced by init_ipxsaparray().

◆ ipxsaptable

struct hnamemem ipxsaptable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by init_ipxsaparray(), and ipxsap_string().

◆ nsaptable

struct enamemem nsaptable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by lookup_nsap().

◆ protoidlist

const struct protoidlist protoidlist[]
static
Initial value:
= {
{{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
{{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
{{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL }
}

◆ protoidtable

struct protoidmem protoidtable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by lookup_protoid().

◆ tporttable

struct hnamemem tporttable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by init_servarray(), and tcpport_string().

◆ uporttable

struct hnamemem uporttable[4096]
static

Definition at line 1 of file addrtoname.c.

Referenced by init_servarray(), and udpport_string().