Future tense -> present tense for the encoding argument to
[obnox/wireshark/wip.git] / tap-sv.c
1 /* tap-sv.c
2  * Copyright 2008 Michael Bernhard
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <stdio.h>
31 #include <stdlib.h>
32
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
35 #endif
36
37 #include <string.h>
38 #include <epan/packet_info.h>
39 #include <epan/tap.h>
40 #include <epan/stat_cmd_args.h>
41 #include <epan/nstime.h>
42 #include <epan/dissectors/packet-sv.h>
43
44 static int
45 sv_packet(void *prs _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri)
46 {
47         int i;
48         const sv_frame_data * sv_data = pri;
49
50         printf("%f %u ", nstime_to_sec(&pinfo->fd->rel_ts), sv_data->smpCnt);
51
52         for(i = 0; i < sv_data->num_phsMeas; i++) {
53                 printf("%d ", sv_data->phsMeas[i].value);
54         }
55
56         printf("\n");
57
58         return 0;
59 }
60
61 static void
62 svstat_init(const char *optarg _U_, void* userdata _U_)
63 {
64         GString *error_string;
65
66         error_string = register_tap_listener(
67                         "sv",
68                         NULL,
69                         NULL,
70                         0,
71                         NULL,
72                         sv_packet,
73                         NULL);
74         if (error_string){
75                 /* error, we failed to attach to the tap. clean up */
76                 fprintf(stderr, "tshark: Couldn't register sv,stat tap: %s\n",
77                                 error_string->str);
78                 g_string_free(error_string, TRUE);
79                 exit(1);
80         }
81 }
82
83 void
84 register_tap_listener_sv(void)
85 {
86         register_stat_cmd_arg("sv", svstat_init, NULL);
87 }