Hi,
I have had the need to make the display of the `lpd' protocol
somewhat better. The lpd protocol is context sensitive and has multiple
meanings for the command codes in the command packets.... I have made
this clear in the info column.
Furthermore, it was usefull for the `follow-tcp-stream' display to show
control characters as well.
Attached is a patch that implements the above additions.
-- Regards,
----------------------------------------------------------------------
Matthijs Melchior +31 35 687 2962 Lucent Technologies
mmelchior@xxxxxxxxxx http://www.lucent.com/ Hilversum, Netherlands
----------------------------------------------------------------------
--- packet-lpd.c-ORG Sat Jan 22 07:22:14 2000
+++ packet-lpd.c Tue Apr 18 14:39:01 2000
@@ -59,9 +59,9 @@
RFC 1179. http://www.astart.com/lprng/LPRng-HOWTO.html */
char *lpd_client_code[] = {
"Unknown command",
- "LPC: start print",
- "LPR: transfer a printer job",
- "LPQ: print short form of queue status",
+ "LPC: start print / jobcmd: abort",
+ "LPR: transfer a printer job / jobcmd: receive control file",
+ "LPQ: print short form of queue status / jobcmd: receive data file",
"LPQ: print long form of queue status",
"LPRM: remove jobs",
"LPRng lpc: do control operation",
@@ -77,7 +77,8 @@
};
- if (pd[offset+1] == '\n') {
+ /* rfc1179 states that all responses are 1 byte long */
+ if (END_OF_FRAME == 1) {
lpr_packet_type = response;
}
else if (pd[offset] <= 9) {
@@ -132,7 +133,7 @@
int response = pd[offset];
if (response <= 3) {
- proto_tree_add_text(lpd_tree, offset, 2, "Response: %s",
+ proto_tree_add_text(lpd_tree, offset, 1, "Response: %s",
lpd_server_code[response]);
}
else {
--- gtk/main.c-ORG Wed Apr 5 04:17:53 2000
+++ gtk/main.c Thu Apr 20 11:19:53 2000
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -428,7 +429,24 @@
/* If our native arch is EBCDIC, call:
* ASCII_TO_EBCDIC(buffer, nchars);
*/
- (*print_line)( buffer, nchars, is_server, arg );
+ { /* we assume ascii for the following code */
+ /* A better solution would be to convert to unicode,
+ byte 0x00 .. 0x20 -> U+2400 .. U+2420, 0x7F -> U+2421,
+ byte 0x80 .. 0xA0 -> U+2400 .. U+2420 with overstrike
+ and use a font with these glyphs present - XXX */
+
+ unsigned char buf2[FLT_BUF_SIZE*2];
+ unsigned char c, *p = buffer, *q = buf2;
+ while (nchars--) { /* make control characters visible */
+ c = *p++;
+ if ((iscntrl(c) || iscntrl(c&0x7f)) && (c != '\n')) {
+ *q++ = '^';
+ c ^= 0x40;
+ }
+ *q++ = c;
+ }
+ (*print_line)( buf2, q - buf2, is_server, arg );
+ }
break;
case E_FOLLOW_HEXDUMP_TYPE:
current_pos = 0;