Make yes_no work in "dissect_netware_ip_suboption()" the way it works
[obnox/wireshark/wip.git] / tap-smbsids.c
1 /* tap-smbsids.c
2  * smbstat   2003 Ronnie Sahlberg
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
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 /* With MSVC and a libethereal.dll this file needs to import some variables 
26    in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */   
27 #define _NEED_VAR_IMPORT_
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <stdio.h>
34
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>
37 #endif
38
39 #include <string.h>
40 #include "epan/packet_info.h"
41 #include <epan/dissectors/packet-smb-sidsnooping.h>
42 #include "register.h"
43 #include <epan/tap.h>
44 #include "epan/value_string.h"
45 #include "smb.h"
46
47
48 static int
49 smbsids_packet(void *pss _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void *psi _U_)
50 {
51         return 1;
52 }
53
54 static void 
55 enum_sids(gpointer key _U_, gpointer value, gpointer userdata _U_)
56 {
57         sid_name *sn=(sid_name *)value;
58
59         printf("%-60s %s\n", sn->sid, sn->name);
60         return;
61 }
62
63 static void
64 smbsids_draw(void *pss _U_)
65 {
66         printf("\n");
67         printf("===================================================================\n");
68         printf("SMB SID List:\n");
69         g_hash_table_foreach(sid_name_table, enum_sids, NULL);
70         printf("===================================================================\n");
71 }
72
73
74 static void
75 smbsids_init(char *optarg _U_)
76 {
77         GString *error_string;
78
79         if(!sid_name_snooping){
80                 fprintf(stderr,"The -z smb,sids function needs SMB/SID-Snooping to be enabled.\n");
81                 fprintf(stderr,"Either enable Edit/Preferences/Protocols/SMB/Snoop SID name mappings  in ethereal\n");
82                 fprintf(stderr,"or override the preference file by specifying\n");
83                 fprintf(stderr,"  -o \"smb.sid_name_snooping=TRUE\"\n");
84                 fprintf(stderr,"on the tethereal command line.\n");
85                 exit(1);
86         }
87
88
89         error_string=register_tap_listener("smb", NULL, NULL, NULL, smbsids_packet, smbsids_draw);
90         if(error_string){
91                 fprintf(stderr, "tethereal: Couldn't register smb,sids tap:%s\n",
92                     error_string->str);
93                 g_string_free(error_string, TRUE);
94                 exit(1);
95         }
96 }
97
98
99 void
100 register_tap_listener_smbsids(void)
101 {
102         register_ethereal_tap("smb,sids", smbsids_init);
103 }
104