14cf49a43SJulian Elischer /*
24cf49a43SJulian Elischer * debug.c
34cf49a43SJulian Elischer *
44cf49a43SJulian Elischer * Copyright (c) 1996-1999 Whistle Communications, Inc.
54cf49a43SJulian Elischer * All rights reserved.
64cf49a43SJulian Elischer *
74cf49a43SJulian Elischer * Subject to the following obligations and disclaimer of warranty, use and
84cf49a43SJulian Elischer * redistribution of this software, in source or object code forms, with or
94cf49a43SJulian Elischer * without modifications are expressly permitted by Whistle Communications;
104cf49a43SJulian Elischer * provided, however, that:
114cf49a43SJulian Elischer * 1. Any and all reproductions of the source or object code must include the
124cf49a43SJulian Elischer * copyright notice above and the following disclaimer of warranties; and
134cf49a43SJulian Elischer * 2. No rights are granted, in any manner or form, to use Whistle
144cf49a43SJulian Elischer * Communications, Inc. trademarks, including the mark "WHISTLE
154cf49a43SJulian Elischer * COMMUNICATIONS" on advertising, endorsements, or otherwise except as
164cf49a43SJulian Elischer * such appears in the above copyright notice or in the software.
174cf49a43SJulian Elischer *
184cf49a43SJulian Elischer * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
194cf49a43SJulian Elischer * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
204cf49a43SJulian Elischer * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
214cf49a43SJulian Elischer * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
224cf49a43SJulian Elischer * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
234cf49a43SJulian Elischer * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
244cf49a43SJulian Elischer * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
254cf49a43SJulian Elischer * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
264cf49a43SJulian Elischer * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
274cf49a43SJulian Elischer * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
284cf49a43SJulian Elischer * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
294cf49a43SJulian Elischer * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
304cf49a43SJulian Elischer * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
314cf49a43SJulian Elischer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
324cf49a43SJulian Elischer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
334cf49a43SJulian Elischer * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
344cf49a43SJulian Elischer * OF SUCH DAMAGE.
354cf49a43SJulian Elischer *
364cf49a43SJulian Elischer * Author: Archie Cobbs <[email protected]>
374cf49a43SJulian Elischer *
384cf49a43SJulian Elischer * $Whistle: debug.c,v 1.24 1999/01/24 01:15:33 archie Exp $
394cf49a43SJulian Elischer */
404cf49a43SJulian Elischer
41fd0d00c5SMatthew Dillon #include <sys/cdefs.h>
424cf49a43SJulian Elischer #include <sys/types.h>
43baa60a3bSArchie Cobbs #include <sys/time.h>
44baa60a3bSArchie Cobbs #include <sys/ioctl.h>
45f8307e12SArchie Cobbs
464cf49a43SJulian Elischer #include <stdarg.h>
47f8307e12SArchie Cobbs
48f8307e12SArchie Cobbs #include <netinet/in.h>
49f8307e12SArchie Cobbs #include <net/ethernet.h>
50baa60a3bSArchie Cobbs #include <net/bpf.h>
51f8307e12SArchie Cobbs
524cf49a43SJulian Elischer #include <netgraph/ng_message.h>
534cf49a43SJulian Elischer #include <netgraph/ng_socket.h>
544cf49a43SJulian Elischer
554cf49a43SJulian Elischer #include "netgraph.h"
564cf49a43SJulian Elischer #include "internal.h"
574cf49a43SJulian Elischer
58f8307e12SArchie Cobbs #include <netgraph/ng_UI.h>
594cf49a43SJulian Elischer #include <netgraph/ng_async.h>
60baa60a3bSArchie Cobbs #include <netgraph/ng_bpf.h>
6141fa1ea9SRuslan Ermilov #include <netgraph/ng_bridge.h>
62*78a786f9SAlexander Motin #include <netgraph/ng_car.h>
63f8307e12SArchie Cobbs #include <netgraph/ng_cisco.h>
64*78a786f9SAlexander Motin #include <netgraph/ng_deflate.h>
6541fa1ea9SRuslan Ermilov #include <netgraph/ng_device.h>
66f8307e12SArchie Cobbs #include <netgraph/ng_echo.h>
6741fa1ea9SRuslan Ermilov #include <netgraph/ng_eiface.h>
6841fa1ea9SRuslan Ermilov #include <netgraph/ng_etf.h>
69f8307e12SArchie Cobbs #include <netgraph/ng_ether.h>
70*78a786f9SAlexander Motin #include <netgraph/ng_ether_echo.h>
714cf49a43SJulian Elischer #include <netgraph/ng_frame_relay.h>
7241fa1ea9SRuslan Ermilov #include <netgraph/ng_gif.h>
7341fa1ea9SRuslan Ermilov #include <netgraph/ng_gif_demux.h>
74f8307e12SArchie Cobbs #include <netgraph/ng_hole.h>
7541fa1ea9SRuslan Ermilov #include <netgraph/ng_hub.h>
76f8307e12SArchie Cobbs #include <netgraph/ng_iface.h>
7741fa1ea9SRuslan Ermilov #include <netgraph/ng_ip_input.h>
7841fa1ea9SRuslan Ermilov #include <netgraph/ng_ipfw.h>
79f8307e12SArchie Cobbs #include <netgraph/ng_ksocket.h>
8041fa1ea9SRuslan Ermilov #include <netgraph/ng_l2tp.h>
814cf49a43SJulian Elischer #include <netgraph/ng_lmi.h>
8241fa1ea9SRuslan Ermilov #include <netgraph/ng_mppc.h>
8341fa1ea9SRuslan Ermilov #include <netgraph/ng_nat.h>
84*78a786f9SAlexander Motin #include <netgraph/netflow/ng_netflow.h>
8541fa1ea9SRuslan Ermilov #include <netgraph/ng_one2many.h>
86*78a786f9SAlexander Motin #include <netgraph/ng_patch.h>
87*78a786f9SAlexander Motin #include <netgraph/ng_pipe.h>
88f8307e12SArchie Cobbs #include <netgraph/ng_ppp.h>
89f8307e12SArchie Cobbs #include <netgraph/ng_pppoe.h>
9041fa1ea9SRuslan Ermilov #include <netgraph/ng_pptpgre.h>
91*78a786f9SAlexander Motin #include <netgraph/ng_pred1.h>
92f8307e12SArchie Cobbs #include <netgraph/ng_rfc1490.h>
93f8307e12SArchie Cobbs #include <netgraph/ng_socket.h>
9441fa1ea9SRuslan Ermilov #include <netgraph/ng_source.h>
9541fa1ea9SRuslan Ermilov #include <netgraph/ng_split.h>
96*78a786f9SAlexander Motin #include <netgraph/ng_tag.h>
9741fa1ea9SRuslan Ermilov #include <netgraph/ng_tcpmss.h>
98f8307e12SArchie Cobbs #include <netgraph/ng_tee.h>
994cf49a43SJulian Elischer #include <netgraph/ng_tty.h>
100f8307e12SArchie Cobbs #include <netgraph/ng_vjc.h>
10141fa1ea9SRuslan Ermilov #include <netgraph/ng_vlan.h>
102f8307e12SArchie Cobbs #ifdef WHISTLE
103f8307e12SArchie Cobbs #include <machine/../isa/df_def.h>
104f8307e12SArchie Cobbs #include <machine/../isa/if_wfra.h>
105f8307e12SArchie Cobbs #include <machine/../isa/ipac.h>
106f8307e12SArchie Cobbs #include <netgraph/ng_df.h>
107f8307e12SArchie Cobbs #include <netgraph/ng_ipac.h>
108f8307e12SArchie Cobbs #include <netgraph/ng_tn.h>
109f8307e12SArchie Cobbs #endif
1104cf49a43SJulian Elischer
1114cf49a43SJulian Elischer /* Global debug level */
1124cf49a43SJulian Elischer int _gNgDebugLevel = 0;
1134cf49a43SJulian Elischer
1144cf49a43SJulian Elischer /* Debug printing functions */
1154cf49a43SJulian Elischer void (*_NgLog) (const char *fmt,...) = warn;
1164cf49a43SJulian Elischer void (*_NgLogx) (const char *fmt,...) = warnx;
1174cf49a43SJulian Elischer
1184cf49a43SJulian Elischer /* Internal functions */
1194cf49a43SJulian Elischer static const char *NgCookie(int cookie);
120f8307e12SArchie Cobbs
121f8307e12SArchie Cobbs /* Known typecookie list */
122f8307e12SArchie Cobbs struct ng_cookie {
123f8307e12SArchie Cobbs int cookie;
124f8307e12SArchie Cobbs const char *type;
125f8307e12SArchie Cobbs };
126f8307e12SArchie Cobbs
127f8307e12SArchie Cobbs #define COOKIE(c) { NGM_ ## c ## _COOKIE, #c }
128f8307e12SArchie Cobbs
129f8307e12SArchie Cobbs /* List of known cookies */
130f8307e12SArchie Cobbs static const struct ng_cookie cookies[] = {
131f8307e12SArchie Cobbs COOKIE(UI),
132f8307e12SArchie Cobbs COOKIE(ASYNC),
133e489a907SArchie Cobbs COOKIE(BPF),
13441fa1ea9SRuslan Ermilov COOKIE(BRIDGE),
135*78a786f9SAlexander Motin COOKIE(CAR),
136f8307e12SArchie Cobbs COOKIE(CISCO),
137*78a786f9SAlexander Motin COOKIE(DEFLATE),
13841fa1ea9SRuslan Ermilov COOKIE(DEVICE),
139f8307e12SArchie Cobbs COOKIE(ECHO),
14041fa1ea9SRuslan Ermilov COOKIE(EIFACE),
14141fa1ea9SRuslan Ermilov COOKIE(ETF),
142f8307e12SArchie Cobbs COOKIE(ETHER),
143*78a786f9SAlexander Motin COOKIE(ETHER_ECHO),
144f8307e12SArchie Cobbs COOKIE(FRAMERELAY),
14541fa1ea9SRuslan Ermilov COOKIE(GIF),
14641fa1ea9SRuslan Ermilov COOKIE(GIF_DEMUX),
147f8307e12SArchie Cobbs COOKIE(GENERIC),
148f8307e12SArchie Cobbs COOKIE(HOLE),
14941fa1ea9SRuslan Ermilov COOKIE(HUB),
150f8307e12SArchie Cobbs COOKIE(IFACE),
15141fa1ea9SRuslan Ermilov COOKIE(IP_INPUT),
15241fa1ea9SRuslan Ermilov COOKIE(IPFW),
153f8307e12SArchie Cobbs COOKIE(KSOCKET),
15441fa1ea9SRuslan Ermilov COOKIE(L2TP),
155f8307e12SArchie Cobbs COOKIE(LMI),
15641fa1ea9SRuslan Ermilov COOKIE(MPPC),
15741fa1ea9SRuslan Ermilov COOKIE(NAT),
158*78a786f9SAlexander Motin COOKIE(NETFLOW),
15941fa1ea9SRuslan Ermilov COOKIE(ONE2MANY),
160*78a786f9SAlexander Motin COOKIE(PATCH),
161*78a786f9SAlexander Motin COOKIE(PIPE),
162f8307e12SArchie Cobbs COOKIE(PPP),
163f8307e12SArchie Cobbs COOKIE(PPPOE),
16441fa1ea9SRuslan Ermilov COOKIE(PPTPGRE),
165*78a786f9SAlexander Motin COOKIE(PRED1),
166f8307e12SArchie Cobbs COOKIE(RFC1490),
167f8307e12SArchie Cobbs COOKIE(SOCKET),
16841fa1ea9SRuslan Ermilov COOKIE(SOURCE),
16941fa1ea9SRuslan Ermilov COOKIE(SPLIT),
170*78a786f9SAlexander Motin COOKIE(TAG),
17141fa1ea9SRuslan Ermilov COOKIE(TCPMSS),
172f8307e12SArchie Cobbs COOKIE(TEE),
173f8307e12SArchie Cobbs COOKIE(TTY),
174f8307e12SArchie Cobbs COOKIE(VJC),
17541fa1ea9SRuslan Ermilov COOKIE(VLAN),
176f8307e12SArchie Cobbs #ifdef WHISTLE
177f8307e12SArchie Cobbs COOKIE(DF),
178f8307e12SArchie Cobbs COOKIE(IPAC),
179f8307e12SArchie Cobbs COOKIE(TN),
180f8307e12SArchie Cobbs COOKIE(WFRA),
181f8307e12SArchie Cobbs #endif
182f8307e12SArchie Cobbs { 0, NULL }
183f8307e12SArchie Cobbs };
1844cf49a43SJulian Elischer
1854cf49a43SJulian Elischer /*
1864cf49a43SJulian Elischer * Set debug level, ie, verbosity, if "level" is non-negative.
1874cf49a43SJulian Elischer * Returns old debug level.
1884cf49a43SJulian Elischer */
1894cf49a43SJulian Elischer int
NgSetDebug(int level)1904cf49a43SJulian Elischer NgSetDebug(int level)
1914cf49a43SJulian Elischer {
1924cf49a43SJulian Elischer int old = _gNgDebugLevel;
1934cf49a43SJulian Elischer
194*78a786f9SAlexander Motin if (level >= 0)
1954cf49a43SJulian Elischer _gNgDebugLevel = level;
1964cf49a43SJulian Elischer return (old);
1974cf49a43SJulian Elischer }
1984cf49a43SJulian Elischer
1994cf49a43SJulian Elischer /*
2004cf49a43SJulian Elischer * Set debug logging functions.
2014cf49a43SJulian Elischer */
2024cf49a43SJulian Elischer void
NgSetErrLog(void (* log)(const char * fmt,...),void (* logx)(const char * fmt,...))2034cf49a43SJulian Elischer NgSetErrLog(void (*log) (const char *fmt,...),
2044cf49a43SJulian Elischer void (*logx) (const char *fmt,...))
2054cf49a43SJulian Elischer {
2064cf49a43SJulian Elischer _NgLog = log;
2074cf49a43SJulian Elischer _NgLogx = logx;
2084cf49a43SJulian Elischer }
2094cf49a43SJulian Elischer
2104cf49a43SJulian Elischer /*
2114cf49a43SJulian Elischer * Display a netgraph sockaddr
2124cf49a43SJulian Elischer */
2134cf49a43SJulian Elischer void
_NgDebugSockaddr(const struct sockaddr_ng * sg)214f8307e12SArchie Cobbs _NgDebugSockaddr(const struct sockaddr_ng *sg)
2154cf49a43SJulian Elischer {
2164cf49a43SJulian Elischer NGLOGX("SOCKADDR: { fam=%d len=%d addr=\"%s\" }",
2174cf49a43SJulian Elischer sg->sg_family, sg->sg_len, sg->sg_data);
2184cf49a43SJulian Elischer }
2194cf49a43SJulian Elischer
2201816e452SArchie Cobbs #define ARGS_BUFSIZE 2048
2211816e452SArchie Cobbs #define RECURSIVE_DEBUG_ADJUST 4
222f8307e12SArchie Cobbs
2234cf49a43SJulian Elischer /*
2244cf49a43SJulian Elischer * Display a negraph message
2254cf49a43SJulian Elischer */
2264cf49a43SJulian Elischer void
_NgDebugMsg(const struct ng_mesg * msg,const char * path)227f8307e12SArchie Cobbs _NgDebugMsg(const struct ng_mesg *msg, const char *path)
2284cf49a43SJulian Elischer {
229f8307e12SArchie Cobbs u_char buf[2 * sizeof(struct ng_mesg) + ARGS_BUFSIZE];
230f8307e12SArchie Cobbs struct ng_mesg *const req = (struct ng_mesg *)buf;
231f8307e12SArchie Cobbs struct ng_mesg *const bin = (struct ng_mesg *)req->data;
2321816e452SArchie Cobbs int arglen, csock = -1;
233f8307e12SArchie Cobbs
234f8307e12SArchie Cobbs /* Display header stuff */
2354cf49a43SJulian Elischer NGLOGX("NG_MESG :");
2364cf49a43SJulian Elischer NGLOGX(" vers %d", msg->header.version);
237*78a786f9SAlexander Motin NGLOGX(" arglen %u", msg->header.arglen);
238*78a786f9SAlexander Motin NGLOGX(" flags %x", msg->header.flags);
239*78a786f9SAlexander Motin NGLOGX(" token %u", msg->header.token);
240*78a786f9SAlexander Motin NGLOGX(" cookie %s (%u)",
241f8307e12SArchie Cobbs NgCookie(msg->header.typecookie), msg->header.typecookie);
242f8307e12SArchie Cobbs
243f8307e12SArchie Cobbs /* At lower debugging levels, skip ASCII translation */
244f8307e12SArchie Cobbs if (_gNgDebugLevel <= 2)
245f8307e12SArchie Cobbs goto fail2;
246f8307e12SArchie Cobbs
247f8307e12SArchie Cobbs /* If path is not absolute, don't bother trying to use relative
248f8307e12SArchie Cobbs address on a different socket for the ASCII translation */
249f8307e12SArchie Cobbs if (strchr(path, ':') == NULL)
250f8307e12SArchie Cobbs goto fail2;
251f8307e12SArchie Cobbs
252f8307e12SArchie Cobbs /* Get a temporary socket */
253f8307e12SArchie Cobbs if (NgMkSockNode(NULL, &csock, NULL) < 0)
254f8307e12SArchie Cobbs goto fail;
255f8307e12SArchie Cobbs
256f8307e12SArchie Cobbs /* Copy binary message into request message payload */
257f8307e12SArchie Cobbs arglen = msg->header.arglen;
258f8307e12SArchie Cobbs if (arglen > ARGS_BUFSIZE)
259f8307e12SArchie Cobbs arglen = ARGS_BUFSIZE;
260f8307e12SArchie Cobbs memcpy(bin, msg, sizeof(*msg) + arglen);
261f8307e12SArchie Cobbs bin->header.arglen = arglen;
262f8307e12SArchie Cobbs
2631816e452SArchie Cobbs /* Lower debugging to avoid infinite recursion */
2641816e452SArchie Cobbs _gNgDebugLevel -= RECURSIVE_DEBUG_ADJUST;
2651816e452SArchie Cobbs
266f8307e12SArchie Cobbs /* Ask the node to translate the binary message to ASCII for us */
267f8307e12SArchie Cobbs if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
2681816e452SArchie Cobbs NGM_BINARY2ASCII, bin, sizeof(*bin) + bin->header.arglen) < 0) {
2691816e452SArchie Cobbs _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
270f8307e12SArchie Cobbs goto fail;
2711816e452SArchie Cobbs }
2721816e452SArchie Cobbs if (NgRecvMsg(csock, req, sizeof(buf), NULL) < 0) {
2731816e452SArchie Cobbs _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
274f8307e12SArchie Cobbs goto fail;
2751816e452SArchie Cobbs }
2761816e452SArchie Cobbs
2771816e452SArchie Cobbs /* Restore debugging level */
2781816e452SArchie Cobbs _gNgDebugLevel += RECURSIVE_DEBUG_ADJUST;
279f8307e12SArchie Cobbs
280f8307e12SArchie Cobbs /* Display command string and arguments */
281f8307e12SArchie Cobbs NGLOGX(" cmd %s (%d)", bin->header.cmdstr, bin->header.cmd);
282f8307e12SArchie Cobbs NGLOGX(" args %s", bin->data);
283f8307e12SArchie Cobbs goto done;
284f8307e12SArchie Cobbs
285f8307e12SArchie Cobbs fail:
286f8307e12SArchie Cobbs /* Just display binary version */
287f8307e12SArchie Cobbs NGLOGX(" [error decoding message: %s]", strerror(errno));
288f8307e12SArchie Cobbs fail2:
289f8307e12SArchie Cobbs NGLOGX(" cmd %d", msg->header.cmd);
290f8307e12SArchie Cobbs NGLOGX(" args (%d bytes)", msg->header.arglen);
291b9236794SMaxime Henrion _NgDebugBytes((u_char *)msg->data, msg->header.arglen);
292f8307e12SArchie Cobbs
293f8307e12SArchie Cobbs done:
294f8307e12SArchie Cobbs if (csock != -1)
295f8307e12SArchie Cobbs (void)close(csock);
2964cf49a43SJulian Elischer }
2974cf49a43SJulian Elischer
2984cf49a43SJulian Elischer /*
2994cf49a43SJulian Elischer * Return the name of the node type corresponding to the cookie
3004cf49a43SJulian Elischer */
3014cf49a43SJulian Elischer static const char *
NgCookie(int cookie)3024cf49a43SJulian Elischer NgCookie(int cookie)
3034cf49a43SJulian Elischer {
304f8307e12SArchie Cobbs int k;
3054cf49a43SJulian Elischer
306f8307e12SArchie Cobbs for (k = 0; cookies[k].cookie != 0; k++) {
307f8307e12SArchie Cobbs if (cookies[k].cookie == cookie)
308f8307e12SArchie Cobbs return cookies[k].type;
3094cf49a43SJulian Elischer }
310f8307e12SArchie Cobbs return "??";
3114cf49a43SJulian Elischer }
3124cf49a43SJulian Elischer
3134cf49a43SJulian Elischer /*
3144cf49a43SJulian Elischer * Dump bytes in hex
3154cf49a43SJulian Elischer */
3164cf49a43SJulian Elischer void
_NgDebugBytes(const u_char * ptr,int len)3174cf49a43SJulian Elischer _NgDebugBytes(const u_char *ptr, int len)
3184cf49a43SJulian Elischer {
3194cf49a43SJulian Elischer char buf[100];
3204cf49a43SJulian Elischer int k, count;
3214cf49a43SJulian Elischer
3224cf49a43SJulian Elischer #define BYPERLINE 16
3234cf49a43SJulian Elischer
3244cf49a43SJulian Elischer for (count = 0; count < len; ptr += BYPERLINE, count += BYPERLINE) {
3254cf49a43SJulian Elischer
3264cf49a43SJulian Elischer /* Do hex */
3274cf49a43SJulian Elischer snprintf(buf, sizeof(buf), "%04x: ", count);
3284cf49a43SJulian Elischer for (k = 0; k < BYPERLINE; k++, count++)
3294cf49a43SJulian Elischer if (count < len)
3304cf49a43SJulian Elischer snprintf(buf + strlen(buf),
3314cf49a43SJulian Elischer sizeof(buf) - strlen(buf), "%02x ", ptr[k]);
3324cf49a43SJulian Elischer else
3334cf49a43SJulian Elischer snprintf(buf + strlen(buf),
3344cf49a43SJulian Elischer sizeof(buf) - strlen(buf), " ");
3354cf49a43SJulian Elischer snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " ");
3364cf49a43SJulian Elischer count -= BYPERLINE;
3374cf49a43SJulian Elischer
3384cf49a43SJulian Elischer /* Do ASCII */
3394cf49a43SJulian Elischer for (k = 0; k < BYPERLINE; k++, count++)
3404cf49a43SJulian Elischer if (count < len)
3414cf49a43SJulian Elischer snprintf(buf + strlen(buf),
3424cf49a43SJulian Elischer sizeof(buf) - strlen(buf),
3434cf49a43SJulian Elischer "%c", isprint(ptr[k]) ? ptr[k] : '.');
3444cf49a43SJulian Elischer else
3454cf49a43SJulian Elischer snprintf(buf + strlen(buf),
3464cf49a43SJulian Elischer sizeof(buf) - strlen(buf), " ");
3474cf49a43SJulian Elischer count -= BYPERLINE;
3484cf49a43SJulian Elischer
3494cf49a43SJulian Elischer /* Print it */
3504cf49a43SJulian Elischer NGLOGX("%s", buf);
3514cf49a43SJulian Elischer }
3524cf49a43SJulian Elischer }
3534cf49a43SJulian Elischer
354