[netfilter-cvslog] r3742 - trunk/nfsim/core/ipv4
rusty at netfilter.org
rusty at netfilter.org
Wed Feb 23 17:43:30 CET 2005
Author: rusty at netfilter.org
Date: 2005-02-23 17:43:29 +0100 (Wed, 23 Feb 2005)
New Revision: 3742
Modified:
trunk/nfsim/core/ipv4/ipv4.c
Log:
>From Max Kellermann:
escape all non-printable and 8 bit characters in print_data(). This is
required to write nfsim scripts in 7bit US-ASCII.
Modified: trunk/nfsim/core/ipv4/ipv4.c
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.c 2005-02-22 11:37:27 UTC (rev 3741)
+++ trunk/nfsim/core/ipv4/ipv4.c 2005-02-23 16:43:29 UTC (rev 3742)
@@ -740,6 +740,7 @@
static char *print_data(char *ptr, const char *data, int len)
{
+ static const char hexbuf[]= "0123456789abcdef";
int i;
ptr += sprintf(ptr, "DATA ");
@@ -759,6 +760,11 @@
} else if (data[i] == '\\') {
*ptr++ = '\\';
*ptr++ = '\\';
+ } else if (data[i] & 0x80 || (data[i] & 0xe0) == 0) {
+ *ptr++ = '\\';
+ *ptr++ = 'x';
+ *ptr++ = hexbuf[(data[i] >> 4) & 0xf];
+ *ptr++ = hexbuf[data[i] & 0xf];
} else
*ptr++ = data[i];
}
More information about the netfilter-cvslog
mailing list