Conformance File (.cnf)
The .cnf file tells the compiler what to do with certain things, skip auto generation for some ASN1 entries etc.. The "headings" are: (Text in quotes are added here only)
Directives |
|
#.OPT |
Compiler options |
#.MODULE |
Assign Wireshark protocol name to ASN.1 module name |
Include another conformance file |
|
Export type or information object class |
|
Create PDU functions and register them optionally to dissector table |
|
#.CLASS |
Declare or define information object class |
#.ASSIGNED_OBJECT_IDENTIFIER |
Declare assigned object identifier |
#.TABLE_HDR |
User tables |
#.TABLE_BODY |
|
#.TABLE_FTR |
|
#.OMIT_ASSIGNMENT |
Ignore assignments from ASN.1 source |
#.NO_OMIT_ASSGN |
|
#.OMIT_ALL_ASSIGNMENTS |
|
#.OMIT_ASSIGNMENTS_EXCEPT |
|
#.OMIT_ALL_TYPE_ASSIGNMENTS |
|
#.OMIT_TYPE_ASSIGNMENTS_EXCEPT |
|
#.OMIT_ALL_VALUE_ASSIGNMENTS |
|
#.OMIT_VALUE_ASSIGNMENTS_EXCEPT |
|
|
|
#.VIRTUAL_ASSGN |
|
#.SET_TYPE |
|
#.MAKE_ENUM |
|
#.MAKE_DEFINES |
|
#.ASSIGN_VALUE_TO_TYPE |
|
#.TYPE_RENAME |
Type/field renaming |
#.FIELD_RENAME |
|
#.TF_RENAME |
|
#.IMPORT_TAG |
Type attributes |
#.TYPE_ATTR |
|
#.FIELD_ATTR |
|
#.FN_HDR |
Type function modification |
#.FN_FTR |
|
#.FN_PARS |
|
End of directive |
|
#.END_OF_CNF |
End of conformance file |
Example .cnf File
#.MODULE IMPORT
InformationFramework x509if
#.INCLUDE ../x509if/x509if_exp.cnf
#.EXPORTS
ObjectName
#.PDU
ObjectName
#.REGISTER
Certificate B "2.5.4.36" "id-at-userCertificate"
#.NO EMIT
Type1 [WITH_VALS|WITHOUT_VALS|ONLY_VALS]
#.USER DEFINED
Type1 [WITH_VALS|WITHOUT_VALS|ONLY_VALS]
#.TYPE_RENAME
#.FIELD_RENAME
#.TYPE_ATTR Ss-Code TYPE = FT_UINT16 DISPLAY = BASE_HEX STRINGS = VALS(ssCode_vals)
" This entry will change the hf definition from the auto-generated one for Ss-Code ::= OCTET STRING(SIZE(1))
{ &hf_gsm_map_ss_Code,
- { "ss-Code", "gsm_map.ss_Code",
- FT_BYTES, BASE_HEX, NULL, 0, "", HFILL }},
- { "ss-Code", "gsm_map.ss_Code",
to:
{ &hf_gsm_map_ss_Code,
- { "ss-Code", "gsm_map.ss_Code",
- FT_UINT16, BASE_HEX, VALS(ssCode_vals), 0, "", HFILL }},
- { "ss-Code", "gsm_map.ss_Code",
In the proto_abr-template.c file the corresponding value string must be inserted."
Foo is expressed in different ways depending on where you want to insert your codeasnd the ASN1 code in question.
- Foo
- Foo/foo
- Foo/_item/foo
For Tagged type use:
- Foo/_untag
#.FN_HDR Foo
#.FN_BODY Foo
/* This here is code to replace the actual call to the helper completely */
offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, &out_tvb);
Puting %(DEFAULT_BODY)s inside #.FN_BODY will insert the original code there.
#.FN_FTR Foo
/* this is code to be inserted into the dissector for Foo AFTER the ber/per helper has returned called*/
if(foo_reassemble){
..
#.FN_PARS
#.END
Example packet-protocol-template.h File
Example template.h file.
Replace all PROTOCOL/protocol references with the name of your protocol.
/* packet-protocol.h * Routines for Protocol packet dissection * * $Id$ * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PACKET_PROTOCOL_H #define PACKET_PROTOCOL_H #include "packet-protocol-exp.h" #endif /* PACKET_PROTOCOL_H */
Example packet-protocol-template.c File
Example template.c file.
Replace all PROTOCOL/protocol references with the name of your protocol.
/* packet-protocol.c
* Routines for PROTOCOL packet dissection
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
#include <epan/packet.h>
#include <epan/conversation.h>
#include <stdio.h>
#include <string.h>
#include "packet-ber.h"
#include "packet-protocol.h"
#define PNAME "This Is The Protocol Name"
#define PSNAME "PROTOCOL"
#define PFNAME "protocol"
/* Initialize the protocol and registered fields */
int proto_protocol = -1;
#include "packet-protocol-hf.c"
/* Initialize the subtree pointers */
#include "packet-protocol-ett.c"
#include "packet-protocol-fn.c"
/*--- proto_register_protocol ----------------------------------------------*/
void proto_register_protocol(void) {
/* List of fields */
static hf_register_info hf[] = {
#include "packet-protocol-hfarr.c"
};
/* List of subtrees */
static gint *ett[] = {
#include "packet-protocol-ettarr.c"
};
/* Register protocol */
proto_protocol = proto_register_protocol(PNAME, PSNAME, PFNAME);
/* Register fields and subtrees */
proto_register_field_array(proto_protocol, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
/*--- proto_reg_handoff_protocol -------------------------------------------*/
void proto_reg_handoff_protocol(void) {
#include "packet-protocol-dis-tab.c"
}