Make infiniband plugin compile.
[obnox/wireshark/wip.git] / randpkt.c
index bd3d3e7baeb8dee7229a53b6c5421c35ab1fe108..ab88c2c907f4efc1fa35e722e4fd34290b30d31e 100644 (file)
--- a/randpkt.c
+++ b/randpkt.c
 /* Types of produceable packets */
 enum {
        PKT_ARP,
+       PKT_BGP,
+       PKT_BVLC,
        PKT_DNS,
        PKT_ETHERNET,
        PKT_FDDI,
+       PKT_GIOP,
        PKT_ICMP,
        PKT_IP,
        PKT_LLC,
+       PKT_M2M,
+       PKT_MEGACO,
        PKT_NBNS,
+       PKT_NCP2222,
+       PKT_SCTP,
        PKT_SYSLOG,
        PKT_TCP,
-       PKT_TR,
-       PKT_UDP,
-       PKT_BVLC,
-       PKT_NCP2222,
-       PKT_GIOP,
-       PKT_BGP,
        PKT_TDS,
-       PKT_SCTP,
-       PKT_MEGACO
+       PKT_TR,
+       PKT_UDP
 };
 
 typedef struct {
-       char    *abbrev;
-       char    *longname;
-       int     produceable_type;
-       guint8  *sample_buffer;
-       int     sample_wtap_encap;
-       int     sample_length;
+       const char      *abbrev;
+       const char      *longname;
+       int             produceable_type;
+       guint8          *sample_buffer;
+       int             sample_wtap_encap;
+       int             sample_length;
 } pkt_example;
 
 /* Ethernet, indicating ARP */
@@ -138,6 +139,14 @@ guint8 pkt_llc[] = {
        0xc4, 0x67
 };
 
+/* Ethernet, indicating WiMAX M2M */
+guint8 pkt_m2m[] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0x00, 0x00,
+       0x32, 0x25, 0x0f, 0xff,
+       0x08, 0xf0
+};
+
 /* Ethernet+IP+UDP, indicating NBNS */
 guint8 pkt_nbns[] = {
        0xff, 0xff, 0xff, 0xff,
@@ -386,6 +395,9 @@ pkt_example examples[] = {
        { "llc", "Logical Link Control",
                PKT_LLC,        pkt_llc,        WTAP_ENCAP_TOKEN_RING,  array_length(pkt_llc) },
 
+       { "m2m", "WiMAX M2M Encapsulation Protocol",
+               PKT_M2M,        pkt_m2m,        WTAP_ENCAP_ETHERNET,    array_length(pkt_m2m) },
+
        { "megaco", "MEGACO",
                PKT_MEGACO,     pkt_megaco,     WTAP_ENCAP_ETHERNET,    array_length(pkt_megaco) },
 
@@ -477,12 +489,16 @@ main(int argc, char **argv)
 
        example = find_example(produce_type);
 
-       pkthdr.ts.tv_sec = 0;
-       pkthdr.ts.tv_usec = 0;
+       pkthdr.ts.secs = 0;
+       pkthdr.ts.nsecs = 0;
        pkthdr.pkt_encap = example->sample_wtap_encap;
 
        dump = wtap_dump_open(produce_filename, WTAP_FILE_PCAP,
-               example->sample_wtap_encap, produce_max_bytes, &err);
+               example->sample_wtap_encap, produce_max_bytes, FALSE /* compressed */, &err);
+    if (!dump) {
+        printf("Error writing to %s\n", produce_filename);
+        exit(1);
+    }
 
        seed();
 
@@ -513,9 +529,9 @@ main(int argc, char **argv)
 
                pkthdr.caplen = len_this_pkt;
                pkthdr.len = len_this_pkt;
-               pkthdr.ts.tv_sec = i; /* just for variety */
+               pkthdr.ts.secs = i; /* just for variety */
 
-               for (j = example->sample_length; j < len_random; j++) {
+               for (j = example->sample_length; j < len_this_pkt; j++) {
                        /* Add format strings here and there */
                        if ((int) (100.0*rand()/(RAND_MAX+1.0)) < 3 && j < (len_random - 3)) {
                                memcpy(&buffer[j], "%s", 3);