aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/ncp_stat.c
blob: ebc43fceb9858640ba78ab17e74cdbd9e1def0a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/* ncp_stat.c
 * ncp_stat   2005 Greg Morris
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <string.h>

#include <gtk/gtk.h>

#include <epan/packet_info.h>
#include <epan/epan.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/dissectors/packet-ncp-int.h>

#include "../timestats.h"
#include "ui/simple_dialog.h"
#include "../file.h"
#include "../stat_menu.h"

#include "ui/gtk/gui_utils.h"
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/service_response_time_table.h"
#include "ui/gtk/tap_param_dlg.h"
#include "ui/gtk/gtkglobals.h"
#include "ui/gtk/main.h"


/* used to keep track of the statistics for an entire program interface */
typedef struct _ncpstat_t {
	GtkWidget *win;
	srt_stat_table ncp_srt_table;
    srt_stat_table nds_srt_table;
    srt_stat_table func_srt_table;
    srt_stat_table sss_srt_table;
    srt_stat_table nmas_srt_table;
    srt_stat_table sub_17_srt_table;
    srt_stat_table sub_21_srt_table;
    srt_stat_table sub_22_srt_table;
    srt_stat_table sub_23_srt_table;
    srt_stat_table sub_32_srt_table;
    srt_stat_table sub_34_srt_table;
    srt_stat_table sub_35_srt_table;
    srt_stat_table sub_36_srt_table;
    srt_stat_table sub_86_srt_table;
    srt_stat_table sub_87_srt_table;
    srt_stat_table sub_89_srt_table;
    srt_stat_table sub_90_srt_table;
    srt_stat_table sub_92_srt_table;
    srt_stat_table sub_94_srt_table;
    srt_stat_table sub_104_srt_table;
    srt_stat_table sub_111_srt_table;
    srt_stat_table sub_114_srt_table;
    srt_stat_table sub_123_srt_table;
    srt_stat_table sub_131_srt_table;
} ncpstat_t;

static const value_string ncp_group_vals[] = {
	{ 0, "Synchronization" },
	{ 1, "Print" },
	{ 2, "File System" },
	{ 3, "Connection" },
	{ 4, "File Server Environment" },
	{ 5, "Message" },
	{ 6, "Bindery" },
	{ 7, "Queue Management System (QMS)" },
	{ 8, "Accounting" },
	{ 9, "Transaction Tracking" },
	{ 10, "AFP" },
	{ 11, "NCP Extension" },
	{ 12, "Extended Attribute" },
	{ 13, "Auditing" },
	{ 14, "Enhanced File System" },
	{ 15, "Migration" },
	{ 16, "Novell Modular Authentication Services (NMAS)" },
	{ 17, "Secret Store Services (SSS)" },
	{ 18, "Packet Burst" },
	{ 19, "Novell Directory Services (NDS)" },
	{ 20, "Time Synchronization" },
	{ 21, "Server Statistics" },
	{ 22, "Remote" },
	{ 0,  NULL}
};

static const value_string sss_verb_enum[] = {
	{ 0x00000000, "Query Server" },
	{ 0x00000001, "Read App Secrets" },
	{ 0x00000002, "Write App Secrets" },
	{ 0x00000003, "Add Secret ID" },
	{ 0x00000004, "Remove Secret ID" },
	{ 0x00000005, "Remove SecretStore" },
	{ 0x00000006, "Enumerate Secret IDs" },
	{ 0x00000007, "Unlock Store" },
	{ 0x00000008, "Set Master Password" },
	{ 0x00000009, "Get Service Information" },
	{ 0x000000ff, "Fragment"},
	{ 0x00000000, NULL}
};

static const value_string nmas_subverb_enum[] = {
	{ 0, "Fragmented Ping" },
	{ 2, "Client Put Data" },
	{ 4, "Client Get Data" },
	{ 6, "Client Get User NDS Credentials" },
	{ 8, "Login Store Management" },
	{ 10, "Writable Object Check" },
	{ 1242, "Message Handler" },
	{ 0,  NULL}
};

static const value_string ncp_nds_verb_vals[] = {
	{ 1, "Resolve Name" },
	{ 2, "Read Entry Information" },
	{ 3, "Read" },
	{ 4, "Compare" },
	{ 5, "List" },
	{ 6, "Search Entries" },
	{ 7, "Add Entry" },
	{ 8, "Remove Entry" },
	{ 9, "Modify Entry" },
	{ 10, "Modify RDN" },
	{ 11, "Create Attribute" },
	{ 12, "Read Attribute Definition" },
	{ 13, "Remove Attribute Definition" },
	{ 14, "Define Class" },
	{ 15, "Read Class Definition" },
	{ 16, "Modify Class Definition" },
	{ 17, "Remove Class Definition" },
	{ 18, "List Containable Classes" },
	{ 19, "Get Effective Rights" },
	{ 20, "Add Partition" },
	{ 21, "Remove Partition" },
	{ 22, "List Partitions" },
	{ 23, "Split Partition" },
	{ 24, "Join Partitions" },
	{ 25, "Add Replica" },
	{ 26, "Remove Replica" },
	{ 27, "Open Stream" },
	{ 28, "Search Filter" },
	{ 29, "Create Subordinate Reference" },
	{ 30, "Link Replica" },
	{ 31, "Change Replica Type" },
	{ 32, "Start Update Schema" },
	{ 33, "End Update Schema" },
	{ 34, "Update Schema" },
	{ 35, "Start Update Replica" },
	{ 36, "End Update Replica" },
	{ 37, "Update Replica" },
	{ 38, "Synchronize Partition" },
	{ 39, "Synchronize Schema" },
	{ 40, "Read Syntaxes" },
	{ 41, "Get Replica Root ID" },
	{ 42, "Begin Move Entry" },
	{ 43, "Finish Move Entry" },
	{ 44, "Release Moved Entry" },
	{ 45, "Backup Entry" },
	{ 46, "Restore Entry" },
	{ 47, "Save DIB (Obsolete)" },
	{ 48, "Control" },
	{ 49, "Remove Backlink" },
	{ 50, "Close Iteration" },
	{ 51, "Mutate Entry" },
	{ 52, "Audit Skulking" },
	{ 53, "Get Server Address" },
	{ 54, "Set Keys" },
	{ 55, "Change Password" },
	{ 56, "Verify Password" },
	{ 57, "Begin Login" },
	{ 58, "Finish Login" },
	{ 59, "Begin Authentication" },
	{ 60, "Finish Authentication" },
	{ 61, "Logout" },
	{ 62, "Repair Ring (Obsolete)" },
	{ 63, "Repair Timestamps" },
	{ 64, "Create Back Link" },
	{ 65, "Delete External Reference" },
	{ 66, "Rename External Reference" },
	{ 67, "Create Queue Entry Directory" },
	{ 68, "Remove Queue Entry Directory" },
	{ 69, "Merge Entries" },
	{ 70, "Change Tree Name" },
	{ 71, "Partition Entry Count" },
	{ 72, "Check Login Restrictions" },
	{ 73, "Start Join" },
	{ 74, "Low Level Split" },
	{ 75, "Low Level Join" },
	{ 76, "Abort Partition Operation" },
	{ 77, "Get All Servers" },
	{ 78, "Partition Function" },
	{ 79, "Read References" },
	{ 80, "Inspect Entry" },
	{ 81, "Get Remote Entry ID" },
	{ 82, "Change Security" },
	{ 83, "Check Console Operator" },
	{ 84, "Start Move Tree" },
	{ 85, "Move Tree" },
	{ 86, "End Move Tree" },
	{ 87, "Low Level Abort Join" },
	{ 88, "Check Security Equivalence" },
	{ 89, "Merge Tree" },
	{ 90, "Sync External Reference" },
	{ 91, "Resend Entry" },
	{ 92, "New Schema Epoch" },
	{ 93, "Statistics" },
	{ 94, "Ping" },
	{ 95, "Get Bindery Contexts" },
	{ 96, "Monitor Connection" },
	{ 97, "Get DS Statistics" },
	{ 98, "Reset DS Counters" },
	{ 99, "Console" },
	{ 100, "Read Stream" },
	{ 101, "Write Stream" },
	{ 102, "Create Orphan Partition" },
	{ 103, "Remove Orphan Partition" },
	{ 104, "Link Orphan Partition" },
	{ 105, "Set Distributed Reference Link (DRL)" },
	{ 106, "Available" },
	{ 107, "Available" },
	{ 108, "Verify Distributed Reference Link (DRL)" },
	{ 109, "Verify Partition" },
	{ 110, "Iterator" },
	{ 111, "Available" },
	{ 112, "Close Stream" },
	{ 113, "Available" },
	{ 114, "Read Status" },
	{ 115, "Partition Sync Status" },
	{ 116, "Read Reference Data" },
	{ 117, "Write Reference Data" },
	{ 118, "Resource Event" },
	{ 119, "DIB Request (obsolete)" },
	{ 120, "Set Replication Filter" },
	{ 121, "Get Replication Filter" },
	{ 122, "Change Attribute Definition" },
	{ 123, "Schema in Use" },
	{ 124, "Remove Keys" },
	{ 125, "Clone" },
	{ 126, "Multiple Operations Transaction" },
	{ 240, "Ping" },
	{ 255, "EDirectory Call" },
	{ 0,  NULL }
};

static void
ncpstat_set_title(ncpstat_t *ss)
{
	set_window_title(ss->win, "NCP Service Response Time statistics");
}

static void
ncpstat_reset(void *pss)
{
	ncpstat_t *ss=(ncpstat_t *)pss;

	reset_srt_table_data(&ss->ncp_srt_table);
	reset_srt_table_data(&ss->func_srt_table);
	reset_srt_table_data(&ss->nds_srt_table);
	reset_srt_table_data(&ss->sss_srt_table);
	reset_srt_table_data(&ss->nmas_srt_table);
	reset_srt_table_data(&ss->sub_17_srt_table);
	reset_srt_table_data(&ss->sub_21_srt_table);
	reset_srt_table_data(&ss->sub_22_srt_table);
	reset_srt_table_data(&ss->sub_23_srt_table);
	reset_srt_table_data(&ss->sub_32_srt_table);
	reset_srt_table_data(&ss->sub_34_srt_table);
	reset_srt_table_data(&ss->sub_35_srt_table);
	reset_srt_table_data(&ss->sub_36_srt_table);
	reset_srt_table_data(&ss->sub_86_srt_table);
	reset_srt_table_data(&ss->sub_87_srt_table);
	reset_srt_table_data(&ss->sub_89_srt_table);
	reset_srt_table_data(&ss->sub_90_srt_table);
	reset_srt_table_data(&ss->sub_92_srt_table);
	reset_srt_table_data(&ss->sub_94_srt_table);
	reset_srt_table_data(&ss->sub_104_srt_table);
	reset_srt_table_data(&ss->sub_111_srt_table);
	reset_srt_table_data(&ss->sub_114_srt_table);
	reset_srt_table_data(&ss->sub_123_srt_table);
	reset_srt_table_data(&ss->sub_131_srt_table);
	ncpstat_set_title(ss);
}

static int
ncpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
{
	ncpstat_t *ss=(ncpstat_t *)pss;
    const ncp_req_hash_value *request_val=prv;

	/* if we havent seen the request, just ignore it */
	if(!request_val || request_val->ncp_rec==0){
		return 0;
	}
    /* By Group */
    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)"));
    add_srt_table_data(&ss->ncp_srt_table, request_val->ncp_rec->group, &request_val->req_frame_time, pinfo);
    /* By NCP number without subfunction*/
    if (request_val->ncp_rec->subfunc==0) {
        init_srt_table_row(&ss->func_srt_table, request_val->ncp_rec->func, request_val->ncp_rec->name);
        add_srt_table_data(&ss->func_srt_table, request_val->ncp_rec->func, &request_val->req_frame_time, pinfo);
    }
    /* By Subfunction number */
	if(request_val->ncp_rec->subfunc!=0){
        if (request_val->ncp_rec->func==17) {
            init_srt_table_row(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==21) {
            init_srt_table_row(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==22) {
            init_srt_table_row(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==23) {
            init_srt_table_row(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==32) {
            init_srt_table_row(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==34) {
            init_srt_table_row(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==35) {
            init_srt_table_row(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==36) {
            init_srt_table_row(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==86) {
            init_srt_table_row(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==87) {
            init_srt_table_row(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==89) {
            init_srt_table_row(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==90) {
            init_srt_table_row(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==92) {
            init_srt_table_row(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==94) {
            init_srt_table_row(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==104) {
            init_srt_table_row(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==111) {
            init_srt_table_row(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==114) {
            init_srt_table_row(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==123) {
            init_srt_table_row(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
        if (request_val->ncp_rec->func==131) {
            init_srt_table_row(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name);
            add_srt_table_data(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo);
        }
	}
    /* By NDS verb */
    if (request_val->ncp_rec->func==0x68) {
        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)"));
        add_srt_table_data(&ss->nds_srt_table, (request_val->nds_request_verb), &request_val->req_frame_time, pinfo);
    }
    if (request_val->ncp_rec->func==0x5c) {
        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)"));
        add_srt_table_data(&ss->sss_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo);
    }
    if (request_val->ncp_rec->func==0x5e) {
        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)"));
        add_srt_table_data(&ss->nmas_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo);
    }
    return 1;
}



static void
ncpstat_draw(void *pss)
{
	ncpstat_t *ss=(ncpstat_t *)pss;

	draw_srt_table_data(&ss->ncp_srt_table);
	draw_srt_table_data(&ss->func_srt_table);
	draw_srt_table_data(&ss->nds_srt_table);
	draw_srt_table_data(&ss->sss_srt_table);
	draw_srt_table_data(&ss->nmas_srt_table);
	draw_srt_table_data(&ss->sub_17_srt_table);
	draw_srt_table_data(&ss->sub_21_srt_table);
	draw_srt_table_data(&ss->sub_22_srt_table);
	draw_srt_table_data(&ss->sub_23_srt_table);
	draw_srt_table_data(&ss->sub_32_srt_table);
	draw_srt_table_data(&ss->sub_34_srt_table);
	draw_srt_table_data(&ss->sub_35_srt_table);
	draw_srt_table_data(&ss->sub_36_srt_table);
	draw_srt_table_data(&ss->sub_86_srt_table);
	draw_srt_table_data(&ss->sub_87_srt_table);
	draw_srt_table_data(&ss->sub_89_srt_table);
	draw_srt_table_data(&ss->sub_90_srt_table);
	draw_srt_table_data(&ss->sub_92_srt_table);
	draw_srt_table_data(&ss->sub_94_srt_table);
	draw_srt_table_data(&ss->sub_104_srt_table);
	draw_srt_table_data(&ss->sub_111_srt_table);
	draw_srt_table_data(&ss->sub_114_srt_table);
	draw_srt_table_data(&ss->sub_123_srt_table);
	draw_srt_table_data(&ss->sub_131_srt_table);
}

static void
win_destroy_cb(GtkWindow *win _U_, gpointer data)
{
	ncpstat_t *ss=(ncpstat_t *)data;

	protect_thread_critical_region();
	remove_tap_listener(ss);
	unprotect_thread_critical_region();


	free_srt_table_data(&ss->ncp_srt_table);
	free_srt_table_data(&ss->func_srt_table);
	free_srt_table_data(&ss->nds_srt_table);
	free_srt_table_data(&ss->sss_srt_table);
	free_srt_table_data(&ss->nmas_srt_table);
	free_srt_table_data(&ss->sub_17_srt_table);
	free_srt_table_data(&ss->sub_21_srt_table);
	free_srt_table_data(&ss->sub_22_srt_table);
	free_srt_table_data(&ss->sub_23_srt_table);
	free_srt_table_data(&ss->sub_32_srt_table);
	free_srt_table_data(&ss->sub_34_srt_table);
	free_srt_table_data(&ss->sub_35_srt_table);
	free_srt_table_data(&ss->sub_36_srt_table);
	free_srt_table_data(&ss->sub_86_srt_table);
	free_srt_table_data(&ss->sub_87_srt_table);
	free_srt_table_data(&ss->sub_89_srt_table);
	free_srt_table_data(&ss->sub_90_srt_table);
	free_srt_table_data(&ss->sub_92_srt_table);
	free_srt_table_data(&ss->sub_94_srt_table);
	free_srt_table_data(&ss->sub_104_srt_table);
	free_srt_table_data(&ss->sub_111_srt_table);
	free_srt_table_data(&ss->sub_114_srt_table);
	free_srt_table_data(&ss->sub_123_srt_table);
	free_srt_table_data(&ss->sub_131_srt_table);
	g_free(ss);
}


static void
gtk_ncpstat_init(const char *optarg, void *userdata _U_)
{
    ncpstat_t *ss;
    const char *filter=NULL;
    GtkWidget *label;
    char *filter_string;
    GString *error_string;
    GtkWidget *temp_page;
    GtkWidget *main_nb;
    GtkWidget *vbox;
    GtkWidget *bbox;
    GtkWidget *close_bt;

    if(!strncmp(optarg,"ncp,srt,",8)){
        filter=optarg+8;
    } else {
        filter=NULL;
    }

    ss=g_malloc(sizeof(ncpstat_t));

	ss->win = dlg_window_new("ncp-stat");  /* transient_for top_level */
	gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
    gtk_window_set_default_size(GTK_WINDOW(ss->win), 300, 400);

    ncpstat_set_title(ss);

    vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
    gtk_container_add(GTK_CONTAINER(ss->win), vbox);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);

    label=gtk_label_new("NCP Service Response Time Statistics");
    gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);

    filter_string = g_strdup_printf("Filter: %s",filter ? filter : "");
    label=gtk_label_new(filter_string);
    g_free(filter_string);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

    main_nb = gtk_notebook_new();
    gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0);
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label = gtk_label_new("Groups");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);

    /* NCP Groups */
    /* We must display TOP LEVEL Widget before calling init_srt_table() */
    gtk_widget_show_all(ss->win);
    label=gtk_label_new("NCP by Group Type");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->ncp_srt_table, 256, temp_page, "ncp.group");

    /* NCP Functions */
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label = gtk_label_new("Functions");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("NCP Functions without Subfunctions");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->func_srt_table, 256, temp_page, "ncp.func");

    /* NCP Subfunctions */

    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label = gtk_label_new("17");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 17");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_17_srt_table, 256, temp_page, "ncp.func==17 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("21");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 21");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_21_srt_table, 256, temp_page, "ncp.func==21 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("22");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 22");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_22_srt_table, 256, temp_page, "ncp.func==22 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("23");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 23");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_23_srt_table, 256, temp_page, "ncp.func==23 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("32");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 32");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_32_srt_table, 256, temp_page, "ncp.func==32 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("34");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 34");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_34_srt_table, 256, temp_page, "ncp.func==34 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("35");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 35");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_35_srt_table, 256, temp_page, "ncp.func==35 && ncp.subfunc");
    temp_page =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("36");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 36");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_36_srt_table, 256, temp_page, "ncp.func==36 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("86");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 86");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_86_srt_table, 256, temp_page, "ncp.func==86 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("87");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 87");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_87_srt_table, 256, temp_page, "ncp.func==87 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("89");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 89 (Extended NCP's with UTF8 Support)");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_89_srt_table, 256, temp_page, "ncp.func==89 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("90");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 90");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_90_srt_table, 256, temp_page, "ncp.func==90 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("92");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 92 (Secret Store Services)");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_92_srt_table, 256, temp_page, "ncp.func==92 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("94");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 94 (Novell Modular Authentication Services)");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_94_srt_table, 256, temp_page, "ncp.func==94 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("104");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 104");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_104_srt_table, 256, temp_page, "ncp.func==104 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("111");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 111");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_111_srt_table, 256, temp_page, "ncp.func==111 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("114");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 114");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_114_srt_table, 256, temp_page, "ncp.func==114 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("123");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 123");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_123_srt_table, 256, temp_page, "ncp.func==123 && ncp.subfunc");
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("131");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Subfunctions for NCP 131");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sub_131_srt_table, 256, temp_page, "ncp.func==131 && ncp.subfunc");

    /* NDS Verbs */
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("NDS");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("NDS Verbs");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->nds_srt_table, 256, temp_page, "ncp.ndsverb");
    /* Secret Store Verbs */
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("SSS");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("Secret Store Verbs");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->sss_srt_table, 256, temp_page, "sss.subverb");
    /* NMAS Verbs */
    temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
    label=gtk_label_new("NMAS");
    gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label);
    label=gtk_label_new("NMAS Verbs");
    gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0);
    init_srt_table(&ss->nmas_srt_table, 256, temp_page, "nmas.subverb");

    /* Register the tap listener */
    error_string=register_tap_listener("ncp_srt", ss, filter, 0, ncpstat_reset, ncpstat_packet, ncpstat_draw);
    if(error_string){
        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
        g_string_free(error_string, TRUE);
        g_free(ss);
        return;
    }

    /* Button row. */
    bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
    gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);

    close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
    window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);

    g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
    g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);

    gtk_widget_show_all(ss->win);
    window_present(ss->win);

    cf_redissect_packets(&cfile);
}

static tap_param ncp_stat_params[] = {
	{ PARAM_FILTER, "Filter", NULL }
};

static tap_param_dlg ncp_stat_dlg = {
	"NCP SRT Statistics",
	"ncp,srt",
	gtk_ncpstat_init,
	-1,
	G_N_ELEMENTS(ncp_stat_params),
	ncp_stat_params
};

void
register_tap_listener_gtkncpstat(void)
{
	register_dfilter_stat(&ncp_stat_dlg, "NCP",
	    REGISTER_STAT_GROUP_RESPONSE_TIME);
}
void ncp_srt_cb(GtkAction *action, gpointer user_data _U_)
{
	tap_param_dlg_cb(action, &ncp_stat_dlg);
}