f5e76e4a8cdd2032beda1271b4f890bb7d80ebb3
[obnox/wireshark/wip.git] / asn1 / s4406 / packet-s4406-template.c
1 /* packet-s4406.c
2  * Routines for STANAG 4406 (X.400 Military Message Extensions)  packet dissection
3  * Graeme Lunt 2005
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/conversation.h>
33 #include <epan/asn1.h>
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include "packet-ber.h"
39
40 #include "packet-x509if.h"
41
42 #include "packet-s4406.h"
43 #include "packet-x411.h" 
44 #include "packet-x420.h" 
45
46 #define PNAME  "STANAG 4406 Military Message"
47 #define PSNAME "STANAG 4406"
48 #define PFNAME "s4406"
49
50 /* Initialize the protocol and registered fields */
51 int proto_s4406 = -1;
52
53 #include "packet-s4406-hf.c"
54
55 /* Initialize the subtree pointers */
56 static gint ett_s4406 = -1;
57 #include "packet-s4406-ett.c"
58
59 #include "packet-s4406-fn.c"
60
61
62 /*
63 * Dissect STANAG 4406 PDUs inside a PPDU.
64 */
65 static void
66 dissect_s4406(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
67 {
68         int offset = 0;
69         proto_item *item=NULL;
70         proto_tree *tree=NULL;
71         asn1_ctx_t asn1_ctx;
72         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
73
74         if(parent_tree){
75                 item = proto_tree_add_item(parent_tree, proto_s4406, tvb, 0, -1, FALSE);
76                 tree = proto_item_add_subtree(item, ett_s4406);
77         }
78
79         if (check_col(pinfo->cinfo, COL_PROTOCOL))
80                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "S4406");
81         if (check_col(pinfo->cinfo, COL_INFO))
82           col_set_str(pinfo->cinfo, COL_INFO, "Military");
83
84         dissect_s4406_InformationObject(TRUE, tvb, offset, &asn1_ctx , tree, -1);
85 }
86
87
88
89 /*--- proto_register_s4406 -------------------------------------------*/
90 void proto_register_s4406(void) {
91
92   /* List of fields */
93   static hf_register_info hf[] =
94   {
95 #include "packet-s4406-hfarr.c"
96   };
97
98   /* List of subtrees */
99   static gint *ett[] = {
100     &ett_s4406,
101 #include "packet-s4406-ettarr.c"
102   };
103
104   /* Register protocol */
105   proto_s4406 = proto_register_protocol(PNAME, PSNAME, PFNAME);
106
107   /* Register fields and subtrees */
108   proto_register_field_array(proto_s4406, hf, array_length(hf));
109   proto_register_subtree_array(ett, array_length(ett));
110
111 }
112
113
114 /*--- proto_reg_handoff_s4406 --- */
115 void proto_reg_handoff_s4406(void) {
116 #include "packet-s4406-dis-tab.c"
117
118   register_ber_oid_dissector("1.3.26.0.4406.0.4.1", dissect_s4406, proto_s4406, "Military Message");
119
120   register_ber_syntax_dissector("MilitaryMessage", proto_s4406, dissect_s4406); 
121   register_ber_oid_syntax(".p772", NULL, "MilitaryMessage");
122
123 }