Don't destroy something if it doesn't exist.
[obnox/wireshark/wip.git] / gtk / ncp_stat.c
1 /* ncp_stat.c
2  * ncp_stat   2005 Greg Morris
3  *
4  * $Id: ncp_stat.c 00000 2005-09-22 11:09:36Z xxx $
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 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
31 #endif
32
33 #include <string.h>
34
35 #include <gtk/gtk.h>
36
37 #include <epan/packet_info.h>
38 #include <epan/epan.h>
39 #include <epan/value_string.h>
40
41 #include <epan/tap.h>
42 #include <epan/dissectors/packet-ncp-int.h>
43 #include "../register.h"
44 #include "../timestats.h"
45 #include "compat_macros.h"
46 #include "../simple_dialog.h"
47 #include "gui_utils.h"
48 #include "dlg_utils.h"
49 #include "../file.h"
50 #include "../globals.h"
51 #include "filter_dlg.h"
52 #include "service_response_time_table.h"
53 #include "../stat_menu.h"
54 #include "../tap_dfilter_dlg.h"
55 #include "gtkglobals.h"
56
57
58 /* used to keep track of the statistics for an entire program interface */
59 typedef struct _ncpstat_t {
60         GtkWidget *win;
61         srt_stat_table ncp_srt_table;
62     srt_stat_table nds_srt_table;
63     srt_stat_table func_srt_table;
64     srt_stat_table sss_srt_table;
65     srt_stat_table nmas_srt_table;
66     srt_stat_table sub_17_srt_table;
67     srt_stat_table sub_21_srt_table;
68     srt_stat_table sub_22_srt_table;
69     srt_stat_table sub_23_srt_table;
70     srt_stat_table sub_32_srt_table;
71     srt_stat_table sub_34_srt_table;
72     srt_stat_table sub_35_srt_table;
73     srt_stat_table sub_36_srt_table;
74     srt_stat_table sub_86_srt_table;
75     srt_stat_table sub_87_srt_table;
76     srt_stat_table sub_89_srt_table;
77     srt_stat_table sub_90_srt_table;
78     srt_stat_table sub_92_srt_table;
79     srt_stat_table sub_94_srt_table;
80     srt_stat_table sub_104_srt_table;
81     srt_stat_table sub_111_srt_table;
82     srt_stat_table sub_114_srt_table;
83     srt_stat_table sub_123_srt_table;
84     srt_stat_table sub_131_srt_table;
85 } ncpstat_t;
86
87 static const value_string ncp_group_vals[] = {
88         { 0, "Synchronization" },
89         { 1, "Print" },
90         { 2, "File System" },
91         { 3, "Connection" },
92         { 4, "File Server Environment" },
93         { 5, "Message" },
94         { 6, "Bindery" },
95         { 7, "Queue Management System (QMS)" },
96         { 8, "Accounting" },
97         { 9, "Transaction Tracking" },
98         { 10, "AFP" },
99         { 11, "NCP Extension" },
100         { 12, "Extended Attribute" },
101         { 13, "Auditing" },
102         { 14, "Enhanced File System" },
103         { 15, "Migration" },
104         { 16, "Novell Modular Authentication Services (NMAS)" },
105         { 17, "Secret Store Services (SSS)" },
106         { 18, "Packet Burst" },
107         { 19, "Novell Directory Services (NDS)" },
108         { 20, "Time Synchronization" },
109         { 21, "Server Statistics" },
110         { 22, "Remote" }
111 };
112
113 static const value_string sss_verb_enum[] = {
114     { 0x00000000, "Query Server" },
115     { 0x00000001, "Read App Secrets" },
116     { 0x00000002, "Write App Secrets" },
117     { 0x00000003, "Add Secret ID" },
118     { 0x00000004, "Remove Secret ID" },
119     { 0x00000005, "Remove SecretStore" },
120     { 0x00000006, "Enumerate Secret IDs" },
121     { 0x00000007, "Unlock Store" },
122     { 0x00000008, "Set Master Password" },
123     { 0x00000009, "Get Service Information" },
124     { 0x000000ff, "Fragment"},
125 };
126
127 static const value_string nmas_subverb_enum[] = {
128     { 0, "Fragmented Ping" },
129     { 2, "Client Put Data" },
130     { 4, "Client Get Data" },
131     { 6, "Client Get User NDS Credentials" },
132     { 8, "Login Store Management" },
133     { 10, "Writable Object Check" },
134     { 1242, "Message Handler" },
135 };
136
137 static const value_string ncp_nds_verb_vals[] = {
138         { 1, "Resolve Name" },
139         { 2, "Read Entry Information" },
140         { 3, "Read" },
141         { 4, "Compare" },
142         { 5, "List" },
143         { 6, "Search Entries" },
144         { 7, "Add Entry" },
145         { 8, "Remove Entry" },
146         { 9, "Modify Entry" },
147         { 10, "Modify RDN" },
148         { 11, "Create Attribute" },
149         { 12, "Read Attribute Definition" },
150         { 13, "Remove Attribute Definition" },
151         { 14, "Define Class" },
152         { 15, "Read Class Definition" },
153         { 16, "Modify Class Definition" },
154         { 17, "Remove Class Definition" },
155         { 18, "List Containable Classes" },
156         { 19, "Get Effective Rights" },
157         { 20, "Add Partition" },
158         { 21, "Remove Partition" },
159         { 22, "List Partitions" },
160         { 23, "Split Partition" },
161         { 24, "Join Partitions" },
162         { 25, "Add Replica" },
163         { 26, "Remove Replica" },
164         { 27, "Open Stream" },
165         { 28, "Search Filter" },
166         { 29, "Create Subordinate Reference" },
167         { 30, "Link Replica" },
168         { 31, "Change Replica Type" },
169         { 32, "Start Update Schema" },
170         { 33, "End Update Schema" },
171         { 34, "Update Schema" },
172         { 35, "Start Update Replica" },
173         { 36, "End Update Replica" },
174         { 37, "Update Replica" },
175         { 38, "Synchronize Partition" },
176         { 39, "Synchronize Schema" },
177         { 40, "Read Syntaxes" },
178         { 41, "Get Replica Root ID" },
179         { 42, "Begin Move Entry" },
180         { 43, "Finish Move Entry" },
181         { 44, "Release Moved Entry" },
182         { 45, "Backup Entry" },
183         { 46, "Restore Entry" },
184         { 47, "Save DIB" },
185         { 48, "Control" },
186         { 49, "Remove Backlink" },
187         { 50, "Close Iteration" },
188         { 51, "Unused" },
189         { 52, "Audit Skulking" },
190         { 53, "Get Server Address" },
191         { 54, "Set Keys" },
192         { 55, "Change Password" },
193         { 56, "Verify Password" },
194         { 57, "Begin Login" },
195         { 58, "Finish Login" },
196         { 59, "Begin Authentication" },
197         { 60, "Finish Authentication" },
198         { 61, "Logout" },
199         { 62, "Repair Ring" },
200         { 63, "Repair Timestamps" },
201         { 64, "Create Back Link" },
202         { 65, "Delete External Reference" },
203         { 66, "Rename External Reference" },
204         { 67, "Create Directory Entry" },
205         { 68, "Remove Directory Entry" },
206         { 69, "Designate New Master" },
207         { 70, "Change Tree Name" },
208         { 71, "Partition Entry Count" },
209         { 72, "Check Login Restrictions" },
210         { 73, "Start Join" },
211         { 74, "Low Level Split" },
212         { 75, "Low Level Join" },
213         { 76, "Abort Low Level Join" },
214         { 77, "Get All Servers" },
215     { 110, "NDS Fragment" },
216     { 240, "NDS Ping" },
217         { 255, "EDirectory Call" },
218         { 0,  NULL }
219 };
220
221 static void
222 ncpstat_set_title(ncpstat_t *ss)
223 {
224         char *title;
225
226         title = g_strdup_printf("NCP Service Response Time statistics: %s",
227             cf_get_display_name(&cfile));
228         gtk_window_set_title(GTK_WINDOW(ss->win), title);
229         g_free(title);
230 }
231
232 static void
233 ncpstat_reset(void *pss)
234 {
235         ncpstat_t *ss=(ncpstat_t *)pss;
236
237         reset_srt_table_data(&ss->ncp_srt_table);
238         reset_srt_table_data(&ss->func_srt_table);
239         reset_srt_table_data(&ss->nds_srt_table);
240         reset_srt_table_data(&ss->sss_srt_table);
241         reset_srt_table_data(&ss->nmas_srt_table);
242         reset_srt_table_data(&ss->sub_17_srt_table);
243         reset_srt_table_data(&ss->sub_21_srt_table);
244         reset_srt_table_data(&ss->sub_22_srt_table);
245         reset_srt_table_data(&ss->sub_23_srt_table);
246         reset_srt_table_data(&ss->sub_32_srt_table);
247         reset_srt_table_data(&ss->sub_34_srt_table);
248         reset_srt_table_data(&ss->sub_35_srt_table);
249         reset_srt_table_data(&ss->sub_36_srt_table);
250         reset_srt_table_data(&ss->sub_86_srt_table);
251         reset_srt_table_data(&ss->sub_87_srt_table);
252         reset_srt_table_data(&ss->sub_89_srt_table);
253         reset_srt_table_data(&ss->sub_90_srt_table);
254         reset_srt_table_data(&ss->sub_92_srt_table);
255         reset_srt_table_data(&ss->sub_94_srt_table);
256         reset_srt_table_data(&ss->sub_104_srt_table);
257         reset_srt_table_data(&ss->sub_111_srt_table);
258         reset_srt_table_data(&ss->sub_114_srt_table);
259         reset_srt_table_data(&ss->sub_123_srt_table);
260         reset_srt_table_data(&ss->sub_131_srt_table);
261         ncpstat_set_title(ss);
262 }
263
264 static int
265 ncpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
266 {
267         ncpstat_t *ss=(ncpstat_t *)pss;
268     const ncp_req_hash_value *request_val=prv;
269
270         /* if we havent seen the request, just ignore it */
271         if(!request_val || request_val->ncp_rec==0){
272                 return 0;
273         }
274     /* By Group */
275     init_srt_table_row(&ss->ncp_srt_table, request_val->ncp_rec->group, val_to_str(request_val->ncp_rec->group, ncp_group_vals, "Unknown(%u)"));
276     add_srt_table_data(&ss->ncp_srt_table, request_val->ncp_rec->group, &request_val->req_frame_time, pinfo);
277     /* By NCP number without subfunction*/
278     if (request_val->ncp_rec->subfunc==0) {
279         init_srt_table_row(&ss->func_srt_table, request_val->ncp_rec->func, request_val->ncp_rec->name);
280         add_srt_table_data(&ss->func_srt_table, request_val->ncp_rec->func, &request_val->req_frame_time, pinfo);
281     }
282     /* By Subfunction number */
283         if(request_val->ncp_rec->subfunc!=0){
284         if (request_val->ncp_rec->func==17) {
285             init_srt_table_row(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
286             add_srt_table_data(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
287         }
288         if (request_val->ncp_rec->func==21) {
289             init_srt_table_row(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
290             add_srt_table_data(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
291         }
292         if (request_val->ncp_rec->func==22) {
293             init_srt_table_row(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
294             add_srt_table_data(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
295         }
296         if (request_val->ncp_rec->func==23) {
297             init_srt_table_row(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
298             add_srt_table_data(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
299         }
300         if (request_val->ncp_rec->func==32) {
301             init_srt_table_row(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
302             add_srt_table_data(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
303         }
304         if (request_val->ncp_rec->func==34) {
305             init_srt_table_row(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
306             add_srt_table_data(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
307         }
308         if (request_val->ncp_rec->func==35) {
309             init_srt_table_row(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
310             add_srt_table_data(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
311         }
312         if (request_val->ncp_rec->func==36) {
313             init_srt_table_row(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
314             add_srt_table_data(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
315         }
316         if (request_val->ncp_rec->func==86) {
317             init_srt_table_row(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
318             add_srt_table_data(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
319         }
320         if (request_val->ncp_rec->func==87) {
321             init_srt_table_row(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
322             add_srt_table_data(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
323         }
324         if (request_val->ncp_rec->func==89) {
325             init_srt_table_row(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
326             add_srt_table_data(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
327         }
328         if (request_val->ncp_rec->func==90) {
329             init_srt_table_row(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
330             add_srt_table_data(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
331         }
332         if (request_val->ncp_rec->func==92) {
333             init_srt_table_row(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
334             add_srt_table_data(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
335         }
336         if (request_val->ncp_rec->func==94) {
337             init_srt_table_row(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
338             add_srt_table_data(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
339         }
340         if (request_val->ncp_rec->func==104) {
341             init_srt_table_row(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
342             add_srt_table_data(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
343         }
344         if (request_val->ncp_rec->func==111) {
345             init_srt_table_row(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
346             add_srt_table_data(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
347         }
348         if (request_val->ncp_rec->func==114) {
349             init_srt_table_row(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
350             add_srt_table_data(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
351         }
352         if (request_val->ncp_rec->func==123) {
353             init_srt_table_row(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
354             add_srt_table_data(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
355         }
356         if (request_val->ncp_rec->func==131) {
357             init_srt_table_row(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
358             add_srt_table_data(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
359         }
360         }
361     /* By NDS verb */
362     if (request_val->ncp_rec->func==0x68) {
363         init_srt_table_row(&ss->nds_srt_table, (request_val->nds_request_verb), val_to_str(request_val->nds_request_verb, ncp_nds_verb_vals, "Unknown(%u)"));
364         add_srt_table_data(&ss->nds_srt_table, (request_val->nds_request_verb), &request_val->req_frame_time, pinfo);
365     }
366     if (request_val->ncp_rec->func==0x5c) {
367         init_srt_table_row(&ss->sss_srt_table, (request_val->req_nds_flags), val_to_str(request_val->req_nds_flags, sss_verb_enum, "Unknown(%u)"));
368         add_srt_table_data(&ss->sss_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo);
369     }
370     if (request_val->ncp_rec->func==0x5e) {
371         init_srt_table_row(&ss->nmas_srt_table, (request_val->req_nds_flags), val_to_str(request_val->req_nds_flags, nmas_subverb_enum, "Unknown(%u)"));
372         add_srt_table_data(&ss->nmas_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo);
373     }
374     return 1;
375 }
376
377
378
379 static void
380 ncpstat_draw(void *pss)
381 {
382         ncpstat_t *ss=(ncpstat_t *)pss;
383
384         draw_srt_table_data(&ss->ncp_srt_table);
385         draw_srt_table_data(&ss->func_srt_table);
386         draw_srt_table_data(&ss->nds_srt_table);
387         draw_srt_table_data(&ss->sss_srt_table);
388         draw_srt_table_data(&ss->nmas_srt_table);
389         draw_srt_table_data(&ss->sub_17_srt_table);
390         draw_srt_table_data(&ss->sub_21_srt_table);
391         draw_srt_table_data(&ss->sub_22_srt_table);
392         draw_srt_table_data(&ss->sub_23_srt_table);
393         draw_srt_table_data(&ss->sub_32_srt_table);
394         draw_srt_table_data(&ss->sub_34_srt_table);
395         draw_srt_table_data(&ss->sub_35_srt_table);
396         draw_srt_table_data(&ss->sub_36_srt_table);
397         draw_srt_table_data(&ss->sub_86_srt_table);
398         draw_srt_table_data(&ss->sub_87_srt_table);
399         draw_srt_table_data(&ss->sub_89_srt_table);
400         draw_srt_table_data(&ss->sub_90_srt_table);
401         draw_srt_table_data(&ss->sub_92_srt_table);
402         draw_srt_table_data(&ss->sub_94_srt_table);
403         draw_srt_table_data(&ss->sub_104_srt_table);
404         draw_srt_table_data(&ss->sub_111_srt_table);
405         draw_srt_table_data(&ss->sub_114_srt_table);
406         draw_srt_table_data(&ss->sub_123_srt_table);
407         draw_srt_table_data(&ss->sub_131_srt_table);
408 }
409
410 void protect_thread_critical_region(void);
411 void unprotect_thread_critical_region(void);
412 static void
413 win_destroy_cb(GtkWindow *win _U_, gpointer data)
414 {
415         ncpstat_t *ss=(ncpstat_t *)data;
416
417         protect_thread_critical_region();
418         remove_tap_listener(ss);
419         unprotect_thread_critical_region();
420
421
422         free_srt_table_data(&ss->ncp_srt_table);
423         free_srt_table_data(&ss->func_srt_table);
424         free_srt_table_data(&ss->nds_srt_table);
425         free_srt_table_data(&ss->sss_srt_table);
426         free_srt_table_data(&ss->nmas_srt_table);
427         free_srt_table_data(&ss->sub_17_srt_table);
428         free_srt_table_data(&ss->sub_21_srt_table);
429         free_srt_table_data(&ss->sub_22_srt_table);
430         free_srt_table_data(&ss->sub_23_srt_table);
431         free_srt_table_data(&ss->sub_32_srt_table);
432         free_srt_table_data(&ss->sub_34_srt_table);
433         free_srt_table_data(&ss->sub_35_srt_table);
434         free_srt_table_data(&ss->sub_36_srt_table);
435         free_srt_table_data(&ss->sub_86_srt_table);
436         free_srt_table_data(&ss->sub_87_srt_table);
437         free_srt_table_data(&ss->sub_89_srt_table);
438         free_srt_table_data(&ss->sub_90_srt_table);
439         free_srt_table_data(&ss->sub_92_srt_table);
440         free_srt_table_data(&ss->sub_94_srt_table);
441         free_srt_table_data(&ss->sub_104_srt_table);
442         free_srt_table_data(&ss->sub_111_srt_table);
443         free_srt_table_data(&ss->sub_114_srt_table);
444         free_srt_table_data(&ss->sub_123_srt_table);
445         free_srt_table_data(&ss->sub_131_srt_table);
446         g_free(ss);
447 }
448
449
450 static void
451 gtk_ncpstat_init(const char *optarg, void *userdata _U_)
452 {
453     ncpstat_t *ss;
454     const char *filter=NULL;
455     GtkWidget *label;
456     char filter_string[256];
457     GString *error_string;
458     GtkWidget *temp_page;
459     GtkWidget *main_nb;
460     GtkWidget *vbox;
461     GtkWidget *bbox;
462     GtkWidget *close_bt;
463
464     if(!strncmp(optarg,"ncp,srt,",8)){
465         filter=optarg+8;
466     } else {
467         filter=NULL;
468     }
469
470     ss=g_malloc(sizeof(ncpstat_t));
471
472     ss->win=window_new(GTK_WINDOW_TOPLEVEL, "ncp-stat");
473     gtk_window_set_default_size(GTK_WINDOW(ss->win), 300, 400);
474
475     ncpstat_set_title(ss);
476
477     vbox=gtk_vbox_new(FALSE, 3);
478     gtk_container_add(GTK_CONTAINER(ss->win), vbox);
479     gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
480
481     label=gtk_label_new("NCP Service Response Time Statistics");
482     gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
483
484     g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
485     label=gtk_label_new(filter_string);
486     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
487
488     main_nb = gtk_notebook_new();
489     gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0);
490     temp_page = gtk_vbox_new(FALSE, 6);
491     label = gtk_label_new("Groups");
492     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
493
494     /* NCP Groups */
495     /* We must display TOP LEVEL Widget before calling init_srt_table() */
496     gtk_widget_show_all(ss->win);
497     label=gtk_label_new("NCP by Group Type");
498     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
499     init_srt_table(&ss->ncp_srt_table, 256, temp_page, "ncp.group");
500     
501     /* NCP Functions */
502     temp_page = gtk_vbox_new(FALSE, 6);
503     label = gtk_label_new("Functions");
504     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
505     label=gtk_label_new("NCP Functions without Subfunctions");
506     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
507     init_srt_table(&ss->func_srt_table, 256, temp_page, "ncp.func");
508
509     /* NCP Subfunctions */
510
511     temp_page = gtk_vbox_new(FALSE, 6);
512     label = gtk_label_new("17");
513     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
514     label=gtk_label_new("Subfunctions for NCP 17");
515     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
516     init_srt_table(&ss->sub_17_srt_table, 256, temp_page, "ncp.func==17 && ncp.subfunc");
517     temp_page = gtk_vbox_new(FALSE, 6);
518     label=gtk_label_new("21");
519     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
520     label=gtk_label_new("Subfunctions for NCP 21");
521     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
522     init_srt_table(&ss->sub_21_srt_table, 256, temp_page, "ncp.func==21 && ncp.subfunc");
523     temp_page = gtk_vbox_new(FALSE, 6);
524     label=gtk_label_new("22");
525     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
526     label=gtk_label_new("Subfunctions for NCP 22");
527     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
528     init_srt_table(&ss->sub_22_srt_table, 256, temp_page, "ncp.func==22 && ncp.subfunc");
529     temp_page = gtk_vbox_new(FALSE, 6);
530     label=gtk_label_new("23");
531     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
532     label=gtk_label_new("Subfunctions for NCP 23");
533     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
534     init_srt_table(&ss->sub_23_srt_table, 256, temp_page, "ncp.func==23 && ncp.subfunc");
535     temp_page = gtk_vbox_new(FALSE, 6);
536     label=gtk_label_new("32");
537     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
538     label=gtk_label_new("Subfunctions for NCP 32");
539     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
540     init_srt_table(&ss->sub_32_srt_table, 256, temp_page, "ncp.func==32 && ncp.subfunc");
541     temp_page = gtk_vbox_new(FALSE, 6);
542     label=gtk_label_new("34");
543     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
544     label=gtk_label_new("Subfunctions for NCP 34");
545     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
546     init_srt_table(&ss->sub_34_srt_table, 256, temp_page, "ncp.func==34 && ncp.subfunc");
547     temp_page = gtk_vbox_new(FALSE, 6);
548     label=gtk_label_new("35");
549     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
550     label=gtk_label_new("Subfunctions for NCP 35");
551     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
552     init_srt_table(&ss->sub_35_srt_table, 256, temp_page, "ncp.func==35 && ncp.subfunc");
553     temp_page = gtk_vbox_new(FALSE, 6);
554     label=gtk_label_new("36");
555     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
556     label=gtk_label_new("Subfunctions for NCP 36");
557     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
558     init_srt_table(&ss->sub_36_srt_table, 256, temp_page, "ncp.func==36 && ncp.subfunc");
559     temp_page = gtk_vbox_new(FALSE, 6);
560     label=gtk_label_new("86");
561     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
562     label=gtk_label_new("Subfunctions for NCP 86");
563     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
564     init_srt_table(&ss->sub_86_srt_table, 256, temp_page, "ncp.func==86 && ncp.subfunc");
565     temp_page = gtk_vbox_new(FALSE, 6);
566     label=gtk_label_new("87");
567     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
568     label=gtk_label_new("Subfunctions for NCP 87");
569     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
570     init_srt_table(&ss->sub_87_srt_table, 256, temp_page, "ncp.func==87 && ncp.subfunc");
571     temp_page = gtk_vbox_new(FALSE, 6);
572     label=gtk_label_new("89");
573     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
574     label=gtk_label_new("Subfunctions for NCP 89 (Extended NCP's with UTF8 Support)");
575     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
576     init_srt_table(&ss->sub_89_srt_table, 256, temp_page, "ncp.func==89 && ncp.subfunc");
577     temp_page = gtk_vbox_new(FALSE, 6);
578     label=gtk_label_new("90");
579     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
580     label=gtk_label_new("Subfunctions for NCP 90");
581     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
582     init_srt_table(&ss->sub_90_srt_table, 256, temp_page, "ncp.func==90 && ncp.subfunc");
583     temp_page = gtk_vbox_new(FALSE, 6);
584     label=gtk_label_new("92");
585     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
586     label=gtk_label_new("Subfunctions for NCP 92 (Secret Store Services)");
587     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
588     init_srt_table(&ss->sub_92_srt_table, 256, temp_page, "ncp.func==92 && ncp.subfunc");
589     temp_page = gtk_vbox_new(FALSE, 6);
590     label=gtk_label_new("94");
591     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
592     label=gtk_label_new("Subfunctions for NCP 94 (Novell Modular Authentication Services)");
593     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
594     init_srt_table(&ss->sub_94_srt_table, 256, temp_page, "ncp.func==94 && ncp.subfunc");
595     temp_page = gtk_vbox_new(FALSE, 6);
596     label=gtk_label_new("104");
597     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
598     label=gtk_label_new("Subfunctions for NCP 104");
599     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
600     init_srt_table(&ss->sub_104_srt_table, 256, temp_page, "ncp.func==104 && ncp.subfunc");
601     temp_page = gtk_vbox_new(FALSE, 6);
602     label=gtk_label_new("111");
603     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
604     label=gtk_label_new("Subfunctions for NCP 111");
605     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
606     init_srt_table(&ss->sub_111_srt_table, 256, temp_page, "ncp.func==111 && ncp.subfunc");
607     temp_page = gtk_vbox_new(FALSE, 6);
608     label=gtk_label_new("114");
609     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
610     label=gtk_label_new("Subfunctions for NCP 114");
611     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
612     init_srt_table(&ss->sub_114_srt_table, 256, temp_page, "ncp.func==114 && ncp.subfunc");
613     temp_page = gtk_vbox_new(FALSE, 6);
614     label=gtk_label_new("123");
615     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
616     label=gtk_label_new("Subfunctions for NCP 123");
617     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
618     init_srt_table(&ss->sub_123_srt_table, 256, temp_page, "ncp.func==123 && ncp.subfunc");
619     temp_page = gtk_vbox_new(FALSE, 6);
620     label=gtk_label_new("131");
621     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
622     label=gtk_label_new("Subfunctions for NCP 131");
623     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
624     init_srt_table(&ss->sub_131_srt_table, 256, temp_page, "ncp.func==131 && ncp.subfunc");
625
626     /* NDS Verbs */
627     temp_page = gtk_vbox_new(FALSE, 6);
628     label=gtk_label_new("NDS");
629     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
630     label=gtk_label_new("NDS Verbs");
631     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
632     init_srt_table(&ss->nds_srt_table, 256, temp_page, "ncp.ndsverb");
633     /* Secret Store Verbs */
634     temp_page = gtk_vbox_new(FALSE, 6);
635     label=gtk_label_new("SSS");
636     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
637     label=gtk_label_new("Secret Store Verbs");
638     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
639     init_srt_table(&ss->sss_srt_table, 256, temp_page, "sss.subverb");
640     /* NMAS Verbs */
641     temp_page = gtk_vbox_new(FALSE, 6);
642     label=gtk_label_new("NMAS");
643     gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
644     label=gtk_label_new("NMAS Verbs");
645     gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
646     init_srt_table(&ss->nmas_srt_table, 256, temp_page, "nmas.subverb");
647
648     /* Register the tap listener */
649     error_string=register_tap_listener("ncp_srt", ss, filter, ncpstat_reset, ncpstat_packet, ncpstat_draw);
650     if(error_string){
651         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
652         g_string_free(error_string, TRUE);
653         g_free(ss);
654         return;
655     }
656
657     /* Button row. */
658     bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
659     gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
660
661     close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
662     window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
663
664     SIGNAL_CONNECT(ss->win, "delete_event", window_delete_event_cb, NULL);
665     SIGNAL_CONNECT(ss->win, "destroy", win_destroy_cb, ss);
666
667     gtk_widget_show_all(ss->win);
668     window_present(ss->win);
669
670     cf_redissect_packets(&cfile);
671 }
672
673 static tap_dfilter_dlg ncp_stat_dlg = {
674         "NCP SRT Statistics",
675         "ncp,srt",
676         gtk_ncpstat_init,
677         -1
678 };
679
680 void
681 register_tap_listener_gtkncpstat(void)
682 {
683         register_dfilter_stat(&ncp_stat_dlg, "NCP",
684             REGISTER_STAT_GROUP_RESPONSE_TIME);
685 }