Removed trailing whitespaces from .h and .c files using the
[obnox/wireshark/wip.git] / randpkt.c
index 746ed812d8e9902904f486a890e4d3384339ca72..639afd206f12d029572792baba55e985ac424a81 100644 (file)
--- a/randpkt.c
+++ b/randpkt.c
@@ -4,9 +4,9 @@
  * Creates random packet traces. Useful for debugging sniffers by testing
  * assumptions about the veracity of the data found in the packet.
  *
- * $Id: randpkt.c,v 1.4 1999/10/06 20:29:26 gram Exp $
+ * $Id: randpkt.c,v 1.14 2002/05/18 14:58:00 gerald Exp $
  *
- * Copyright (C) 1999 by Gilbert Ramirez <gram@xiexie.org>
+ * Copyright (C) 1999 by Gilbert Ramirez <gram@alumni.rice.edu>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -55,9 +55,14 @@ enum {
        PKT_ICMP,
        PKT_IP,
        PKT_LLC,
+       PKT_NBNS,
+       PKT_SYSLOG,
        PKT_TCP,
        PKT_TR,
-       PKT_UDP
+       PKT_UDP,
+       PKT_BVLC,
+       PKT_NCP2222,
+       PKT_GIOP
 };
 
 typedef struct {
@@ -77,7 +82,7 @@ guint8 pkt_arp[] = {
        0x08, 0x06
 };
 
-/* Ethernet+IP+UP, indicating DNS */
+/* Ethernet+IP+UDP, indicating DNS */
 guint8 pkt_dns[] = {
        0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0x01, 0x01,
@@ -95,7 +100,7 @@ guint8 pkt_dns[] = {
        0x30
 };
 
-/* Ethernet+IP, indicating ICMPP */
+/* Ethernet+IP, indicating ICMP */
 guint8 pkt_icmp[] = {
        0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0x01, 0x01,
@@ -125,6 +130,42 @@ guint8 pkt_llc[] = {
        0xc4, 0x67
 };
 
+/* Ethernet+IP+UDP, indicating NBNS */
+guint8 pkt_nbns[] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0x01, 0x01,
+       0x01, 0x01, 0x01, 0x01,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0x3c,
+       0xc5, 0x9e, 0x40, 0x00,
+       0xff, 0x11, 0xd7, 0xe0,
+       0xd0, 0x15, 0x02, 0xb8,
+       0x0a, 0x01, 0x01, 0x63,
+
+       0x00, 0x89, 0x00, 0x89,
+       0x00, 0x00, 0x2a, 0xb9,
+       0x30
+};
+
+/* Ethernet+IP+UDP, indicating syslog */
+guint8 pkt_syslog[] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0x01, 0x01,
+       0x01, 0x01, 0x01, 0x01,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0x64,
+       0x20, 0x48, 0x00, 0x00,
+       0xfc, 0x11, 0xf8, 0x03,
+       0xd0, 0x15, 0x02, 0xb8,
+       0x0a, 0x01, 0x01, 0x63,
+
+       0x05, 0xe8, 0x02, 0x02,
+       0x00, 0x50, 0x51, 0xe1,
+       0x3c
+};
+
 /* TR+LLC+IP, indicating TCP */
 guint8 pkt_tcp[] = {
        0x10, 0x40, 0x68, 0x00,
@@ -156,6 +197,70 @@ guint8 pkt_udp[] = {
        0x0a, 0x01, 0x01, 0x63
 };
 
+/* Ethernet+IP+UDP, indicating BVLC */
+guint8 pkt_bvlc[] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0x01, 0x01,
+       0x01, 0x01, 0x01, 0x01,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0x3c,
+       0xc5, 0x9e, 0x40, 0x00,
+       0xff, 0x11, 0x01, 0xaa,
+       0xc1, 0xff, 0x19, 0x1e,
+       0xc1, 0xff, 0x19, 0xff,
+       0xba, 0xc0, 0xba, 0xc0,
+       0x00, 0xff, 0x2d, 0x5e,
+       0x81
+};
+
+/* TR+LLC+IPX, indicating NCP, with NCP Type == 0x2222 */
+guint8 pkt_ncp2222[] = {
+       0x10, 0x40, 0x00, 0x00,
+       0xf6, 0x7c, 0x9b, 0x70,
+       0x68, 0x00, 0x19, 0x69,
+       0x95, 0x8b, 0xe0, 0xe0,
+       0x03, 0xff, 0xff, 0x00,
+       0x25, 0x02, 0x11, 0x00,
+       0x00, 0x74, 0x14, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x01, 0x04, 0x51, 0x00,
+       0x00, 0x00, 0x04, 0x00,
+       0x02, 0x16, 0x19, 0x7a,
+       0x84, 0x40, 0x01, 0x22,
+       0x22
+};
+
+/* Ethernet+IP+TCP, indicating GIOP */
+guint8 pkt_giop[] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0x01, 0x01,
+       0x01, 0x01, 0x01, 0x01,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0xa6,
+       0x00, 0x2f, 0x40, 0x00,
+       0x40, 0x06, 0x3c, 0x21,
+       0x7f, 0x00, 0x00, 0x01,
+       0x7f, 0x00, 0x00, 0x01,
+
+       0x30, 0x39, 0x04, 0x05,
+       0xac, 0x02, 0x1e, 0x69,
+       0xab, 0x74, 0xab, 0x64,
+       0x80, 0x18, 0x79, 0x60,
+       0xc4, 0xb8, 0x00, 0x00,
+       0x01, 0x01, 0x08, 0x0a,
+       0x00, 0x00, 0x48, 0xf5,
+       0x00, 0x00, 0x48, 0xf5,
+
+       0x47, 0x49, 0x4f, 0x50,
+       0x01, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x30,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x01,
+       0x01
+};
+
 /* This little data table drives the whole program */
 pkt_example examples[] = {
        { "arp", "Address Resolution Protocol",
@@ -177,16 +282,32 @@ pkt_example examples[] = {
                PKT_IP,         pkt_ip,         WTAP_ENCAP_ETHERNET,    array_length(pkt_ip) },
 
        { "llc", "Logical Link Control",
-               PKT_LLC,        pkt_llc,        WTAP_ENCAP_TR,          array_length(pkt_llc) },
+               PKT_LLC,        pkt_llc,        WTAP_ENCAP_TOKEN_RING,  array_length(pkt_llc) },
+
+       { "nbns", "NetBIOS-over-TCP Name Service",
+               PKT_NBNS,       pkt_nbns,       WTAP_ENCAP_ETHERNET,    array_length(pkt_nbns) },
+
+       { "syslog", "Syslog message",
+               PKT_SYSLOG,     pkt_syslog,     WTAP_ENCAP_ETHERNET,    array_length(pkt_syslog) },
 
        { "tcp", "Transmission Control Protocol",
-               PKT_TCP,        pkt_tcp,        WTAP_ENCAP_TR,          array_length(pkt_tcp) },
+               PKT_TCP,        pkt_tcp,        WTAP_ENCAP_TOKEN_RING,  array_length(pkt_tcp) },
 
        { "tr",  "Token-Ring",
-               PKT_TR,         NULL,           WTAP_ENCAP_TR,          0 },
+               PKT_TR,         NULL,           WTAP_ENCAP_TOKEN_RING,  0 },
 
        { "udp", "User Datagram Protocol",
-               PKT_UDP,        pkt_udp,        WTAP_ENCAP_ETHERNET,    array_length(pkt_udp) }
+               PKT_UDP,        pkt_udp,        WTAP_ENCAP_ETHERNET,    array_length(pkt_udp) },
+
+       { "bvlc", "BACnet Virtual Link Control",
+               PKT_BVLC,       pkt_bvlc,       WTAP_ENCAP_ETHERNET,    array_length(pkt_bvlc) },
+
+       { "ncp2222", "NetWare Core Protocol",
+               PKT_NCP2222,    pkt_ncp2222,    WTAP_ENCAP_TOKEN_RING,  array_length(pkt_ncp2222) },
+
+       { "giop", "General Inter-ORB Protocol",
+               PKT_GIOP,       pkt_giop,       WTAP_ENCAP_ETHERNET,    array_length(pkt_giop) },
+
 };
 
 
@@ -203,6 +324,7 @@ main(int argc, char **argv)
 
        wtap_dumper             *dump;
        struct wtap_pkthdr      pkthdr;
+       union wtap_pseudo_header        ps_header;
        int                     i, j, len_this_pkt, len_random, err;
        guint8                  buffer[65536];
 
@@ -216,7 +338,7 @@ main(int argc, char **argv)
        int                     produce_max_bytes = 5000;
        pkt_example             *example;
 
-       while ((opt = getopt(argc, argv, "b:c:t:")) != EOF) {
+       while ((opt = getopt(argc, argv, "b:c:t:")) != -1) {
                switch (opt) {
                        case 'b':       /* max bytes */
                                produce_max_bytes = atoi(optarg);
@@ -292,7 +414,7 @@ main(int argc, char **argv)
                        buffer[j] = (rand() % 0x100);
                }
 
-               wtap_dump(dump, &pkthdr, &buffer[0], &err);
+               wtap_dump(dump, &pkthdr, &ps_header, &buffer[0], &err);
        }
 
        wtap_dump_close(dump, &err);
@@ -335,8 +457,9 @@ int parse_type(char *string)
                }
        }
 
-       /* default type */
-       return PKT_ETHERNET;
+       /* Complain */
+       printf("Type %s not known.\n", string);
+       exit(1);
 }
 
 /* Find pkt_example record and return pointer to it */
@@ -353,7 +476,7 @@ pkt_example* find_example(int type)
        }
 
        printf("Internal error. Type %d has no entry in examples table.\n", type);
-       exit(0);
+       exit(1);
 }
 
 /* Seed the random-number generator */