For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
[obnox/wireshark/wip.git] / epan / dissectors / packet-idmp.c
index e91ab58545f830becf28839b81b5c4b07e72b095..2cd00b89262c971735ef6b844256b74a2942c03a 100644 (file)
@@ -1,11 +1,11 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
 /* packet-idmp.c                                                              */
-/* ../../tools/asn2wrs.py -b -e -L -p idmp -c ./idmp.cnf -s ./packet-idmp-template -D . IDMProtocolSpecification.asn CommonProtocolSpecification.asn */
+/* ../../tools/asn2wrs.py -b -L -p idmp -c ./idmp.cnf -s ./packet-idmp-template -D . -O ../../epan/dissectors IDMProtocolSpecification.asn CommonProtocolSpecification.asn */
 
 /* Input file: packet-idmp-template.c */
 
-#line 1 "packet-idmp-template.c"
+#line 1 "../../asn1/idmp/packet-idmp-template.c"
 /* packet-idmp.c
  * Routines for X.519 Internet Directly Mapped Procotol (IDMP) packet dissection
  * Graeme Lunt 2020
@@ -67,7 +67,7 @@ static const char *protocolID = NULL;
 static const char *saved_protocolID = NULL;
 static guint32 opcode = -1;
 
-void prefs_register_idmp(void); /* forward declaration for use in preferences registration */
+static void prefs_register_idmp(void); /* forward declaration for use in preferences registration */
 
 /* Initialize the protocol and registered fields */
 int proto_idmp = -1;
@@ -79,7 +79,7 @@ static int hf_idmp_PDU = -1;
 
 static GHashTable *idmp_segment_table = NULL;
 static GHashTable *idmp_reassembled_table = NULL;
+
 static int hf_idmp_fragments = -1;
 static int hf_idmp_fragment = -1;
 static int hf_idmp_fragment_overlap = -1;
@@ -87,6 +87,7 @@ static int hf_idmp_fragment_overlap_conflicts = -1;
 static int hf_idmp_fragment_multiple_tails = -1;
 static int hf_idmp_fragment_too_long_fragment = -1;
 static int hf_idmp_fragment_error = -1;
+static int hf_idmp_fragment_count = -1;
 static int hf_idmp_reassembled_in = -1;
 static int hf_idmp_reassembled_length = -1;
 
@@ -105,6 +106,7 @@ static const fragment_items idmp_frag_items = {
        &hf_idmp_fragment_multiple_tails,
        &hf_idmp_fragment_too_long_fragment,
        &hf_idmp_fragment_error,
+       &hf_idmp_fragment_count,
        /* Reassembled in field */
        &hf_idmp_reassembled_in,
        /* Reassembled length field */
@@ -114,10 +116,10 @@ static const fragment_items idmp_frag_items = {
 };
 
 
-static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree _U_) 
+static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree _U_)
 {
        struct SESSION_DATA_STRUCTURE *session;
-       
+
        if((session = (struct SESSION_DATA_STRUCTURE*)pinfo->private_data) != NULL) {
 
                if((!saved_protocolID) && (op == (ROS_OP_BIND | ROS_OP_RESULT))) {
@@ -136,7 +138,7 @@ static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
 
 /*--- Included file: packet-idmp-hf.c ---*/
-#line 1 "packet-idmp-hf.c"
+#line 1 "../../asn1/idmp/packet-idmp-hf.c"
 static int hf_idmp_bind = -1;                     /* IdmBind */
 static int hf_idmp_bindResult = -1;               /* IdmBindResult */
 static int hf_idmp_bindError = -1;                /* IdmBindError */
@@ -171,13 +173,13 @@ static int hf_idmp_present = -1;                  /* INTEGER */
 static int hf_idmp_absent = -1;                   /* NULL */
 
 /*--- End of included file: packet-idmp-hf.c ---*/
-#line 130 "packet-idmp-template.c"
+#line 132 "../../asn1/idmp/packet-idmp-template.c"
 
 /* Initialize the subtree pointers */
 static gint ett_idmp = -1;
 
 /*--- Included file: packet-idmp-ett.c ---*/
-#line 1 "packet-idmp-ett.c"
+#line 1 "../../asn1/idmp/packet-idmp-ett.c"
 static gint ett_idmp_IDM_PDU = -1;
 static gint ett_idmp_IdmBind = -1;
 static gint ett_idmp_IdmBindResult = -1;
@@ -190,11 +192,11 @@ static gint ett_idmp_Code = -1;
 static gint ett_idmp_InvokeId = -1;
 
 /*--- End of included file: packet-idmp-ett.c ---*/
-#line 134 "packet-idmp-template.c"
+#line 136 "../../asn1/idmp/packet-idmp-template.c"
 
 
 /*--- Included file: packet-idmp-fn.c ---*/
-#line 1 "packet-idmp-fn.c"
+#line 1 "../../asn1/idmp/packet-idmp-fn.c"
 
 
 static int
@@ -614,7 +616,7 @@ dissect_idmp_IDM_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U
 
 
 /*--- End of included file: packet-idmp-fn.c ---*/
-#line 136 "packet-idmp-template.c"
+#line 138 "../../asn1/idmp/packet-idmp-template.c"
 
 void
 register_idmp_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name)
@@ -652,7 +654,7 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
        top_tree=parent_tree;
 
        if(parent_tree){
-               item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, FALSE);
+               item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, ENC_NA);
                tree = proto_item_add_subtree(item, ett_idmp);
        }
 
@@ -660,10 +662,10 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
 
        /* now check the segment fields */
 
-       proto_tree_add_item(tree, hf_idmp_version, tvb, offset, 1, FALSE); offset++;
-       proto_tree_add_item(tree, hf_idmp_final, tvb, offset, 1, FALSE); 
+       proto_tree_add_item(tree, hf_idmp_version, tvb, offset, 1, ENC_BIG_ENDIAN); offset++;
+       proto_tree_add_item(tree, hf_idmp_final, tvb, offset, 1, ENC_BIG_ENDIAN);
        idmp_final = tvb_get_guint8(tvb, offset); offset++;
-       proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, FALSE); 
+       proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, ENC_BIG_ENDIAN);
        idmp_length = tvb_get_ntohl(tvb, offset); offset += 4;
 
        if(idmp_reassemble) {
@@ -671,7 +673,7 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
                pinfo->fragmented = !idmp_final;
 
                if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_fstr(pinfo->cinfo, COL_INFO, " [%sIDMP fragment, %u byte%s]", 
+                       col_append_fstr(pinfo->cinfo, COL_INFO, " [%sIDMP fragment, %u byte%s]",
                                idmp_final ? "Final " : "" ,
                                idmp_length, plurality(idmp_length, "", "s"));
 
@@ -682,7 +684,7 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
                if(fd_head && fd_head->next) {
                        proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
                          "IDMP segment data (%u byte%s)", idmp_length,
-                         plurality(idmp_length, "", "s"));     
+                         plurality(idmp_length, "", "s"));
 
                        if (idmp_final) {
                        /* This is the last segment */
@@ -695,17 +697,17 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
                                tvb, 0, 0, fd_head->reassembled_in);
                        }
                }
-       
-       } else { 
+
+       } else {
                if(!idmp_final) {
 
                        if (check_col(pinfo->cinfo, COL_INFO))
-                               col_append_fstr(pinfo->cinfo, COL_INFO, " [IDMP fragment, %u byte%s, IDMP reassembly not enabled]", 
+                               col_append_fstr(pinfo->cinfo, COL_INFO, " [IDMP fragment, %u byte%s, IDMP reassembly not enabled]",
                                        idmp_length, plurality(idmp_length, "", "s"));
 
                        proto_tree_add_text(tree, tvb, offset, (idmp_length) ? -1 : 0,
                                "IDMP segment data (%u byte%s) (IDMP reassembly not enabled)", idmp_length,
-                               plurality(idmp_length, "", "s"));               
+                               plurality(idmp_length, "", "s"));
                }
        }
        /* not reassembling - just dissect */
@@ -716,7 +718,7 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t
                offset = dissect_idmp_IDM_PDU(FALSE, tvb, offset, &asn1_ctx, tree, hf_idmp_PDU);
 
                pinfo->private_data = save_private_data;
-       } 
+       }
 
 }
 
@@ -790,6 +792,9 @@ void proto_register_idmp(void) {
     { &hf_idmp_fragment_error,
       { "IDMP defragmentation error", "idmp.fragment.error", FT_FRAMENUM,
        BASE_NONE, NULL, 0x00, NULL, HFILL } },
+    { &hf_idmp_fragment_count,
+      { "IDMP fragment count", "idmp.fragment.count", FT_UINT32, BASE_DEC,
+       NULL, 0x00, NULL, HFILL } },
     { &hf_idmp_reassembled_in,
       { "Reassembled IDMP in frame", "idmp.reassembled.in", FT_FRAMENUM, BASE_NONE,
        NULL, 0x00, "This IDMP packet is reassembled in this frame", HFILL } },
@@ -799,7 +804,7 @@ void proto_register_idmp(void) {
 
 
 /*--- Included file: packet-idmp-hfarr.c ---*/
-#line 1 "packet-idmp-hfarr.c"
+#line 1 "../../asn1/idmp/packet-idmp-hfarr.c"
     { &hf_idmp_bind,
       { "bind", "idmp.bind",
         FT_NONE, BASE_NONE, NULL, 0,
@@ -930,7 +935,7 @@ void proto_register_idmp(void) {
         NULL, HFILL }},
 
 /*--- End of included file: packet-idmp-hfarr.c ---*/
-#line 319 "packet-idmp-template.c"
+#line 324 "../../asn1/idmp/packet-idmp-template.c"
   };
 
   /* List of subtrees */
@@ -940,7 +945,7 @@ void proto_register_idmp(void) {
     &ett_idmp_fragments,
 
 /*--- Included file: packet-idmp-ettarr.c ---*/
-#line 1 "packet-idmp-ettarr.c"
+#line 1 "../../asn1/idmp/packet-idmp-ettarr.c"
     &ett_idmp_IDM_PDU,
     &ett_idmp_IdmBind,
     &ett_idmp_IdmBindResult,
@@ -953,7 +958,7 @@ void proto_register_idmp(void) {
     &ett_idmp_InvokeId,
 
 /*--- End of included file: packet-idmp-ettarr.c ---*/
-#line 327 "packet-idmp-template.c"
+#line 332 "../../asn1/idmp/packet-idmp-template.c"
   };
   module_t *idmp_module;
 
@@ -984,7 +989,7 @@ void proto_register_idmp(void) {
                                 " To use this option, you must also enable"
                                 " \"Allow subdissectors to reassemble TCP streams\""
                                 " in the TCP protocol settings.", &idmp_reassemble);
-  
+
   prefs_register_uint_preference(idmp_module, "tcp.port", "IDMP TCP Port",
                                 "Set the port for Internet Directly Mapped Protocol requests/responses",
                                 10, &global_idmp_tcp_port);
@@ -1001,17 +1006,19 @@ void proto_reg_handoff_idm(void) {
 }
 
 
-void prefs_register_idmp(void) {
+static void
+prefs_register_idmp(void)
+{
 
   /* de-register the old port */
   /* port 102 is registered by TPKT - don't undo this! */
   if(idmp_handle)
-    dissector_delete("tcp.port", tcp_port, idmp_handle);
+    dissector_delete_uint("tcp.port", tcp_port, idmp_handle);
 
   /* Set our port number for future use */
   tcp_port = global_idmp_tcp_port;
 
   if((tcp_port > 0) && idmp_handle)
-    dissector_add("tcp.port", global_idmp_tcp_port, idmp_handle);
+    dissector_add_uint("tcp.port", global_idmp_tcp_port, idmp_handle);
 
 }