* Copyright (c) 1989 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)utility.c 5.8 (Berkeley) 3/22/91";
* utility functions performing io related tasks
* A small subroutine to flush the network output buffer, get some data
* from the network, and pass it through the telnet state machine. We
* also flush the pty input buffer (by dropping its data) if it becomes
DIAG(TD_REPORT
, {sprintf(nfrontp
, "td: ttloop\r\n");
nfrontp
+= strlen(nfrontp
);});
ncc
= read(net
, netibuf
, sizeof netibuf
);
syslog(LOG_INFO
, "ttloop: read: %m\n");
syslog(LOG_INFO
, "ttloop: peer died: %m\n");
DIAG(TD_REPORT
, {sprintf(nfrontp
, "td: ttloop read %d chars\r\n", ncc
);
nfrontp
+= strlen(nfrontp
);});
telrcv(); /* state machine */
pfrontp
= pbackp
= ptyobuf
;
* Check a descriptor to see if out of band data exists on it.
int s
; /* socket number */
static struct timeval timeout
= { 0 };
value
= select(s
+1, (fd_set
*)0, (fd_set
*)0, &excepts
, &timeout
);
} while ((value
== -1) && (errno
== EINTR
));
fatalperror(pty
, "select");
if (FD_ISSET(s
, &excepts
)) {
if ((n
= pfrontp
- pbackp
) > 0) {
DIAG((TD_REPORT
| TD_PTYDATA
),
{ sprintf(nfrontp
, "td: ptyflush %d chars\r\n", n
);
nfrontp
+= strlen(nfrontp
); });
DIAG(TD_PTYDATA
, printdata("pd", pbackp
, n
));
n
= write(pty
, pbackp
, n
);
if (errno
== EWOULDBLOCK
|| errno
== EINTR
)
pbackp
= pfrontp
= ptyobuf
;
* Return the address of the next "item" in the TELNET data
* stream. This will be the address of the next character if
* the current address is a user data character, or it will
* be the address of the character following the TELNET command
* if the current address is a TELNET IAC ("I Am a Command")
if ((*current
&0xff) != IAC
) {
switch (*(current
+1)&0xff) {
case SB
: /* loop forever looking for the SE */
register char *look
= current
+2;
if ((*look
++&0xff) == IAC
) {
if ((*look
++&0xff) == SE
) {
* We are about to do a TELNET SYNCH operation. Clear
* the path to the network.
* Things are a bit tricky since we may have sent the first
* byte or so of a previous TELNET command into the network.
* So, we have to scan the network buffer from the beginning
* until we are up to where we want to be.
* A side effect of what we do, just to keep things
* simple, is to clear the urgent data pointer. The principal
* caller should be setting the urgent data pointer AFTER calling
register char *thisitem
, *next
;
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
thisitem
= nclearto
> netobuf
? nclearto
: netobuf
;
while ((next
= nextitem(thisitem
)) <= nbackp
) {
/* Now, thisitem is first before/at boundary. */
good
= nclearto
> netobuf
? nclearto
: netobuf
;
good
= netobuf
; /* where the good bytes go */
while (nfrontp
> thisitem
) {
} while (wewant(next
) && (nfrontp
> next
));
bcopy(thisitem
, good
, length
);
thisitem
= nextitem(thisitem
);
nfrontp
= good
; /* next byte to be sent */
* Send as much data as possible to the network,
* handling requests for urgent data.
if ((n
= nfrontp
- nbackp
) > 0) {
{ sprintf(nfrontp
, "td: netflush %d chars\r\n", n
);
n
+= strlen(nfrontp
); /* get count first */
nfrontp
+= strlen(nfrontp
); /* then move pointer */
char *s
= nclearto
? nclearto
: nbackp
;
(*encrypt_output
)((unsigned char *)s
, nfrontp
-s
);
* if no urgent data, or if the other side appears to be an
* old 4.2 client (and thus unable to survive TCP urgent data),
* write the entire buffer in non-OOB mode.
if ((neturg
== 0) || (not42
== 0)) {
n
= write(net
, nbackp
, n
); /* normal write */
* In 4.2 (and 4.3) systems, there is some question about
* what byte in a sendOOB operation is the "OOB" data.
* To make ourselves compatible, we only send ONE byte
* out of band, the one WE THINK should be OOB (though
* we really have more the TCP philosophy of urgent data
* rather than the Unix philosophy of OOB data).
n
= send(net
, nbackp
, n
-1, 0); /* send URGENT all by itself */
n
= send(net
, nbackp
, n
, MSG_OOB
); /* URGENT data */
if (errno
== EWOULDBLOCK
|| errno
== EINTR
)
nbackp
= nfrontp
= netobuf
;
* Just a handy little function to write a bit of raw data to the net.
* It will force a transmit of the buffer if necessary
* ptr - A pointer to a character string to write
* len - How many bytes to write
register unsigned char *ptr
;
/* flush buffer if no room for new data) */
if ((&netobuf
[BUFSIZ
] - nfrontp
) < len
) {
/* if this fails, don't worry, buffer is a little big */
bcopy(ptr
, nfrontp
, len
);
* miscellaneous functions doing a variety of little jobs follow ...
(void) sprintf(buf
, "telnetd: %s.\r\n", msg
);
* Better turn off encryption first....
(void) write(f
, buf
, (int)strlen(buf
));
char buf
[BUFSIZ
], *strerror();
(void) sprintf(buf
, "%s: %s\r\n", msg
, strerror(errno
));
register char *res
= editedhost
;
if (res
== &editedhost
[sizeof editedhost
- 1]) {
(void) strncpy(res
, host
,
sizeof editedhost
- (res
- editedhost
) -1);
editedhost
[sizeof editedhost
- 1] = '\0';
static char *putlocation
;
* This is split on two lines so that SCCS will not see the M
* between two % signs and expand it...
static char fmtstr
[] = { "%l:%M\
slash
= rindex(line
, '/');
(void)strftime(db
, sizeof(db
), fmtstr
, localtime(&t
));
* Print telnet options and commands in plain text, if possible.
sprintf(nfrontp
, "%s %s\r\n", fmt
, TELOPT(option
));
else if (TELCMD_OK(option
))
sprintf(nfrontp
, "%s %s\r\n", fmt
, TELCMD(option
));
sprintf(nfrontp
, "%s %d\r\n", fmt
, option
);
nfrontp
+= strlen(nfrontp
);
printsub(direction
, pointer
, length
)
char direction
; /* '<' or '>' */
unsigned char *pointer
; /* where suboption data sits */
int length
; /* length of suboption data */
if (!(diagnostic
& TD_OPTIONS
))
sprintf(nfrontp
, "td: %s suboption ",
direction
== '<' ? "recv" : "send");
nfrontp
+= strlen(nfrontp
);
if (i
!= IAC
|| j
!= SE
) {
sprintf(nfrontp
, "(terminated by ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%s ", TELOPT(i
));
sprintf(nfrontp
, "%s ", TELCMD(i
));
sprintf(nfrontp
, "%d ", i
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%s", TELOPT(j
));
sprintf(nfrontp
, "%s", TELCMD(j
));
sprintf(nfrontp
, "%d", j
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, ", not IAC SE!) ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "(Empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "TERMINAL-TYPE ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "IS \"%.*s\"", length
-2, (char *)pointer
+2);
sprintf(nfrontp
, "SEND");
"- unknown qualifier %d (0x%x).",
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "TERMINAL-SPEED");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " IS %.*s", length
-2, (char *)pointer
+2);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " SEND");
sprintf(nfrontp
, " %d (unknown)", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "TOGGLE-FLOW-CONTROL");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " OFF"); break;
sprintf(nfrontp
, " ON"); break;
sprintf(nfrontp
, " %d (unknown)", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "NAWS");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " ?%d?", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %d %d (%d)",
(int)((((unsigned int)pointer
[1])<<8)|((unsigned int)pointer
[2])));
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " ?%d?", pointer
[3]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %d %d (%d)",
(int)((((unsigned int)pointer
[3])<<8)|((unsigned int)pointer
[4])));
nfrontp
+= strlen(nfrontp
);
for (i
= 5; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "LINEMODE ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "WILL ");
sprintf(nfrontp
, "WONT ");
sprintf(nfrontp
, "DONT ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "(no option???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "Forward Mask");
nfrontp
+= strlen(nfrontp
);
for (i
= 3; i
< length
; i
++) {
sprintf(nfrontp
, " %x", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%d (unknown)", pointer
[2]);
nfrontp
+= strlen(nfrontp
);
for (i
= 3; i
< length
; i
++) {
sprintf(nfrontp
, " %d", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
- 2; i
+= 3) {
if (SLC_NAME_OK(pointer
[i
+SLC_FUNC
]))
sprintf(nfrontp
, " %s", SLC_NAME(pointer
[i
+SLC_FUNC
]));
sprintf(nfrontp
, " %d", pointer
[i
+SLC_FUNC
]);
nfrontp
+= strlen(nfrontp
);
switch (pointer
[i
+SLC_FLAGS
]&SLC_LEVELBITS
) {
sprintf(nfrontp
, " NOSUPPORT"); break;
sprintf(nfrontp
, " CANTCHANGE"); break;
sprintf(nfrontp
, " VARIABLE"); break;
sprintf(nfrontp
, " DEFAULT"); break;
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%s%s%s",
pointer
[i
+SLC_FLAGS
]&SLC_ACK
? "|ACK" : "",
pointer
[i
+SLC_FLAGS
]&SLC_FLUSHIN
? "|FLUSHIN" : "",
pointer
[i
+SLC_FLAGS
]&SLC_FLUSHOUT
? "|FLUSHOUT" : "");
nfrontp
+= strlen(nfrontp
);
if (pointer
[i
+SLC_FLAGS
]& ~(SLC_ACK
|SLC_FLUSHIN
|
SLC_FLUSHOUT
| SLC_LEVELBITS
)) {
sprintf(nfrontp
, "(0x%x)", pointer
[i
+SLC_FLAGS
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %d;", pointer
[i
+SLC_VALUE
]);
nfrontp
+= strlen(nfrontp
);
if ((pointer
[i
+SLC_VALUE
] == IAC
) &&
(pointer
[i
+SLC_VALUE
+1] == IAC
))
for (; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "MODE ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "(no mode???)");
nfrontp
+= strlen(nfrontp
);
sprintf(tbuf
, "%s%s%s%s%s",
pointer
[2]&MODE_EDIT
? "|EDIT" : "",
pointer
[2]&MODE_TRAPSIG
? "|TRAPSIG" : "",
pointer
[2]&MODE_SOFT_TAB
? "|SOFT_TAB" : "",
pointer
[2]&MODE_LIT_ECHO
? "|LIT_ECHO" : "",
pointer
[2]&MODE_ACK
? "|ACK" : "");
sprintf(nfrontp
, "%s", tbuf
[1] ? &tbuf
[1] : "0");
nfrontp
+= strlen(nfrontp
);
if (pointer
[2]&~(MODE_EDIT
|MODE_TRAPSIG
|MODE_ACK
)) {
sprintf(nfrontp
, " (0x%x)", pointer
[2]);
nfrontp
+= strlen(nfrontp
);
for (i
= 3; i
< length
; i
++) {
sprintf(nfrontp
, " ?0x%x?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%d (unknown)", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " %d", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "STATUS");
nfrontp
+= strlen(nfrontp
);
if (pointer
[1] == TELQUAL_SEND
)
sprintf(nfrontp
, " SEND");
sprintf(nfrontp
, " %d (unknown)", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " IS\r\n");
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
case DO
: cp
= "DO"; goto common2
;
case DONT
: cp
= "DONT"; goto common2
;
case WILL
: cp
= "WILL"; goto common2
;
case WONT
: cp
= "WONT"; goto common2
;
if (TELOPT_OK((int)pointer
[i
]))
sprintf(nfrontp
, " %s %s", cp
, TELOPT(pointer
[i
]));
sprintf(nfrontp
, " %s %d", cp
, pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "\r\n");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " SB ");
nfrontp
+= strlen(nfrontp
);
pointer
[k
++] = pointer
[j
++];
printsub(0, &pointer
[i
], k
- i
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "\r\n");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %d", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "X-DISPLAY-LOCATION ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "IS \"%.*s\"", length
-2, (char *)pointer
+2);
sprintf(nfrontp
, "SEND");
sprintf(nfrontp
, "- unknown qualifier %d (0x%x).",
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "ENVIRON ");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "SEND ");
sprintf(nfrontp
, "INFO ");
nfrontp
+= strlen(nfrontp
);
register int noquote
= 2;
for (i
= 2; i
< length
; i
++ ) {
if (pointer
[1] == TELQUAL_SEND
)
sprintf(nfrontp
, "\" VAR " + noquote
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "\" VALUE " + noquote
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "\" ESC " + noquote
);
nfrontp
+= strlen(nfrontp
);
if (isprint(pointer
[i
]) && pointer
[i
] != '"') {
sprintf(nfrontp
, "\" %03o " + noquote
,
nfrontp
+= strlen(nfrontp
);
#if defined(AUTHENTICATE)
case TELOPT_AUTHENTICATION
:
sprintf(nfrontp
, "AUTHENTICATION");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %s ", (pointer
[1] == TELQUAL_IS
) ?
nfrontp
+= strlen(nfrontp
);
if (AUTHTYPE_NAME_OK(pointer
[2]))
sprintf(nfrontp
, "%s ", AUTHTYPE_NAME(pointer
[2]));
sprintf(nfrontp
, "%d ", pointer
[2]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "(partial suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%s|%s",
((pointer
[3] & AUTH_WHO_MASK
) == AUTH_WHO_CLIENT
) ?
((pointer
[3] & AUTH_HOW_MASK
) == AUTH_HOW_MUTUAL
) ?
nfrontp
+= strlen(nfrontp
);
auth_printsub(&pointer
[1], length
- 1, buf
, sizeof(buf
));
sprintf(nfrontp
, "%s", buf
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " SEND ");
nfrontp
+= strlen(nfrontp
);
if (AUTHTYPE_NAME_OK(pointer
[i
]))
sprintf(nfrontp
, "%s ", AUTHTYPE_NAME(pointer
[i
]));
sprintf(nfrontp
, "%d ", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "(partial suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "%s|%s ",
((pointer
[i
] & AUTH_WHO_MASK
) == AUTH_WHO_CLIENT
) ?
((pointer
[i
] & AUTH_HOW_MASK
) == AUTH_HOW_MUTUAL
) ?
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " NAME \"");
nfrontp
+= strlen(nfrontp
);
*nfrontp
+= pointer
[i
++];
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " ?%d?", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "ENCRYPT");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (empty suboption???)");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " START");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " END");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " REQUEST-START");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " REQUEST-END");
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %s ", (pointer
[1] == ENCRYPT_IS
) ?
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " (partial suboption???)");
nfrontp
+= strlen(nfrontp
);
if (ENCTYPE_NAME_OK(pointer
[2]))
sprintf(nfrontp
, "%s ", ENCTYPE_NAME(pointer
[2]));
sprintf(nfrontp
, " %d (unknown)", pointer
[2]);
nfrontp
+= strlen(nfrontp
);
encrypt_printsub(&pointer
[1], length
- 1, buf
, sizeof(buf
));
sprintf(nfrontp
, "%s", buf
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " SUPPORT ");
nfrontp
+= strlen(nfrontp
);
if (ENCTYPE_NAME_OK(pointer
[i
]))
sprintf(nfrontp
, "%s ", ENCTYPE_NAME(pointer
[i
]));
sprintf(nfrontp
, "%d ", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " ENC_KEYID", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " DEC_KEYID", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %d (unknown)", pointer
[1]);
nfrontp
+= strlen(nfrontp
);
for (i
= 2; i
< length
; i
++) {
sprintf(nfrontp
, " %d", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
if (TELOPT_OK(pointer
[0]))
sprintf(nfrontp
, "%s (unknown)", TELOPT(pointer
[0]));
sprintf(nfrontp
, "%d (unknown)", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
for (i
= 1; i
< length
; i
++) {
sprintf(nfrontp
, " %d", pointer
[i
]);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, "\r\n");
nfrontp
+= strlen(nfrontp
);
* Dump a data buffer in hex and ascii to the output data stream.
/* flush net output buffer if no room for new data) */
if ((&netobuf
[BUFSIZ
] - nfrontp
) < 80) {
/* add a line of output */
sprintf(nfrontp
, "%s: ", tag
);
nfrontp
+= strlen(nfrontp
);
for (i
= 0; i
< 20 && cnt
; i
++) {
sprintf(nfrontp
, "%02x", *ptr
);
nfrontp
+= strlen(nfrontp
);
sprintf(nfrontp
, " %s\r\n", xbuf
);
nfrontp
+= strlen(nfrontp
);