Home | History | Annotate | Download | only in layers
      1 ## This file is part of Scapy
      2 ## See http://www.secdev.org/projects/scapy for more informations
      3 ## Copyright (C) Philippe Biondi <phil (at] secdev.org>
      4 ## This program is published under a GPLv2 license
      5 
      6 """
      7 RTP (Real-time Transport Protocol).
      8 """
      9 
     10 from scapy.packet import *
     11 from scapy.fields import *
     12 
     13 _rtp_payload_types = {
     14     # http://www.iana.org/assignments/rtp-parameters
     15     0:  'G.711 PCMU',    3:  'GSM',
     16     4:  'G723',          5:  'DVI4',
     17     6:  'DVI4',          7:  'LPC',
     18     8:  'PCMA',          9:  'G722',
     19     10: 'L16',           11: 'L16',
     20     12: 'QCELP',         13: 'CN',
     21     14: 'MPA',           15: 'G728',
     22     16: 'DVI4',          17: 'DVI4',
     23     18: 'G729',          25: 'CelB',
     24     26: 'JPEG',          28: 'nv',
     25     31: 'H261',          32: 'MPV',
     26     33: 'MP2T',          34: 'H263' }
     27 
     28 
     29 class RTPExtension(Packet):
     30     name = "RTP extension"
     31     fields_desc = [ ShortField("header_id", 0),
     32                     FieldLenField("header_len", None, count_of="header", fmt="H"),
     33                     FieldListField('header', [], IntField("hdr", 0), count_from=lambda pkt: pkt.header_len) ]
     34 
     35 
     36 class RTP(Packet):
     37     name="RTP"
     38     fields_desc = [ BitField('version', 2, 2),
     39                     BitField('padding', 0, 1),
     40                     BitField('extension', 0, 1),
     41                     BitFieldLenField('numsync', None, 4, count_of='sync'),
     42                     BitField('marker', 0, 1),
     43                     BitEnumField('payload_type', 0, 7, _rtp_payload_types),
     44                     ShortField('sequence', 0),
     45                     IntField('timestamp', 0),
     46                     IntField('sourcesync', 0),
     47                     FieldListField('sync', [], IntField("id",0), count_from=lambda pkt:pkt.numsync) ]
     48 
     49 bind_layers(RTP, RTPExtension, extension=1)
     50