aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/rspro/packet-rspro-template.c
blob: 24e655e181f32913b696f41522311f819b8f11ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* packet-rspro.c
 * Routines for RSPRO (Remote SIM Protocol) packet dissection
 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#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-rspro.h"

#define PNAME  "Remote SIM Protocol"
#define PSNAME "RSPRO"
#define PFNAME "rspro"
#define IPAC_PROTO_EXT_RSPRO 0x07
static dissector_handle_t rspro_handle=NULL;

void proto_reg_handoff_rspro(void);
void proto_register_rspro(void);

/* Initialize the protocol and registered fields */
static int proto_rspro = -1;

#include "packet-rspro-hf.c"

/* Initialize the subtree pointers */
static int ett_rspro = -1;

#include "packet-rspro-ett.c"

#include "packet-rspro-fn.c"


static int
dissect_rspro(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	proto_item      *rspro_item = NULL;
	proto_tree      *rspro_tree = NULL;

	/* make entry in the Protocol column on summary display */
	col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);

	/* create the rspro protocol tree */
	if (tree) {
		rspro_item = proto_tree_add_item(tree, proto_rspro, tvb, 0, -1, FALSE);
		rspro_tree = proto_item_add_subtree(rspro_item, ett_rspro);

		dissect_RsproPDU_PDU(tvb, pinfo, rspro_tree, data);
	}

	return tvb_captured_length(tvb);
}

/*--- proto_register_rspro -------------------------------------------*/
void proto_register_rspro(void) {
	/* List of fields */
	static hf_register_info hf[] = {
#include "packet-rspro-hfarr.c"
	};

	/* List of subtrees */
	static gint *ett[] = {
		  &ett_rspro,
#include "packet-rspro-ettarr.c"
	};

	/* Register protocol */
	proto_rspro = proto_register_protocol(PNAME, PSNAME, PFNAME);
	/* Register fields and subtrees */
	proto_register_field_array(proto_rspro, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}


/*--- proto_reg_handoff_rspro ---------------------------------------*/
void
proto_reg_handoff_rspro(void)
{
	rspro_handle = create_dissector_handle(dissect_rspro, proto_rspro);
	dissector_add_uint_with_preference("ipa.osmo.protocol", IPAC_PROTO_EXT_RSPRO, rspro_handle);
}