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