#include "isisd/isisd.h"
#include "isisd/isis_misc.h"
-#include "isisd/isis_tlv.h"
#include "isisd/isis_lsp.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_adjacency.h"
/*
* This converts the isonet to its printable format
*/
-const char *isonet_print(const u_char *from, int len)
+const char *isonet_print(const uint8_t *from, int len)
{
int i = 0;
char *pos = isonet;
* Returns 0 on error, length of buff on ok
* extract dot from the dotted str, and insert all the number in a buff
*/
-int dotformat2buff(u_char *buff, const char *dotted)
+int dotformat2buff(uint8_t *buff, const char *dotted)
{
int dotlen, len = 0;
const char *pos = dotted;
- u_char number[3];
+ uint8_t number[3];
int nextdotpos = 2;
number[2] = '\0';
/*
* conversion of XXXX.XXXX.XXXX to memory
*/
-int sysid2buff(u_char *buff, const char *dotted)
+int sysid2buff(uint8_t *buff, const char *dotted)
{
int len = 0;
const char *pos = dotted;
- u_char number[3];
+ uint8_t number[3];
number[2] = '\0';
// surely not a sysid_string if not 14 length
return nlpidstring;
}
-/*
- * supports the given af ?
- */
-int speaks(struct nlpids *nlpids, int family)
-{
- int i, speaks = 0;
-
- if (nlpids == (struct nlpids *)NULL)
- return speaks;
- for (i = 0; i < nlpids->count; i++) {
- if (family == AF_INET && nlpids->nlpids[i] == NLPID_IP)
- speaks = 1;
- if (family == AF_INET6 && nlpids->nlpids[i] == NLPID_IPV6)
- speaks = 1;
- }
-
- return speaks;
-}
-
/*
* Returns 0 on error, IS-IS Circuit Type on ok
*/
/*
* Print functions - we print to static vars
*/
-const char *snpa_print(const u_char *from)
+const char *snpa_print(const uint8_t *from)
{
return isis_format_id(from, ISIS_SYS_ID_LEN);
}
-const char *sysid_print(const u_char *from)
+const char *sysid_print(const uint8_t *from)
{
return isis_format_id(from, ISIS_SYS_ID_LEN);
}
-const char *rawlspid_print(const u_char *from)
+const char *rawlspid_print(const uint8_t *from)
{
return isis_format_id(from, 8);
}
return rv;
}
-const char *time2string(u_int32_t time)
+const char *time2string(uint32_t time)
{
char *pos = datestring;
- u_int32_t rest;
+ uint32_t rest;
if (time == 0)
return "-";
return timer;
}
-struct in_addr newprefix2inaddr(u_char *prefix_start, u_char prefix_masklen)
+struct in_addr newprefix2inaddr(uint8_t *prefix_start, uint8_t prefix_masklen)
{
memset(&new_prefix, 0, sizeof(new_prefix));
memcpy(&new_prefix, prefix_start,
return new_prefix;
}
-/*
- * Returns host.name if any, otherwise
- * it returns the system hostname.
- */
-const char *unix_hostname(void)
-{
- static struct utsname names;
- const char *hostname;
-
- hostname = host.name;
- if (!hostname) {
- uname(&names);
- hostname = names.nodename;
- }
-
- 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)
+const char *print_sys_hostname(const uint8_t *sysid)
{
struct isis_dynhn *dyn;
/* For our system ID return our host name */
if (memcmp(sysid, isis->sysid, ISIS_SYS_ID_LEN) == 0)
- return unix_hostname();
+ return cmd_hostname_get();
dyn = dynhn_find_by_id(sysid);
if (dyn)
- return (const char *)dyn->name.name;
+ return dyn->hostname;
return sysid_print(sysid);
}
XFREE(MTYPE_TMP, p);
}
+
+void vty_out_timestr(struct vty *vty, time_t uptime)
+{
+ struct tm *tm;
+ time_t difftime = time(NULL);
+ difftime -= uptime;
+ tm = gmtime(&difftime);
+
+ if (difftime < ONE_DAY_SECOND)
+ vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
+ else if (difftime < ONE_WEEK_SECOND)
+ vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+ tm->tm_min);
+ else
+ vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
+ tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour);
+ vty_out(vty, " ago");
+}