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