From c3b66ffa9c91b61fc8c2593c4552c1f6377bde0e Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 13 Apr 2002 18:36:24 +0000 Subject: [PATCH] From Michael Tuexen: The -S option has been changed such that the payload protocol identifier can be specified instead of the verification tag. The error messages for -s -S have been corrected. Update the text2pcap man page to reflect the "-S" change. svn path=/trunk/; revision=5150 --- doc/text2pcap.pod | 24 +++++++++++++-------- text2pcap.c | 54 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/doc/text2pcap.pod b/doc/text2pcap.pod index aad903e78e..0c45e20c32 100644 --- a/doc/text2pcap.pod +++ b/doc/text2pcap.pod @@ -137,17 +137,23 @@ appropriate Ethernet and IP headers with each packet. Example: I<-u =item -s srcport,destport,tag -Include dummy SCTP headers before each packet. Specify the source and -destination SCTP ports, and verification tag, for the packet in decimal. -Use this option if your dump is the SCTP payload of a packet but does not -include any SCTP, IP or Ethernet headers. Note that this automatically -includes appropriate Ethernet and IP headers with each packet. A CRC32C -checksum will be put into the SCTP header. +Include dummy SCTP headers before each packet. Specify, in decimal, the +source and destination SCTP ports, and verification tag, for the packet. +Use this option if your dump is the SCTP payload of a packet but does +not include any SCTP, IP or Ethernet headers. Note that this +automatically includes appropriate Ethernet and IP headers with each +packet. A CRC32C checksum will be put into the SCTP header. -=item -S srcport,destport,tag +=item -S srcport,destport,ppi -Like B<-s>, but it also includes the DATA chunk header, for input files -that contain only the SCTP payload. +Include dummy SCTP headers before each packet. Specify, in decimal, the +source and destination SCTP ports, and a verification tag of 0, for the +packet, and prepend a dummy SCTP DATA chunk header with a payload +protocol identifier if I. Use this option if your dump is the SCTP +payload of a packet but does not include any SCTP, IP or Ethernet +headers. Note that this automatically includes appropriate Ethernet and +IP headers with each packet. A CRC32C checksum will be put into the +SCTP header. =item -t timefmt diff --git a/text2pcap.c b/text2pcap.c index 92f7fcf540..a09f8d1caa 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -6,7 +6,7 @@ * * (c) Copyright 2001 Ashok Narayanan * - * $Id: text2pcap.c,v 1.14 2002/01/30 10:19:43 guy Exp $ + * $Id: text2pcap.c,v 1.15 2002/04/13 18:36:23 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -941,7 +941,9 @@ help (char *progname) " verification tag (in DECIMAL).\n" " Automatically prepends Ethernet and IP headers as well\n" " Example: -s 30,40,34\n" - " -S srcp,dstp,tag: Same as -s srcp,dstp,tag but also prepends a DATA chunk header.\n" + " -S srcp,dstp,ppi: Prepend dummy SCTP header with specified dest/source ports and\n" + " verification tag 0. It also prepends a dummy SCTP DATA chunk header\n" + " with payload protocol identifier ppi.\n" " Example: -S 30,40,34\n" " -t timefmt : Treats the text before the packet as a date/time code; the\n" " specified argument is a format string of the sort supported\n" @@ -999,11 +1001,45 @@ parse_options (int argc, char *argv[]) hdr_ethernet_proto = 0x800; break; - case 'S': - hdr_data_chunk = TRUE; case 's': - hdr_sctp = TRUE; - hdr_sctp_src = strtol(optarg, &p, 10); + hdr_sctp = TRUE; + hdr_sctp_src = strtol(optarg, &p, 10); + if (p == optarg || (*p != ',' && *p != '\0')) { + fprintf(stderr, "Bad src port for '-%c'\n", c); + help(argv[0]); + } + if (*p == '\0') { + fprintf(stderr, "No dest port specified for '-%c'\n", c); + help(argv[0]); + } + p++; + optarg = p; + hdr_sctp_dest = strtol(optarg, &p, 10); + if (p == optarg || (*p != ',' && *p != '\0')) { + fprintf(stderr, "Bad dest port for '-s'\n"); + help(argv[0]); + } + if (*p == '\0') { + fprintf(stderr, "No tag specified for '-%c'\n", c); + help(argv[0]); + } + p++; + optarg = p; + hdr_sctp_tag = strtol(optarg, &p, 10); + if (p == optarg || *p != '\0') { + fprintf(stderr, "Bad tag for '-%c'\n", c); + help(argv[0]); + } + + hdr_ip = TRUE; + hdr_ip_proto = 132; + hdr_ethernet = TRUE; + hdr_ethernet_proto = 0x800; + break; + case 'S': + hdr_sctp = TRUE; + hdr_data_chunk = TRUE; + hdr_sctp_src = strtol(optarg, &p, 10); if (p == optarg || (*p != ',' && *p != '\0')) { fprintf(stderr, "Bad src port for '-%c'\n", c); help(argv[0]); @@ -1019,14 +1055,14 @@ parse_options (int argc, char *argv[]) fprintf(stderr, "Bad dest port for '-s'\n"); help(argv[0]); } if (*p == '\0') { - fprintf(stderr, "No dest port specified for '-%c'\n", c); + fprintf(stderr, "No ppi specified for '-%c'\n", c); help(argv[0]); } p++; optarg = p; - hdr_sctp_tag = strtol(optarg, &p, 10); + hdr_data_chunk_ppid = strtol(optarg, &p, 10); if (p == optarg || *p != '\0') { - fprintf(stderr, "Bad tag for '-%c'\n", c); + fprintf(stderr, "Bad ppi for '-%c'\n", c); help(argv[0]); }