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

#.MODULE_IMPORT

#.INCLUDE

Include another conformance file

#.EXPORTS

Export type or information object class

#.PDU

Create PDU functions and register them optionally to dissector table

#.PDU_NEW

#.REGISTER

#.REGISTER_NEW

#.SYNTAX

#.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

#.NO_EMIT

See linked text for info

#.USER_DEFINED

#.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_BODY

#.FN_FTR

#.FN_PARS

#.END

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"

#.SYNTAX
ObjectName [FriendlyName]

#.NO_EMIT ONLY_VALS
# this can be used with: [WITH_VALS|WITHOUT_VALS|ONLY_VALS]
# using NO_EMIT NO_VALS means it won't generate value_string array for it
Type1

#.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))

to:

In the proto_abr-template.c file the corresponding value string must be inserted. As an example the following would be included in proto_abr-template.c to define ssCode_vals:

static const value_string ssCode_vals[] = {
   { 0, "ssCodeString 1" },     /* The string for value 0 */
   { 1, "String 2" },           /* String for value 1 */
   { 5, "String for value 5" }, /* Value String 5 */
   { 0, NULL }                  /* Null terminated array */
}

Note that the NULL value must be the final entry and that the index values need not be consecutive.

Foo is expressed in different ways depending on where you want to insert your codeasnd the ASN1 code in question.

For Tagged type use:

#.FN_HDR Foo

#.FN_BODY Foo

#.FN_FTR Foo

#.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"
}

Asn2wrsAuxiliary (last edited 2014-03-15 15:39:03 by HadrielKaplan)