aboutsummaryrefslogtreecommitdiffstats
path: root/packet-pptp.c
blob: 5ffe972cededd4287fb4b3794fd5f6a8ab97db3b (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
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
/* packet-pptp.c
 * Routines for the Point-to-Point Tunnelling Protocol (PPTP)
 * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
 *
 * $Id: packet-pptp.c,v 1.5 1999/09/17 05:56:55 guy Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@unicom.net>
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

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

#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

#include <stdio.h>

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

#include <glib.h>
#include "packet.h"

#define NUM_MSG_TYPES		3
#define msgtype2str(t)	\
  ((t < NUM_MSG_TYPES) ? msgtypestr[t] : "UNKNOWN-MESSAGES-TYPE")

static const char *msgtypestr[NUM_MSG_TYPES] = {
  "UNKNOWN-MESSAGE-TYPE",
  "CONTROL-MESSAGE",
  "MANAGEMENT-MESSAGE"
};

#define NUM_FRAME_TYPES		4
#define frametype2str(t)	\
  ((t < NUM_FRAME_TYPES) ? frametypestr[t] : "UNKNOWN-FRAMING-TYPE")

static const char *frametypestr[NUM_FRAME_TYPES] = {
  "UNKNOWN-FRAMING-TYPE",
  "ASYNCHRONOUS",
  "SYNCHRONOUS",
  "EITHER"
};

#define NUM_BEARER_TYPES	4
#define bearertype2str(t)	\
  ((t < NUM_BEARER_TYPES) ? bearertypestr[t] : "UNKNOWN-BEARER-TYPE")

static const char *bearertypestr[NUM_BEARER_TYPES] = {
  "UNKNOWN-BEARER-TYPE",
  "ANALOG",
  "DIGITAL",
  "EITHER"
};

#define NUM_CNTRLRESULT_TYPES	6
#define cntrlresulttype2str(t)	\
  ((t < NUM_CNTRLRESULT_TYPES) ? cntrlresulttypestr[t] : "UNKNOWN-CNTRLRESULT-TYPE")

static const char *cntrlresulttypestr[NUM_CNTRLRESULT_TYPES] = {
  "UNKNOWN-CNTRLRESULT-TYPE",
  "SUCCESS",
  "GENERAL-ERROR",
  "COMMAND-CHANNEL-EXISTS",
  "NOT-AUTHORIZED",
  "VERSION-NOT-SUPPORTED"
};

#define NUM_ERROR_TYPES		7
#define errortype2str(t)	\
  ((t < NUM_ERROR_TYPES) ? errortypestr[t] : "UNKNOWN-ERROR-TYPE")

static const char *errortypestr[NUM_ERROR_TYPES] = {
  "NONE",
  "NOT-CONNECTED",
  "BAD-FORMAT",
  "BAD-VALUE",
  "NO-RESOURCE",
  "BAD-CALL-ID",
  "PAC-ERROR"
};

#define NUM_REASON_TYPES	4
#define reasontype2str(t)	\
  ((t < NUM_REASON_TYPES) ? reasontypestr[t] : "UNKNOWN-REASON-TYPE")

static const char *reasontypestr[NUM_REASON_TYPES] = {
  "UNKNOWN-REASON-TYPE",
  "NONE",
  "STOP-PROTOCOL",
  "STOP-LOCAL-SHUTDOWN"
};

#define NUM_STOPRESULT_TYPES	3
#define stopresulttype2str(t)	\
  ((t < NUM_STOPRESULT_TYPES) ? stopresulttypestr[t] : "UNKNOWN-STOPRESULT-TYPE")

static const char *stopresulttypestr[NUM_STOPRESULT_TYPES] = {
  "UNKNOWN-STOPRESULT-TYPE",
  "SUCCESS",
  "GENERAL-ERROR"
};

#define NUM_ECHORESULT_TYPES	3
#define echoresulttype2str(t)	\
  ((t < NUM_ECHORESULT_TYPES) ? echoresulttypestr[t] : "UNKNOWN-ECHORESULT-TYPE")

static const char *echoresulttypestr[NUM_ECHORESULT_TYPES] = {
  "UNKNOWN-ECHORESULT-TYPE",
  "SUCCESS",
  "GENERAL-ERROR"
};

#define NUM_OUTRESULT_TYPES	8
#define outresulttype2str(t)	\
  ((t < NUM_OUTRESULT_TYPES) ? outresulttypestr[t] : "UNKNOWN-OUTRESULT-TYPE")

static const char *outresulttypestr[NUM_OUTRESULT_TYPES] = {
  "UNKNOWN-OUTRESULT-TYPE",
  "CONNECTED",
  "GENERAL-ERROR",
  "NO-CARRIER",
  "BUSY",
  "NO-DIAL-TONE",
  "TIME-OUT",
  "DO-NOT-ACCEPT"
};

#define NUM_INRESULT_TYPES	4
#define inresulttype2str(t)	\
  ((t < NUM_INRESULT_TYPES) ? inresulttypestr[t] : "UNKNOWN-INRESULT-TYPE")

static const char *inresulttypestr[NUM_INRESULT_TYPES] = {
  "UNKNOWN-INRESULT-TYPE",
  "CONNECT",
  "GENERAL-ERROR",
  "DO-NOT-ACCEPT"
};

#define NUM_DISCRESULT_TYPES	5
#define discresulttype2str(t)	\
  ((t < NUM_DISCRESULT_TYPES) ? discresulttypestr[t] : "UNKNOWN-DISCRESULT-TYPE")

static const char *discresulttypestr[NUM_DISCRESULT_TYPES] = {
  "UNKNOWN-DISCRESULT-TYPE",
  "LOST-CARRIER",
  "GENERAL-ERROR",
  "ADMIN-SHUTDOWN",
  "REQUEST"
};

static void dissect_unknown(const u_char *, int, frame_data *, proto_tree *);
static void dissect_cntrl_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_cntrl_reply(const u_char *, int, frame_data *, proto_tree *);
static void dissect_stop_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_stop_reply(const u_char *, int, frame_data *, proto_tree *);
static void dissect_echo_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_echo_reply(const u_char *, int, frame_data *, proto_tree *);
static void dissect_out_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_out_reply(const u_char *, int, frame_data *, proto_tree *);
static void dissect_in_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_in_reply(const u_char *, int, frame_data *, proto_tree *);
static void dissect_in_connected(const u_char *, int, frame_data *, proto_tree *);
static void dissect_clear_req(const u_char *, int, frame_data *, proto_tree *);
static void dissect_disc_notify(const u_char *, int, frame_data *, proto_tree *);
static void dissect_error_notify(const u_char *, int, frame_data *, proto_tree *);
static void dissect_set_link(const u_char *, int, frame_data *, proto_tree *);

#define NUM_CNTRL_TYPES		16
#define cntrltype2str(t)	\
  ((t < NUM_CNTRL_TYPES) ? strfuncs[t].str : "UNKNOWN-CONTROL-TYPE")

static struct strfunc {
  const char *	str;
  void          (*func)(const u_char *, int, frame_data *, proto_tree *);
} strfuncs[NUM_CNTRL_TYPES] = {
  {"UNKNOWN-CONTROL-TYPE",    dissect_unknown      },
  {"START-CONTROL-REQUEST",   dissect_cntrl_req    },
  {"START-CONTROL-REPLY",     dissect_cntrl_reply  },
  {"STOP-CONTROL-REQUEST",    dissect_stop_req     },
  {"STOP-CONTROL-REPLY",      dissect_stop_reply   },
  {"ECHO-REQUEST",            dissect_echo_req     },
  {"ECHO-REPLY",              dissect_echo_reply   },
  {"OUTGOING-CALL-REQUEST",   dissect_out_req      },
  {"OUTGOING-CALL-REPLY",     dissect_out_reply    },
  {"INCOMING-CALL-REQUEST",   dissect_in_req       },
  {"INCOMING-CALL-REPLY",     dissect_in_reply     },
  {"INCOMING-CALL-CONNECTED", dissect_in_connected },
  {"CLEAR-CALL-REQUEST",      dissect_clear_req    },
  {"DISCONNECT-NOTIFY",       dissect_disc_notify  },
  {"ERROR-NOTIFY",            dissect_error_notify },
  {"SET-LINK",                dissect_set_link     }
};

struct pptp_hdr
{
  guint16	len;
  guint16	type;
  guint32	cookie;
  guint16	cntrl_type;
  guint16	resv;
};

struct cntrl_req
{
  guint8	major_ver;
  guint8	minor_ver;
  guint16	resv;
  guint32	frame;
  guint32	bearer;
  guint16	max_chan;
  guint16	firm_rev;
  guint8	host[64];
  guint8	vendor[64];
};

struct cntrl_reply
{
  guint8	major_ver;
  guint8	minor_ver;
  guint8	result;
  guint8	error;
  guint32	frame;
  guint32	bearer;
  guint16	max_chan;
  guint16	firm_rev;
  guint8	host[64];
  guint8	vendor[64];
};

struct stop_req
{
  guint8	reason;
  guint8	resv0;
  guint16	resv1;
};

struct stop_reply
{
  guint8	result;
  guint8	error;
  guint16	resv;
};

struct echo_req
{
  guint32	ident;
};

struct echo_reply
{
  guint32	ident;
  guint8	result;
  guint8	error;
  guint16	resv;
};

struct out_req
{
  guint16	call_id;
  guint16	call_serial;
  guint32	min_bps;
  guint32	max_bps;
  guint32	bearer;
  guint32	frame;
  guint16	win_size;
  guint16	delay;
  guint16	phone_len;
  guint16	resv;
  guint8	phone[64];
  guint8	subaddr[64];
};

struct out_reply
{
  guint16	call_id;
  guint16	peer_id;
  guint8	result;
  guint8	error;
  guint16	cause;
  guint32	speed;
  guint16	win_size;
  guint16	delay;
  guint32	channel_id;
};

struct in_req
{
  guint16	call_id;
  guint16	call_serial;
  guint32	bearer;
  guint32	channel_id;
  guint16	dialed_len;
  guint16	dialing_len;
  guint8	dialed[64];
  guint8	dialing[64];
  guint8	subaddr[64];
};

struct in_reply
{
  guint16	call_id;
  guint16	peer_id;
  guint8	result;
  guint8	error;
  guint16	win_size;
  guint16	delay;
  guint16	resv;
};

struct in_connected
{
  guint16	peer_id;
  guint16	resv;
  guint32	speed;
  guint16	win_size;
  guint16	delay;
  guint32	frame;
};

struct clear_req
{
  guint16	call_id;
  guint16	resv;
};

struct disc_notify
{
  guint16	call_id;
  guint8	result;
  guint8	error;
  guint16	cause;
  guint16	resv;
  guint8	stats[128];
};

struct error_notify
{
  guint16	peer_id;
  guint16	resv;
  guint32	crc;
  guint32	frame;
  guint32	hardware;
  guint32	buffer;
  guint32	timeout;
  guint32	alignment;
};

struct set_link
{
  guint16	peer_id;
  guint16	resv;
  guint32	send_acm;
  guint32	recv_acm;
};

void
dissect_pptp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {

  struct pptp_hdr *	hdr = (struct pptp_hdr *)(pd + offset);
  guint16		len;
  guint16		cntrl_type;
  
  if (check_col(fd, COL_PROTOCOL))
    col_add_str(fd, COL_PROTOCOL, "PPTP");
  
  len	     = pntohs(&hdr->len);
  cntrl_type = pntohs(&hdr->cntrl_type);

  if (check_col(fd, COL_INFO))
    col_add_fstr(fd, COL_INFO, "%s", cntrltype2str(cntrl_type));
    
  if (IS_DATA_IN_FRAME(offset) && tree) {
    guint16		msg_type;
    proto_item *	ti;
    proto_tree *	pptp_tree;

    ti = proto_tree_add_text(tree, offset, len, "PPTP Control Channel");
    pptp_tree = proto_item_add_subtree(ti, ETT_PPTP);
    
    proto_tree_add_text(pptp_tree, offset, sizeof(hdr->len), 
			"Length: %u", len);
    offset += sizeof(hdr->len);

    msg_type = pntohs(&hdr->type);
    proto_tree_add_text(pptp_tree, offset, sizeof(hdr->type),
			"Message type: %s (%u)", msgtype2str(msg_type), msg_type);
    offset += sizeof(hdr->type);

    proto_tree_add_text(pptp_tree, offset, sizeof(hdr->cookie),
			"Cookie: %#08x", pntohl(&hdr->cookie));
    offset += sizeof(hdr->cookie);
    
    proto_tree_add_text(pptp_tree, offset, sizeof(hdr->cntrl_type),
			"Control type: %s (%u)", cntrltype2str(cntrl_type), cntrl_type);
    offset += sizeof(hdr->cntrl_type);

    proto_tree_add_text(pptp_tree, offset, sizeof(hdr->resv),
			"Reserved: %u", pntohs(&hdr->resv));
    offset += sizeof(hdr->resv);

    if (cntrl_type < NUM_CNTRL_TYPES)
      ( *(strfuncs[cntrl_type].func))(pd, offset, fd, pptp_tree);
    else
      dissect_data(pd, offset, fd, pptp_tree);
  }
}

static void
dissect_unknown(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  dissect_data(pd, offset, fd, tree);
}

static void
dissect_cntrl_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {

  struct cntrl_req *	hdr = (struct cntrl_req *)(pd + offset);
  guint32		frame;
  guint32		bearer;
  
  proto_tree_add_text(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver), 
		      "Protocol version: %u.%u", hdr->major_ver, hdr->minor_ver );
  offset += sizeof(hdr->major_ver) + sizeof(hdr->minor_ver);

  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);

  frame = pntohl(&hdr->frame);
  proto_tree_add_text(tree, offset, sizeof(hdr->frame),
		      "Framing capabilities: %s (%u)", frametype2str(frame), frame);
  offset += sizeof(hdr->frame);

  bearer = pntohl(&hdr->bearer);
  proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
		      "Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
  offset += sizeof(hdr->bearer);

  proto_tree_add_text(tree, offset, sizeof(hdr->max_chan),
		      "Maximum channels: %u", hdr->max_chan);
  offset += sizeof(hdr->max_chan);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->firm_rev),
		      "Firmware revision: %u", hdr->firm_rev);
  offset += sizeof(hdr->firm_rev);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->host),
		      "Hostname: %s", hdr->host);
  offset += sizeof(hdr->host);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->vendor),
		      "Vendor: %s", hdr->vendor);
}

static void
dissect_cntrl_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct cntrl_reply *	hdr = (struct cntrl_reply *)(pd + offset);
  guint32		frame;
  guint32		bearer;

  proto_tree_add_text(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver), 
		      "Protocol version: %u.%u", hdr->major_ver, hdr->minor_ver );
  offset += sizeof(hdr->major_ver) + sizeof(hdr->minor_ver);

  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", cntrlresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);
  
  frame = pntohl(&hdr->frame);
  proto_tree_add_text(tree, offset, sizeof(hdr->frame),
		      "Framing capabilities: %s (%u)", frametype2str(frame), frame);
  offset += sizeof(hdr->frame);

  bearer = pntohl(&hdr->bearer);
  proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
		      "Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
  offset += sizeof(hdr->bearer);

  proto_tree_add_text(tree, offset, sizeof(hdr->max_chan),
		      "Maximum channels: %u", hdr->max_chan);
  offset += sizeof(hdr->max_chan);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->firm_rev),
		      "Firmware revision: %u", hdr->firm_rev);
  offset += sizeof(hdr->firm_rev);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->host),
		      "Hostname: %s", hdr->host);
  offset += sizeof(hdr->host);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->vendor),
		      "Vendor: %s", hdr->vendor);
}

static void
dissect_stop_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct stop_req *	hdr = (struct stop_req *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->reason),
		      "Reason: %s (%u)", reasontype2str(hdr->reason), hdr->reason);
  offset += sizeof(hdr->reason);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv0),
		      "Reserved: %u", hdr->resv0);
  offset += sizeof(hdr->resv0);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv1),
		      "Reserved: %u", hdr->resv1);
  offset += sizeof(hdr->resv1);
}

static void
dissect_stop_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct stop_reply *	hdr = (struct stop_reply *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", stopresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);
}

static void
dissect_echo_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct echo_req *	hdr = (struct echo_req *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->ident),
		      "Identifier: %u", hdr->ident);
  offset += sizeof(hdr->ident);
}

static void
dissect_echo_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct echo_reply *	hdr = (struct echo_reply *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->ident),
		      "Identifier: %u", hdr->ident);
  offset += sizeof(hdr->ident);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", echoresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);
}

static void
dissect_out_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct out_req *	hdr = (struct out_req *)(pd + offset);
  guint32		bearer;
  guint32		frame;
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_serial),
		      "Call Serial Number: %u", hdr->call_serial);
  offset += sizeof(hdr->call_serial);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->min_bps),
		      "Minimum BPS: %u", hdr->min_bps);
  offset += sizeof(hdr->min_bps);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->max_bps),
		      "Maximum BPS: %u", hdr->max_bps);
  offset += sizeof(hdr->max_bps);
  
  bearer = pntohl(&hdr->bearer);
  proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
		      "Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
  offset += sizeof(hdr->bearer);

  frame = pntohl(&hdr->frame);
  proto_tree_add_text(tree, offset, sizeof(hdr->frame),
		      "Framing capabilities: %s (%u)", frametype2str(frame), frame);
  offset += sizeof(hdr->frame);

  proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
		      "Receive window size: %u", hdr->win_size);
  offset += sizeof(hdr->win_size);

  proto_tree_add_text(tree, offset, sizeof(hdr->delay),
		      "Processing delay: %u", hdr->delay);
  offset += sizeof(hdr->delay);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->phone_len),
		      "Phone number length: %u", hdr->phone_len);
  offset += sizeof(hdr->phone_len);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->phone),
		      "Phone number: %s", hdr->phone);
  offset += sizeof(hdr->phone);

  proto_tree_add_text(tree, offset, sizeof(hdr->subaddr),
		      "Subaddress: %s", hdr->subaddr);
  offset += sizeof(hdr->subaddr);
}

static void
dissect_out_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct out_reply *	hdr = (struct out_reply *)(pd + offset);

  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
		      "Peer's call ID: %u", hdr->peer_id);
  offset += sizeof(hdr->peer_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", outresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);

  proto_tree_add_text(tree, offset, sizeof(hdr->cause),
		      "Cause code: %u", hdr->cause);
  offset += sizeof(hdr->cause);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->speed),
		      "Connect speed: %u", hdr->speed);
  offset += sizeof(hdr->speed);

  proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
		      "Receive window size: %u", hdr->win_size);
  offset += sizeof(hdr->win_size);

  proto_tree_add_text(tree, offset, sizeof(hdr->delay),
		      "Processing delay: %u", hdr->delay);
  offset += sizeof(hdr->delay);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->channel_id),
		      "Physical channel ID: %u", hdr->channel_id);
  offset += sizeof(hdr->channel_id);
}


static void
dissect_in_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct in_req *	hdr = (struct in_req *)(pd + offset);
  guint32		bearer;
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_serial),
		      "Call serial number: %u", hdr->call_serial);
  offset += sizeof(hdr->call_serial);
  
  bearer = pntohl(&hdr->bearer);
  proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
		      "Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
  offset += sizeof(hdr->bearer);

  proto_tree_add_text(tree, offset, sizeof(hdr->channel_id),
		      "Physical channel ID: %u", hdr->channel_id);
  offset += sizeof(hdr->channel_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->dialed_len),
		      "Dialed number length: %u", hdr->dialed_len);
  offset += sizeof(hdr->dialed_len);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->dialing_len),
		      "Dialing number length: %u", hdr->dialing_len);
  offset += sizeof(hdr->dialing_len);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->dialed),
		      "Dialed number: %s", hdr->dialed);
  offset += sizeof(hdr->dialed);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->dialing),
		      "Dialing number: %s", hdr->dialing);
  offset += sizeof(hdr->dialing);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->subaddr),
		      "Subaddress: %s", hdr->subaddr);
  offset += sizeof(hdr->subaddr);
}

static void
dissect_in_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct in_reply *	hdr = (struct in_reply *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
		      "Peer's call ID: %u", hdr->peer_id);
  offset += sizeof(hdr->peer_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", inresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);

  proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
		      "Receive window size: %u", hdr->win_size);
  offset += sizeof(hdr->win_size);

  proto_tree_add_text(tree, offset, sizeof(hdr->delay),
		      "Processing delay: %u", hdr->delay);
  offset += sizeof(hdr->delay);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);
}

static void
dissect_in_connected(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct in_connected *	hdr = (struct in_connected *)(pd + offset);
  guint32		frame;
  
  proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
		      "Peer's call ID: %u", hdr->peer_id);
  offset += sizeof(hdr->peer_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);

  proto_tree_add_text(tree, offset, sizeof(hdr->speed),
		      "Connect speed: %u", hdr->speed);
  offset += sizeof(hdr->speed);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
		      "Receive window size: %u", hdr->win_size);
  offset += sizeof(hdr->win_size);

  proto_tree_add_text(tree, offset, sizeof(hdr->delay),
		      "Processing delay: %u", hdr->delay);
  offset += sizeof(hdr->delay);
  
  frame = pntohl(&hdr->frame);
  proto_tree_add_text(tree, offset, sizeof(hdr->frame),
		      "Framing capabilities: %s (%u)", frametype2str(frame), frame);
  offset += sizeof(hdr->frame);
}

static void
dissect_clear_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct clear_req *	hdr = (struct clear_req *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);
}

static void
dissect_disc_notify(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct disc_notify *	hdr = (struct disc_notify *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
		      "Call ID: %u", hdr->call_id);
  offset += sizeof(hdr->call_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->result),
		      "Result: %s (%u)", discresulttype2str(hdr->result), hdr->result);
  offset += sizeof(hdr->result);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->error),
		      "Error: %s (%u)", errortype2str(hdr->error), hdr->error);
  offset += sizeof(hdr->error);

  proto_tree_add_text(tree, offset, sizeof(hdr->cause),
		      "Cause code: %u", hdr->cause);
  offset += sizeof(hdr->cause);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);

  proto_tree_add_text(tree, offset, sizeof(hdr->stats),
		      "Call statistics: %s", hdr->stats);
  offset += sizeof(hdr->stats);
}

static void
dissect_error_notify(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct error_notify *	hdr = (struct error_notify *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
		      "Peer's call ID: %u", hdr->peer_id);
  offset += sizeof(hdr->peer_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);

  proto_tree_add_text(tree, offset, sizeof(hdr->crc),
		      "CRC errors: %u", hdr->crc);
  offset += sizeof(hdr->crc);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->frame),
		      "Framing errors: %u", hdr->frame);
  offset += sizeof(hdr->frame);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->hardware),
		      "Hardware overruns: %u", hdr->hardware);
  offset += sizeof(hdr->hardware);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->buffer),
		      "Buffer overruns: %u", hdr->buffer);
  offset += sizeof(hdr->buffer);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->timeout),
		      "Time-out errors: %u", hdr->timeout);
  offset += sizeof(hdr->timeout);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->alignment),
		      "Alignment errors: %u", hdr->alignment);
  offset += sizeof(hdr->alignment);
}

static void
dissect_set_link(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
  struct set_link *	hdr = (struct set_link *)(pd + offset);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
		      "Peer's call ID: %u", hdr->peer_id);
  offset += sizeof(hdr->peer_id);

  proto_tree_add_text(tree, offset, sizeof(hdr->resv),
		      "Reserved: %u", hdr->resv);
  offset += sizeof(hdr->resv);

  proto_tree_add_text(tree, offset, sizeof(hdr->send_acm),
		      "Send ACCM: %#08x", hdr->send_acm);
  offset += sizeof(hdr->send_acm);
  
  proto_tree_add_text(tree, offset, sizeof(hdr->recv_acm),
		      "Recv ACCM: %#08x", hdr->recv_acm);
  offset += sizeof(hdr->recv_acm);
}