## 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>
$(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
/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)
# 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
*
* (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>
*
* 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.\r
- * 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3...\7f..\r
- * 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..\r
- * 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......\r
+ * 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...\7f..
+ * 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
* 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
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;
{
unsigned long num;
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
num = parse_num(str, FALSE);
packet_buf[curr_offset] = num;
curr_offset ++;
{
struct pcap_hdr fh;
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
fh.magic = PCAP_MAGIC;
fh.version_major = 2;
fh.version_minor = 4;
static void
start_new_packet (void)
{
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
if (debug>=1)
fprintf(stderr, "Start new packet\n");
static void
process_directive (char *str)
{
- if (debug>=2)
- fprintf(stderr, __FUNCTION__);
-
fprintf(stderr, "\n--- Directive [%s] currently unsupported ---\n", str+10);
}
if (num==0) {
/* New packet starts here */
start_new_packet();
- state = OFFSET;
+ state = READ_OFFSET;
}
break;
default:
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)
write_current_packet();
state = INIT;
} else
- state = OFFSET;
+ state = READ_OFFSET;
break;
default:
break;
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;
break;
/* ----- Processing packet, read byte -------------------------------------*/
- case BYTE:
+ case READ_BYTE:
switch(token) {
case T_BYTE:
/* Record the byte */
case T_TEXT:
case T_DIRECTIVE:
case T_OFFSET:
- state = TEXT;
+ state = READ_TEXT;
break;
case T_EOL:
state = START_OF_LINE;
break;
/* ----- Processing packet, read text -------------------------------------*/
- case TEXT:
+ case READ_TEXT:
switch(token) {
case T_EOL:
state = START_OF_LINE;