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