[netfilter-cvslog] r3435 - in trunk/nfsim: core/ipv4 tools
rusty at netfilter.org
rusty at netfilter.org
Fri Dec 17 11:32:22 CET 2004
Author: rusty at netfilter.org
Date: 2004-12-17 11:32:22 +0100 (Fri, 17 Dec 2004)
New Revision: 3435
Modified:
trunk/nfsim/core/ipv4/ipv4.c
trunk/nfsim/tools/gen_ip.c
Log:
Better packet descriptions and more gen_ip options to test ipt_LOG.
Reorder TCP flags printing so testsuite doesn't break.
Modified: trunk/nfsim/core/ipv4/ipv4.c
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.c 2004-12-17 09:29:00 UTC (rev 3434)
+++ trunk/nfsim/core/ipv4/ipv4.c 2004-12-17 10:32:22 UTC (rev 3435)
@@ -713,6 +713,8 @@
ptr += sprintf(ptr, "DF ");
if (ntohs(iph->frag_off) & IP_MF)
ptr += sprintf(ptr, "MF ");
+ if (ntohs(iph->frag_off) & IP_CE)
+ ptr += sprintf(ptr, "CE ");
if (dump_flags & __NFSIM_DUMP_TTL)
ptr += sprintf(ptr, "TTL=%i ", iph->ttl);
@@ -814,12 +816,12 @@
if (tcph->syn)
ptr += sprintf(ptr, "SYN");
+ if (tcph->fin)
+ ptr += sprintf(ptr, "%sFIN", ptr == p ? "" : "/");
+ if (tcph->rst)
+ ptr += sprintf(ptr, "%sRST", ptr == p ? "" : "/");
if (tcph->ack)
ptr += sprintf(ptr, "%sACK", ptr == p ? "" : "/");
- if (tcph->rst)
- ptr += sprintf(ptr, "%sRST", ptr == p ? "" : "/");
- if (tcph->fin)
- ptr += sprintf(ptr, "%sFIN", ptr == p ? "" : "/");
if (tcph->urg)
ptr += sprintf(ptr, "%sURG", ptr == p ? "" : "/");
if (tcph->psh)
Modified: trunk/nfsim/tools/gen_ip.c
===================================================================
--- trunk/nfsim/tools/gen_ip.c 2004-12-17 09:29:00 UTC (rev 3434)
+++ trunk/nfsim/tools/gen_ip.c 2004-12-17 10:32:22 UTC (rev 3435)
@@ -254,6 +254,15 @@
packet->u.icmph.un.echo.id = htons(id);
packet->u.icmph.un.echo.sequence = htons(seq);
+ } else if (type == ICMP_PARAMETERPROB) {
+ int param;
+
+ if (!args[2] || (param = string_to_number(args[2], 0, 255)) < 0) {
+ nfsim_log(LOG_UI, "Bad param problem: `%s'", args[2]);
+ return -1;
+ }
+
+ packet->u.icmph.un.gateway = htonl(param << 24);
} else if (args[2]) {
nfsim_log(LOG_UI, "Extra argument: `%s'", args[2]);
return -1;
@@ -570,6 +579,7 @@
<arg choice="opt">FRAG=</arg>
<arg choice="opt">DF</arg>
<arg choice="opt">MF</arg>
+ <arg choice="opt">CE</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>
@@ -643,7 +653,7 @@
bool parse_packet(struct packet *packet, int argc, char *argv[],
int *dump_flags)
{
- int tos = 0, mf = 0, df = 0, ttl = 255, len, datalen;
+ int tos = 0, mf = 0, df = 0, ce = 0, ttl = 255, len, datalen;
u_int16_t fragoff = 0, fraglen = 0;
if (argc < 5)
@@ -687,6 +697,12 @@
argv++;
}
+ if (argc > 5 && strcmp(argv[1], "CE") == 0) {
+ ce = 1;
+ argc--;
+ argv++;
+ }
+
if (argc > 5 && strncmp(argv[1], "MAC=", 4) == 0) {
if (!parse_mac(argv[1]+4, packet->ehdr.h_source)) {
nfsim_log(LOG_UI, "Invalid mac address.");
@@ -761,6 +777,8 @@
packet->iph.frag_off |= htons(IP_DF);
if (mf)
packet->iph.frag_off |= htons(IP_MF);
+ if (ce)
+ packet->iph.frag_off |= htons(IP_CE);
packet->iph.check = ~csum_partial(&packet->iph, sizeof(packet->iph),0);
packet->ehdr.h_proto = htons(ETH_P_IP);
More information about the netfilter-cvslog
mailing list