2 * camel message counter for tshark
3 * Copyright 2006 Florent DROUIN
5 * This part of code is extracted from tap-h225counter.c from Lars Roland
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include "epan/packet.h"
33 #include "epan/packet_info.h"
35 #include "epan/value_string.h"
36 #include "epan/stat_tap_ui.h"
37 #include "epan/asn1.h"
38 #include "epan/dissectors/packet-camel.h"
40 void register_tap_listener_camelcounter(void);
42 /* used to keep track of the statistics for an entire program interface */
43 struct camelcounter_t {
45 guint32 camel_msg[camel_MAX_NUM_OPR_CODES];
49 static void camelcounter_reset(void *phs)
51 struct camelcounter_t * p_counter= ( struct camelcounter_t *) phs;
52 memset(p_counter, 0, sizeof(struct camelcounter_t));
55 static int camelcounter_packet(void *phs,
56 packet_info *pinfo _U_,
57 epan_dissect_t *edt _U_,
60 struct camelcounter_t * p_counter =(struct camelcounter_t *)phs;
61 const struct camelsrt_info_t * pi = (const struct camelsrt_info_t *)phi;
62 if (pi->opcode != 255)
63 p_counter->camel_msg[pi->opcode]++;
69 static void camelcounter_draw(void *phs)
71 struct camelcounter_t * p_counter= (struct camelcounter_t *)phs;
74 printf("CAMEL Message and Response Status Counter:\n");
75 printf("------------------------------------------\n");
77 for (i=0; i<camel_MAX_NUM_OPR_CODES; i++) {
79 if (p_counter->camel_msg[i] != 0) {
80 printf("%30s ", val_to_str(i, camel_opr_code_strings, "Unknown message "));
81 printf("%6d\n", p_counter->camel_msg[i]);
84 printf("------------------------------------------\n");
87 static void camelcounter_init(const char *opt_arg, void *userdata _U_)
89 struct camelcounter_t *p_camelcounter;
90 GString *error_string;
92 p_camelcounter = g_new(struct camelcounter_t, 1);
93 if (!strncmp(opt_arg, "camel,counter,", 13)) {
94 p_camelcounter->filter = g_strdup(opt_arg+13);
96 p_camelcounter->filter = NULL;
99 camelcounter_reset(p_camelcounter);
101 error_string = register_tap_listener("CAMEL",
103 p_camelcounter->filter,
110 /* error, we failed to attach to the tap. clean up */
111 g_free(p_camelcounter->filter);
112 g_free(p_camelcounter);
114 fprintf(stderr, "tshark: Couldn't register camel,counter tap: %s\n",
116 g_string_free(error_string, TRUE);
121 static stat_tap_ui camelcounter_ui = {
122 REGISTER_STAT_GROUP_GENERIC,
131 void /* Next line mandatory */
132 register_tap_listener_camelcounter(void)
134 register_stat_tap_ui(&camelcounter_ui, NULL);
138 * Editor modelines - http://www.wireshark.org/tools/modelines.html
143 * indent-tabs-mode: nil
146 * ex: set shiftwidth=2 tabstop=8 expandtab:
147 * :indentSize=2:tabSize=8:noTabs=true: