summaryrefslogtreecommitdiff
path: root/isisd/isis_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'isisd/isis_misc.c')
-rw-r--r--isisd/isis_misc.c102
1 files changed, 7 insertions, 95 deletions
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 95d24036ec..09ffa3479a 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -32,48 +32,13 @@
#include "isisd/isis_dynhn.h"
/* staticly assigned vars for printing purposes */
+static char sys_hostname[ISO_SYSID_STRLEN];
struct in_addr new_prefix;
-/* len of xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx */
-/* + place for #0 termination */
-char isonet[51];
/* len of xxYxxMxWxdxxhxxmxxs + place for #0 termination */
char datestring[20];
char nlpidstring[30];
/*
- * This converts the isonet to its printable format
- */
-const char *isonet_print(const uint8_t *from, int len)
-{
- int i = 0;
- char tbuf[4];
- isonet[0] = '\0';
-
- if (!from)
- return "unknown";
-
- while (i < len) {
- if (i & 1) {
- snprintf(tbuf, sizeof(tbuf), "%02x", *(from + i));
- strlcat(isonet, tbuf, sizeof(isonet));
- } else {
- if (i == (len - 1)) { /* No dot at the end of address */
- snprintf(tbuf, sizeof(tbuf), "%02x",
- *(from + i));
- strlcat(isonet, tbuf, sizeof(isonet));
- } else {
- snprintf(tbuf, sizeof(tbuf), "%02x.",
- *(from + i));
- strlcat(isonet, tbuf, sizeof(isonet));
- }
- }
- i++;
- }
-
- return isonet;
-}
-
-/*
* Returns 0 on error, length of buff on ok
* extract dot from the dotted str, and insert all the number in a buff
*/
@@ -307,60 +272,6 @@ const char *isis_hello_padding2string(int hello_padding_type)
return NULL; /* not reached */
}
-/*
- * Print functions - we print to static vars
- */
-const char *snpa_print(const uint8_t *from)
-{
- return isis_format_id(from, ISIS_SYS_ID_LEN);
-}
-
-const char *sysid_print(const uint8_t *from)
-{
- return isis_format_id(from, ISIS_SYS_ID_LEN);
-}
-
-const char *rawlspid_print(const uint8_t *from)
-{
- return isis_format_id(from, 8);
-}
-
-#define FORMAT_ID_SIZE sizeof("0000.0000.0000.00-00")
-const char *isis_format_id(const uint8_t *id, size_t len)
-{
-#define FORMAT_BUF_COUNT 4
- static char buf_ring[FORMAT_BUF_COUNT][FORMAT_ID_SIZE];
- static size_t cur_buf = 0;
-
- char *rv;
-
- cur_buf++;
- if (cur_buf >= FORMAT_BUF_COUNT)
- cur_buf = 0;
-
- rv = buf_ring[cur_buf];
-
- if (!id) {
- snprintf(rv, FORMAT_ID_SIZE, "unknown");
- return rv;
- }
-
- if (len < 6) {
- snprintf(rv, FORMAT_ID_SIZE, "Short ID");
- return rv;
- }
-
- snprintf(rv, FORMAT_ID_SIZE, "%02x%02x.%02x%02x.%02x%02x", id[0], id[1],
- id[2], id[3], id[4], id[5]);
-
- if (len > 6)
- snprintf(rv + 14, FORMAT_ID_SIZE - 14, ".%02x", id[6]);
- if (len > 7)
- snprintf(rv + 17, FORMAT_ID_SIZE - 17, "-%02x", id[7]);
-
- return rv;
-}
-
const char *time2string(uint32_t time)
{
uint32_t rest;
@@ -474,7 +385,8 @@ const char *print_sys_hostname(const uint8_t *sysid)
return dyn->hostname;
}
- return sysid_print(sysid);
+ snprintfrr(sys_hostname, ISO_SYSID_STRLEN, "%pSY", sysid);
+ return sys_hostname;
}
/*
@@ -508,11 +420,11 @@ void zlog_dump_data(void *data, int len)
/* store hex str (for left side) */
snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
- strncat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
+ strlcat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
/* store char str (for right side) */
snprintf(bytestr, sizeof(bytestr), "%c", c);
- strncat(charstr, bytestr,
+ strlcat(charstr, bytestr,
sizeof(charstr) - strlen(charstr) - 1);
if ((i % 16) == 0) {
@@ -523,9 +435,9 @@ void zlog_dump_data(void *data, int len)
charstr[0] = 0;
} else if ((i % 8) == 0) {
/* half line: add whitespaces */
- strncat(hexstr, " ",
+ strlcat(hexstr, " ",
sizeof(hexstr) - strlen(hexstr) - 1);
- strncat(charstr, " ",
+ strlcat(charstr, " ",
sizeof(charstr) - strlen(charstr) - 1);
}
p++; /* next byte */