aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.nmake16
-rw-r--r--text2pcap.c65
2 files changed, 47 insertions, 34 deletions
diff --git a/Makefile.nmake b/Makefile.nmake
index 45aa1144f0..bb5a90f93d 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
-# $Id: Makefile.nmake,v 1.106 2001/05/20 22:20:33 guy Exp $
+# $Id: Makefile.nmake,v 1.107 2001/05/21 03:17:14 guy Exp $
include config.nmake
include <win32.mak>
@@ -271,7 +271,7 @@ dftest_LIBS= epan\ethereal.lib \
$(GLIB_DIR)\glib-$(GLIB_VERSION).lib \
$(GLIB_DIR)\gmodule\gmodule-$(GLIB_VERSION).lib
-EXECUTABLES=ethereal.exe tethereal.exe editcap.exe
+EXECUTABLES=ethereal.exe tethereal.exe editcap.exe text2pcap.exe
RESOURCES=image\ethereal.res image\tethereal.res image\editcap.res
@@ -295,6 +295,12 @@ editcap.exe : config.h editcap.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).li
/OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console editcap.obj getopt.obj $(editcap_LIBS) image\editcap.res
<<
+text2pcap.exe : config.h text2pcap.obj text2pcap-scanner.obj getopt.obj
+ @echo Linking $@
+ $(LINK) @<<
+ /OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console text2pcap.obj text2pcap-scanner.obj getopt.obj
+<<
+
dftest.exe : $(dftest_OBJECTS) $(EXTRA_OBJECTS)
$(LINK) @<<
/OUT:dftest.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dftest_LIBS) $(dftest_OBJECTS) $(EXTRA_OBJECTS)
@@ -329,9 +335,13 @@ register.c: $(DISSECTOR_SRC)
# to use python if PYTHON is defined, otherwise try to use shell.
# @sh make-reg-dotc . $(DISSECTOR_SRC)
+text2pcap-scanner.c : text2pcap-scanner.l
+ $(LEX) -otext2pcap-scanner.c text2pcap-scanner.l
+
clean:
rm -f $(ethereal_OBJECTS) $(EXTRA_OBJECTS) $(EXECUTABLES) \
- tethereal.obj editcap.obj register.c rdps.obj config.h \
+ tethereal.obj editcap.obj text2pcap.obj \
+ text2pcap-scanner.c register.c rdps.obj config.h \
ps.c packet-ncp2222.c register.c
cd wiretap
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
diff --git a/text2pcap.c b/text2pcap.c
index 77e98da952..17508a172e 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -6,7 +6,7 @@
*
* (c) Copyright 2001 Ashok Narayanan <ashokn@cisco.com>
*
- * $Id: text2pcap.c,v 1.1 2001/05/16 21:32:04 ashokn Exp $
+ * $Id: text2pcap.c,v 1.2 2001/05/21 03:17:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -34,10 +34,10 @@
*
* This utility reads in an ASCII hexdump of this common format:
*
- * 00000000 00 E0 1E A7 05 6F 00 10 5A A0 B9 12 08 00 46 00 .....o..Z.....F.
- * 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3.....
- * 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..
- * 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......
+ * 00000000 00 E0 1E A7 05 6F 00 10 5A A0 B9 12 08 00 46 00 .....o..Z.....F.
+ * 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3.....
+ * 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..
+ * 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......
*
* Each bytestring line consists of an offset, one or more bytes, and
* text at the end. An offset is defined as a hex string of more than
@@ -79,15 +79,30 @@
* snaplength is automatically set to 64K.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
-#include <netinet/in.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_WINSOCK_H
+# include <winsock.h>
+#endif
#include <errno.h>
#include <assert.h>
+#ifdef NEED_GETOPT_H
+# include "getopt.h"
+#endif
+
#ifndef TRUE
#define TRUE 1
#endif
@@ -147,9 +162,9 @@ FILE *yyin;
typedef enum {
INIT, /* Waiting for start of new packet */
START_OF_LINE, /* Starting from beginning of line */
- OFFSET, /* Just read the offset */
- BYTE, /* Just read a byte */
- TEXT, /* Just read text - ignore until EOL */
+ READ_OFFSET, /* Just read the offset */
+ READ_BYTE, /* Just read a byte */
+ READ_TEXT, /* Just read text - ignore until EOL */
} parser_state_t;
parser_state_t state = INIT;
@@ -262,9 +277,6 @@ write_byte (char *str)
{
unsigned long num;
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
num = parse_num(str, FALSE);
packet_buf[curr_offset] = num;
curr_offset ++;
@@ -379,9 +391,6 @@ write_file_header (void)
{
struct pcap_hdr fh;
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
fh.magic = PCAP_MAGIC;
fh.version_major = 2;
fh.version_minor = 4;
@@ -399,9 +408,6 @@ write_file_header (void)
static void
start_new_packet (void)
{
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
if (debug>=1)
fprintf(stderr, "Start new packet\n");
@@ -417,9 +423,6 @@ start_new_packet (void)
static void
process_directive (char *str)
{
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
fprintf(stderr, "\n--- Directive [%s] currently unsupported ---\n", str+10);
}
@@ -460,7 +463,7 @@ parse_token (token_t token, char *str)
if (num==0) {
/* New packet starts here */
start_new_packet();
- state = OFFSET;
+ state = READ_OFFSET;
}
break;
default:
@@ -479,7 +482,7 @@ parse_token (token_t token, char *str)
if (num==0) {
/* New packet starts here */
start_new_packet();
- state = OFFSET;
+ state = READ_OFFSET;
} else if (num != curr_offset) {
/* Bad offset; switch to INIT state */
if (debug>=1)
@@ -488,7 +491,7 @@ parse_token (token_t token, char *str)
write_current_packet();
state = INIT;
} else
- state = OFFSET;
+ state = READ_OFFSET;
break;
default:
break;
@@ -496,17 +499,17 @@ parse_token (token_t token, char *str)
break;
/* ----- Processing packet, read offset -----------------------------------*/
- case OFFSET:
+ case READ_OFFSET:
switch(token) {
case T_BYTE:
/* Record the byte */
- state = BYTE;
+ state = READ_BYTE;
write_byte(str);
break;
case T_TEXT:
case T_DIRECTIVE:
case T_OFFSET:
- state = TEXT;
+ state = READ_TEXT;
break;
case T_EOL:
state = START_OF_LINE;
@@ -517,7 +520,7 @@ parse_token (token_t token, char *str)
break;
/* ----- Processing packet, read byte -------------------------------------*/
- case BYTE:
+ case READ_BYTE:
switch(token) {
case T_BYTE:
/* Record the byte */
@@ -526,7 +529,7 @@ parse_token (token_t token, char *str)
case T_TEXT:
case T_DIRECTIVE:
case T_OFFSET:
- state = TEXT;
+ state = READ_TEXT;
break;
case T_EOL:
state = START_OF_LINE;
@@ -537,7 +540,7 @@ parse_token (token_t token, char *str)
break;
/* ----- Processing packet, read text -------------------------------------*/
- case TEXT:
+ case READ_TEXT:
switch(token) {
case T_EOL:
state = START_OF_LINE;