Asterisk - The Open Source Telephony Project  21.4.1
Public Member Functions | Data Fields | Static Public Attributes
FaxPcap Class Reference
Inheritance diagram for FaxPcap:

Public Member Functions

def __init__ (self, outfile)
 
def add (self, ifp)
 

Data Fields

 date
 
 outfile
 
 prev_data
 
 seqno
 
 udpseqno
 

Static Public Attributes

tuple PCAP_PREAMBLE
 

Detailed Description

Definition at line 56 of file spandspflow2pcap.py.

Member Function Documentation

def add (   self,
  ifp 
)
Add the IFP packet.

T.38 basic format of UDPTL payload section with redundancy:

UDPTL_SEQNO
- 2 sequence number (big endian)
UDPTL_PRIMARY_PAYLOAD (T30?)
- 1 subpacket length (excluding this byte)
- 1 type of message (e.g. 0xd0 for data(?))
- 1 items in data field (e.g. 0x01)
- 2 length of data (big endian)
- N data
RECOVERY (optional)
- 2 count of previous seqno packets (big endian)
- N UDPTL_PRIMARY_PAYLOAD of (seqno-1)
- N UDPTL_PRIMARY_PAYLOAD of (seqno-2)
- ...

Definition at line 71 of file spandspflow2pcap.py.

References FaxPcap._add_garbage(), FaxPcap._add_preamble(), FaxPcap._make_packet(), FaxPcap.add(), FaxPcap.date, FaxPcap.PCAP_PREAMBLE, FaxPcap.prev_data, FaxPcap.seqno, and FaxPcap.udpseqno.

Referenced by FaxPcap.add().

71  def add(self, ifp):
72  """
73  Add the IFP packet.
74 
75  T.38 basic format of UDPTL payload section with redundancy:
76 
77  UDPTL_SEQNO
78  - 2 sequence number (big endian)
79  UDPTL_PRIMARY_PAYLOAD (T30?)
80  - 1 subpacket length (excluding this byte)
81  - 1 type of message (e.g. 0xd0 for data(?))
82  - 1 items in data field (e.g. 0x01)
83  - 2 length of data (big endian)
84  - N data
85  RECOVERY (optional)
86  - 2 count of previous seqno packets (big endian)
87  - N UDPTL_PRIMARY_PAYLOAD of (seqno-1)
88  - N UDPTL_PRIMARY_PAYLOAD of (seqno-2)
89  - ...
90  """
91  # First packet?
92  if self.seqno is None:
93  # Add preamble.
94  self._add_preamble()
95  # Start a second late (optional).
96  self._add_garbage(ifp.date)
97 
98  # Set sequence, and fill with missing leading zeroes.
99  self.seqno = 0
100  for i in range(ifp.seqno):
101  self.add(IFP(date=ifp.date, seqno=i, data=bytearray([0])))
102 
103  # Auto-increasing dates
104  if self.date is None or ifp.date > self.date:
105  self.date = ifp.date
106  elif ifp.date < self.date.replace(microsecond=0):
107  assert False, 'More packets than expected in 1s? {!r}/{!r}'.format(
108  ifp.date, self.date)
109  else:
110  self.date += timedelta(microseconds=9000)
111 
112  # Add packet.
113  self.seqno = ifp.seqno
114  try:
115  self.outfile.write(self._make_packet(ifp.data))
116  except SkipPacket:
117  pass
118 
def _add_garbage(self, date)

Field Documentation

tuple PCAP_PREAMBLE
static
Initial value:
1 = n2b(
2  'd4 c3 b2 a1 02 00 04 00'
3  '00 00 00 00 00 00 00 00'
4  'ff ff 00 00 71 00 00 00')

Definition at line 57 of file spandspflow2pcap.py.

Referenced by FaxPcap.add().


The documentation for this class was generated from the following file: