]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fixed the application of the T.30 T1 timeout in faxing.
authorSteve Underwood <steveu@coppice.org>
Sat, 23 Jan 2016 17:58:36 +0000 (01:58 +0800)
committerSteve Underwood <steveu@coppice.org>
Sat, 23 Jan 2016 17:58:36 +0000 (01:58 +0800)
libs/spandsp/spandsp/fax-tests.xml
libs/spandsp/src/t30.c
libs/spandsp/src/t30_api.c
libs/spandsp/src/t30_logging.c
libs/spandsp/tests/fax_tester.c
libs/spandsp/tests/tsb85_extra_tests.sh

index 2f524687219e22e3de887c878111ff0008f0c58f..1428bb97f5cb3ebc588066b120e82d75c0dbbfd9 100644 (file)
         <step dir="R" type="CLEAR" timein="800" timeout="1200"/>
         <step type="STATUS" value="OK"/>
     </test>
+    <test name="Invalid-signalling-rate">
+        <step type="CALL"/>
+
+        <!--<step dir="T" type="CNG"/>-->
+
+        <step dir="R" type="CED"/>
+        <!-- Invalid signalling rate in DCS -->
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..." timeout="60000"/>
+        <step dir="R" type="SILENCE"/>
+
+        <step type="WAIT" value="75"/>
+        <step dir="T" type="PREAMBLE" modem="V.21"/>
+        <step dir="T" type="HDLC" tag="DCS" value="FF C8 C1 00 49 1f 00"/>
+        <step dir="T" type="POSTAMBLE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DCN" value="FF C8 5F"/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="CLEAR" timein="800" timeout="1200"/>
+        <step type="STATUS" value="OK"/>
+    </test>
+    <test name="No-caller-response">
+        <step type="CALL"/>
+        <step dir="T" type="SET" tag="IDENT" value="+0123456789"/>
+
+        <!--<step dir="T" type="CNG"/>-->
+
+        <step dir="R" type="CED"/>
+        <!-- -->
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..." timeout="60000"/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..."/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..."/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..."/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..."/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DIS" value="FF C8 01 ..."/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="HDLC" modem="V.21" tag="DCN" value="FF C8 5F"/>
+        <step dir="R" type="SILENCE"/>
+
+        <step dir="R" type="CLEAR" timein="800" timeout="1200"/>
+        <step type="STATUS" value="T1_EXPIRED"/>
+    </test>
+    <test name="No-answerer-response">
+        <step type="ANSWER" value="etsi_300_242_a4_impress_white.tif"/>
+        <step dir="T" type="SET" tag="IDENT" value="+0123456789"/>
+
+        <step dir="R" type="CNG"/>
+
+        <step type="WAIT" value="75"/>
+
+        <step dir="R" type="CLEAR" timein="55000" timeout="65000"/>
+        <step type="STATUS" value="T0_EXPIRED"/>
+    </test>
 </test-group>
 </fax-tests>
index f13d4eb879460444286f3a43b9112f6dd45436cc..189a16b00c6bd806a98fea82b4ca24eb531b9b0a 100644 (file)
@@ -2712,6 +2712,7 @@ static int send_cfr_sequence(t30_state_t *s, int start)
         s->step++;
         if (send_csa_frame(s))
             break;
+        /*endif*/
         /* Fall through */
     case 1:
         s->step++;
@@ -5721,6 +5722,7 @@ static void set_phase(t30_state_t *s, int phase)
     case T30_PHASE_D_TX:
         if (!s->far_end_detected  &&  s->timer_t0_t1 > 0)
         {
+            /* Switch from T0 to T1 */
             s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1);
             s->far_end_detected = true;
         }
@@ -5822,7 +5824,10 @@ static void set_state(t30_state_t *s, int state)
 static void repeat_last_command(t30_state_t *s)
 {
     s->step = 0;
-    if (++s->retries >= MAX_COMMAND_TRIES)
+    /* If T0 or T1 are in progress we do not want to apply a limit to the maximum number of retries. We
+       let T0 or T1 terminate things if the far end doesn't communicate. */
+    s->retries++;
+    if (s->timer_t0_t1 == 0  &&  s->retries >= MAX_COMMAND_TRIES)
     {
         span_log(&s->logging, SPAN_LOG_FLOW, "Too many retries. Giving up.\n");
         switch (s->state)
@@ -6667,6 +6672,7 @@ static void t30_hdlc_rx_status(void *user_data, int status)
     case SIG_STATUS_FRAMING_OK:
         if (!s->far_end_detected  &&  s->timer_t0_t1 > 0)
         {
+            /* Switch from T0 to T1 */
             s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1);
             s->far_end_detected = true;
             if (s->phase == T30_PHASE_A_CED  ||  s->phase == T30_PHASE_A_CNG)
index 724dcf97354009e5b15f804301c75fe93c4c35d8..23c2d49375f49befde4b1c657b8244fcaa81c057 100644 (file)
@@ -120,26 +120,34 @@ SPAN_DECLARE(int) t33_sub_address_extract_field(uint8_t num[21], const uint8_t t
             {
                 type = T33_SST;
             }
+            /*endif*/
             while (t33[i])
             {
                 ch = t33[i++];
                 if (ch == '#')
                     break;
+                /*endif*/
                 num[j++] = ch;
                 if (j >= 20)
                     return -1;
+                /*endif*/
             }
+            /*endwhile*/
             num[j] = '\0';
             return type;
         }
+        /*endif*/
         /* Skip this field */
         i++;
         while (t33[i])
         {
             if (t33[i++] == '#')
                 break;
+            /*endif*/
         }
+        /*endwhile*/
     }
+    /*endfor*/
     return T33_NONE;
 }
 /*- End of function --------------------------------------------------------*/
@@ -148,8 +156,10 @@ SPAN_DECLARE(void) t33_sub_address_add_field(uint8_t t33[], const uint8_t field[
 {
     if (t33[0] != '\0')
         strcat((char *) t33, "#");
+    /*endif*/
     if (type == T33_SST)
         strcat((char *) t33, "#");
+    /*endif*/
     strcat((char *) t33, (const char *) field);
 }
 /*- End of function --------------------------------------------------------*/
@@ -161,8 +171,10 @@ SPAN_DECLARE(int) t30_set_tx_ident(t30_state_t *s, const char *id)
         s->tx_info.ident[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(id) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.ident, id);
     t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident);
     return 0;
@@ -173,6 +185,7 @@ SPAN_DECLARE(const char *) t30_get_tx_ident(t30_state_t *s)
 {
     if (s->tx_info.ident[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.ident;
 }
 /*- End of function --------------------------------------------------------*/
@@ -181,6 +194,7 @@ SPAN_DECLARE(const char *) t30_get_rx_ident(t30_state_t *s)
 {
     if (s->rx_info.ident[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.ident;
 }
 /*- End of function --------------------------------------------------------*/
@@ -192,8 +206,10 @@ SPAN_DECLARE(int) t30_set_tx_sub_address(t30_state_t *s, const char *sub_address
         s->tx_info.sub_address[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(sub_address) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.sub_address, sub_address);
     return 0;
 }
@@ -203,6 +219,7 @@ SPAN_DECLARE(const char *) t30_get_tx_sub_address(t30_state_t *s)
 {
     if (s->tx_info.sub_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.sub_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -211,6 +228,7 @@ SPAN_DECLARE(const char *) t30_get_rx_sub_address(t30_state_t *s)
 {
     if (s->rx_info.sub_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.sub_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -222,8 +240,10 @@ SPAN_DECLARE(int) t30_set_tx_selective_polling_address(t30_state_t *s, const cha
         s->tx_info.selective_polling_address[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(selective_polling_address) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.selective_polling_address, selective_polling_address);
     return 0;
 }
@@ -233,6 +253,7 @@ SPAN_DECLARE(const char *) t30_get_tx_selective_polling_address(t30_state_t *s)
 {
     if (s->tx_info.selective_polling_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.selective_polling_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -241,6 +262,7 @@ SPAN_DECLARE(const char *) t30_get_rx_selective_polling_address(t30_state_t *s)
 {
     if (s->rx_info.selective_polling_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.selective_polling_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -252,8 +274,10 @@ SPAN_DECLARE(int) t30_set_tx_polled_sub_address(t30_state_t *s, const char *poll
         s->tx_info.polled_sub_address[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(polled_sub_address) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.polled_sub_address, polled_sub_address);
     return 0;
 }
@@ -263,6 +287,7 @@ SPAN_DECLARE(const char *) t30_get_tx_polled_sub_address(t30_state_t *s)
 {
     if (s->tx_info.polled_sub_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.polled_sub_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -271,6 +296,7 @@ SPAN_DECLARE(const char *) t30_get_rx_polled_sub_address(t30_state_t *s)
 {
     if (s->rx_info.polled_sub_address[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.polled_sub_address;
 }
 /*- End of function --------------------------------------------------------*/
@@ -282,8 +308,10 @@ SPAN_DECLARE(int) t30_set_tx_sender_ident(t30_state_t *s, const char *sender_ide
         s->tx_info.sender_ident[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(sender_ident) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.sender_ident, sender_ident);
     return 0;
 }
@@ -293,6 +321,7 @@ SPAN_DECLARE(const char *) t30_get_tx_sender_ident(t30_state_t *s)
 {
     if (s->tx_info.sender_ident[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.sender_ident;
 }
 /*- End of function --------------------------------------------------------*/
@@ -301,6 +330,7 @@ SPAN_DECLARE(const char *) t30_get_rx_sender_ident(t30_state_t *s)
 {
     if (s->rx_info.sender_ident[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.sender_ident;
 }
 /*- End of function --------------------------------------------------------*/
@@ -312,8 +342,10 @@ SPAN_DECLARE(int) t30_set_tx_password(t30_state_t *s, const char *password)
         s->tx_info.password[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(password) > T30_MAX_IDENT_LEN)
         return -1;
+    /*endif*/
     strcpy(s->tx_info.password, password);
     return 0;
 }
@@ -323,6 +355,7 @@ SPAN_DECLARE(const char *) t30_get_tx_password(t30_state_t *s)
 {
     if (s->tx_info.password[0] == '\0')
         return NULL;
+    /*endif*/
     return s->tx_info.password;
 }
 /*- End of function --------------------------------------------------------*/
@@ -331,6 +364,7 @@ SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s)
 {
     if (s->rx_info.password[0] == '\0')
         return NULL;
+    /*endif*/
     return s->rx_info.password;
 }
 /*- End of function --------------------------------------------------------*/
@@ -339,6 +373,7 @@ SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len)
 {
     if (s->tx_info.nsf)
         span_free(s->tx_info.nsf);
+    /*endif*/
     if (nsf  &&  len > 0  &&  (s->tx_info.nsf = span_alloc(len + 3)))
     {
         memcpy(&s->tx_info.nsf[3], nsf, len);
@@ -349,6 +384,7 @@ SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len)
         s->tx_info.nsf = NULL;
         s->tx_info.nsf_len = 0;
     }
+    /*endif*/
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -357,6 +393,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nsf(t30_state_t *s, const uint8_t *nsf[])
 {
     if (nsf)
         *nsf = s->tx_info.nsf;
+    /*endif*/
     return s->tx_info.nsf_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -365,6 +402,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[])
 {
     if (nsf)
         *nsf = s->rx_info.nsf;
+    /*endif*/
     return s->rx_info.nsf_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -373,6 +411,7 @@ SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len)
 {
     if (s->tx_info.nsc)
         span_free(s->tx_info.nsc);
+    /*endif*/
     if (nsc  &&  len > 0  &&  (s->tx_info.nsc = span_alloc(len + 3)))
     {
         memcpy(&s->tx_info.nsc[3], nsc, len);
@@ -383,6 +422,7 @@ SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len)
         s->tx_info.nsc = NULL;
         s->tx_info.nsc_len = 0;
     }
+    /*endif*/
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -391,6 +431,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nsc(t30_state_t *s, const uint8_t *nsc[])
 {
     if (nsc)
         *nsc = s->tx_info.nsc;
+    /*endif*/
     return s->tx_info.nsc_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -399,6 +440,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[])
 {
     if (nsc)
         *nsc = s->rx_info.nsc;
+    /*endif*/
     return s->rx_info.nsc_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -407,6 +449,7 @@ SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len)
 {
     if (s->tx_info.nss)
         span_free(s->tx_info.nss);
+    /*endif*/
     if (nss  &&  len > 0  &&  (s->tx_info.nss = span_alloc(len + 3)))
     {
         memcpy(&s->tx_info.nss[3], nss, len);
@@ -417,6 +460,7 @@ SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len)
         s->tx_info.nss = NULL;
         s->tx_info.nss_len = 0;
     }
+    /*endif*/
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -425,6 +469,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nss(t30_state_t *s, const uint8_t *nss[])
 {
     if (nss)
         *nss = s->tx_info.nss;
+    /*endif*/
     return s->tx_info.nss_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -433,6 +478,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[])
 {
     if (nss)
         *nss = s->rx_info.nss;
+    /*endif*/
     return s->rx_info.nss_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -441,20 +487,24 @@ SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address,
 {
     if (s->tx_info.tsa)
         span_free(s->tx_info.tsa);
+    /*endif*/
     if (address == NULL  ||  len == 0)
     {
         s->tx_info.tsa = NULL;
         s->tx_info.tsa_len = 0;
         return 0;
     }
+    /*endif*/
     s->tx_info.tsa_type = type;
     if (len < 0)
         len = strlen(address);
+    /*endif*/
     if ((s->tx_info.tsa = span_alloc(len)))
     {
         memcpy(s->tx_info.tsa, address, len);
         s->tx_info.tsa_len = len;
     }
+    /*endif*/
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -463,8 +513,10 @@ SPAN_DECLARE(size_t) t30_get_tx_tsa(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->tx_info.tsa_type;
+    /*endif*/
     if (address)
         *address = s->tx_info.tsa;
+    /*endif*/
     return s->tx_info.tsa_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -473,8 +525,10 @@ SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->rx_info.tsa_type;
+    /*endif*/
     if (address)
         *address = s->rx_info.tsa;
+    /*endif*/
     return s->rx_info.tsa_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -483,11 +537,13 @@ SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address,
 {
     if (s->tx_info.ira)
         span_free(s->tx_info.ira);
+    /*endif*/
     if (address == NULL)
     {
         s->tx_info.ira = NULL;
         return 0;
     }
+    /*endif*/
     s->tx_info.ira = strdup(address);
     return 0;
 }
@@ -497,8 +553,10 @@ SPAN_DECLARE(size_t) t30_get_tx_ira(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->tx_info.ira_type;
+    /*endif*/
     if (address)
         *address = s->tx_info.ira;
+    /*endif*/
     return s->tx_info.ira_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -507,8 +565,10 @@ SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->rx_info.ira_type;
+    /*endif*/
     if (address)
         *address = s->rx_info.ira;
+    /*endif*/
     return s->rx_info.ira_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -517,11 +577,13 @@ SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address,
 {
     if (s->tx_info.cia)
         span_free(s->tx_info.cia);
+    /*endif*/
     if (address == NULL)
     {
         s->tx_info.cia = NULL;
         return 0;
     }
+    /*endif*/
     s->tx_info.cia = strdup(address);
     return 0;
 }
@@ -531,8 +593,10 @@ SPAN_DECLARE(size_t) t30_get_tx_cia(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->tx_info.cia_type;
+    /*endif*/
     if (address)
         *address = s->tx_info.cia;
+    /*endif*/
     return s->tx_info.cia_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -541,8 +605,10 @@ SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->rx_info.cia_type;
+    /*endif*/
     if (address)
         *address = s->rx_info.cia;
+    /*endif*/
     return s->rx_info.cia_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -551,11 +617,13 @@ SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address,
 {
     if (s->tx_info.isp)
         span_free(s->tx_info.isp);
+    /*endif*/
     if (address == NULL)
     {
         s->tx_info.isp = NULL;
         return 0;
     }
+    /*endif*/
     s->tx_info.isp = strdup(address);
     return 0;
 }
@@ -565,8 +633,10 @@ SPAN_DECLARE(size_t) t30_get_tx_isp(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->tx_info.isp_type;
+    /*endif*/
     if (address)
         *address = s->tx_info.isp;
+    /*endif*/
     return s->tx_info.isp_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -575,8 +645,10 @@ SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->rx_info.isp_type;
+    /*endif*/
     if (address)
         *address = s->rx_info.isp;
+    /*endif*/
     return s->rx_info.isp_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -585,11 +657,13 @@ SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address,
 {
     if (s->tx_info.csa)
         span_free(s->tx_info.csa);
+    /*endif*/
     if (address == NULL)
     {
         s->tx_info.csa = NULL;
         return 0;
     }
+    /*endif*/
     s->tx_info.csa = strdup(address);
     return 0;
 }
@@ -599,8 +673,10 @@ SPAN_DECLARE(size_t) t30_get_tx_csa(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->tx_info.csa_type;
+    /*endif*/
     if (address)
         *address = s->tx_info.csa;
+    /*endif*/
     return s->tx_info.csa_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -609,8 +685,10 @@ SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *addre
 {
     if (type)
         *type = s->rx_info.csa_type;
+    /*endif*/
     if (address)
         *address = s->rx_info.csa;
+    /*endif*/
     return s->rx_info.csa_len;
 }
 /*- End of function --------------------------------------------------------*/
@@ -630,8 +708,10 @@ SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info)
         s->header_info[0] = '\0';
         return 0;
     }
+    /*endif*/
     if (strlen(info) > T30_MAX_PAGE_HEADER_INFO)
         return -1;
+    /*endif*/
     strcpy(s->header_info, info);
     t4_tx_set_header_info(&s->t4.tx, s->header_info);
     return 0;
@@ -642,6 +722,7 @@ SPAN_DECLARE(size_t) t30_get_tx_page_header_info(t30_state_t *s, char *info)
 {
     if (info)
         strcpy(info, s->header_info);
+    /*endif*/
     return strlen(s->header_info);
 }
 /*- End of function --------------------------------------------------------*/
@@ -654,6 +735,7 @@ SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring
         t4_tx_set_header_tz(&s->t4.tx, &s->tz);
         return 0;
     }
+    /*endif*/
     return -1;
 }
 /*- End of function --------------------------------------------------------*/
@@ -758,6 +840,7 @@ SPAN_DECLARE(int) t30_set_minimum_scan_line_time(t30_state_t *s, int min_time)
         s->local_min_scan_time_code = 4;
     else
         return -1;
+    /*endif*/
     t30_build_dis_or_dtc(s);
     return 0;
 }
@@ -856,8 +939,10 @@ SPAN_DECLARE(int) t30_set_supported_image_sizes(t30_state_t *s, int supported_im
     /* Force the sizes which depend on sizes which are supported */
     if ((supported_image_sizes & T4_SUPPORT_LENGTH_UNLIMITED))
         supported_image_sizes |= T4_SUPPORT_LENGTH_B4;
+    /*endif*/
     if ((supported_image_sizes & T4_SUPPORT_WIDTH_303MM))
         supported_image_sizes |= T4_SUPPORT_WIDTH_255MM;
+    /*endif*/
     s->supported_image_sizes = supported_image_sizes;
     t30_build_dis_or_dtc(s);
     return 0;
@@ -879,6 +964,7 @@ SPAN_DECLARE(void) t30_set_status(t30_state_t *s, int status)
         span_log(&s->logging, SPAN_LOG_FLOW, "Status changing to '%s'\n", t30_completion_code_to_str(status));
         s->current_status = status;
     }
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
index 51739999d1244d59a43c509c146eeabbe9a8f63e..0ef46b9f31f88ed0c1e756a7fd51084e4754306b 100644 (file)
@@ -497,12 +497,15 @@ static void octet_bit_field(logging_state_t *log,
     {
         if ((tag = yeah) == NULL)
             tag = "Set";
+        /*endif*/
     }
     else
     {
         if ((tag = neigh) == NULL)
             tag = "Not set";
+        /*endif*/
     }
+    /*endif*/
     /* Eh, voila! */
     span_log(log, SPAN_LOG_FLOW, "  %s= %s: %s\n", s, desc, tag);
 }
@@ -528,6 +531,7 @@ static void octet_field(logging_state_t *log,
     /* Edit the bit string for display. */
     for (i = start;  i < end;  i++)
         s[7 - i + ((i < 4)  ?  1  :  0)] = (uint8_t) ((octet >> i) & 1) + '0';
+    /*endfor*/
 
     /* Find the right tag to display. */
     octet = (uint8_t) ((octet >> start) & ((0xFF + (1 << (end - start))) & 0xFF));
@@ -539,7 +543,9 @@ static void octet_field(logging_state_t *log,
             tag = tags[i].str;
             break;
         }
+        /*endif*/
     }
+    /*endfor*/
     /* Eh, voila! */
     span_log(log, SPAN_LOG_FLOW, "  %s= %s: %s\n", s, desc, tag);
 }
@@ -670,6 +676,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
 
     if (!span_log_test(&s->logging, SPAN_LOG_FLOW))
         return;
+    /*endif*/
     frame_type = pkt[2] & 0xFE;
     log = &s->logging;
     if (len <= 2)
@@ -677,6 +684,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     span_log(log, SPAN_LOG_FLOW, "%s:\n", t30_frametype(pkt[2]));
     if (len <= 3)
@@ -684,6 +692,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
     octet_bit_field(log, pkt, 1, "Store and forward Internet fax (T.37)", NULL, NULL);
     octet_reserved_bit(log, pkt, 2, 0);
     octet_bit_field(log, pkt, 3, "Real-time Internet fax (T.38)", NULL, NULL);
@@ -699,12 +708,14 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 6, "V.8 capabilities", NULL, NULL);
         octet_bit_field(log, pkt, 7, "Preferred octets", "64 octets", "256 octets");
     }
+    /*endif*/
     octet_reserved_bit(log, pkt, 8, 0);
     if (len <= 4)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     if (frame_type == T30_DCS)
     {
@@ -718,6 +729,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 10, "Can receive fax", NULL, NULL);
         octet_field(log, pkt, 11, 14, "Supported data signalling rates", available_signalling_rate_tags);
     }
+    /*endif*/
     octet_bit_field(log, pkt, 15, "R8x7.7lines/mm and/or 200x200pels/25.4mm", NULL, NULL);
     octet_bit_field(log, pkt, 16, "2-D coding", NULL, NULL);
     if (len <= 5)
@@ -725,6 +737,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     if (frame_type == T30_DCS)
     {
@@ -738,14 +751,17 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_field(log, pkt, 19, 20, "Recording length", available_recording_length_tags);
         octet_field(log, pkt, 21, 23, "Receiver's minimum scan line time", available_minimum_scan_line_time_tags);
     }
+    /*endif*/
     octet_bit_field(log, pkt, 24, "Extension indicator", NULL, NULL);
     if (!(pkt[5] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 6)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_reserved_bit(log, pkt, 25, 0);
     octet_bit_field(log, pkt, 26, "Compressed/uncompressed mode", "Uncompressed", "Compressed");
@@ -754,17 +770,20 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 28, "Frame size", "64 octets", "256 octets");
     else
         octet_reserved_bit(log, pkt, 28, 0);
+    /*endif*/
     octet_reserved_bit(log, pkt, 29, 0);
     octet_reserved_bit(log, pkt, 30, 0);
     octet_bit_field(log, pkt, 31, "T.6 coding", NULL, NULL);
     octet_bit_field(log, pkt, 32, "Extension indicator", NULL, NULL);
     if (!(pkt[6] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 7)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 33, "\"Field not valid\" supported", NULL, NULL);
     if (frame_type == T30_DCS)
@@ -777,6 +796,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 34, "Multiple selective polling", NULL, NULL);
         octet_bit_field(log, pkt, 35, "Polled sub-address", NULL, NULL);
     }
+    /*endif*/
     octet_bit_field(log, pkt, 36, "T.43 coding", NULL, NULL);
     octet_bit_field(log, pkt, 37, "Plane interleave", NULL, NULL);
     octet_bit_field(log, pkt, 38, "Voice coding with 32kbit/s ADPCM (Rec. G.726)", NULL, NULL);
@@ -784,11 +804,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 40, "Extension indicator", NULL, NULL);
     if (!(pkt[7] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 8)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
     octet_bit_field(log, pkt, 41, "R8x15.4lines/mm", NULL, NULL);
     octet_bit_field(log, pkt, 42, "300x300pels/25.4mm", NULL, NULL);
     octet_bit_field(log, pkt, 43, "R16x15.4lines/mm and/or 400x400pels/25.4mm", NULL, NULL);
@@ -806,14 +828,17 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 46, "Minimum scan line time for higher resolutions", "T15.4 = 1/2 T7.7", "T15.4 = T7.7");
         octet_bit_field(log, pkt, 47, "Selective polling", NULL, NULL);
     }
+    /*endif*/
     octet_bit_field(log, pkt, 48, "Extension indicator", NULL, NULL);
     if (!(pkt[8] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 9)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 49, "Sub-addressing", NULL, NULL);
     if (frame_type == T30_DCS)
@@ -826,6 +851,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 50, "Password", NULL, NULL);
         octet_bit_field(log, pkt, 51, "Ready to transmit a data file (polling)", NULL, NULL);
     }
+    /*endif*/
     octet_reserved_bit(log, pkt, 52, 0);
     octet_bit_field(log, pkt, 53, "Binary file transfer (BFT)", NULL, NULL);
     octet_bit_field(log, pkt, 54, "Document transfer mode (DTM)", NULL, NULL);
@@ -833,11 +859,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 56, "Extension indicator", NULL, NULL);
     if (!(pkt[9] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 10)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 57, "Basic transfer mode (BTM)", NULL, NULL);
     octet_reserved_bit(log, pkt, 58, 0);
@@ -845,6 +873,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_reserved_bit(log, pkt, 59, 0);
     else
         octet_bit_field(log, pkt, 59, "Ready to transfer a character or mixed mode document (polling)", NULL, NULL);
+    /*endif*/
     octet_bit_field(log, pkt, 60, "Character mode", NULL, NULL);
     octet_reserved_bit(log, pkt, 61, 0);
     octet_bit_field(log, pkt, 62, "Mixed mode (Annex E/T.4)", NULL, NULL);
@@ -852,11 +881,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 64, "Extension indicator", NULL, NULL);
     if (!(pkt[10] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 11)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 65, "Processable mode 26 (Rec. T.505)", NULL, NULL);
     octet_bit_field(log, pkt, 66, "Digital network capability", NULL, NULL);
@@ -865,20 +896,24 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 68, "Full colour mode", NULL, NULL);
     else
         octet_bit_field(log, pkt, 68, "JPEG coding", NULL, NULL);
+    /*endif*/
     octet_bit_field(log, pkt, 69, "Full colour mode", NULL, NULL);
     if (frame_type == T30_DCS)
         octet_bit_field(log, pkt, 70, "Preferred Huffman tables", NULL, NULL);
     else
         octet_reserved_bit(log, pkt, 70, 0);
+    /*endif*/
     octet_bit_field(log, pkt, 71, "12bits/pel component", NULL, NULL);
     octet_bit_field(log, pkt, 72, "Extension indicator", NULL, NULL);
     if (!(pkt[11] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 12)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 73, "No subsampling (1:1:1)", NULL, NULL);
     octet_bit_field(log, pkt, 74, "Custom illuminant", NULL, NULL);
@@ -890,11 +925,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 80, "Extension indicator", NULL, NULL);
     if (!(pkt[12] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 13)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 81, "HKM key management", NULL, NULL);
     octet_bit_field(log, pkt, 82, "RSA key management", NULL, NULL);
@@ -906,11 +943,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 88, "Extension indicator", NULL, NULL);
     if (!(pkt[13] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 14)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 89, "Alternative hashing system 2", NULL, NULL);
     octet_bit_field(log, pkt, 90, "Alternative hashing system 3", NULL, NULL);
@@ -925,6 +964,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     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);
     octet_bit_field(log, pkt, 98, "100pels/25.4mm x 100lines/25.4mm for colour/gray scale", NULL, NULL);
@@ -939,16 +979,19 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 100, "Extended BFT Negotiations capable", NULL, NULL);
         octet_bit_field(log, pkt, 101, "Internet Selective Polling address (ISP)", NULL, NULL);
     }
+    /*endif*/
     octet_bit_field(log, pkt, 102, "Internet Routing Address (IRA)", NULL, NULL);
     octet_reserved_bit(log, pkt, 103, 0);
     octet_bit_field(log, pkt, 104, "Extension indicator", NULL, NULL);
     if (!(pkt[15] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 16)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 105, "600pels/25.4mm x 600lines/25.4mm", NULL, NULL);
     octet_bit_field(log, pkt, 106, "1200pels/25.4mm x 1200lines/25.4mm", NULL, NULL);
@@ -960,11 +1003,13 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 112, "Extension indicator", NULL, NULL);
     if (!(pkt[16] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 17)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 113, "Double sided printing capability (alternate mode)", NULL, NULL);
     octet_bit_field(log, pkt, 114, "Double sided printing capability (continuous mode)", NULL, NULL);
@@ -972,17 +1017,20 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
         octet_bit_field(log, pkt, 115, "Black and white mixed raster content profile (MRCbw)", NULL, NULL);
     else
         octet_reserved_bit(log, pkt, 115, 0);
+    /*endif*/
     octet_bit_field(log, pkt, 116, "T.45 (run length colour encoded)", NULL, NULL);
     octet_field(log, pkt, 117, 118, "Shared memory", shared_data_memory_capacity_tags);
     octet_bit_field(log, pkt, 119, "T.44 colour space", NULL, NULL);
     octet_bit_field(log, pkt, 120, "Extension indicator", NULL, NULL);
     if (!(pkt[17] & DISBIT8))
         return;
+    /*endif*/
     if (len <= 18)
     {
         span_log(log, SPAN_LOG_FLOW, "  Frame is short\n");
         return;
     }
+    /*endif*/
 
     octet_bit_field(log, pkt, 121, "Flow control capability for T.38 communication", NULL, NULL);
     octet_bit_field(log, pkt, 122, "K>4", NULL, NULL);
@@ -992,6 +1040,7 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *pkt, in
     octet_bit_field(log, pkt, 128, "Extension indicator", NULL, NULL);
     if (!(pkt[18] & DISBIT8))
         return;
+    /*endif*/
 
     span_log(log, SPAN_LOG_FLOW, "  Extended beyond the current T.30 specification!\n");
 }
index 88859579728f6212bd2b3e1370cba958413074b6..419fb705fa273d6855a621860cf97bd80920dbe6 100644 (file)
@@ -771,8 +771,6 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr
     s = (faxtester_state_t *) user_data;
     t = &s->modems;
     span_log(&s->logging, SPAN_LOG_FLOW, "Set tx type %d\n", type);
-    if (s->current_tx_type == type)
-        return;
     if (use_hdlc)
     {
         get_bit_func = (get_bit_func_t) hdlc_tx_get_bit;
@@ -783,6 +781,12 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr
         get_bit_func = non_ecm_get_bit;
         get_bit_user_data = (void *) s;
     }
+    if (type == s->current_tx_type)
+    {
+        if (type == T30_MODEM_PAUSE)
+            silence_gen_alter(&t->silence_gen, ms_to_samples(short_train));
+        return;
+    }
     switch (type)
     {
     case T30_MODEM_PAUSE:
@@ -1314,6 +1318,8 @@ SPAN_DECLARE(int) faxtester_next_step(faxtester_state_t *s)
         else if (strcasecmp((const char *) parms.type, "CLEAR") == 0)
         {
             span_log(&s->logging, SPAN_LOG_FLOW, "Far end should drop the call\n");
+            faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false);
+            faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, s->timeout_x, false);
             s->test_for_call_clear = true;
             s->call_clear_timer = 0;
         }
@@ -1648,6 +1654,8 @@ SPAN_DECLARE(int) faxtester_next_step(faxtester_state_t *s)
         else if (strcasecmp((const char *) parms.type, "CLEAR") == 0)
         {
             span_log(&s->logging, SPAN_LOG_FLOW, "Time to drop the call\n");
+            faxtester_set_rx_type(s, T30_MODEM_NONE, 0, false, false);
+            faxtester_set_tx_type(s, T30_MODEM_PAUSE, 0, s->timeout_x, false);
             t30_terminate(s->far_t30);
             free_node_parms(&parms);
             return 0;
index d7a3b08d407a873838af107fdbbc55d1cf7df783..25f7ab77ab9e6ced1898344a0dbe06f61a41a1ed 100755 (executable)
@@ -28,7 +28,7 @@ run_tsb85_test()
     fi
 }
 
-for TEST in PPS-MPS-lost-PPS V17-12000-V29-9600 Phase-D-collision Modem-change-at-CTC ECM-DCN-clipped Non-ECM-DCN-clipped Tx-EOP-echo Tx-PPS-echo
+for TEST in PPS-MPS-lost-PPS V17-12000-V29-9600 Phase-D-collision Modem-change-at-CTC ECM-DCN-clipped Non-ECM-DCN-clipped Tx-EOP-echo Tx-PPS-echo Invalid-signalling-rate No-caller-response No-answerer-response
 do
     run_tsb85_test
 done