Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/t30_logging.c @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 15:50:58 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * t30_logging.c - ITU T.30 FAX transfer processing | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Steve Underwood | |
9 * | |
10 * All rights reserved. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
14 * as published by the Free Software Foundation. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU Lesser General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU Lesser General Public | |
22 * License along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: t30_logging.c,v 1.12.4.2 2009/12/19 10:44:10 steveu Exp $ | |
26 */ | |
27 | |
28 /*! \file */ | |
29 | |
30 #if defined(HAVE_CONFIG_H) | |
31 #include "config.h" | |
32 #endif | |
33 | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <inttypes.h> | |
37 #include <string.h> | |
38 #include <fcntl.h> | |
39 #include <time.h> | |
40 #if defined(HAVE_TGMATH_H) | |
41 #include <tgmath.h> | |
42 #endif | |
43 #if defined(HAVE_MATH_H) | |
44 #include <math.h> | |
45 #endif | |
46 #include "floating_fudge.h" | |
47 #include <tiffio.h> | |
48 | |
49 #include "spandsp/telephony.h" | |
50 #include "spandsp/logging.h" | |
51 #include "spandsp/bit_operations.h" | |
52 #include "spandsp/queue.h" | |
53 #include "spandsp/power_meter.h" | |
54 #include "spandsp/complex.h" | |
55 #include "spandsp/tone_generate.h" | |
56 #include "spandsp/async.h" | |
57 #include "spandsp/hdlc.h" | |
58 #include "spandsp/fsk.h" | |
59 #include "spandsp/v29rx.h" | |
60 #include "spandsp/v29tx.h" | |
61 #include "spandsp/v27ter_rx.h" | |
62 #include "spandsp/v27ter_tx.h" | |
63 #include "spandsp/t4_rx.h" | |
64 #include "spandsp/t4_tx.h" | |
65 #include "spandsp/t30_fcf.h" | |
66 #include "spandsp/t35.h" | |
67 #include "spandsp/t30.h" | |
68 #include "spandsp/t30_logging.h" | |
69 | |
70 #include "spandsp/private/logging.h" | |
71 #include "spandsp/private/t4_rx.h" | |
72 #include "spandsp/private/t4_tx.h" | |
73 #include "spandsp/private/t30.h" | |
74 | |
75 #include "t30_local.h" | |
76 | |
77 /*! Value string pair structure */ | |
78 typedef struct | |
79 { | |
80 int val; | |
81 const char *str; | |
82 } value_string_t; | |
83 | |
84 enum | |
85 { | |
86 DISBIT1 = 0x01, | |
87 DISBIT2 = 0x02, | |
88 DISBIT3 = 0x04, | |
89 DISBIT4 = 0x08, | |
90 DISBIT5 = 0x10, | |
91 DISBIT6 = 0x20, | |
92 DISBIT7 = 0x40, | |
93 DISBIT8 = 0x80 | |
94 }; | |
95 | |
96 SPAN_DECLARE(const char *) t30_completion_code_to_str(int result) | |
97 { | |
98 switch (result) | |
99 { | |
100 case T30_ERR_OK: | |
101 return "OK"; | |
102 case T30_ERR_CEDTONE: | |
103 return "The CED tone exceeded 5s"; | |
104 case T30_ERR_T0_EXPIRED: | |
105 return "Timed out waiting for initial communication"; | |
106 case T30_ERR_T1_EXPIRED: | |
107 return "Timed out waiting for the first message"; | |
108 case T30_ERR_T3_EXPIRED: | |
109 return "Timed out waiting for procedural interrupt"; | |
110 case T30_ERR_HDLC_CARRIER: | |
111 return "The HDLC carrier did not stop in a timely manner"; | |
112 case T30_ERR_CANNOT_TRAIN: | |
113 return "Failed to train with any of the compatible modems"; | |
114 case T30_ERR_OPER_INT_FAIL: | |
115 return "Operator intervention failed"; | |
116 case T30_ERR_INCOMPATIBLE: | |
117 return "Far end is not compatible"; | |
118 case T30_ERR_RX_INCAPABLE: | |
119 return "Far end is not able to receive"; | |
120 case T30_ERR_TX_INCAPABLE: | |
121 return "Far end is not able to transmit"; | |
122 case T30_ERR_NORESSUPPORT: | |
123 return "Far end cannot receive at the resolution of the image"; | |
124 case T30_ERR_NOSIZESUPPORT: | |
125 return "Far end cannot receive at the size of image"; | |
126 case T30_ERR_UNEXPECTED: | |
127 return "Unexpected message received"; | |
128 case T30_ERR_TX_BADDCS: | |
129 return "Received bad response to DCS or training"; | |
130 case T30_ERR_TX_BADPG: | |
131 return "Received a DCN from remote after sending a page"; | |
132 case T30_ERR_TX_ECMPHD: | |
133 return "Invalid ECM response received from receiver"; | |
134 case T30_ERR_TX_GOTDCN: | |
135 return "Received a DCN while waiting for a DIS"; | |
136 case T30_ERR_TX_INVALRSP: | |
137 return "Invalid response after sending a page"; | |
138 case T30_ERR_TX_NODIS: | |
139 return "Received other than DIS while waiting for DIS"; | |
140 case T30_ERR_TX_PHBDEAD: | |
141 return "Received no response to DCS or TCF"; | |
142 case T30_ERR_TX_PHDDEAD: | |
143 return "No response after sending a page"; | |
144 case T30_ERR_TX_T5EXP: | |
145 return "Timed out waiting for receiver ready (ECM mode)"; | |
146 case T30_ERR_RX_ECMPHD: | |
147 return "Invalid ECM response received from transmitter"; | |
148 case T30_ERR_RX_GOTDCS: | |
149 return "DCS received while waiting for DTC"; | |
150 case T30_ERR_RX_INVALCMD: | |
151 return "Unexpected command after page received"; | |
152 case T30_ERR_RX_NOCARRIER: | |
153 return "Carrier lost during fax receive"; | |
154 case T30_ERR_RX_NOEOL: | |
155 return "Timed out while waiting for EOL (end Of line)"; | |
156 case T30_ERR_RX_NOFAX: | |
157 return "Timed out while waiting for first line"; | |
158 case T30_ERR_RX_T2EXPDCN: | |
159 return "Timer T2 expired while waiting for DCN"; | |
160 case T30_ERR_RX_T2EXPD: | |
161 return "Timer T2 expired while waiting for phase D"; | |
162 case T30_ERR_RX_T2EXPFAX: | |
163 return "Timer T2 expired while waiting for fax page"; | |
164 case T30_ERR_RX_T2EXPMPS: | |
165 return "Timer T2 expired while waiting for next fax page"; | |
166 case T30_ERR_RX_T2EXPRR: | |
167 return "Timer T2 expired while waiting for RR command"; | |
168 case T30_ERR_RX_T2EXP: | |
169 return "Timer T2 expired while waiting for NSS, DCS or MCF"; | |
170 case T30_ERR_RX_DCNWHY: | |
171 return "Unexpected DCN while waiting for DCS or DIS"; | |
172 case T30_ERR_RX_DCNDATA: | |
173 return "Unexpected DCN while waiting for image data"; | |
174 case T30_ERR_RX_DCNFAX: | |
175 return "Unexpected DCN while waiting for EOM, EOP or MPS"; | |
176 case T30_ERR_RX_DCNPHD: | |
177 return "Unexpected DCN after EOM or MPS sequence"; | |
178 case T30_ERR_RX_DCNRRD: | |
179 return "Unexpected DCN after RR/RNR sequence"; | |
180 case T30_ERR_RX_DCNNORTN: | |
181 return "Unexpected DCN after requested retransmission"; | |
182 case T30_ERR_FILEERROR: | |
183 return "TIFF/F file cannot be opened"; | |
184 case T30_ERR_NOPAGE: | |
185 return "TIFF/F page not found"; | |
186 case T30_ERR_BADTIFF: | |
187 return "TIFF/F format is not compatible"; | |
188 case T30_ERR_BADPAGE: | |
189 return "TIFF/F page number tag missing"; | |
190 case T30_ERR_BADTAG: | |
191 return "Incorrect values for TIFF/F tags"; | |
192 case T30_ERR_BADTIFFHDR: | |
193 return "Bad TIFF/F header - incorrect values in fields"; | |
194 case T30_ERR_NOMEM: | |
195 return "Cannot allocate memory for more pages"; | |
196 case T30_ERR_RETRYDCN: | |
197 return "Disconnected after permitted retries"; | |
198 case T30_ERR_CALLDROPPED: | |
199 return "The call dropped prematurely"; | |
200 case T30_ERR_NOPOLL: | |
201 return "Poll not accepted"; | |
202 case T30_ERR_IDENT_UNACCEPTABLE: | |
203 return "Ident not accepted"; | |
204 case T30_ERR_PSA_UNACCEPTABLE: | |
205 return "Polled sub-address not accepted"; | |
206 case T30_ERR_SEP_UNACCEPTABLE: | |
207 return "Selective polling address not accepted"; | |
208 case T30_ERR_SID_UNACCEPTABLE: | |
209 return "Sender identification not accepted"; | |
210 case T30_ERR_PWD_UNACCEPTABLE: | |
211 return "Password not accepted"; | |
212 case T30_ERR_SUB_UNACCEPTABLE: | |
213 return "Sub-address not accepted"; | |
214 case T30_ERR_TSA_UNACCEPTABLE: | |
215 return "Transmitting subscriber internet address not accepted"; | |
216 case T30_ERR_IRA_UNACCEPTABLE: | |
217 return "Internet routing address not accepted"; | |
218 case T30_ERR_CIA_UNACCEPTABLE: | |
219 return "Calling subscriber internet address not accepted"; | |
220 case T30_ERR_ISP_UNACCEPTABLE: | |
221 return "Internet selective polling address not accepted"; | |
222 case T30_ERR_CSA_UNACCEPTABLE: | |
223 return "Called subscriber internet address not accepted"; | |
224 } | |
225 return "???"; | |
226 } | |
227 /*- End of function --------------------------------------------------------*/ | |
228 | |
229 SPAN_DECLARE(const char *) t30_frametype(uint8_t x) | |
230 { | |
231 switch (x) | |
232 { | |
233 case T30_DIS: | |
234 return "DIS"; | |
235 case T30_CSI: | |
236 return "CSI"; | |
237 case T30_NSF: | |
238 return "NSF"; | |
239 case T30_DTC: | |
240 return "DTC"; | |
241 case T30_CIG: | |
242 return "CIG"; | |
243 case T30_NSC: | |
244 return "NSC"; | |
245 case T30_PWD: | |
246 return "PWD"; | |
247 case T30_SEP: | |
248 return "SEP"; | |
249 case T30_PSA: | |
250 return "PSA"; | |
251 case T30_CIA: | |
252 return "CIA"; | |
253 case T30_ISP: | |
254 return "ISP"; | |
255 case T30_DCS: | |
256 case T30_DCS | 0x01: | |
257 return "DCS"; | |
258 case T30_TSI: | |
259 case T30_TSI | 0x01: | |
260 return "TSI"; | |
261 case T30_NSS: | |
262 case T30_NSS | 0x01: | |
263 return "NSS"; | |
264 case T30_SUB: | |
265 case T30_SUB | 0x01: | |
266 return "SUB"; | |
267 case T30_SID: | |
268 case T30_SID | 0x01: | |
269 return "SID"; | |
270 case T30_CTC: | |
271 case T30_CTC | 0x01: | |
272 return "CTC"; | |
273 case T30_TSA: | |
274 case T30_TSA | 0x01: | |
275 return "TSA"; | |
276 case T30_IRA: | |
277 case T30_IRA | 0x01: | |
278 return "IRA"; | |
279 case T30_CFR: | |
280 case T30_CFR | 0x01: | |
281 return "CFR"; | |
282 case T30_FTT: | |
283 case T30_FTT | 0x01: | |
284 return "FTT"; | |
285 case T30_CTR: | |
286 case T30_CTR | 0x01: | |
287 return "CTR"; | |
288 case T30_CSA: | |
289 case T30_CSA | 0x01: | |
290 return "CSA"; | |
291 case T30_EOM: | |
292 case T30_EOM | 0x01: | |
293 return "EOM"; | |
294 case T30_MPS: | |
295 case T30_MPS | 0x01: | |
296 return "MPS"; | |
297 case T30_EOP: | |
298 case T30_EOP | 0x01: | |
299 return "EOP"; | |
300 case T30_PRI_EOM: | |
301 case T30_PRI_EOM | 0x01: | |
302 return "PRI-EOM"; | |
303 case T30_PRI_MPS: | |
304 case T30_PRI_MPS | 0x01: | |
305 return "PRI-MPS"; | |
306 case T30_PRI_EOP: | |
307 case T30_PRI_EOP | 0x01: | |
308 return "PRI-EOP"; | |
309 case T30_EOS: | |
310 case T30_EOS | 0x01: | |
311 return "EOS"; | |
312 case T30_PPS: | |
313 case T30_PPS | 0x01: | |
314 return "PPS"; | |
315 case T30_EOR: | |
316 case T30_EOR | 0x01: | |
317 return "EOR"; | |
318 case T30_RR: | |
319 case T30_RR | 0x01: | |
320 return "RR"; | |
321 case T30_MCF: | |
322 case T30_MCF | 0x01: | |
323 return "MCF"; | |
324 case T30_RTP: | |
325 case T30_RTP | 0x01: | |
326 return "RTP"; | |
327 case T30_RTN: | |
328 case T30_RTN | 0x01: | |
329 return "RTN"; | |
330 case T30_PIP: | |
331 case T30_PIP | 0x01: | |
332 return "PIP"; | |
333 case T30_PIN: | |
334 case T30_PIN | 0x01: | |
335 return "PIN"; | |
336 case T30_PPR: | |
337 case T30_PPR | 0x01: | |
338 return "PPR"; | |
339 case T30_RNR: | |
340 case T30_RNR | 0x01: | |
341 return "RNR"; | |
342 case T30_ERR: | |
343 case T30_ERR | 0x01: | |
344 return "ERR"; | |
345 case T30_FDM: | |
346 case T30_FDM | 0x01: | |
347 return "FDM"; | |
348 case T30_DCN: | |
349 case T30_DCN | 0x01: | |
350 return "DCN"; | |
351 case T30_CRP: | |
352 case T30_CRP | 0x01: | |
353 return "CRP"; | |
354 case T30_FNV: | |
355 case T30_FNV | 0x01: | |
356 return "FNV"; | |
357 case T30_TNR: | |
358 case T30_TNR | 0x01: | |
359 return "TNR"; | |
360 case T30_TR: | |
361 case T30_TR | 0x01: | |
362 return "TR"; | |
363 case T30_TK: | |
364 return "TK"; | |
365 case T30_RK: | |
366 return "RK"; | |
367 #if 0 | |
368 case T30_PSS: | |
369 return "PSS"; | |
370 #endif | |
371 case T30_DES: | |
372 return "DES"; | |
373 case T30_DEC: | |
374 return "DEC"; | |
375 case T30_DER: | |
376 return "DER"; | |
377 #if 0 | |
378 case T30_DTR: | |
379 return "DTR"; | |
380 #endif | |
381 case T30_DNK: | |
382 case T30_DNK | 0x01: | |
383 return "DNK"; | |
384 case T30_PID: | |
385 case T30_PID | 0x01: | |
386 return "PID"; | |
387 case T30_NULL: | |
388 return "NULL"; | |
389 case T4_FCD: | |
390 return "FCD"; | |
391 case T4_RCP: | |
392 return "RCP"; | |
393 } | |
394 return "???"; | |
395 } | |
396 /*- End of function --------------------------------------------------------*/ | |
397 | |
398 static void octet_reserved_bit(logging_state_t *log, | |
399 const uint8_t *msg, | |
400 int bit_no, | |
401 int expected) | |
402 { | |
403 char s[10] = ".... ...."; | |
404 int bit; | |
405 uint8_t octet; | |
406 | |
407 /* Break out the octet and the bit number within it. */ | |
408 octet = msg[((bit_no - 1) >> 3) + 3]; | |
409 bit_no = (bit_no - 1) & 7; | |
410 /* Now get the actual bit. */ | |
411 bit = (octet >> bit_no) & 1; | |
412 /* Is it what it should be. */ | |
413 if (bit ^ expected) | |
414 { | |
415 /* Only log unexpected values. */ | |
416 s[7 - bit_no + ((bit_no < 4) ? 1 : 0)] = (uint8_t) (bit + '0'); | |
417 span_log(log, SPAN_LOG_FLOW, " %s= Unexpected state for reserved bit: %d\n", s, bit); | |
418 } | |
419 } | |
420 /*- End of function --------------------------------------------------------*/ | |
421 | |
422 static void octet_bit_field(logging_state_t *log, | |
423 const uint8_t *msg, | |
424 int bit_no, | |
425 const char *desc, | |
426 const char *yeah, | |
427 const char *neigh) | |
428 { | |
429 char s[10] = ".... ...."; | |
430 int bit; | |
431 uint8_t octet; | |
432 const char *tag; | |
433 | |
434 /* Break out the octet and the bit number within it. */ | |
435 octet = msg[((bit_no - 1) >> 3) + 3]; | |
436 bit_no = (bit_no - 1) & 7; | |
437 /* Now get the actual bit. */ | |
438 bit = (octet >> bit_no) & 1; | |
439 /* Edit the bit string for display. */ | |
440 s[7 - bit_no + ((bit_no < 4) ? 1 : 0)] = (uint8_t) (bit + '0'); | |
441 /* Find the right tag to display. */ | |
442 if (bit) | |
443 { | |
444 if ((tag = yeah) == NULL) | |
445 tag = "Set"; | |
446 } | |
447 else | |
448 { | |
449 if ((tag = neigh) == NULL) | |
450 tag = "Not set"; | |
451 } | |
452 /* Eh, voila! */ | |
453 span_log(log, SPAN_LOG_FLOW, " %s= %s: %s\n", s, desc, tag); | |
454 } | |
455 /*- End of function --------------------------------------------------------*/ | |
456 | |
457 static void octet_field(logging_state_t *log, | |
458 const uint8_t *msg, | |
459 int start, | |
460 int end, | |
461 const char *desc, | |
462 const value_string_t tags[]) | |
463 { | |
464 char s[10] = ".... ...."; | |
465 int i; | |
466 uint8_t octet; | |
467 const char *tag; | |
468 | |
469 /* Break out the octet and the bit number range within it. */ | |
470 octet = msg[((start - 1) >> 3) + 3]; | |
471 start = (start - 1) & 7; | |
472 end = ((end - 1) & 7) + 1; | |
473 | |
474 /* Edit the bit string for display. */ | |
475 for (i = start; i < end; i++) | |
476 s[7 - i + ((i < 4) ? 1 : 0)] = (uint8_t) ((octet >> i) & 1) + '0'; | |
477 | |
478 /* Find the right tag to display. */ | |
479 octet = (uint8_t) ((octet >> start) & ((0xFF + (1 << (end - start))) & 0xFF)); | |
480 tag = "Invalid"; | |
481 for (i = 0; tags[i].str; i++) | |
482 { | |
483 if (octet == tags[i].val) | |
484 { | |
485 tag = tags[i].str; | |
486 break; | |
487 } | |
488 } | |
489 /* Eh, voila! */ | |
490 span_log(log, SPAN_LOG_FLOW, " %s= %s: %s\n", s, desc, tag); | |
491 } | |
492 /*- End of function --------------------------------------------------------*/ | |
493 | |
494 SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, int len) | |
495 { | |
496 logging_state_t *log; | |
497 uint8_t frame_type; | |
498 static const value_string_t available_signalling_rate_tags[] = | |
499 { | |
500 { 0x00, "V.27 ter fall-back mode" }, | |
501 { 0x01, "V.29" }, | |
502 { 0x02, "V.27 ter" }, | |
503 { 0x03, "V.27 ter and V.29" }, | |
504 { 0x0B, "V.27 ter, V.29, and V.17" }, | |
505 { 0x06, "Reserved" }, | |
506 { 0x0A, "Reserved" }, | |
507 { 0x0E, "Reserved" }, | |
508 { 0x0F, "Reserved" }, | |
509 { 0x04, "Not used" }, | |
510 { 0x05, "Not used" }, | |
511 { 0x08, "Not used" }, | |
512 { 0x09, "Not used" }, | |
513 { 0x0C, "Not used" }, | |
514 { 0x0D, "Not used" }, | |
515 { 0x00, NULL } | |
516 }; | |
517 static const value_string_t selected_signalling_rate_tags[] = | |
518 { | |
519 { 0x00, "V.27ter 2400bps" }, | |
520 { 0x01, "V.29, 9600bps" }, | |
521 { 0x02, "V.27ter 4800bps" }, | |
522 { 0x03, "V.29 7200bps" }, | |
523 { 0x08, "V.17 14400bps" }, | |
524 { 0x09, "V.17 9600bps" }, | |
525 { 0x0A, "V.17 12000bps" }, | |
526 { 0x0B, "V.17 7200bps" }, | |
527 { 0x05, "Reserved" }, | |
528 { 0x07, "Reserved" }, | |
529 { 0x0C, "Reserved" }, | |
530 { 0x0D, "Reserved" }, | |
531 { 0x0E, "Reserved" }, | |
532 { 0x0F, "Reserved" }, | |
533 { 0x00, NULL } | |
534 }; | |
535 static const value_string_t available_scan_line_length_tags[] = | |
536 { | |
537 { 0x00, "215mm +- 1%" }, | |
538 { 0x01, "215mm +- 1% and 255mm +- 1%" }, | |
539 { 0x02, "215mm +- 1%, 255mm +- 1% and 303mm +- 1%" }, | |
540 { 0x00, NULL } | |
541 }; | |
542 static const value_string_t selected_scan_line_length_tags[] = | |
543 { | |
544 { 0x00, "215mm +- 1%" }, | |
545 { 0x01, "255mm +- 1%" }, | |
546 { 0x02, "303mm +- 1%" }, | |
547 { 0x00, NULL } | |
548 }; | |
549 static const value_string_t available_recording_length_tags[] = | |
550 { | |
551 { 0x00, "A4 (297mm)" }, | |
552 { 0x01, "A4 (297mm) and B4 (364mm)" }, | |
553 { 0x02, "Unlimited" }, | |
554 { 0x00, NULL } | |
555 }; | |
556 static const value_string_t selected_recording_length_tags[] = | |
557 { | |
558 { 0x00, "A4 (297mm)" }, | |
559 { 0x01, "B4 (364mm)" }, | |
560 { 0x02, "Unlimited" }, | |
561 { 0x00, NULL } | |
562 }; | |
563 static const value_string_t available_minimum_scan_line_time_tags[] = | |
564 { | |
565 { 0x00, "20ms at 3.85 l/mm; T7.7 = T3.85" }, | |
566 { 0x01, "5ms at 3.85 l/mm; T7.7 = T3.85" }, | |
567 { 0x02, "10ms at 3.85 l/mm; T7.7 = T3.85" }, | |
568 { 0x03, "20ms at 3.85 l/mm; T7.7 = 1/2 T3.85" }, | |
569 { 0x04, "40ms at 3.85 l/mm; T7.7 = T3.85" }, | |
570 { 0x05, "40ms at 3.85 l/mm; T7.7 = 1/2 T3.85" }, | |
571 { 0x06, "10ms at 3.85 l/mm; T7.7 = 1/2 T3.85" }, | |
572 { 0x07, "0ms at 3.85 l/mm; T7.7 = T3.85" }, | |
573 { 0x00, NULL } | |
574 }; | |
575 static const value_string_t selected_minimum_scan_line_time_tags[] = | |
576 { | |
577 { 0x00, "20ms" }, | |
578 { 0x01, "5ms" }, | |
579 { 0x02, "10ms" }, | |
580 { 0x04, "40ms" }, | |
581 { 0x07, "0ms" }, | |
582 { 0x00, NULL } | |
583 }; | |
584 static const value_string_t shared_data_memory_capacity_tags[] = | |
585 { | |
586 { 0x00, "Not available" }, | |
587 { 0x01, "Level 2 = 2.0 Mbytes" }, | |
588 { 0x02, "Level 1 = 1.0 Mbytes" }, | |
589 { 0x03, "Level 3 = unlimited (i.e. >= 32 Mbytes)" }, | |
590 { 0x00, NULL } | |
591 }; | |
592 static const value_string_t t89_profile_tags[] = | |
593 { | |
594 { 0x00, "Not used" }, | |
595 { 0x01, "Profiles 2 and 3" }, | |
596 { 0x02, "Profile 2" }, | |
597 { 0x04, "Profile 1" }, | |
598 { 0x06, "Profile 3" }, | |
599 { 0x03, "Reserved" }, | |
600 { 0x05, "Reserved" }, | |
601 { 0x07, "Reserved" }, | |
602 { 0x00, NULL } | |
603 }; | |
604 static const value_string_t t44_mixed_raster_content_tags[] = | |
605 { | |
606 { 0x00, "0" }, | |
607 { 0x01, "1" }, | |
608 { 0x02, "2" }, | |
609 { 0x32, "3" }, | |
610 { 0x04, "4" }, | |
611 { 0x05, "5" }, | |
612 { 0x06, "6" }, | |
613 { 0x07, "7" }, | |
614 { 0x00, NULL } | |
615 }; | |
616 | |
617 if (!span_log_test(&s->logging, SPAN_LOG_FLOW)) | |
618 return; | |
619 frame_type = pkt[2] & 0xFE; | |
620 log = &s->logging; | |
621 if (len <= 2) | |
622 { | |
623 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
624 return; | |
625 } | |
626 | |
627 span_log(log, SPAN_LOG_FLOW, "%s:\n", t30_frametype(pkt[2])); | |
628 if (len <= 3) | |
629 { | |
630 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
631 return; | |
632 } | |
633 octet_bit_field(log, pkt, 1, "Store and forward Internet fax (T.37)", NULL, NULL); | |
634 octet_reserved_bit(log, pkt, 2, 0); | |
635 octet_bit_field(log, pkt, 3, "Real-time Internet fax (T.38)", NULL, NULL); | |
636 octet_bit_field(log, pkt, 4, "3G mobile network", NULL, NULL); | |
637 octet_reserved_bit(log, pkt, 5, 0); | |
638 if (frame_type == T30_DCS) | |
639 { | |
640 octet_reserved_bit(log, pkt, 6, 0); | |
641 octet_reserved_bit(log, pkt, 7, 0); | |
642 } | |
643 else | |
644 { | |
645 octet_bit_field(log, pkt, 6, "V.8 capabilities", NULL, NULL); | |
646 octet_bit_field(log, pkt, 7, "Preferred octets", "64 octets", "256 octets"); | |
647 } | |
648 octet_reserved_bit(log, pkt, 8, 0); | |
649 if (len <= 4) | |
650 { | |
651 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
652 return; | |
653 } | |
654 | |
655 if (frame_type == T30_DCS) | |
656 { | |
657 octet_reserved_bit(log, pkt, 9, 0); | |
658 octet_bit_field(log, pkt, 10, "Receive fax", NULL, NULL); | |
659 octet_field(log, pkt, 11, 14, "Selected data signalling rate", selected_signalling_rate_tags); | |
660 } | |
661 else | |
662 { | |
663 octet_bit_field(log, pkt, 9, "Ready to transmit a fax document (polling)", NULL, NULL); | |
664 octet_bit_field(log, pkt, 10, "Can receive fax", NULL, NULL); | |
665 octet_field(log, pkt, 11, 14, "Supported data signalling rates", available_signalling_rate_tags); | |
666 } | |
667 octet_bit_field(log, pkt, 15, "R8x7.7lines/mm and/or 200x200pels/25.4mm", NULL, NULL); | |
668 octet_bit_field(log, pkt, 16, "2-D coding", NULL, NULL); | |
669 if (len <= 5) | |
670 { | |
671 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
672 return; | |
673 } | |
674 | |
675 if (frame_type == T30_DCS) | |
676 { | |
677 octet_field(log, pkt, 17, 18, "Recording width", selected_scan_line_length_tags); | |
678 octet_field(log, pkt, 19, 20, "Recording length", selected_recording_length_tags); | |
679 octet_field(log, pkt, 21, 23, "Minimum scan line time", selected_minimum_scan_line_time_tags); | |
680 } | |
681 else | |
682 { | |
683 octet_field(log, pkt, 17, 18, "Recording width", available_scan_line_length_tags); | |
684 octet_field(log, pkt, 19, 20, "Recording length", available_recording_length_tags); | |
685 octet_field(log, pkt, 21, 23, "Receiver's minimum scan line time", available_minimum_scan_line_time_tags); | |
686 } | |
687 octet_bit_field(log, pkt, 24, "Extension indicator", NULL, NULL); | |
688 if (!(pkt[5] & DISBIT8)) | |
689 return; | |
690 if (len <= 6) | |
691 { | |
692 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
693 return; | |
694 } | |
695 | |
696 octet_reserved_bit(log, pkt, 25, 0); | |
697 octet_bit_field(log, pkt, 26, "Compressed/uncompressed mode", "Uncompressed", "Compressed"); | |
698 octet_bit_field(log, pkt, 27, "Error correction mode (ECM)", "ECM", "Non-ECM"); | |
699 if (frame_type == T30_DCS) | |
700 octet_bit_field(log, pkt, 28, "Frame size", "64 octets", "256 octets"); | |
701 else | |
702 octet_reserved_bit(log, pkt, 28, 0); | |
703 octet_reserved_bit(log, pkt, 29, 0); | |
704 octet_reserved_bit(log, pkt, 30, 0); | |
705 octet_bit_field(log, pkt, 31, "T.6 coding", NULL, NULL); | |
706 octet_bit_field(log, pkt, 32, "Extension indicator", NULL, NULL); | |
707 if (!(pkt[6] & DISBIT8)) | |
708 return; | |
709 if (len <= 7) | |
710 { | |
711 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
712 return; | |
713 } | |
714 | |
715 octet_bit_field(log, pkt, 33, "\"Field not valid\" supported", NULL, NULL); | |
716 if (frame_type == T30_DCS) | |
717 { | |
718 octet_reserved_bit(log, pkt, 34, 0); | |
719 octet_reserved_bit(log, pkt, 35, 0); | |
720 } | |
721 else | |
722 { | |
723 octet_bit_field(log, pkt, 34, "Multiple selective polling", NULL, NULL); | |
724 octet_bit_field(log, pkt, 35, "Polled sub-address", NULL, NULL); | |
725 } | |
726 octet_bit_field(log, pkt, 36, "T.43 coding", NULL, NULL); | |
727 octet_bit_field(log, pkt, 37, "Plane interleave", NULL, NULL); | |
728 octet_bit_field(log, pkt, 38, "Voice coding with 32kbit/s ADPCM (Rec. G.726)", NULL, NULL); | |
729 octet_bit_field(log, pkt, 39, "Reserved for the use of extended voice coding set", NULL, NULL); | |
730 octet_bit_field(log, pkt, 40, "Extension indicator", NULL, NULL); | |
731 if (!(pkt[7] & DISBIT8)) | |
732 return; | |
733 if (len <= 8) | |
734 { | |
735 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
736 return; | |
737 } | |
738 octet_bit_field(log, pkt, 41, "R8x15.4lines/mm", NULL, NULL); | |
739 octet_bit_field(log, pkt, 42, "300x300pels/25.4mm", NULL, NULL); | |
740 octet_bit_field(log, pkt, 43, "R16x15.4lines/mm and/or 400x400pels/25.4mm", NULL, NULL); | |
741 if (frame_type == T30_DCS) | |
742 { | |
743 octet_bit_field(log, pkt, 44, "Resolution type selection", "Inch", "Metric"); | |
744 octet_reserved_bit(log, pkt, 45, 0); | |
745 octet_reserved_bit(log, pkt, 46, 0); | |
746 octet_reserved_bit(log, pkt, 47, 0); | |
747 } | |
748 else | |
749 { | |
750 octet_bit_field(log, pkt, 44, "Inch-based resolution preferred", NULL, NULL); | |
751 octet_bit_field(log, pkt, 45, "Metric-based resolution preferred", NULL, NULL); | |
752 octet_bit_field(log, pkt, 46, "Minimum scan line time for higher resolutions", "T15.4 = 1/2 T7.7", "T15.4 = T7.7"); | |
753 octet_bit_field(log, pkt, 47, "Selective polling", NULL, NULL); | |
754 } | |
755 octet_bit_field(log, pkt, 48, "Extension indicator", NULL, NULL); | |
756 if (!(pkt[8] & DISBIT8)) | |
757 return; | |
758 if (len <= 9) | |
759 { | |
760 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
761 return; | |
762 } | |
763 | |
764 octet_bit_field(log, pkt, 49, "Sub-addressing", NULL, NULL); | |
765 if (frame_type == T30_DCS) | |
766 { | |
767 octet_bit_field(log, pkt, 50, "Sender identification transmission", NULL, NULL); | |
768 octet_reserved_bit(log, pkt, 51, 0); | |
769 } | |
770 else | |
771 { | |
772 octet_bit_field(log, pkt, 50, "Password", NULL, NULL); | |
773 octet_bit_field(log, pkt, 51, "Ready to transmit a data file (polling)", NULL, NULL); | |
774 } | |
775 octet_reserved_bit(log, pkt, 52, 0); | |
776 octet_bit_field(log, pkt, 53, "Binary file transfer (BFT)", NULL, NULL); | |
777 octet_bit_field(log, pkt, 54, "Document transfer mode (DTM)", NULL, NULL); | |
778 octet_bit_field(log, pkt, 55, "Electronic data interchange (EDI)", NULL, NULL); | |
779 octet_bit_field(log, pkt, 56, "Extension indicator", NULL, NULL); | |
780 if (!(pkt[9] & DISBIT8)) | |
781 return; | |
782 if (len <= 10) | |
783 { | |
784 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
785 return; | |
786 } | |
787 | |
788 octet_bit_field(log, pkt, 57, "Basic transfer mode (BTM)", NULL, NULL); | |
789 octet_reserved_bit(log, pkt, 58, 0); | |
790 if (frame_type == T30_DCS) | |
791 octet_reserved_bit(log, pkt, 59, 0); | |
792 else | |
793 octet_bit_field(log, pkt, 59, "Ready to transfer a character or mixed mode document (polling)", NULL, NULL); | |
794 octet_bit_field(log, pkt, 60, "Character mode", NULL, NULL); | |
795 octet_reserved_bit(log, pkt, 61, 0); | |
796 octet_bit_field(log, pkt, 62, "Mixed mode (Annex E/T.4)", NULL, NULL); | |
797 octet_reserved_bit(log, pkt, 63, 0); | |
798 octet_bit_field(log, pkt, 64, "Extension indicator", NULL, NULL); | |
799 if (!(pkt[10] & DISBIT8)) | |
800 return; | |
801 if (len <= 11) | |
802 { | |
803 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
804 return; | |
805 } | |
806 | |
807 octet_bit_field(log, pkt, 65, "Processable mode 26 (Rec. T.505)", NULL, NULL); | |
808 octet_bit_field(log, pkt, 66, "Digital network capability", NULL, NULL); | |
809 octet_bit_field(log, pkt, 67, "Duplex capability", "Full", "Half only"); | |
810 if (frame_type == T30_DCS) | |
811 octet_bit_field(log, pkt, 68, "Full colour mode", NULL, NULL); | |
812 else | |
813 octet_bit_field(log, pkt, 68, "JPEG coding", NULL, NULL); | |
814 octet_bit_field(log, pkt, 69, "Full colour mode", NULL, NULL); | |
815 if (frame_type == T30_DCS) | |
816 octet_bit_field(log, pkt, 70, "Preferred Huffman tables", NULL, NULL); | |
817 else | |
818 octet_reserved_bit(log, pkt, 70, 0); | |
819 octet_bit_field(log, pkt, 71, "12bits/pel component", NULL, NULL); | |
820 octet_bit_field(log, pkt, 72, "Extension indicator", NULL, NULL); | |
821 if (!(pkt[11] & DISBIT8)) | |
822 return; | |
823 if (len <= 12) | |
824 { | |
825 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
826 return; | |
827 } | |
828 | |
829 octet_bit_field(log, pkt, 73, "No subsampling (1:1:1)", NULL, NULL); | |
830 octet_bit_field(log, pkt, 74, "Custom illuminant", NULL, NULL); | |
831 octet_bit_field(log, pkt, 75, "Custom gamut range", NULL, NULL); | |
832 octet_bit_field(log, pkt, 76, "North American Letter (215.9mm x 279.4mm)", NULL, NULL); | |
833 octet_bit_field(log, pkt, 77, "North American Legal (215.9mm x 355.6mm)", NULL, NULL); | |
834 octet_bit_field(log, pkt, 78, "Single-progression sequential coding (Rec. T.85) basic", NULL, NULL); | |
835 octet_bit_field(log, pkt, 79, "Single-progression sequential coding (Rec. T.85) optional L0", NULL, NULL); | |
836 octet_bit_field(log, pkt, 80, "Extension indicator", NULL, NULL); | |
837 if (!(pkt[12] & DISBIT8)) | |
838 return; | |
839 if (len <= 13) | |
840 { | |
841 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
842 return; | |
843 } | |
844 | |
845 octet_bit_field(log, pkt, 81, "HKM key management", NULL, NULL); | |
846 octet_bit_field(log, pkt, 82, "RSA key management", NULL, NULL); | |
847 octet_bit_field(log, pkt, 83, "Override", NULL, NULL); | |
848 octet_bit_field(log, pkt, 84, "HFX40 cipher", NULL, NULL); | |
849 octet_bit_field(log, pkt, 85, "Alternative cipher number 2", NULL, NULL); | |
850 octet_bit_field(log, pkt, 86, "Alternative cipher number 3", NULL, NULL); | |
851 octet_bit_field(log, pkt, 87, "HFX40-I hashing", NULL, NULL); | |
852 octet_bit_field(log, pkt, 88, "Extension indicator", NULL, NULL); | |
853 if (!(pkt[13] & DISBIT8)) | |
854 return; | |
855 if (len <= 14) | |
856 { | |
857 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
858 return; | |
859 } | |
860 | |
861 octet_bit_field(log, pkt, 89, "Alternative hashing system 2", NULL, NULL); | |
862 octet_bit_field(log, pkt, 90, "Alternative hashing system 3", NULL, NULL); | |
863 octet_bit_field(log, pkt, 91, "Reserved for future security features", NULL, NULL); | |
864 octet_field(log, pkt, 92, 94, "T.44 (Mixed Raster Content)", t44_mixed_raster_content_tags); | |
865 octet_bit_field(log, pkt, 95, "Page length maximum stripe size for T.44 (Mixed Raster Content)", NULL, NULL); | |
866 octet_bit_field(log, pkt, 96, "Extension indicator", NULL, NULL); | |
867 if (!(pkt[14] & DISBIT8)) | |
868 return; | |
869 if (len <= 15) | |
870 { | |
871 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
872 return; | |
873 } | |
874 | |
875 octet_bit_field(log, pkt, 97, "Colour/gray-scale 300pels/25.4mm x 300lines/25.4mm or 400pels/25.4mm x 400lines/25.4mm resolution", NULL, NULL); | |
876 octet_bit_field(log, pkt, 98, "100pels/25.4mm x 100lines/25.4mm for colour/gray scale", NULL, NULL); | |
877 octet_bit_field(log, pkt, 99, "Simple phase C BFT negotiations", NULL, NULL); | |
878 if (frame_type == T30_DCS) | |
879 { | |
880 octet_reserved_bit(log, pkt, 100, 0); | |
881 octet_reserved_bit(log, pkt, 101, 0); | |
882 } | |
883 else | |
884 { | |
885 octet_bit_field(log, pkt, 100, "Extended BFT Negotiations capable", NULL, NULL); | |
886 octet_bit_field(log, pkt, 101, "Internet Selective Polling address (ISP)", NULL, NULL); | |
887 } | |
888 octet_bit_field(log, pkt, 102, "Internet Routing Address (IRA)", NULL, NULL); | |
889 octet_reserved_bit(log, pkt, 103, 0); | |
890 octet_bit_field(log, pkt, 104, "Extension indicator", NULL, NULL); | |
891 if (!(pkt[15] & DISBIT8)) | |
892 return; | |
893 if (len <= 16) | |
894 { | |
895 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
896 return; | |
897 } | |
898 | |
899 octet_bit_field(log, pkt, 105, "600pels/25.4mm x 600lines/25.4mm", NULL, NULL); | |
900 octet_bit_field(log, pkt, 106, "1200pels/25.4mm x 1200lines/25.4mm", NULL, NULL); | |
901 octet_bit_field(log, pkt, 107, "300pels/25.4mm x 600lines/25.4mm", NULL, NULL); | |
902 octet_bit_field(log, pkt, 108, "400pels/25.4mm x 800lines/25.4mm", NULL, NULL); | |
903 octet_bit_field(log, pkt, 109, "600pels/25.4mm x 1200lines/25.4mm", NULL, NULL); | |
904 octet_bit_field(log, pkt, 110, "Colour/gray scale 600pels/25.4mm x 600lines/25.4mm", NULL, NULL); | |
905 octet_bit_field(log, pkt, 111, "Colour/gray scale 1200pels/25.4mm x 1200lines/25.4mm", NULL, NULL); | |
906 octet_bit_field(log, pkt, 112, "Extension indicator", NULL, NULL); | |
907 if (!(pkt[16] & DISBIT8)) | |
908 return; | |
909 if (len <= 17) | |
910 { | |
911 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
912 return; | |
913 } | |
914 | |
915 octet_bit_field(log, pkt, 113, "Double sided printing capability (alternate mode)", NULL, NULL); | |
916 octet_bit_field(log, pkt, 114, "Double sided printing capability (continuous mode)", NULL, NULL); | |
917 if (frame_type == T30_DCS) | |
918 octet_bit_field(log, pkt, 115, "Black and white mixed raster content profile (MRCbw)", NULL, NULL); | |
919 else | |
920 octet_reserved_bit(log, pkt, 115, 0); | |
921 octet_bit_field(log, pkt, 116, "T.45 (run length colour encoded)", NULL, NULL); | |
922 octet_field(log, pkt, 117, 118, "Shared memory", shared_data_memory_capacity_tags); | |
923 octet_bit_field(log, pkt, 119, "T.44 colour space", NULL, NULL); | |
924 octet_bit_field(log, pkt, 120, "Extension indicator", NULL, NULL); | |
925 if (!(pkt[17] & DISBIT8)) | |
926 return; | |
927 if (len <= 18) | |
928 { | |
929 span_log(log, SPAN_LOG_FLOW, " Frame is short\n"); | |
930 return; | |
931 } | |
932 | |
933 octet_bit_field(log, pkt, 121, "Flow control capability for T.38 communication", NULL, NULL); | |
934 octet_bit_field(log, pkt, 122, "K>4", NULL, NULL); | |
935 octet_bit_field(log, pkt, 123, "Internet aware T.38 mode fax (not affected by data signal rate bits)", NULL, NULL); | |
936 octet_field(log, pkt, 124, 126, "T.89 (Application profiles for ITU-T Rec T.88)", t89_profile_tags); | |
937 octet_bit_field(log, pkt, 127, "sYCC-JPEG coding", NULL, NULL); | |
938 octet_bit_field(log, pkt, 128, "Extension indicator", NULL, NULL); | |
939 if (!(pkt[18] & DISBIT8)) | |
940 return; | |
941 | |
942 span_log(log, SPAN_LOG_FLOW, " Extended beyond the current T.30 specification!\n"); | |
943 } | |
944 /*- End of function --------------------------------------------------------*/ | |
945 /*- End of file ------------------------------------------------------------*/ |