Get rid of -Wshadow warning - I guess we're including something that
[metze/wireshark/wip.git] / ui / cli / tap-smbsids.c
1 /* tap-smbsids.c
2  * smbstat   2003 Ronnie Sahlberg
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #include "config.h"
26
27 #include <stdio.h>
28
29 #include <string.h>
30 #include "epan/packet_info.h"
31 #include <epan/dissectors/packet-smb-sidsnooping.h>
32 #include <epan/tap.h>
33 #include <epan/stat_cmd_args.h>
34 #include "epan/value_string.h"
35 #include <epan/dissectors/packet-smb.h>
36
37
38 static int
39 smbsids_packet(void *pss _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *psi _U_)
40 {
41         return 1;
42 }
43
44 static void
45 enum_sids(gpointer key _U_, gpointer value, gpointer userdata _U_)
46 {
47         sid_name *sn=(sid_name *)value;
48
49         printf("%-60s %s\n", sn->sid, sn->name);
50         return;
51 }
52
53 static void
54 smbsids_draw(void *pss _U_)
55 {
56         printf("\n");
57         printf("===================================================================\n");
58         printf("SMB SID List:\n");
59         g_hash_table_foreach(sid_name_table, enum_sids, NULL);
60         printf("===================================================================\n");
61 }
62
63
64 static void
65 smbsids_init(const char *opt_arg _U_, void* userdata _U_)
66 {
67         GString *error_string;
68
69         if(!sid_name_snooping){
70                 fprintf(stderr,"The -z smb,sids function needs SMB/SID-Snooping to be enabled.\n");
71                 fprintf(stderr,"Either enable Edit/Preferences/Protocols/SMB/Snoop SID name mappings  in wireshark\n");
72                 fprintf(stderr,"or override the preference file by specifying\n");
73                 fprintf(stderr,"  -o \"smb.sid_name_snooping=TRUE\"\n");
74                 fprintf(stderr,"on the tshark command line.\n");
75                 exit(1);
76         }
77
78
79         error_string=register_tap_listener("smb", NULL, NULL, 0, NULL, smbsids_packet, smbsids_draw);
80         if(error_string){
81                 fprintf(stderr, "tshark: Couldn't register smb,sids tap:%s\n",
82                     error_string->str);
83                 g_string_free(error_string, TRUE);
84                 exit(1);
85         }
86 }
87
88
89 void
90 register_tap_listener_smbsids(void)
91 {
92         register_stat_cmd_arg("smb,sids", smbsids_init,NULL);
93 }
94