version 1.1, 2012/02/21 17:26:11
|
version 1.1.1.3, 2016/11/02 10:09:10
|
Line 32
|
Line 32
|
#include "isisd/dict.h" |
#include "isisd/dict.h" |
#include "isisd/isis_constants.h" |
#include "isisd/isis_constants.h" |
#include "isisd/isis_common.h" |
#include "isisd/isis_common.h" |
|
#include "isisd/isis_flags.h" |
#include "isisd/isis_circuit.h" |
#include "isisd/isis_circuit.h" |
|
#include "isisd/isis_csm.h" |
#include "isisd/isisd.h" |
#include "isisd/isisd.h" |
#include "isisd/isis_misc.h" |
#include "isisd/isis_misc.h" |
|
|
Line 40
|
Line 42
|
#include "isisd/isis_lsp.h" |
#include "isisd/isis_lsp.h" |
#include "isisd/isis_constants.h" |
#include "isisd/isis_constants.h" |
#include "isisd/isis_adjacency.h" |
#include "isisd/isis_adjacency.h" |
|
#include "isisd/isis_dynhn.h" |
|
|
/* staticly assigned vars for printing purposes */ |
/* staticly assigned vars for printing purposes */ |
struct in_addr new_prefix; |
struct in_addr new_prefix; |
Line 60 char nlpidstring[30];
|
Line 63 char nlpidstring[30];
|
* This converts the isonet to its printable format |
* This converts the isonet to its printable format |
*/ |
*/ |
const char * |
const char * |
isonet_print (u_char * from, int len) | isonet_print (const u_char * from, int len) |
{ |
{ |
int i = 0; |
int i = 0; |
char *pos = isonet; |
char *pos = isonet; |
Line 99 isonet_print (u_char * from, int len)
|
Line 102 isonet_print (u_char * from, int len)
|
* extract dot from the dotted str, and insert all the number in a buff |
* extract dot from the dotted str, and insert all the number in a buff |
*/ |
*/ |
int |
int |
dotformat2buff (u_char * buff, const u_char * dotted) | dotformat2buff (u_char * buff, const char * dotted) |
{ |
{ |
int dotlen, len = 0; |
int dotlen, len = 0; |
const u_char *pos = dotted; | const char *pos = dotted; |
u_char number[3]; |
u_char number[3]; |
int nextdotpos = 2; |
int nextdotpos = 2; |
|
|
Line 157 dotformat2buff (u_char * buff, const u_char * dotted)
|
Line 160 dotformat2buff (u_char * buff, const u_char * dotted)
|
* conversion of XXXX.XXXX.XXXX to memory |
* conversion of XXXX.XXXX.XXXX to memory |
*/ |
*/ |
int |
int |
sysid2buff (u_char * buff, const u_char * dotted) | sysid2buff (u_char * buff, const char * dotted) |
{ |
{ |
int len = 0; |
int len = 0; |
const u_char *pos = dotted; | const char *pos = dotted; |
u_char number[3]; |
u_char number[3]; |
|
|
number[2] = '\0'; |
number[2] = '\0'; |
Line 271 speaks (struct nlpids *nlpids, int family)
|
Line 274 speaks (struct nlpids *nlpids, int family)
|
* Returns 0 on error, IS-IS Circuit Type on ok |
* Returns 0 on error, IS-IS Circuit Type on ok |
*/ |
*/ |
int |
int |
string2circuit_t (const u_char * str) | string2circuit_t (const char * str) |
{ |
{ |
|
|
if (!str) |
if (!str) |
Line 290 string2circuit_t (const u_char * str)
|
Line 293 string2circuit_t (const u_char * str)
|
} |
} |
|
|
const char * |
const char * |
|
circuit_state2string (int state) |
|
{ |
|
|
|
switch (state) |
|
{ |
|
case C_STATE_INIT: |
|
return "Init"; |
|
case C_STATE_CONF: |
|
return "Config"; |
|
case C_STATE_UP: |
|
return "Up"; |
|
default: |
|
return "Unknown"; |
|
} |
|
return NULL; |
|
} |
|
|
|
const char * |
|
circuit_type2string (int type) |
|
{ |
|
|
|
switch (type) |
|
{ |
|
case CIRCUIT_T_P2P: |
|
return "p2p"; |
|
case CIRCUIT_T_BROADCAST: |
|
return "lan"; |
|
case CIRCUIT_T_LOOPBACK: |
|
return "loopback"; |
|
default: |
|
return "Unknown"; |
|
} |
|
return NULL; |
|
} |
|
|
|
const char * |
circuit_t2string (int circuit_t) |
circuit_t2string (int circuit_t) |
{ |
{ |
switch (circuit_t) |
switch (circuit_t) |
Line 331 syst2string (int type)
|
Line 370 syst2string (int type)
|
* Print functions - we print to static vars |
* Print functions - we print to static vars |
*/ |
*/ |
const char * |
const char * |
snpa_print (u_char * from) | snpa_print (const u_char * from) |
{ |
{ |
int i = 0; |
int i = 0; |
u_char *pos = (u_char *)snpa; |
u_char *pos = (u_char *)snpa; |
Line 363 snpa_print (u_char * from)
|
Line 402 snpa_print (u_char * from)
|
} |
} |
|
|
const char * |
const char * |
sysid_print (u_char * from) | sysid_print (const u_char * from) |
{ |
{ |
int i = 0; |
int i = 0; |
char *pos = sysid; |
char *pos = sysid; |
Line 395 sysid_print (u_char * from)
|
Line 434 sysid_print (u_char * from)
|
} |
} |
|
|
const char * |
const char * |
rawlspid_print (u_char * from) | rawlspid_print (const u_char * from) |
{ |
{ |
char *pos = lspid; |
char *pos = lspid; |
if (!from) |
if (!from) |
Line 471 isis_jitter (unsigned long timer, unsigned long jitter
|
Line 510 isis_jitter (unsigned long timer, unsigned long jitter
|
* most IS-IS timers are no longer than 16 bit |
* most IS-IS timers are no longer than 16 bit |
*/ |
*/ |
|
|
j = 1 + (int) ((RANDOM_SPREAD * rand ()) / (RAND_MAX + 1.0)); | j = 1 + (int) ((RANDOM_SPREAD * random ()) / (RAND_MAX + 1.0)); |
|
|
k = timer - (timer * (100 - jitter)) / 100; |
k = timer - (timer * (100 - jitter)) / 100; |
|
|
Line 498 unix_hostname (void)
|
Line 537 unix_hostname (void)
|
{ |
{ |
static struct utsname names; |
static struct utsname names; |
const char *hostname; |
const char *hostname; |
extern struct host host; |
|
|
|
hostname = host.name; |
hostname = host.name; |
if (!hostname) |
if (!hostname) |
Line 508 unix_hostname (void)
|
Line 546 unix_hostname (void)
|
} |
} |
|
|
return hostname; |
return hostname; |
|
} |
|
|
|
/* |
|
* Returns the dynamic hostname associated with the passed system ID. |
|
* If no dynamic hostname found then returns formatted system ID. |
|
*/ |
|
const char * |
|
print_sys_hostname (const u_char *sysid) |
|
{ |
|
struct isis_dynhn *dyn; |
|
|
|
if (!sysid) |
|
return "nullsysid"; |
|
|
|
/* For our system ID return our host name */ |
|
if (memcmp(sysid, isis->sysid, ISIS_SYS_ID_LEN) == 0) |
|
return unix_hostname(); |
|
|
|
dyn = dynhn_find_by_id (sysid); |
|
if (dyn) |
|
return (const char *)dyn->name.name; |
|
|
|
return sysid_print (sysid); |
|
} |
|
|
|
/* |
|
* This function is a generic utility that logs data of given length. |
|
* Move this to a shared lib so that any protocol can use it. |
|
*/ |
|
void |
|
zlog_dump_data (void *data, int len) |
|
{ |
|
int i; |
|
unsigned char *p; |
|
unsigned char c; |
|
char bytestr[4]; |
|
char addrstr[10]; |
|
char hexstr[ 16*3 + 5]; |
|
char charstr[16*1 + 5]; |
|
|
|
p = data; |
|
memset (bytestr, 0, sizeof(bytestr)); |
|
memset (addrstr, 0, sizeof(addrstr)); |
|
memset (hexstr, 0, sizeof(hexstr)); |
|
memset (charstr, 0, sizeof(charstr)); |
|
|
|
for (i = 1; i <= len; i++) |
|
{ |
|
c = *p; |
|
if (isalnum (c) == 0) |
|
c = '.'; |
|
|
|
/* store address for this line */ |
|
if ((i % 16) == 1) |
|
snprintf (addrstr, sizeof(addrstr), "%p", p); |
|
|
|
/* store hex str (for left side) */ |
|
snprintf (bytestr, sizeof (bytestr), "%02X ", *p); |
|
strncat (hexstr, bytestr, sizeof (hexstr) - strlen (hexstr) - 1); |
|
|
|
/* store char str (for right side) */ |
|
snprintf (bytestr, sizeof (bytestr), "%c", c); |
|
strncat (charstr, bytestr, sizeof (charstr) - strlen (charstr) - 1); |
|
|
|
if ((i % 16) == 0) |
|
{ |
|
/* line completed */ |
|
zlog_debug ("[%8.8s] %-50.50s %s", addrstr, hexstr, charstr); |
|
hexstr[0] = 0; |
|
charstr[0] = 0; |
|
} |
|
else if ((i % 8) == 0) |
|
{ |
|
/* half line: add whitespaces */ |
|
strncat (hexstr, " ", sizeof (hexstr) - strlen (hexstr) - 1); |
|
strncat (charstr, " ", sizeof (charstr) - strlen (charstr) - 1); |
|
} |
|
p++; /* next byte */ |
|
} |
|
|
|
/* print rest of buffer if not empty */ |
|
if (strlen (hexstr) > 0) |
|
zlog_debug ("[%8.8s] %-50.50s %s", addrstr, hexstr, charstr); |
|
return; |
} |
} |