check_function_exists(getopt_long HAVE_GETOPT_LONG)
#
-# With MSVC 2015, stdio.h defines snprintf() and vsnprintf() as inline
-# functions, so you need to include stdio.h when testing for them -
-# check_function_exists() won't do it, you need check_symbol_exists().
-#
-check_symbol_exists(vsnprintf stdio.h HAVE_VSNPRINTF)
-check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
-check_function_exists(fork HAVE_FORK)
-check_function_exists(vfork HAVE_VFORK)
+# For Windows, either
+#
+# 1) we're using VS 2015, in which case we have both snprintf()
+# and vsnprintf(), and they behave in a C99-compliant fashion,
+# so we use them
+#
+# or
+#
+# 2) we're not, and we don't have snprintf(), and we either don't
+# have vsnprintf() or we have one that *doesn't* behave in a
+# C99-compliant fashion, but we *do* have _snprintf_s() and
+# _vsnprintf_s(), so we wrap them with #defines
+#
+# and we test for both of them at compile time, so we don't need to
+# check for snprintf() or vsnprintf() here.
+#
+# XXX - do we need to care about UN*Xes that don't have snprintf()
+# or vsnprintf() any more?
+#
+# We also don't need to waste time checking for fork() or vfork().
+#
+if(NOT WIN32)
+ check_function_exists(vsnprintf HAVE_VSNPRINTF)
+ check_function_exists(snprintf HAVE_SNPRINTF)
+ check_function_exists(fork HAVE_FORK)
+ check_function_exists(vfork HAVE_VFORK)
+endif(NOT WIN32)
check_function_exists(strftime HAVE_STRFTIME)
check_function_exists(setlinebuf HAVE_SETLINEBUF)
set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c)
endif()
endforeach()
-if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
- if(WIN32)
- set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/win_snprintf.c)
- else(WIN32)
+if(NOT WIN32)
+ if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/snprintf.c)
- endif(WIN32)
-endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
+ endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
+endif(NOT WIN32)
add_library(netdissect STATIC
${NETDISSECT_SOURCE_LIST_C}
missing/strsep.c \
missing/win_ether_ntohost.c \
missing/win_ether_ntohost.h \
- missing/win_snprintf.c \
mkdep \
packetdat.awk \
pcap_dump_ftell.c \
}
if (!ndo->ndo_nflag) {
- snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
+ nd_snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
tok2str(oui_values, "Unknown", oui));
} else
*cp = '\0';
tp->addr = i;
tp->nxt = newhnamemem(ndo);
- (void)snprintf(buf, sizeof(buf), "%u", i);
+ (void)nd_snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
tp->addr = i;
tp->nxt = newhnamemem(ndo);
- (void)snprintf(buf, sizeof(buf), "%u", i);
+ (void)nd_snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
while (table->name)
table = table->nxt;
if (ndo->ndo_nflag) {
- (void)snprintf(buf, sizeof(buf), "%d", port);
+ (void)nd_snprintf(buf, sizeof(buf), "%d", port);
table->name = strdup(buf);
} else
table->name = strdup(sv->s_name);
ieee8021q_tci_string(const uint16_t tci)
{
static char buf[128];
- snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
+ nd_snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
tci & 0xfff,
tci >> 13,
(tci & 0x1000) ? ", DEI" : "");
space_left -= added_space;
break;
}
- snprintfed = snprintf (dp, space_left, "%x", words[i]);
+ snprintfed = nd_snprintf (dp, space_left, "%x", words[i]);
if (snprintfed < 0)
return (NULL);
if ((size_t) snprintfed >= space_left)
#include "funcattrs.h"
-/* snprintf et al */
-
#include <stdarg.h>
#if HAVE_STDINT_H
#include <sys/sysinfo.h>
#include <sys/proc.h>
-#if !defined(HAVE_SNPRINTF)
-int snprintf(char *, size_t, const char *, ...) PRINTFLIKE(3, 4);
-#endif /* !defined(HAVE_SNPRINTF) */
-#endif /* __osf__ */
-
#include "machdep.h"
/*
return (file);
else
#ifdef _WIN32
- snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
+ nd_snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
#else
- snprintf(path, sizeof(path), "%s%s", env, file);
+ nd_snprintf(path, sizeof(path), "%s%s", env, file);
#endif
return (path);
}
#ifndef HAVE_SNPRINTF
int
-snprintf (char *str, size_t sz, const char *format, ...)
+nd_snprintf (char *str, size_t sz, const char *format, ...)
{
va_list args;
int ret;
va_start(args, format);
- ret = vsnprintf (str, sz, format, args);
+ ret = nd_vsnprintf (str, sz, format, args);
#ifdef PARANOIA
{
#ifndef HAVE_ASNPRINTF
int
-asnprintf (char **ret, size_t max_sz, const char *format, ...)
+nd_asnprintf (char **ret, size_t max_sz, const char *format, ...)
{
va_list args;
int val;
va_start(args, format);
- val = vasnprintf (ret, max_sz, format, args);
+ val = nd_vasnprintf (ret, max_sz, format, args);
#ifdef PARANOIA
{
int
vasprintf (char **ret, const char *format, va_list args)
{
- return vasnprintf (ret, 0, format, args);
+ return nd_vasnprintf (ret, 0, format, args);
}
#endif
#ifndef HAVE_VASNPRINTF
int
-vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
+nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
{
int st;
size_t len;
#ifndef HAVE_VSNPRINTF
int
-vsnprintf (char *str, size_t sz, const char *format, va_list args)
+nd_vsnprintf (char *str, size_t sz, const char *format, va_list args)
{
struct state state;
int ret;
return (file);
if (win9x)
- snprintf (path, sizeof(path), "%s\\etc\\%s", env, file);
+ nd_snprintf (path, sizeof(path), "%s\\etc\\%s", env, file);
else
- snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file);
+ nd_snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file);
return (path);
}
+++ /dev/null
-#include <stdio.h>
-#include <stdarg.h>
-
-int
-vsnprintf(char *str, size_t str_size, const char *format, va_list args)
-{
- int ret;
-
- ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
-
- /*
- * XXX - _vsnprintf() and _snprintf() do *not* guarantee
- * that str is null-terminated, but C99's vsnprintf()
- * and snprintf() do, and we want to offer C99 behavior,
- * so forcibly null-terminate the string.
- */
- str[str_size - 1] = '\0';
- return (ret);
-}
-
-int
-snprintf(char *str, size_t str_size, const char *format, ...)
-{
- va_list args;
- int ret;
-
- va_start(args, format);
- ret = vsnprintf(str, str_size, format, args);
- va_end(args);
- return (ret);
-}
* and define vsnprintf to be _vsnprintf, as we're relying on null-
* termination of strings in all cases.
*
- * We also want to allow this to be built with versions of Visual Studio
- * prior to VS 2015, so we can't rely on snprintf() being present.
+ * Furthermore, some versions of Visual Studio prior to Visual
+ * Studio 2015 had vsnprintf() (but not snprintf()!), but those
+ * versions don't guarantee null termination, either.
*
- * And, if there are any UN*Xes out there on which we can run that
- * don't have snprintf() or don't have vsnprintf(), we define our
- * own as well.
+ * We assume all UN*Xes that have snprintf() and vsnprintf() provide
+ * C99 behavior.
*/
-#if !defined(HAVE_SNPRINTF)
-int snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...)
- PRINTFLIKE(3, 4);
-#endif /* !defined(HAVE_SNPRINTF) */
-
-#if !defined(HAVE_VSNPRINTF)
-int vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
- va_list ap) PRINTFLIKE(3, 0);
-#endif /* !defined(HAVE_VSNPRINTF) */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #if defined(_MSC_VER) && _MSC_VER >= 1900
+ /*
+ * VS 2015 or newer; just use the C runtime's snprintf() and
+ * vsnprintf().
+ */
+ #define nd_snprintf snprintf
+ #define nd_vsnprintf vsnprintf
+ #else /* defined(_MSC_VER) && _MSC_VER >= 1900 */
+ /*
+ * VS prior to 2015, or MingGW; assume we have _snprintf_s() and
+ * _vsnprintf_s(), which guarantee null termination.
+ */
+ #define nd_snprintf(buf, buflen, fmt, ...) \
+ _snprintf_s(buf, buflen, _TRUNCATE, fmt, __VA_ARGS__)
+ #define nd_vsnprintf(buf, buflen, fmt, ap) \
+ _vsnprintf_s(buf, buflen, _TRUNCATE, fmt, ap)
+ #endif /* defined(_MSC_VER) && _MSC_VER >= 1900 */
+#else /* defined(_MSC_VER) || defined(__MINGW32__) */
+ /*
+ * Some other compiler, which we assume to be a UN*X compiler.
+ * Use the system's snprintf() if we have it, otherwise use
+ * our own implementation
+ */
+ #ifdef HAVE_SNPRINTF
+ #define nd_snprintf snprintf
+ #else /* HAVE_SNPRINTF */
+ int nd_snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...)
+ PRINTFLIKE(3, 4);
+ #endif /* HAVE_SNPRINTF */
+
+ #ifdef HAVE_VSNPRINTF
+ #define nd_vsnprintf vsnprintf
+ #else /* HAVE_VSNPRINTF */
+ int nd_vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
+ va_list ap) PRINTFLIKE(3, 0);
+ #endif /* HAVE_VSNPRINTF */
+#endif /* defined(_MSC_VER) || defined(__MINGW32__) */
/*
* fopen() read and write modes for text files and binary files.
{
#ifdef USE_LIBSMI
if (smiLoadModule(module) == 0) {
- snprintf(errbuf, errbuf_size, "could not load MIB module %s",
+ nd_snprintf(errbuf, errbuf_size, "could not load MIB module %s",
module);
return (-1);
}
nd_smi_module_loaded = 1;
return (0);
#else
- snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
+ nd_snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
module);
return (-1);
#endif
*/
typedef unsigned char nd_byte;
-/* snprintf et al */
+/* nd_snprintf et al */
#include <stdarg.h>
#include <pcap.h>
#endif
/* Save the actual handle, so it can be display with -u */
for (i = 0; i < len*4 && i*2 < sizeof(fsidp->Opaque_Handle) - 1; i++)
- (void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X",
+ (void)nd_snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X",
EXTRACT_U_1(fhp + i));
fsidp->Opaque_Handle[i*2] = '\0';
cp++;
s2 = EXTRACT_U_1(cp);
cp++;
- (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
if (length & 1) {
s1 = EXTRACT_U_1(cp);
cp++;
- (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x", s1);
hsp += 3;
*(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem(ndo);
- (void)snprintf(nambuf, sizeof(nambuf), "%s.%u",
+ (void)nd_snprintf(nambuf, sizeof(nambuf), "%s.%u",
tp2->name, athost);
tp->name = strdup(nambuf);
if (tp->name == NULL)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem(ndo);
if (athost != 255)
- (void)snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost);
+ (void)nd_snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost);
else
- (void)snprintf(nambuf, sizeof(nambuf), "%u", atnet);
+ (void)nd_snprintf(nambuf, sizeof(nambuf), "%u", atnet);
tp->name = strdup(nambuf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
static char buf[8];
if (ndo->ndo_nflag) {
- (void)snprintf(buf, sizeof(buf), "%u", skt);
+ (void)nd_snprintf(buf, sizeof(buf), "%u", skt);
return (buf);
}
return (tok2str(skt2str, "%u", skt));
format_id(const u_char *id)
{
static char buf[25];
- snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
+ nd_snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
EXTRACT_U_1(id), EXTRACT_U_1(id + 1), EXTRACT_U_1(id + 2),
EXTRACT_U_1(id + 3), EXTRACT_U_1(id + 4), EXTRACT_U_1(id + 5),
EXTRACT_U_1(id + 6), EXTRACT_U_1(id + 7));
{
static char buf[50];
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
- snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
+ nd_snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
- snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
+ nd_snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
buf[49] = '\0';
return buf;
}
if (i == 0)
return "0.0s (bogus)";
- snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
+ nd_snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
return buf;
}
format_timestamp(const uint32_t i)
{
static char buf[sizeof("0000.000000s")];
- snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+ nd_snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
return buf;
}
char *str, size_t size, u_int asnum)
{
if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
- snprintf(str, size, "%u", asnum);
+ nd_snprintf(str, size, "%u", asnum);
} else {
- snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
+ nd_snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
}
return str;
}
if (plen % 8) {
((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, &addr), plen);
+ nd_snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "%s/%u, label:%u %s",
+ nd_snprintf(buf, buflen, "%s/%u, label:%u %s",
ipaddr_string(ndo, &addr),
plen,
EXTRACT_BE_U_3(pptr + 1)>>4,
switch(addr_length) {
case (sizeof(struct in_addr) << 3): /* 32 */
ND_TCHECK_LEN(pptr, sizeof(struct in_addr));
- snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
+ nd_snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
break;
case (sizeof(struct in6_addr) << 3): /* 128 */
ND_TCHECK_LEN(pptr, sizeof(struct in6_addr));
- snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
+ nd_snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
default:
- snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
+ nd_snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
break;
}
pos += strlen(pos);
total_length += (addr_length >> 3) + 1;
offset = strlen(buf);
if (addr_length) {
- snprintf(buf + offset, buflen - offset, ", Source %s",
+ nd_snprintf(buf + offset, buflen - offset, ", Source %s",
bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
total_length += (addr_length >> 3) + 1;
offset = strlen(buf);
if (addr_length) {
- snprintf(buf + offset, buflen - offset, ", Group %s",
+ nd_snprintf(buf + offset, buflen - offset, ", Group %s",
bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
/* 2-byte-AS:number fmt*/
case 0:
- snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)",
+ nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)",
EXTRACT_BE_U_2(pptr + 2),
EXTRACT_BE_U_4(pptr + 4),
EXTRACT_U_1(pptr + 4), EXTRACT_U_1(pptr + 5),
/* IP-address:AS fmt*/
case 1:
- snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u",
+ nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u",
EXTRACT_U_1(pptr + 2), EXTRACT_U_1(pptr + 3),
EXTRACT_U_1(pptr + 4), EXTRACT_U_1(pptr + 5),
EXTRACT_BE_U_2(pptr + 6));
/* 4-byte-AS:number fmt*/
case 2:
- snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
+ nd_snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(pptr + 2)),
EXTRACT_BE_U_2(pptr + 6), EXTRACT_U_1(pptr + 2),
EXTRACT_U_1(pptr + 3), EXTRACT_U_1(pptr + 4),
EXTRACT_U_1(pptr + 5), EXTRACT_BE_U_2(pptr + 6));
break;
default:
- snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
+ nd_snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
break;
}
pos += strlen(pos);
*/
if (0 == plen) {
/* Without "origin AS", without "route target". */
- snprintf(buf, buflen, "default route target");
+ nd_snprintf(buf, buflen, "default route target");
return 1;
}
((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "origin AS: %s, route target %s",
+ nd_snprintf(buf, buflen, "origin AS: %s, route target %s",
asbuf,
bgp_vpn_rd_print(ndo, (u_char *)&route_target));
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
ipaddr_string(ndo, &addr),
plen,
/* MDT Group Address */
ND_TCHECK_LEN(pptr, sizeof(struct in_addr));
- snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
+ nd_snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
return MDT_VPN_NLRI_LEN + 1;
route_length = EXTRACT_U_1(pptr);
pptr++;
- snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
+ nd_snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
tok2str(bgp_multicast_vpn_route_type_values,
"Unknown", route_type),
route_type, route_length);
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
+ nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
bgp_vpn_rd_print(ndo, pptr),
bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN,
(route_length - BGP_VPN_RD_LEN) << 3));
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+ nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
bgp_vpn_rd_print(ndo, pptr),
as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s",
+ nd_snprintf(buf + offset, buflen - offset, ", RD: %s",
bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
ND_TCHECK_LEN(pptr, addr_length);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", Originator %s",
+ nd_snprintf(buf + offset, buflen - offset, ", Originator %s",
bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s",
+ nd_snprintf(buf + offset, buflen - offset, ", RD: %s",
bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+ nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
bgp_vpn_rd_print(ndo, pptr),
as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
/* assume AD-only with RD, BGPNH */
ND_TCHECK_LEN(pptr, 12);
buf[0] = '\0';
- stringlen = snprintf(buf, buflen, "RD: %s, BGPNH: %s",
+ stringlen = nd_snprintf(buf, buflen, "RD: %s, BGPNH: %s",
bgp_vpn_rd_print(ndo, pptr),
ipaddr_string(ndo, pptr+8));
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
ND_TCHECK_LEN(pptr, 15);
buf[0] = '\0';
- stringlen = snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
+ stringlen = nd_snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
bgp_vpn_rd_print(ndo, pptr),
EXTRACT_BE_U_2(pptr + 8),
EXTRACT_BE_U_2(pptr + 10),
while (tlen != 0) {
if (tlen < 3) {
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tran past the end");
+ stringlen=nd_snprintf(buf,buflen, "\n\t\tran past the end");
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
return plen + 2;
switch(tlv_type) {
case 1:
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
+ stringlen=nd_snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
tlv_type,
tlv_len);
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
while (ttlv_len != 0) {
if (tlen < 1) {
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, " (ran past the end)");
+ stringlen=nd_snprintf(buf,buflen, " (ran past the end)");
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
return plen + 2;
}
ND_TCHECK_1(pptr);
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "%02x",
+ stringlen=nd_snprintf(buf,buflen, "%02x",
EXTRACT_U_1(pptr));
pptr++;
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
break;
default:
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
+ stringlen=nd_snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
tlv_type,
tlv_len);
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
if (tlen < ttlv_len) {
if (buflen != 0) {
- stringlen=snprintf(buf,buflen, " (ran past the end)");
+ stringlen=nd_snprintf(buf,buflen, " (ran past the end)");
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
return plen + 2;
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, &addr), plen);
+ nd_snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "%s/%u, label:%u %s",
+ nd_snprintf(buf, buflen, "%s/%u, label:%u %s",
ip6addr_string(ndo, &addr),
plen,
EXTRACT_BE_U_3(pptr + 1)>>4,
((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
ip6addr_string(ndo, &addr),
plen,
addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%u",
+ nd_snprintf(buf, buflen, "%s/%u",
isonsap_string(ndo, addr,(plen + 7) / 8),
plen);
addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
}
/* the label may get offsetted by 4 bits so lets shift it right */
- snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+ nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
bgp_vpn_rd_print(ndo, pptr+4),
isonsap_string(ndo, addr,(plen + 7) / 8),
plen,
EXTRACT_BE_U_4(nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
- snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
- snprintf(asbuf, sizeof(asbuf), ":%u",
+ nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
+ nd_snprintf(asbuf, sizeof(asbuf), ":%u",
EXTRACT_BE_U_2(nr->src_as));
ND_PRINT("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
EXTRACT_BE_U_2(nr->srcport));
- snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
- snprintf(asbuf, sizeof(asbuf), ":%u",
+ nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
+ nd_snprintf(asbuf, sizeof(asbuf), ":%u",
EXTRACT_BE_U_2(nr->dst_as));
ND_PRINT("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
EXTRACT_BE_U_2(nr->dstport));
EXTRACT_BE_U_4(nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
- snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
- snprintf(asbuf, sizeof(asbuf), ":%u",
+ nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
+ nd_snprintf(asbuf, sizeof(asbuf), ":%u",
EXTRACT_BE_U_2(nr->src_as));
ND_PRINT("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
EXTRACT_BE_U_2(nr->srcport));
- snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
- snprintf(asbuf, sizeof(asbuf), ":%u",
+ nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
+ nd_snprintf(asbuf, sizeof(asbuf), ":%u",
EXTRACT_BE_U_2(nr->dst_as));
ND_PRINT("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
EXTRACT_BE_U_2(nr->dstport));
}
buf[0]='\0';
- snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
+ nd_snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
(EXTRACT_BE_U_2(nr->flags) >> 8) & 0xff,
(EXTRACT_BE_U_2(nr->flags)) & 0xff);
ND_PRINT("tos %u, %u (%u octets) %s",
str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
(*ndo->ndo_error)(ndo, "dnnum_string: malloc");
- snprintf(str, siz, "%u.%u", area, node);
+ nd_snprintf(str, siz, "%u.%u", area, node);
return(str);
}
memset(buffer, 0, sizeof(buffer));
if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
- snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
+ nd_snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
}
return buffer;
static char buf[4][sizeof("01:01:01:01")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
+ nd_snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
EXTRACT_U_1(data), EXTRACT_U_1(data + 1), EXTRACT_U_1(data + 2),
EXTRACT_U_1(data + 3));
return buf[i];
static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
+ nd_snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
EXTRACT_BE_U_8(data),
EXTRACT_BE_U_8(data + 8),
EXTRACT_BE_U_8(data + 16),
static char buf[4][sizeof("0000000.000s")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
+ nd_snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
return buf[i];
}
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, &addr), plen);
+ nd_snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, &addr), plen);
plenbytes += 1 + IPV4_MAPPED_HEADING_LEN;
} else {
plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf));
sec = tstamp / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;
- snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
+ nd_snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
return buf;
}
case ICMP_ECHO:
case ICMP_ECHOREPLY:
ND_TCHECK_2(dp->icmp_seq);
- (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
+ (void)nd_snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
icmp_type == ICMP_ECHO ?
"request" : "reply",
EXTRACT_BE_U_2(dp->icmp_id),
case ICMP_UNREACH_PROTOCOL:
ND_TCHECK_1(dp->icmp_ip.ip_p);
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s protocol %u unreachable",
ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
EXTRACT_U_1(dp->icmp_ip.ip_p));
switch (ip_proto) {
case IPPROTO_TCP:
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
ipaddr_string(ndo, &oip->ip_dst),
tcpport_string(ndo, dport));
break;
case IPPROTO_UDP:
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
ipaddr_string(ndo, &oip->ip_dst),
udpport_string(ndo, dport));
break;
default:
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s protocol %u port %u unreachable",
ipaddr_string(ndo, &oip->ip_dst),
ip_proto, dport);
mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void;
mtu = EXTRACT_BE_U_2(mp->nexthopmtu);
if (mtu) {
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s unreachable - need to frag (mtu %u)",
ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu);
} else {
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"%s unreachable - need to frag",
ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
}
default:
fmt = tok2str(unreach2str, "#%u %%s unreachable",
icmp_code);
- (void)snprintf(buf, sizeof(buf), fmt,
+ (void)nd_snprintf(buf, sizeof(buf), fmt,
ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
break;
}
ND_TCHECK_4(dp->icmp_ip.ip_dst);
fmt = tok2str(type2str, "redirect-#%u %%s to net %%s",
icmp_code);
- (void)snprintf(buf, sizeof(buf), fmt,
+ (void)nd_snprintf(buf, sizeof(buf), fmt,
ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
ipaddr_string(ndo, &dp->icmp_gwaddr));
break;
const struct id_rdiscovery *idp;
u_int lifetime, num, size;
- (void)snprintf(buf, sizeof(buf), "router advertisement");
+ (void)nd_snprintf(buf, sizeof(buf), "router advertisement");
cp = buf + strlen(buf);
ihp = (const struct ih_rdiscovery *)&dp->icmp_void;
cp = buf + strlen(buf);
lifetime = EXTRACT_BE_U_2(ihp->ird_lifetime);
if (lifetime < 60) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u",
lifetime);
} else if (lifetime < 60 * 60) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
lifetime / 60, lifetime % 60);
} else {
- (void)snprintf(cp, sizeof(buf) - (cp - buf),
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf),
"%u:%02u:%02u",
lifetime / 3600,
(lifetime % 3600) / 60,
cp = buf + strlen(buf);
num = EXTRACT_U_1(ihp->ird_addrnum);
- (void)snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num);
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num);
cp = buf + strlen(buf);
size = EXTRACT_U_1(ihp->ird_addrsiz);
if (size != 2) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf),
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf),
" [size %u]", size);
break;
}
idp = (const struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
ND_TCHECK_SIZE(idp);
- (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
+ (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
ipaddr_string(ndo, &idp->ird_addr),
EXTRACT_BE_U_4(idp->ird_pref));
cp = buf + strlen(buf);
break;
default:
- (void)snprintf(buf, sizeof(buf), "time exceeded-#%u",
+ (void)nd_snprintf(buf, sizeof(buf), "time exceeded-#%u",
icmp_code);
break;
}
case ICMP_PARAMPROB:
if (icmp_code)
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"parameter problem - code %u", icmp_code);
else {
ND_TCHECK_1(dp->icmp_pptr);
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"parameter problem - octet %u", EXTRACT_U_1(dp->icmp_pptr));
}
break;
case ICMP_MASKREPLY:
ND_TCHECK_4(dp->icmp_mask);
- (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
+ (void)nd_snprintf(buf, sizeof(buf), "address mask is 0x%08x",
EXTRACT_BE_U_4(dp->icmp_mask));
break;
case ICMP_TSTAMP:
ND_TCHECK_2(dp->icmp_seq);
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"time stamp query id %u seq %u",
EXTRACT_BE_U_2(dp->icmp_id),
EXTRACT_BE_U_2(dp->icmp_seq));
case ICMP_TSTAMPREPLY:
ND_TCHECK_4(dp->icmp_ttime);
- (void)snprintf(buf, sizeof(buf),
+ (void)nd_snprintf(buf, sizeof(buf),
"time stamp reply id %u seq %u: org %s",
EXTRACT_BE_U_2(dp->icmp_id),
EXTRACT_BE_U_2(dp->icmp_seq),
icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_otime)));
- (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s",
+ (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s",
icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_rtime)));
- (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s",
+ (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s",
icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_ttime)));
break;
if (v == (uint32_t)~0UL)
return "infinity";
else {
- snprintf(buf, sizeof(buf), "%us", v);
+ nd_snprintf(buf, sizeof(buf), "%us", v);
return buf;
}
}
{
static char line[256];
- snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x",
+ nd_snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x",
net, EXTRACT_U_1(node), EXTRACT_U_1(node + 1),
EXTRACT_U_1(node + 2), EXTRACT_U_1(node + 3),
EXTRACT_U_1(node + 4), EXTRACT_U_1(node + 5));
numstr(u_int x)
{
static char buf[20];
- snprintf(buf, sizeof(buf), "#%u", x);
+ nd_snprintf(buf, sizeof(buf), "#%u", x);
return buf;
}
if (sysid_len > id_len)
sysid_len = id_len;
for (i = 1; i <= sysid_len; i++) {
- snprintf(pos, sizeof(id) - (pos - id), "%02x", EXTRACT_U_1(cp));
+ nd_snprintf(pos, sizeof(id) - (pos - id), "%02x", EXTRACT_U_1(cp));
cp++;
pos += strlen(pos);
if (i == 2 || i == 4)
*pos++ = '.';
}
if (id_len >= NODE_ID_LEN) {
- snprintf(pos, sizeof(id) - (pos - id), ".%02x", EXTRACT_U_1(cp));
+ nd_snprintf(pos, sizeof(id) - (pos - id), ".%02x", EXTRACT_U_1(cp));
cp++;
pos += strlen(pos);
}
if (id_len == LSP_ID_LEN)
- snprintf(pos, sizeof(id) - (pos - id), "-%02x", EXTRACT_U_1(cp));
+ nd_snprintf(pos, sizeof(id) - (pos - id), "-%02x", EXTRACT_U_1(cp));
return (id);
}
if (subtlv_sum_len) {
ND_PRINT(" (%u)", subtlv_sum_len);
/* prepend the indent string */
- snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
+ nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
ident = ident_buffer;
while (subtlv_sum_len != 0) {
if (!ND_TTEST_2(tptr))
subtlvlen=EXTRACT_U_1(tptr + 1);
tptr+=2;
/* prepend the indent string */
- snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
+ nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
return(0);
tptr+=subtlvlen;
}
if (!pfunc) {
- snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
+ nd_snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
tok2str(af_values, "Unknown", af), af);
} else {
- snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
+ nd_snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
}
ND_TCHECK_4(rp->rm_xid);
if (!ndo->ndo_nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
- snprintf(dstid, sizeof(dstid), "%u",
+ nd_snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_BE_U_4(rp->rm_xid));
} else {
- snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
- snprintf(dstid, sizeof(dstid), "%u",
+ nd_snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
+ nd_snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_BE_U_4(rp->rm_xid));
}
print_nfsaddr(ndo, bp2, srcid, dstid);
if (vid == OFP_VLAN_NONE)
return "NONE";
fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
- snprintf(buf, sizeof(buf), fmt, vid);
+ nd_snprintf(buf, sizeof(buf), fmt, vid);
return buf;
}
pcp_str(const uint8_t pcp)
{
static char buf[sizeof("255 (bogus)")];
- snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
+ nd_snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
return buf;
}
acl & PRSFS_ADMINISTER ? "a" : "");
for (i = 0; i < pos; i++) {
- snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+ nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
}
for (i = 0; i < neg; i++) {
- snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+ nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
#define DECODE_ErrorStatus(e) \
( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
? ErrorStatus[e] \
- : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
+ : (nd_snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
/*
* generic-trap values in the SNMP Trap-PDU
#define DECODE_GenericTrap(t) \
( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
? GenericTrap[t] \
- : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
+ : (nd_snprintf(buf, sizeof(buf), "gt=%d", t), buf))
/*
* ASN.1 type class table
{
static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")];
- snprintf(bridge_id_str, sizeof(bridge_id_str),
+ nd_snprintf(bridge_id_str, sizeof(bridge_id_str),
"%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
EXTRACT_U_1(p), EXTRACT_U_1(p + 1), EXTRACT_U_1(p + 2),
EXTRACT_U_1(p + 3), EXTRACT_U_1(p + 4), EXTRACT_U_1(p + 5),
rp = (const struct sunrpc_msg *)bp;
if (!ndo->ndo_nflag) {
- snprintf(srcid, sizeof(srcid), "0x%x",
+ nd_snprintf(srcid, sizeof(srcid), "0x%x",
EXTRACT_BE_U_4(rp->rm_xid));
strlcpy(dstid, "sunrpc", sizeof(dstid));
} else {
- snprintf(srcid, sizeof(srcid), "0x%x",
+ nd_snprintf(srcid, sizeof(srcid), "0x%x",
EXTRACT_BE_U_4(rp->rm_xid));
- snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
+ nd_snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
}
switch (IP_V((const struct ip *)bp2)) {
rp = getrpcbynumber(prog);
if (rp == NULL)
#endif
- (void) snprintf(buf, sizeof(buf), "#%u", prog);
+ (void) nd_snprintf(buf, sizeof(buf), "#%u", prog);
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
else
strlcpy(buf, rp->r_name, sizeof(buf));
{
static char buf[20];
- snprintf(buf, sizeof(buf), "%#x", x);
+ nd_snprintf(buf, sizeof(buf), "%#x", x);
return buf;
}
{
if (!*recipient)
recipient = "*";
- snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient);
+ nd_snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient);
z_buf[sizeof(z_buf)-1] = '\0';
return z_buf;
}
const err_code_struct *err = err_classes[i].err_msgs;
for (j = 0; err[j].name; j++)
if (num == err[j].code) {
- snprintf(ret, sizeof(ret), "%s - %s (%s)",
+ nd_snprintf(ret, sizeof(ret), "%s - %s (%s)",
err_classes[i].class, err[j].name, err[j].message);
return ret;
}
}
- snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
+ nd_snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
return ret;
}
- snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
+ nd_snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
return(ret);
}
return nt_errors[i].name;
}
- snprintf(ret, sizeof(ret), "0x%08x", err);
+ nd_snprintf(ret, sizeof(ret), "0x%08x", err);
return ret;
}
if (cnt == 0 && max_chars == 0)
strncpy(buffer, filename, PATH_MAX + 1);
else
- if (snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
+ if (nd_snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
/* Report an error if the filename is too large */
error("too many output files or filename is too long (> %d)", PATH_MAX);
free(filename);
/*
* Return an error for our caller to handle.
*/
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
+ nd_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
device, pcap_statustostr(status), cp);
pcap_close(pc);
return (NULL);
char sysctl[32];
size_t s = sizeof(parent);
- snprintf(sysctl, sizeof(sysctl),
+ nd_snprintf(sysctl, sizeof(sysctl),
"net.wlan.%d.%%parent", atoi(device + 4));
sysctlbyname(sysctl, parent, &s, NULL, 0);
strlcpy(newdev, device, sizeof(newdev));
format = "%02d:%02d:%02d.%06u";
#endif
- snprintf(buf, TS_BUF_SIZE, format,
+ nd_snprintf(buf, TS_BUF_SIZE, format,
sec / 3600, (sec % 3600) / 60, sec % 60, usec);
return buf;
format = "%u.%06u";
#endif
- snprintf(buf, TS_BUF_SIZE, format,
+ nd_snprintf(buf, TS_BUF_SIZE, format,
(unsigned)sec, (unsigned)usec);
return buf;
if (fmt == NULL)
fmt = "#%d";
- (void)snprintf(buf, bufsize, fmt, v);
+ (void)nd_snprintf(buf, bufsize, fmt, v);
return (const char *)buf;
}
if (bufp == buf)
/* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
- (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
+ (void)nd_snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
return (buf);
}
return lp[v];
if (fmt == NULL)
fmt = "#%d";
- (void)snprintf(buf, sizeof(buf), fmt, v);
+ (void)nd_snprintf(buf, sizeof(buf), fmt, v);
return (buf);
}