[netfilter-cvslog] r3388 - in trunk/nfsim: core/ipv4 tools
rusty at netfilter.org
rusty at netfilter.org
Wed Dec 15 05:52:11 CET 2004
Author: rusty at netfilter.org
Date: 2004-12-15 05:52:10 +0100 (Wed, 15 Dec 2004)
New Revision: 3388
Modified:
trunk/nfsim/core/ipv4/ipv4.c
trunk/nfsim/tools/gen_ip.c
Log:
TTL= support in gen_ip.
Report non-255 TTL in describe_packet().
Modified: trunk/nfsim/core/ipv4/ipv4.c
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.c 2004-12-15 04:47:01 UTC (rev 3387)
+++ trunk/nfsim/core/ipv4/ipv4.c 2004-12-15 04:52:10 UTC (rev 3388)
@@ -710,6 +710,8 @@
ptr += sprintf(ptr, "DF ");
if (ntohs(iph->frag_off) & IP_MF)
ptr += sprintf(ptr, "MF ");
+ if (iph->ttl != 255)
+ ptr += sprintf(ptr, "TTL=%i ", iph->ttl);
ptr += sprintf(ptr, "%u.%u.%u.%u %u.%u.%u.%u ",
NIPQUAD(iph->saddr),
Modified: trunk/nfsim/tools/gen_ip.c
===================================================================
--- trunk/nfsim/tools/gen_ip.c 2004-12-15 04:47:01 UTC (rev 3387)
+++ trunk/nfsim/tools/gen_ip.c 2004-12-15 04:52:10 UTC (rev 3388)
@@ -135,7 +135,7 @@
static int parse_header(struct packet *packet,
const char *srcip, const char *dstip,
const char *lenstr, const char *protocol,
- int tos)
+ int tos, int ttl)
{
int proto, len;
u_int32_t saddr, daddr;
@@ -172,7 +172,7 @@
4, 5,
#endif
tos, 0,
- 0, 0, 255, proto, 0,
+ 0, 0, ttl, proto, 0,
saddr, daddr });
return len;
}
@@ -531,6 +531,7 @@
<arg choice="opt">MF</arg>
<arg choice="opt">MAC=<replaceable>ethaddr</replaceable></arg>
<arg choice="opt">TOS=<replaceable>diffserv field</replaceable></arg>
+ <arg choice="opt">TTL=<replaceable>ttl</replaceable></arg>
<arg choice="req">src</arg>
<arg choice="req">dest</arg>
<arg choice="req">datalen</arg>
@@ -601,7 +602,7 @@
bool parse_packet(struct packet *packet, int argc, char *argv[],
bool *dump_data)
{
- int tos = 0, mf = 0, df = 0, len, datalen;
+ int tos = 0, mf = 0, df = 0, ttl = 255, len, datalen;
u_int16_t fragoff = 0, fraglen = 0;
if (argc < 5) {
@@ -663,9 +664,21 @@
argv++;
}
+ if (argc > 5 && strncmp(argv[1], "TTL=", 4) == 0) {
+ ttl = atoi(argv[1]+4);
+
+ if (ttl == 0 || ttl > 255) {
+ nfsim_log(LOG_UI, "`%s' not >= 0, <= 255",
+ argv[1]+4);
+ return false;
+ }
+ argc--;
+ argv++;
+ }
+
memset(&packet->u, 0, sizeof(packet->u));
datalen = parse_header(packet, argv[1], argv[2], argv[3], argv[4],
- tos);
+ tos, ttl);
if (datalen < 0)
return false;
More information about the netfilter-cvslog
mailing list