Move a bunch of the crypt modules and pint.h into wsutil.
[metze/wireshark/wip.git] / asn1 / c1222 / packet-c1222-template.c
index e2158b6ecaaa188ebbf0747e0e29901a8bb98024..d63c23d3e8cddc794470260e4b37b7fcedc7326b 100644 (file)
@@ -26,6 +26,9 @@
 #include "config.h"
 
 #include <glib.h>
+
+#include <wsutil/eax.h>
+
 #include <epan/conversation.h>
 #include <epan/expert.h>
 #include <epan/packet.h>
@@ -34,7 +37,6 @@
 #include <epan/dissectors/packet-ber.h>
 #include <epan/dissectors/packet-tcp.h>
 #include <epan/uat.h>
-#include <epan/crypt/eax.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -128,6 +130,7 @@ static int hf_c1222_write_table = -1;
 static int hf_c1222_write_offset = -1;
 static int hf_c1222_write_size = -1;
 static int hf_c1222_write_data = -1;
+static int hf_c1222_procedure_num = -1;
 static int hf_c1222_write_chksum = -1;
 static int hf_c1222_wait_secs = -1;
 static int hf_c1222_neg_pkt_size = -1;
@@ -229,7 +232,7 @@ static const value_string tableflags[] = {
 
 static const value_string procflags[] = {
   { 0x00, "SF" },
-  { 0x01, "MF" },
+  { 0x08, "MF" },
   { 0, NULL }
 };
 
@@ -362,6 +365,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
   guint8 wait_seconds = 0;
   int numrates = 0;
   guint16 packet_size;
+  guint16 procedure_num = 0;
   guint8 nbr_packet;
   /* timing setup parameters */
   guint8 traffic;
@@ -477,18 +481,36 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
            *offset += 2;
            *length -= 2;
            if (*length >= tblsize+1U) {
+               if (table == 7) {/* is it a procedure call? */
+                   procedure_num = tvb_get_letohs(tvb, *offset);
+                   proto_tree_add_uint(tree, hf_c1222_procedure_num, tvb, *offset, 2, procedure_num);
+                   *offset += 2;
+                   *length -= 2;
+                   tblsize -= 2;
+               }
                proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
                *offset += tblsize;
                *length -= tblsize;
                chksum = tvb_get_guint8(tvb, *offset);
                item = proto_tree_add_uint(tree, hf_c1222_write_chksum, tvb, *offset, 1, chksum);
-               calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
+               if (table == 7) {/* is it a procedure call? */
+                   calcsum = c1222_cksum(tvb, (*offset)-tblsize-2, tblsize+2);
+               } else {
+                   calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
+               }
                if (chksum != calcsum) {
                  expert_add_info_format_text(pinfo, item, &ei_c1222_bad_checksum, "Bad checksum [should be 0x%02x]", calcsum);
                }
-               proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d)",
-                       val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
-                       val_to_str((table >> 8) & 0xF8, tableflags,"Unknown (0x%04x)"), table & 0x7FF);
+               if (table == 7) {/* is it a procedure call? */
+                   proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d, %s-%d)",
+                           val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
+                           val_to_str((table >> 8) & 0xF8, tableflags,"Unknown (0x%04x)"), table & 0x7FF,
+                           val_to_str((procedure_num >> 8) & 0xF8, procflags,"Unknown (0x%04x)"), procedure_num & 0x7FF);
+               } else {
+                   proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d)",
+                           val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
+                           val_to_str((table >> 8) & 0xF8, tableflags,"Unknown (0x%04x)"), table & 0x7FF);
+               }
                *offset += 1;
                *length -= 1;
            } else {
@@ -590,11 +612,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
        /* don't do anything */
        proto_item_set_text(tree, "C12.22 EPSEM: %s", val_to_str(cmd, commandnames, "Unknown (0x%02x)"));
        if (*length) {
-           if (*length >= *length) {
-             proto_tree_add_item(tree, hf_c1222_data, tvb, *offset, *length, ENC_NA);
-           } else {
-               expert_add_info_format_text(pinfo, tree, &ei_c1222_command_truncated, "C12.22 unknown command truncated");
-           }
+         proto_tree_add_item(tree, hf_c1222_data, tvb, *offset, *length, ENC_NA);
        }
        break;
   }
@@ -1019,7 +1037,7 @@ dissect_c1222_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     if (tree) {
         c1222_item = proto_tree_add_item(tree, proto_c1222, tvb, 0, -1, ENC_NA);
         c1222_tree = proto_item_add_subtree(c1222_item, ett_c1222);
-        dissect_C1222_MESSAGE_PDU(tvb, pinfo, c1222_tree);
+        dissect_MESSAGE_PDU(tvb, pinfo, c1222_tree);
     }
 }
 
@@ -1213,6 +1231,12 @@ void proto_register_c1222(void) {
     NULL, 0x0,
     NULL, HFILL }
    },
+   { &hf_c1222_procedure_num,
+    { "C12.22 Procedure Number", "c1222.procedure.num",
+    FT_UINT16, BASE_DEC,
+    NULL, 0x7ff,
+    NULL, HFILL }
+   },
    { &hf_c1222_neg_pkt_size,
     { "C12.22 Negotiate Packet Size", "c1222.negotiate.pktsize",
     FT_UINT16, BASE_DEC,
@@ -1361,7 +1385,7 @@ proto_reg_handoff_c1222(void)
 
     if( !initialized ) {
         c1222_handle = create_dissector_handle(dissect_c1222, proto_c1222);
-               c1222_udp_handle = create_dissector_handle(dissect_c1222_common, proto_c1222);
+       c1222_udp_handle = create_dissector_handle(dissect_c1222_common, proto_c1222);
         dissector_add_uint("tcp.port", global_c1222_port, c1222_handle);
         dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle);
         initialized = TRUE;