From Graeme Lunt:
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 4 Sep 2005 09:00:01 +0000 (09:00 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 4 Sep 2005 09:00:01 +0000 (09:00 +0000)
Basically the changes are:
a) [pres] make the find_oid_by_[pres_]ctx_id (I changed the name to make it more specific) non-static so it can be called from other dissectors (see acse.cnf changes). I also call it from RTSE and ROS dissectors
b) [acse] remove (#ifdef NOT_NEEDED) the oid lookup table and any reference to acse_handle - as these are no longer needed
c) [acse] register the acse dissector on 2.2.1.0.1
with some modifications: -#ifdef:ed code removed
- renamed aco -> pco

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15678 f5534014-38df-0310-8fa8-9805f1628bb7

asn1/acse/acse.cnf
asn1/acse/packet-acse-template.c
asn1/pres/packet-pres-template.c
asn1/pres/packet-pres-template.h
asn1/pres/pres.cnf
epan/dissectors/packet-acse.c
epan/dissectors/packet-acse.h
epan/dissectors/packet-pres.c
epan/dissectors/packet-pres.h

index 92d038e7d71ede76d780a8ac3f5b64293dbf733b..34b5c79526db556becf044b363acd57a5ccf0d45 100644 (file)
@@ -76,10 +76,19 @@ ACRQ-apdu/aSO-context-name  aCRQ_aSO_context_name
                                          hf_index, object_identifier_id);
 
 #.FN_BODY EXTERNAL/indirect-reference
+  char *oid;
   offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset,
                 hf_acse_indirect_reference,
                 &indir_ref);
 
+  /* look up the indirect reference */
+  if(oid = find_oid_by_pres_ctx_id(pinfo, indir_ref)) {
+    strcpy(object_identifier_id, oid);
+  }
+
+  if(session)
+       session->pres_ctx_id = indir_ref;
+
 #.FN_BODY EXTERNAL/encoding/single-ASN1-type
   offset=call_ber_oid_callback(object_identifier_id, tvb, offset, pinfo, top_tree);
 
index ad51c59bd94f67e81c280b42ddbe10bef04a8119..abda0486de343baf3ac0afd545b9cf500d1680ba 100644 (file)
@@ -49,6 +49,7 @@
 #include "packet-ber.h"
 #include "packet-acse.h"
 #include "packet-ses.h"
+#include "packet-pres.h"
 #include "packet-x509if.h"
 
 #define PNAME  "ACSE"
@@ -72,6 +73,7 @@ static guint32 indir_ref=0;
 
 static proto_tree *top_tree=NULL;
 
+#if NOT_NEEDED
 /* to keep track of presentation context identifiers and protocol-oids */
 typedef struct _acse_ctx_oid_t {
        /* XXX here we should keep track of ADDRESS/PORT as well */
@@ -134,6 +136,7 @@ find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx)
        return NULL;
 }
 
+# endif /* NOT_NEEDED */
 
 #include "packet-acse-fn.c"
 
@@ -182,14 +185,14 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
        /*  data pdu is not ACSE pdu and has to go directly to app dissector */
        switch(session->spdu_type){
        case SES_CONNECTION_REQUEST:            /*   AARQ   */
-       case SES_CONNECTION_ACCEPT:                     /*   AARE   */
-       case SES_REFUSE:                                        /*   RLRE   */
-       case SES_DISCONNECT:                            /*   RLRQ   */
-       case SES_FINISH:                                        /*   RLRE   */
-       case SES_ABORT:                                         /*   ABRT   */
+       case SES_CONNECTION_ACCEPT:             /*   AARE   */
+       case SES_REFUSE:                        /*   RLRE   */
+       case SES_DISCONNECT:                    /*   RLRQ   */
+       case SES_FINISH:                        /*   RLRE   */
+       case SES_ABORT:                         /*   ABRT   */
                break;
        case SES_DATA_TRANSFER:
-               oid=find_oid_by_ctx_id(pinfo, indir_ref);
+               oid=find_oid_by_pres_ctx_id(pinfo, indir_ref);
                if(oid){
                        call_ber_oid_callback(oid, tvb, offset, pinfo, parent_tree);
                } else {
@@ -223,18 +226,6 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                }
        }
 
-       switch(session->spdu_type){
-       case SES_CONNECTION_REQUEST:            /*   AARQ   */
-       case SES_CONNECTION_ACCEPT:                     /*   AARE   */
-               /* these two functions are used to set up the association
-                  between a presentation identifier (indir_ref) and
-                  a protocol identified by a oid.
-                  it is ugly to handle it with global variables but
-                  better than nothing.
-               */
-               register_ctx_id_and_oid(pinfo, indir_ref, object_identifier_id);
-               break;
-       }
 }
 
 /*--- proto_register_acse ----------------------------------------------*/
@@ -259,14 +250,16 @@ void proto_register_acse(void) {
   proto_register_field_array(proto_acse, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
-  register_init_routine(acse_init);
 }
 
 
 /*--- proto_reg_handoff_acse -------------------------------------------*/
 void proto_reg_handoff_acse(void) {
 /*#include "packet-acse-dis-tab.c"*/
-       register_ber_oid_dissector("2.2.3.1.1", dissect_acse, proto_acse, "acse");
+
+       register_ber_oid_name("2.2.3.1.1","aCSE-id");
        register_ber_oid_dissector("2.2.1.0.1", dissect_acse, proto_acse, "acse-as-id");
+
+
 }
 
index 82b5e4aae2558b45454b7ec4ed8a7a4126bef211..bddc97f1a0bb4a0ca26126981c56a6844be3d4d0 100644 (file)
@@ -53,9 +53,9 @@ static struct SESSION_DATA_STRUCTURE* session = NULL;
 /*      pointers for acse dissector  */
 proto_tree *global_tree  = NULL;
 packet_info *global_pinfo = NULL;
+
 /* dissector for data */
 static dissector_handle_t data_handle;
-static dissector_handle_t acse_handle;
 
 static char abstract_syntax_name_oid[BER_MAX_OID_STR_LEN];
 static guint32 presentation_context_identifier;
@@ -79,16 +79,16 @@ static gint ett_pres           = -1;
 static guint
 pres_ctx_oid_hash(gconstpointer k)
 {
-       pres_ctx_oid_t *aco=(pres_ctx_oid_t *)k;
-       return aco->ctx_id;
+       pres_ctx_oid_t *pco=(pres_ctx_oid_t *)k;
+       return pco->ctx_id;
 }
 /* XXX this one should be made ADDRESS/PORT aware */
 static gint
 pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2)
 {
-       pres_ctx_oid_t *aco1=(pres_ctx_oid_t *)k1;
-       pres_ctx_oid_t *aco2=(pres_ctx_oid_t *)k2;
-       return aco1->ctx_id==aco2->ctx_id;
+       pres_ctx_oid_t *pco1=(pres_ctx_oid_t *)k1;
+       pres_ctx_oid_t *pco2=(pres_ctx_oid_t *)k2;
+       return pco1->ctx_id==pco2->ctx_id;
 }
 
 static void
@@ -106,26 +106,27 @@ pres_init(void)
 static void
 register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, char *oid)
 {
-       pres_ctx_oid_t *aco, *tmpaco;
-       aco=se_alloc(sizeof(pres_ctx_oid_t));
-       aco->ctx_id=idx;
-       aco->oid=se_strdup(oid);
+       pres_ctx_oid_t *pco, *tmppco;
+       pco=se_alloc(sizeof(pres_ctx_oid_t));
+       pco->ctx_id=idx;
+       pco->oid=se_strdup(oid);
 
        /* if this ctx already exists, remove the old one first */
-       tmpaco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, aco);
-       if(tmpaco){
-               g_hash_table_remove(pres_ctx_oid_table, tmpaco);
+       tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, pco);
+       if(tmppco){
+               g_hash_table_remove(pres_ctx_oid_table, tmppco);
+
        }
-       g_hash_table_insert(pres_ctx_oid_table, aco, aco);
+       g_hash_table_insert(pres_ctx_oid_table, pco, pco);
 }
-static char *
-find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx)
+char *
+find_oid_by_pres_ctx_id(packet_info *pinfo _U_, guint32 idx)
 {
-       pres_ctx_oid_t aco, *tmpaco;
-       aco.ctx_id=idx;
-       tmpaco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &aco);
-       if(tmpaco){
-               return tmpaco->oid;
+       pres_ctx_oid_t pco, *tmppco;
+       pco.ctx_id=idx;
+       tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &pco);
+       if(tmppco){
+               return tmppco->oid;
        }
        return NULL;
 }
@@ -261,5 +262,5 @@ void proto_reg_handoff_pres(void) {
          "itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) abstractSyntax(1) pres(1) version1(1)"); */
 
        data_handle = find_dissector("data");
-       acse_handle = find_dissector("acse");
+
 }
index 0f65aa1b032985fb179ac4b69f5938b7d40dc4e5..00590f3a0315d7b464dcb250f6516cd5ad39785a 100644 (file)
@@ -27,4 +27,6 @@
 
 /*#include "packet-pres-exp.h"*/
 
+extern char *find_oid_by_pres_ctx_id(packet_info *pinfo _U_, guint32 idx);
+
 #endif  /* PACKET_PRES_H */
index 6daf4a42d26f7c5d1d8b1f4e38eb4bef9bd899fb..120e85362f54beb3f9e79f5c7961ea17e303d787 100644 (file)
@@ -36,7 +36,7 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason
  tvbuff_t      *next_tvb;
  char *oid; 
 
-       oid=find_oid_by_ctx_id(pinfo, presentation_context_identifier);
+       oid=find_oid_by_pres_ctx_id(pinfo, presentation_context_identifier);
        if(oid){
                next_tvb = tvb_new_subset(tvb, offset, -1, -1);
                call_ber_oid_callback(oid, next_tvb, offset, pinfo, global_tree);
index 1692de78bf7592f1088ab5fca693c825d1ae6a69..a259bcd3ff05871554a2f9a8f3678705d77bd1fb 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* ./packet-acse.c                                                            */
+/* .\packet-acse.c                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p acse -c acse.cnf -s packet-acse-template acse.asn */
 
 /* Input file: packet-acse-template.c */
@@ -56,6 +56,7 @@
 #include "packet-ber.h"
 #include "packet-acse.h"
 #include "packet-ses.h"
+#include "packet-pres.h"
 #include "packet-x509if.h"
 
 #define PNAME  "ACSE"
@@ -230,6 +231,7 @@ static guint32 indir_ref=0;
 
 static proto_tree *top_tree=NULL;
 
+#if NOT_NEEDED
 /* to keep track of presentation context identifiers and protocol-oids */
 typedef struct _acse_ctx_oid_t {
        /* XXX here we should keep track of ADDRESS/PORT as well */
@@ -292,6 +294,7 @@ find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx)
        return NULL;
 }
 
+# endif /* NOT_NEEDED */
 
 
 /*--- Included file: packet-acse-fn.c ---*/
@@ -316,10 +319,19 @@ static int dissect_direct_reference(packet_info *pinfo, proto_tree *tree, tvbuff
 
 static int
 dissect_acse_T_indirect_reference(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
+  char *oid;
   offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset,
                 hf_acse_indirect_reference,
                 &indir_ref);
 
+  /* look up the indirect reference */
+  if(oid = find_oid_by_pres_ctx_id(pinfo, indir_ref)) {
+    strcpy(object_identifier_id, oid);
+  }
+
+  if(session)
+       session->pres_ctx_id = indir_ref;
+
 
   return offset;
 }
@@ -1874,14 +1886,14 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
        /*  data pdu is not ACSE pdu and has to go directly to app dissector */
        switch(session->spdu_type){
        case SES_CONNECTION_REQUEST:            /*   AARQ   */
-       case SES_CONNECTION_ACCEPT:                     /*   AARE   */
-       case SES_REFUSE:                                        /*   RLRE   */
-       case SES_DISCONNECT:                            /*   RLRQ   */
-       case SES_FINISH:                                        /*   RLRE   */
-       case SES_ABORT:                                         /*   ABRT   */
+       case SES_CONNECTION_ACCEPT:             /*   AARE   */
+       case SES_REFUSE:                        /*   RLRE   */
+       case SES_DISCONNECT:                    /*   RLRQ   */
+       case SES_FINISH:                        /*   RLRE   */
+       case SES_ABORT:                         /*   ABRT   */
                break;
        case SES_DATA_TRANSFER:
-               oid=find_oid_by_ctx_id(pinfo, indir_ref);
+               oid=find_oid_by_pres_ctx_id(pinfo, indir_ref);
                if(oid){
                        call_ber_oid_callback(oid, tvb, offset, pinfo, parent_tree);
                } else {
@@ -1915,18 +1927,6 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                }
        }
 
-       switch(session->spdu_type){
-       case SES_CONNECTION_REQUEST:            /*   AARQ   */
-       case SES_CONNECTION_ACCEPT:                     /*   AARE   */
-               /* these two functions are used to set up the association
-                  between a presentation identifier (indir_ref) and
-                  a protocol identified by a oid.
-                  it is ugly to handle it with global variables but
-                  better than nothing.
-               */
-               register_ctx_id_and_oid(pinfo, indir_ref, object_identifier_id);
-               break;
-       }
 }
 
 /*--- proto_register_acse ----------------------------------------------*/
@@ -2416,14 +2416,16 @@ void proto_register_acse(void) {
   proto_register_field_array(proto_acse, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
-  register_init_routine(acse_init);
 }
 
 
 /*--- proto_reg_handoff_acse -------------------------------------------*/
 void proto_reg_handoff_acse(void) {
 /*#include "packet-acse-dis-tab.c"*/
-       register_ber_oid_dissector("2.2.3.1.1", dissect_acse, proto_acse, "acse");
+
+       register_ber_oid_name("2.2.3.1.1","aCSE-id");
        register_ber_oid_dissector("2.2.1.0.1", dissect_acse, proto_acse, "acse-as-id");
+
+
 }
 
index 2cf1e27146a482a4a2b76c25e2bc4e48129ede9e..32bada10582a93a96d7ef75b55bc3cf7c37d7a4b 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* ./packet-acse.h                                                            */
+/* .\packet-acse.h                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p acse -c acse.cnf -s packet-acse-template acse.asn */
 
 /* Input file: packet-acse-template.h */
index 7c7fae26779e57190938a54c48871263b5d68339..9c3223872042fb68c77f94ac616aff1641f43f77 100644 (file)
@@ -60,9 +60,9 @@ static struct SESSION_DATA_STRUCTURE* session = NULL;
 /*      pointers for acse dissector  */
 proto_tree *global_tree  = NULL;
 packet_info *global_pinfo = NULL;
+
 /* dissector for data */
 static dissector_handle_t data_handle;
-static dissector_handle_t acse_handle;
 
 static char abstract_syntax_name_oid[BER_MAX_OID_STR_LEN];
 static guint32 presentation_context_identifier;
@@ -233,16 +233,16 @@ static gint ett_pres_User_session_requirements = -1;
 static guint
 pres_ctx_oid_hash(gconstpointer k)
 {
-       pres_ctx_oid_t *aco=(pres_ctx_oid_t *)k;
-       return aco->ctx_id;
+       pres_ctx_oid_t *pco=(pres_ctx_oid_t *)k;
+       return pco->ctx_id;
 }
 /* XXX this one should be made ADDRESS/PORT aware */
 static gint
 pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2)
 {
-       pres_ctx_oid_t *aco1=(pres_ctx_oid_t *)k1;
-       pres_ctx_oid_t *aco2=(pres_ctx_oid_t *)k2;
-       return aco1->ctx_id==aco2->ctx_id;
+       pres_ctx_oid_t *pco1=(pres_ctx_oid_t *)k1;
+       pres_ctx_oid_t *pco2=(pres_ctx_oid_t *)k2;
+       return pco1->ctx_id==pco2->ctx_id;
 }
 
 static void
@@ -260,26 +260,27 @@ pres_init(void)
 static void
 register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, char *oid)
 {
-       pres_ctx_oid_t *aco, *tmpaco;
-       aco=se_alloc(sizeof(pres_ctx_oid_t));
-       aco->ctx_id=idx;
-       aco->oid=se_strdup(oid);
+       pres_ctx_oid_t *pco, *tmppco;
+       pco=se_alloc(sizeof(pres_ctx_oid_t));
+       pco->ctx_id=idx;
+       pco->oid=se_strdup(oid);
 
        /* if this ctx already exists, remove the old one first */
-       tmpaco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, aco);
-       if(tmpaco){
-               g_hash_table_remove(pres_ctx_oid_table, tmpaco);
+       tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, pco);
+       if(tmppco){
+               g_hash_table_remove(pres_ctx_oid_table, tmppco);
+
        }
-       g_hash_table_insert(pres_ctx_oid_table, aco, aco);
+       g_hash_table_insert(pres_ctx_oid_table, pco, pco);
 }
-static char *
-find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx)
+char *
+find_oid_by_pres_ctx_id(packet_info *pinfo _U_, guint32 idx)
 {
-       pres_ctx_oid_t aco, *tmpaco;
-       aco.ctx_id=idx;
-       tmpaco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &aco);
-       if(tmpaco){
-               return tmpaco->oid;
+       pres_ctx_oid_t pco, *tmppco;
+       pco.ctx_id=idx;
+       tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &pco);
+       if(tmppco){
+               return tmppco->oid;
        }
        return NULL;
 }
@@ -948,7 +949,7 @@ dissect_pres_T_single_ASN1_type(gboolean implicit_tag _U_, tvbuff_t *tvb, int of
  tvbuff_t      *next_tvb;
  char *oid; 
 
-       oid=find_oid_by_ctx_id(pinfo, presentation_context_identifier);
+       oid=find_oid_by_pres_ctx_id(pinfo, presentation_context_identifier);
        if(oid){
                next_tvb = tvb_new_subset(tvb, offset, -1, -1);
                call_ber_oid_callback(oid, next_tvb, offset, pinfo, global_tree);
@@ -2245,5 +2246,5 @@ void proto_reg_handoff_pres(void) {
          "itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) abstractSyntax(1) pres(1) version1(1)"); */
 
        data_handle = find_dissector("data");
-       acse_handle = find_dissector("acse");
+
 }
index b1b35692e6f12a4b16bb85e7eb5452f32b51e8a2..8fa80518873adb9d16e3aa4bb488e357fca17a65 100644 (file)
@@ -34,4 +34,6 @@
 
 /*#include "packet-pres-exp.h"*/
 
+extern char *find_oid_by_pres_ctx_id(packet_info *pinfo _U_, guint32 idx);
+
 #endif  /* PACKET_PRES_H */