aboutsummaryrefslogtreecommitdiffstats
path: root/packet-iax2.c
blob: 7cc67aeb1809716f945ce05f334d0ba0dd90d92e (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
/*
 * packet-iax2.c
 *
 * Routines for IAX2 packet disassembly
 * By Alastair Maw <asterisk@almaw.com>
 * Copyright 2003 Alastair Maw
 *
 * IAX2 is a VoIP protocol for the open source PBX Asterisk. Please see
 * http://www.asterisk.org for more information.
 *
 * $Id: packet-iax2.c,v 1.5 2004/02/18 14:30:45 jmayer Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * 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

#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <epan/packet.h>

#include "packet-iax2.h"

#define IAX2_PORT		4569
#define PROTO_TAG_IAX2	"IAX2"

static int proto_iax2 = -1;

static int hf_iax2_retransmission = -1;
static int hf_iax2_scallno = -1;
static int hf_iax2_dcallno = -1;
static int hf_iax2_ts = -1;
static int hf_iax2_minits = -1;
static int hf_iax2_voicedata = -1;
static int hf_iax2_oseqno = -1;
static int hf_iax2_iseqno = -1;
static int hf_iax2_type = -1;
static int hf_iax2_csub = -1;
static int hf_iax2_cmd_csub = -1;
static int hf_iax2_iax_csub = -1;
static int hf_iax2_voice_csub = -1;
static int hf_iax2_ies = -1;

static int hf_IAX_IE_APPARENTADDR_SINFAMILY = -1;
static int hf_IAX_IE_APPARENTADDR_SINPORT = -1;
static int hf_IAX_IE_APPARENTADDR_SINADDR = -1;
static int hf_IAX_IE_APPARENTADDR_SINZERO = -1;		  
static int hf_IAX_IE_CALLED_NUMBER = -1;
static int hf_IAX_IE_CALLING_NUMBER = -1;
static int hf_IAX_IE_CALLING_ANI = -1;
static int hf_IAX_IE_CALLING_NAME = -1;
static int hf_IAX_IE_CALLED_CONTEXT = -1;
static int hf_IAX_IE_USERNAME = -1;
static int hf_IAX_IE_PASSWORD = -1;
static int hf_IAX_IE_CAPABILITY = -1;
static int hf_IAX_IE_FORMAT = -1;
static int hf_IAX_IE_LANGUAGE = -1;
static int hf_IAX_IE_VERSION = -1;
static int hf_IAX_IE_ADSICPE = -1;
static int hf_IAX_IE_DNID = -1;
static int hf_IAX_IE_AUTHMETHODS = -1;
static int hf_IAX_IE_CHALLENGE = -1;
static int hf_IAX_IE_MD5_RESULT = -1;
static int hf_IAX_IE_RSA_RESULT = -1;
static int hf_IAX_IE_REFRESH = -1;
static int hf_IAX_IE_DPSTATUS = -1;
static int hf_IAX_IE_CALLNO = -1;
static int hf_IAX_IE_CAUSE = -1;
static int hf_IAX_IE_IAX_UNKNOWN = -1;
static int hf_IAX_IE_MSGCOUNT = -1;
static int hf_IAX_IE_AUTOANSWER = -1;
static int hf_IAX_IE_MUSICONHOLD = -1;
static int hf_IAX_IE_TRANSFERID = -1;
static int hf_IAX_IE_RDNIS = -1;



static gint ett_iax2 = -1;
static gint ett_iax2_ies = -1;
static gint ett_iax2_codecs = -1;
static gint ett_iax2_ies_apparent_addr = -1;

static const value_string iax_frame_types[] = {
  {0, "(0?)"},
  {1, "DTMF"},
  {2, "Voice"},
  {3, "Video"},
  {4, "Control"},
  {5, "NULL"},
  {6, "IAX"},
  {7, "Text"},
  {8, "Image"}
};
static const value_string iax_iax_subclasses[] = {
  {0, "(0?)"},
  {1, "NEW"},
  {2, "PING"},
  {3, "PONG"},
  {4, "ACK"},
  {5, "HANGUP"},
  {6, "REJECT"},
  {7, "ACCEPT"},
  {8, "AUTHREQ"},
  {9, "AUTHREP"},
  {10, "INVAL"},
  {11, "LAGRQ"},
  {12, "LAGRP"},
  {13, "REGREQ"},
  {14, "REGAUTH"},
  {15, "REGACK"},
  {16, "REGREJ"},
  {17, "REGREL"},
  {18, "VNAK"},
  {19, "DPREQ"},
  {20, "DPREP"},
  {21, "DIAL"},
  {22, "TXREQ"},
  {23, "TXCNT"},
  {24, "TXACC"},
  {25, "TXREADY"},
  {26, "TXREL"},
  {27, "TXREJ"},
  {28, "QUELCH"},
  {29, "UNQULCH"},
  {30, "POKE"},
  {31, "PAGE"},
  {32, "MWI"},
  {33, "UNSUPPORTED"},
  {34, "TRANSFER"}
};
static const value_string iax_cmd_subclasses[] = {
  {0, "(0?)"},
  {1, "HANGUP"},
  {2, "RING"},
  {3, "RINGING"},
  {4, "ANSWER"},
  {5, "BUSY"},
  {6, "TKOFFHK"},
  {7, "OFFHOOK"}
};

static const value_string iax_ies_type[] = {
  {IAX_IE_CALLED_NUMBER, "Number/extension being called"},
  {IAX_IE_CALLING_NUMBER, "Calling number"},
  {IAX_IE_CALLING_ANI, "Calling number ANI for billing"},
  {IAX_IE_CALLING_NAME, "Name of caller"},
  {IAX_IE_CALLED_CONTEXT, "Context for number"},
  {IAX_IE_USERNAME, "Username (peer or user) for authentication"},
  {IAX_IE_PASSWORD, "Password for authentication"},
  {IAX_IE_CAPABILITY, "Actual codec capability"},
  {IAX_IE_FORMAT, "Desired codec format"},
  {IAX_IE_LANGUAGE, "Desired language"},
  {IAX_IE_VERSION, "Protocol version"},
  {IAX_IE_ADSICPE, "CPE ADSI capability"},
  {IAX_IE_DNID, "Originally dialed DNID"},
  {IAX_IE_AUTHMETHODS, "Authentication method(s)"},
  {IAX_IE_CHALLENGE, "Challenge data for MD5/RSA"},
  {IAX_IE_MD5_RESULT, "MD5 challenge result"},
  {IAX_IE_RSA_RESULT, "RSA challenge result"},
  {IAX_IE_APPARENT_ADDR, "Apparent address of peer"},
  {IAX_IE_REFRESH, "When to refresh registration"},
  {IAX_IE_DPSTATUS, "Dialplan status"},
  {IAX_IE_CALLNO, "Call number of peer"},
  {IAX_IE_CAUSE, "Cause"},
  {IAX_IE_IAX_UNKNOWN, "Unknown IAX command"},
  {IAX_IE_MSGCOUNT, "How many messages waiting"},
  {IAX_IE_AUTOANSWER, "Request auto-answering"},
  {IAX_IE_MUSICONHOLD, "Request musiconhold with QUELCH"},
  {IAX_IE_TRANSFERID, "Transfer Request Identifier"},
  {IAX_IE_RDNIS, "Referring DNIS"}
};

static const value_string codec_types[] = {
  {AST_FORMAT_G723_1, "G.723.1 compression"},
  {AST_FORMAT_GSM, "GSM compression"},
  {AST_FORMAT_ULAW, "Raw mu-law data (G.711)"},
  {AST_FORMAT_ALAW, "Raw A-law data (G.711)"},
  {AST_FORMAT_MP3, "MPEG-2 layer 3"},
  {AST_FORMAT_ADPCM, "ADPCM (whose?)"},
  {AST_FORMAT_SLINEAR, "Raw 16-bit Signed Linear (8000 Hz) PCM"},
  {AST_FORMAT_LPC10, "LPC10, 180 samples/frame"},
  {AST_FORMAT_G729A, "G.729a Audio"}
};

static void
dissect_iax2 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
{
  proto_tree *iax2_tree = NULL, *ies_tree = NULL, *codec_tree = NULL, *sockaddr_tree = NULL;
  proto_item *ti = 0, *ies_base = 0, *codec_base = 0, *sockaddr_item = 0;
  guint32 offset = 0, codecs = 0, i = 0, mask = 0, retransmission = 0;
  guint16 scallno;
  guint16 dcallno;
  guint32 ts;
  guint8 type;
  guint8 csub;

  if (check_col (pinfo->cinfo, COL_PROTOCOL))
    {
      col_set_str (pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_IAX2);
    }
  if (check_col (pinfo->cinfo, COL_INFO))
    {
      col_clear (pinfo->cinfo, COL_INFO);
    }

  if (tree)
    {
      ti = proto_tree_add_item (tree, proto_iax2, tvb, offset, -1, FALSE);
      iax2_tree = proto_item_add_subtree (ti, ett_iax2);
    }

  scallno = tvb_get_ntohs(tvb, offset);
  if (scallno & 0x8000)
    {
      /*
       * remove the top bit for header type detection 
       */
      scallno = scallno & 0x7FFF;
      proto_tree_add_uint (iax2_tree, hf_iax2_scallno, tvb, offset, 2,
			   scallno);

      /*
       * remove the top bit for retransmission detection 
       */
      dcallno = tvb_get_ntohs(tvb, offset + 2);
      retransmission = dcallno & 0x8000;
      dcallno = dcallno & 0x7FFF;
      proto_tree_add_uint (iax2_tree, hf_iax2_dcallno, tvb, offset + 2, 2,
			   dcallno);
      proto_tree_add_boolean (iax2_tree, hf_iax2_retransmission, tvb,
			      offset + 2, 2, retransmission);

      ts = tvb_get_ntohl(tvb, offset + 4);
      proto_tree_add_uint (iax2_tree, hf_iax2_ts, tvb, offset + 4, 4, ts);
      proto_tree_add_item (iax2_tree, hf_iax2_oseqno, tvb, offset + 8, 1,
			   FALSE);
      proto_tree_add_item (iax2_tree, hf_iax2_iseqno, tvb, offset + 9, 1,
			   FALSE);
      type = tvb_get_guint8(tvb, offset + 10);
      proto_tree_add_uint (iax2_tree, hf_iax2_type, tvb, offset + 10, 1,
			   type);

      csub = tvb_get_guint8(tvb, offset + 11);
      if (type == AST_FRAME_IAX)
	{
	  proto_tree_add_uint (iax2_tree, hf_iax2_iax_csub, tvb,
			       offset + 11, 1, csub);
	  if (check_col (pinfo->cinfo, COL_INFO))
	    {
	      col_add_fstr (pinfo->cinfo, COL_INFO,
			    "%s %s, source call# %d, timestamp %ums",
			    val_to_str (type, iax_frame_types,
					"Unknown (0x%02x)"),
			    val_to_str (csub, iax_iax_subclasses,
					"unknown (0x%02x)"), scallno,
			    ts);
	    }

	}
      else if (type == AST_FRAME_DTMF)
	{
	  proto_tree_add_text (iax2_tree, tvb, offset + 11, 1, "DTMF digit: %c", csub);
	  if (check_col (pinfo->cinfo, COL_INFO))
	    {
	      col_add_fstr (pinfo->cinfo, COL_INFO,
			    "%s digit %c, source call# %d, timestamp %ums",
			    val_to_str (type, iax_frame_types,
					"Unknown (0x%02x)"), csub,
			    scallno, ts);
	    }

	}
      else if (type == AST_FRAME_CONTROL)
	{
	  proto_tree_add_uint (iax2_tree, hf_iax2_cmd_csub, tvb,
			       offset + 11, 1, csub);
	  if (check_col (pinfo->cinfo, COL_INFO))
	    {
	      col_add_fstr (pinfo->cinfo, COL_INFO,
			    "%s %s, source call# %d, timestamp %ums",
			    val_to_str (type, iax_frame_types,
					"Unknown (0x%02x)"),
			    val_to_str (csub, iax_cmd_subclasses,
					"unknown (0x%02x)"), scallno,
			    ts);
	    }

	}
      else if (type == AST_FRAME_VOICE)
	{
	  proto_tree_add_uint (iax2_tree, hf_iax2_voice_csub, tvb,
			       offset + 11, 1, csub);
	  if (check_col (pinfo->cinfo, COL_INFO))
	    {
	      col_add_fstr (pinfo->cinfo, COL_INFO,
			    "%s codec %s, source call# %d, timestamp %ums",
			    val_to_str (type, iax_frame_types,
					"Unknown (0x%02x)"),
			    val_to_str (csub, codec_types,
					"unknown (0x%02x)"), scallno,
			    ts);
	    }
	}
      else
	{
	  proto_tree_add_uint (iax2_tree, hf_iax2_csub, tvb, offset + 11,
			       1, csub);
	  if (check_col (pinfo->cinfo, COL_INFO))
	    {
	      col_add_fstr (pinfo->cinfo, COL_INFO,
			    "%s subclass %d, source call# %d, timestamp %ums",
			    val_to_str (type, iax_frame_types,
					"Unknown (0x%02x)"), csub,
			    scallno, ts);
	    }
	}
      offset += 12;

      if (type == AST_FRAME_IAX && (offset < tvb_reported_length (tvb)))
	{
	  ies_base =
	    proto_tree_add_item (iax2_tree, hf_iax2_ies, tvb, offset,
				 -1, FALSE);
	  ies_tree = proto_item_add_subtree (ies_base, ett_iax2_ies);
	}

      while (type == AST_FRAME_IAX && offset < tvb_reported_length (tvb))
	{
	  int ies_type = tvb_get_guint8(tvb, offset);
	  int ies_len = tvb_get_guint8(tvb, offset + 1);
	  switch (ies_type)
	    {
	    case IAX_IE_CALLED_NUMBER:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLED_NUMBER, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CALLING_NUMBER:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLING_NUMBER,
				   tvb, offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CALLING_ANI:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLING_ANI, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CALLING_NAME:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLING_NAME, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CALLED_CONTEXT:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLED_CONTEXT,
				   tvb, offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_USERNAME:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_USERNAME, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_PASSWORD:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_PASSWORD, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_LANGUAGE:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_LANGUAGE, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_DNID:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_DNID, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CHALLENGE:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CHALLENGE, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_MD5_RESULT:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_MD5_RESULT, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_RSA_RESULT:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_RSA_RESULT, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_RDNIS:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_RDNIS, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CAPABILITY:
	      codec_base =
		proto_tree_add_item (ies_tree, hf_IAX_IE_CAPABILITY,
				     tvb, offset + 2, ies_len, FALSE);
	      codec_tree =
		proto_item_add_subtree (codec_base, ett_iax2_codecs);

	      codecs = tvb_get_ntohl (tvb, offset + 2);
	      for (i = 0; i < 8; i++)
		{
		  mask = (1 << i);
		  if (codecs & mask)
		    proto_tree_add_text (codec_tree, tvb, offset + 2, 4,
					 "Supported: %s",
					 val_to_str (mask, codec_types,
						     "unknown"));
		}
	      for (i = 0; i < 8; i++)
		{
		  mask = (1 << i);
		  if (!(codecs & mask))
		    proto_tree_add_text (codec_tree, tvb, offset + 2, 4,
					 "Unsupported: %s",
					 val_to_str (mask, codec_types,
						     "unknown"));
		}

	      break;
	    case IAX_IE_FORMAT:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_FORMAT, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_VERSION:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_VERSION, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_ADSICPE:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_ADSICPE, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_AUTHMETHODS:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_AUTHMETHODS, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_APPARENT_ADDR:
	      sockaddr_item = proto_tree_add_text(ies_tree, tvb, offset + 2, 16, "Apparent Address");
	      sockaddr_tree = proto_item_add_subtree(sockaddr_item, ett_iax2_ies_apparent_addr);
	      proto_tree_add_item(sockaddr_tree, hf_IAX_IE_APPARENTADDR_SINADDR, tvb, offset + 6, 4, FALSE);
	      proto_tree_add_item(sockaddr_tree, hf_IAX_IE_APPARENTADDR_SINPORT, tvb, offset + 4, 2, FALSE);
	      break;
	    case IAX_IE_REFRESH:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_REFRESH, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_DPSTATUS:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_DPSTATUS, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CALLNO:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CALLNO, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_CAUSE:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_CAUSE, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_IAX_UNKNOWN:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_IAX_UNKNOWN, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_MSGCOUNT:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_MSGCOUNT, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_AUTOANSWER:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_AUTOANSWER, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_MUSICONHOLD:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_MUSICONHOLD, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    case IAX_IE_TRANSFERID:
	      proto_tree_add_item (ies_tree, hf_IAX_IE_TRANSFERID, tvb,
				   offset + 2, ies_len, FALSE);
	      break;
	    }
	  offset += ies_len + 2;
	}

    }
  else
    {
      proto_tree_add_uint (iax2_tree, hf_iax2_scallno, tvb, offset, 2,
			   scallno);
      ts = tvb_get_ntohs(tvb, offset + 2);
      proto_tree_add_uint (iax2_tree, hf_iax2_minits, tvb, offset + 2, 2,
			   ts);
      if (check_col (pinfo->cinfo, COL_INFO))
	{
	  col_add_fstr (pinfo->cinfo, COL_INFO,
			"Voice frame (mini header), source call# %d, timestamp %ums",
			scallno, ts);
	}
      proto_tree_add_item (iax2_tree, hf_iax2_voicedata, tvb, offset + 4,
			   -1, FALSE);
    }

}				/* dissect_iax2 */

void
proto_register_iax2 (void)
{
  static hf_register_info hf[] = {
    {&hf_iax2_scallno,
     {"Source call", "iax2.src_call", FT_UINT16, BASE_DEC, NULL, 0x0,
      "",
      HFILL}},
    {&hf_iax2_dcallno,
     {"Destination call", "iax2.dst_call", FT_UINT16, BASE_DEC, NULL,
      0x0, "",
      HFILL}},
    {&hf_iax2_retransmission,
     {"Retransmission", "iax2.retransmission", FT_BOOLEAN, BASE_NONE,
      NULL,
      0x0, "", HFILL}},
    {&hf_iax2_ts,
     {"Timestamp", "iax2.timestamp", FT_UINT32, BASE_DEC, NULL, 0x0,
      "",
      HFILL}},
    {&hf_iax2_minits,
     {"Timestamp", "iax2.timestamp", FT_UINT16, BASE_DEC, NULL, 0x0,
      "",
      HFILL}},
    {&hf_iax2_voicedata,
     {"Voice data", "iax2.voicedata", FT_BYTES, BASE_NONE, NULL, 0x0,
      "",
      HFILL}},
    {&hf_iax2_oseqno,
     {"Outbound seq.no.", "iax2.oseqno", FT_UINT16, BASE_DEC, NULL,
      0x0, "",
      HFILL}},
    {&hf_iax2_iseqno,
     {"Inbound seq.no.", "iax2.iseqno", FT_UINT16, BASE_DEC, NULL, 0x0,
      "",
      HFILL}},
    {&hf_iax2_type,
     {"Type", "iax2.type", FT_UINT8, BASE_DEC, VALS (iax_frame_types),
      0x0, "",
      HFILL}},
    {&hf_iax2_csub,
     {"Sub-class", "iax2.subclass", FT_UINT8, BASE_DEC, NULL, 0x0, "",
      HFILL}},
    {&hf_iax2_cmd_csub,
     {"Control type", "iax2.control", FT_UINT8, BASE_DEC,
      VALS (iax_cmd_subclasses), 0x0, "", HFILL}},
    {&hf_iax2_voice_csub,
     {"CODEC", "iax2.voice", FT_UINT8, BASE_DEC, VALS (codec_types),
      0x0, "", HFILL}},
    {&hf_iax2_iax_csub,
     {"IAX type", "iax2.iax", FT_UINT8, BASE_DEC,
      VALS (iax_iax_subclasses),
      0x0, "", HFILL}},
    {&hf_iax2_ies,
     {"Information elements", "iax2.ies", FT_BYTES, BASE_NONE, NULL,
      0x0, "", HFILL}},
	{&hf_IAX_IE_APPARENTADDR_SINFAMILY,
     {"Family", "iax2.ies.app_addr.sinfamily", FT_UINT16, BASE_DEC, NULL, 0, "Family", HFILL }},
	{&hf_IAX_IE_APPARENTADDR_SINPORT,
     {"Port", "iax2.ies.app_addr.sinport", FT_UINT16, BASE_DEC, NULL, 0, "Port", HFILL }},
	{&hf_IAX_IE_APPARENTADDR_SINADDR,
     {"Address", "iax2.ies.app_addr.sinaddr", FT_IPv4, BASE_HEX, NULL, 0, "Address", HFILL }},
	{&hf_IAX_IE_APPARENTADDR_SINZERO,
     {"Zero", "iax2.ies.app_addr.sinzero", FT_BYTES, BASE_HEX, NULL, 0, "Zero", HFILL }},
    {&hf_IAX_IE_CALLED_NUMBER,
     {"Number/extension being called", "iax2.ies.called_number",
      FT_STRING,
      BASE_NONE, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_CALLING_NUMBER,
     {"Calling number", "iax2.ies.calling_number", FT_STRING,
      BASE_NONE, NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_CALLING_ANI,
     {"Calling number ANI for billing", "iax2.ies.calling_ani",
      FT_STRING,
      BASE_NONE, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_CALLING_NAME,
     {"Name of caller", "iax2.ies.calling_name", FT_STRING, BASE_NONE,
      NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_CALLED_CONTEXT,
     {"Context for number", "iax2.ies.called_context", FT_STRING,
      BASE_NONE,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_USERNAME,
     {"Username (peer or user) for authentication",
      "iax2.ies.username",
      FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_PASSWORD,
     {"Password for authentication", "iax2.ies.password", FT_STRING,
      BASE_NONE, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_CAPABILITY,
     {"Actual codec capability", "iax2.ies.capability", FT_UINT32,
      BASE_HEX,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_FORMAT,
     {"Desired codec format", "iax2.ies.format", FT_UINT32, BASE_HEX,
      VALS (codec_types), 0x0, "", HFILL}},
    {&hf_IAX_IE_LANGUAGE,
     {"Desired language", "iax2.ies.language", FT_STRING, BASE_NONE,
      NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_VERSION,
     {"Protocol version", "iax2.ies.version", FT_INT16, BASE_HEX, NULL,
      0x0,
      "", HFILL}},
    {&hf_IAX_IE_ADSICPE,
     {"CPE ADSI capability", "iax2.ies.cpe_adsi", FT_INT16, BASE_HEX,
      NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_DNID,
     {"Originally dialed DNID", "iax2.ies.dnid", FT_STRING, BASE_NONE,
      NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_AUTHMETHODS,
     {"Authentication method(s)", "iax2.ies.auth.methods", FT_INT16,
      BASE_HEX,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_CHALLENGE,
     {"Challenge data for MD5/RSA", "iax2.ies.auth.challenge",
      FT_STRING,
      BASE_NONE, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_MD5_RESULT,
     {"MD5 challenge result", "iax2.ies.auth.md5", FT_STRING,
      BASE_NONE, NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_RSA_RESULT,
     {"RSA challenge result", "iax2.ies.auth.rsa", FT_STRING,
      BASE_NONE, NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_REFRESH,
     {"When to refresh registration", "iax2.ies.refresh", FT_INT16,
      BASE_DEC,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_DPSTATUS,
     {"Dialplan status", "iax2.ies.dialplan_status", FT_INT16,
      BASE_HEX, NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_CALLNO,
     {"Call number of peer", "iax2.ies.call_no", FT_INT16, BASE_DEC,
      NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_CAUSE,
     {"Cause", "iax2.ies.cause", FT_STRING, BASE_NONE, NULL, 0x0, "",
      HFILL}},
    {&hf_IAX_IE_IAX_UNKNOWN,
     {"Unknown IAX command", "iax2.ies.iax_unknown", FT_BYTES,
      BASE_HEX, NULL,
      0x0, "", HFILL}},
    {&hf_IAX_IE_MSGCOUNT,
     {"How many messages waiting", "iax2.ies.msg_count", FT_INT16,
      BASE_DEC,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_AUTOANSWER,
     {"Request auto-answering", "iax2.ies.autoanswer", FT_NONE,
      BASE_NONE,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_MUSICONHOLD,
     {"Request musiconhold with QUELCH", "iax2.ies.moh", FT_NONE,
      BASE_NONE,
      NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_TRANSFERID,
     {"Transfer Request Identifier", "iax2.ies.transferid", FT_INT32,
      BASE_HEX, NULL, 0x0, "", HFILL}},
    {&hf_IAX_IE_RDNIS,
     {"Referring DNIS", "iax2.ies.rdnis", FT_STRING, BASE_NONE, NULL,
      0x0, "",
      HFILL}}
  };

  static gint *ett[] = {
    &ett_iax2,
    &ett_iax2_ies,
    &ett_iax2_codecs,
	&ett_iax2_ies_apparent_addr
  };

  proto_iax2 =
    proto_register_protocol ("IAX2", "Inter-Asterisk eXchange v2", "iax2");
  proto_register_field_array (proto_iax2, hf, array_length (hf));
  proto_register_subtree_array (ett, array_length (ett));

}

void
proto_reg_handoff_iax2 (void)
{

  dissector_handle_t iax2_handle = NULL;

  iax2_handle = create_dissector_handle (dissect_iax2, proto_iax2);

  dissector_add ("udp.port", IAX2_PORT, iax2_handle);
}