File: rtp.c

package info (click to toggle)
ipgrab 0.8.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 540 kB
  • ctags: 555
  • sloc: ansic: 4,608; sh: 1,507; makefile: 120
file content (73 lines) | stat: -rw-r--r-- 1,897 bytes parent folder | download
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
/**************************************************************************** 
** File: rtp.c
**
** Author: Mike Borella
**
** Comments: Dump RTP header information. 
**
*****************************************************************************/

#include <stdio.h>
#include "config.h"
#include "rtp.h"

extern u_char *packet_end;

/*----------------------------------------------------------------------------
**
** dump_rtp()
**
** Parse RTP packet and dump fields
**
**----------------------------------------------------------------------------
*/

void dump_rtp(u_char *bp, int length)
{
  u_char *ep = bp + length;
  u_char *p;
  RtpHdr *rtp;
  int i;

  /*
   * Make sure we don't run off the end of the packet
   */

  if (ep > packet_end) 
    ep = packet_end;

  p = bp;

  printf("-----------------------------------------------------------------\n");
  printf("                        RTP Header\n");
  printf("-----------------------------------------------------------------\n");

  rtp = (RtpHdr *) p;

  printf("Version:                %d\n", (int) rtp->version);
  printf("Padding:                %d\n", (int) rtp->padding);
  printf("Extension:              %d\n", (int) rtp->extension);
  printf("CSRC count:             %d\n", (int) rtp->csrc_count);
  printf("Marker:                 %d\n", (int) rtp->marker);
  printf("Payload type:           %d\n", (int) rtp->payload_type);
  printf("Sequence number:        %d\n", (u_int16_t) rtp->seqno);
  printf("Timestamp:              %d\n", (u_int32_t) rtp->timestamp);
  printf("SSRC:                   %d\n", (u_int32_t) rtp->ssrc);
  p = p + sizeof(RtpHdr);

  /*
   * Dump contributing sources
   */

  for (i=0; i < rtp->csrc_count; i++)
    {
      printf("CSRC                    %d\n", EXTRACT_32BITS(p));
      p = p + sizeof(u_int32_t);
      if (p > ep) 
	{
	  printf("beyond end of packet\n");
	  return;
	}
    }

}