Changes of Revision 300

libosmocore.spec Changed
x
 
1
@@ -14,13 +14,13 @@
2
 
3
 Name:           libosmocore
4
 Requires: osmocom-master
5
-Version: 1.9.0.122.0265
6
+Version: 1.9.0.128.85554
7
 Release:        0
8
 Summary:        The Open Source Mobile Communications Core Library
9
 License:        GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later AND AGPL-3.0-or-later
10
 Group:          Productivity/Telephony/Utilities
11
 Url:            https://osmocom.org/projects/libosmocore/wiki/Libosmocore
12
-Source: libosmocore_1.9.0.122.0265.tar.xz
13
+Source: libosmocore_1.9.0.128.85554.tar.xz
14
 Source1: rpmlintrc
15
 BuildRequires:  automake >= 1.6
16
 BuildRequires:  libtool >= 2
17
commit_026551eced6d0b19e7fd0650216204051d0cd739.txt Deleted
commit_85554db38d45c3f2e72b5b9c37a5c1c7b9ecc009.txt Added
libosmocore_1.9.0.122.0265.dsc -> libosmocore_1.9.0.128.85554.dsc Changed
22
 
1
@@ -2,7 +2,7 @@
2
 Source: libosmocore
3
 Binary: libosmocore, libosmocodec4, libosmocodec-doc, libosmocoding0, libosmocoding-doc, libosmocore21, libosmocore-doc, libosmogb14, libosmogb-doc, libosmogsm20, libosmogsm-doc, libosmoisdn0, libosmoisdn-doc, libosmovty13, libosmovty-doc, libosmoctrl0, libosmoctrl-doc, libosmosim2, libosmosim-doc, libosmousb0, libosmousb-doc, libosmocore-dev, libosmocore-utils, libosmocore-dbg
4
 Architecture: any all
5
-Version: 1.9.0.122.0265
6
+Version: 1.9.0.128.85554
7
 Maintainer: Osmocom team <openbsc@lists.osmocom.org>
8
 Homepage: https://projects.osmocom.org/projects/libosmocore
9
 Standards-Version: 3.9.8
10
@@ -35,8 +35,8 @@
11
  libosmovty-doc deb doc optional arch=all
12
  libosmovty13 deb libs optional arch=any
13
 Checksums-Sha1:
14
- 7fcc118feaccc3cc79e0403eace56d95482b1f36 1093340 libosmocore_1.9.0.122.0265.tar.xz
15
+ 24b95fc04624c4d06b3bb31ac7859fcba509b0a5 1102136 libosmocore_1.9.0.128.85554.tar.xz
16
 Checksums-Sha256:
17
- 5e47285cc2b994bd129fcb2aeaef2a733fea8c4b6752a674e2946ca8f11fb42a 1093340 libosmocore_1.9.0.122.0265.tar.xz
18
+ b31e068f93c2872c3673bcc8cf9e3cc6b74b28ccd38bdfadb3d460efb6554e70 1102136 libosmocore_1.9.0.128.85554.tar.xz
19
 Files:
20
- 88870f3e8548ab0f8395044343ab3def 1093340 libosmocore_1.9.0.122.0265.tar.xz
21
+ 8632a014ac798cf2e443994102ae4666 1102136 libosmocore_1.9.0.128.85554.tar.xz
22
libosmocore_1.9.0.122.0265.tar.xz/.tarball-version -> libosmocore_1.9.0.128.85554.tar.xz/.tarball-version Changed
4
 
1
@@ -1 +1 @@
2
-1.9.0.122-0265
3
+1.9.0.128-85554
4
libosmocore_1.9.0.122.0265.tar.xz/TODO-RELEASE -> libosmocore_1.9.0.128.85554.tar.xz/TODO-RELEASE Changed
10
 
1
@@ -11,6 +11,8 @@
2
 core      ADD       osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf(), osmo_sock_multiaddr_get_name_buf()
3
 core      ADD       osmo_sock_sctp_get_peer_addr_info()
4
 core      ADD       gsmtap_inst_fd2() core, DEPRECATE gsmtap_inst_fd()
5
+core       behavior change     osmo_tdef_fsm_inst_state_chg(): allow millisecond precision
6
 isdn       ABI change      add states and flags for external T200 handling
7
+isdn      ADD              initial implementation of the V.110 Terminal Adapter
8
 gsm        ABI change      add T200 timer states to lapdm_datalink
9
 gsm        ABI change      add UI queue to struct lapdm_datalink
10
libosmocore_1.9.0.122.0265.tar.xz/debian/changelog -> libosmocore_1.9.0.128.85554.tar.xz/debian/changelog Changed
12
 
1
@@ -1,8 +1,8 @@
2
-libosmocore (1.9.0.122.0265) unstable; urgency=medium
3
+libosmocore (1.9.0.128.85554) unstable; urgency=medium
4
 
5
   * Automatically generated changelog entry for building the Osmocom master feed
6
 
7
- -- Osmocom OBS scripts <info@osmocom.org>  Fri, 05 Jan 2024 15:42:18 +0000
8
+ -- Osmocom OBS scripts <info@osmocom.org>  Tue, 09 Jan 2024 13:13:51 +0000
9
 
10
 libosmocore (1.9.0) unstable; urgency=medium
11
 
12
libosmocore_1.9.0.122.0265.tar.xz/include/osmocom/core/fsm.h -> libosmocore_1.9.0.128.85554.tar.xz/include/osmocom/core/fsm.h Changed
10
 
1
@@ -200,7 +200,7 @@
2
                fmt, ## args)
3
 
4
 #define OSMO_T_FMT "%c%u"
5
-#define OSMO_T_FMT_ARGS(T) ((T) >= 0 ? 'T' : 'X'), ((T) >= 0 ? T : -T)
6
+#define OSMO_T_FMT_ARGS(T) ((T) >= 0 ? 'T' : 'X'), ((T) >= 0 ? (T) : -(T))
7
 
8
 int osmo_fsm_register(struct osmo_fsm *fsm);
9
 void osmo_fsm_unregister(struct osmo_fsm *fsm);
10
libosmocore_1.9.0.122.0265.tar.xz/include/osmocom/core/tdef.h -> libosmocore_1.9.0.128.85554.tar.xz/include/osmocom/core/tdef.h Changed
33
 
1
@@ -121,11 +121,13 @@
2
 const struct osmo_tdef_state_timeout *osmo_tdef_get_state_timeout(uint32_t state,
3
                                  const struct osmo_tdef_state_timeout *timeouts_array);
4
 
5
-/*! Call osmo_fsm_inst_state_chg() or osmo_fsm_inst_state_chg_keep_timer(), depending on the timeouts_array, tdefs and
6
- * default_timeout.
7
+/*! Call osmo_fsm_inst_state_chg_ms() or osmo_fsm_inst_state_chg_keep_timer_ms(),
8
+ * depending on the timeouts_array, tdefs and default_timeout.
9
  *
10
- * A T timer configured in sub-second precision is rounded up to the next full second. A timer in unit =
11
- * OSMO_TDEF_CUSTOM is applied as if the unit is in seconds (i.e. this macro does not make sense for custom units!).
12
+ * A timer defined with sub-millisecond precision (e.g OSMO_TDEF_US) is rounded up to the next full millisecond.
13
+ * A timer value defined in units higher than millisecond (e.g. OSMO_TDEF_S, OSMO_TDEF_M) is converted to milliseconds.
14
+ * A timer in unit = OSMO_TDEF_CUSTOM is applied as if the unit is in seconds (i.e. this macro does not make sense
15
+ * for custom units!).
16
  *
17
  * See osmo_tdef_get_state_timeout() and osmo_tdef_get().
18
  *
19
@@ -153,9 +155,10 @@
20
  * \paramin state  State number to transition to.
21
  * \paramin timeouts_array  Array of struct osmo_tdef_state_timeout32 to look up state in.
22
  * \paramin tdefs  Array of struct osmo_tdef (last entry zero initialized) to look up T in.
23
- * \paramin default_timeout  If a T is set in timeouts_array, but no timeout value is configured for T, then use this
24
- *                             default timeout value as fallback, or pass -1 to abort the program.
25
- * \return Return value from osmo_fsm_inst_state_chg() or osmo_fsm_inst_state_chg_keep_timer().
26
+ * \paramin default_timeout  If a T is set in timeouts_array, but no timeout value is configured for T,
27
+ *                             then use this default timeout value (in seconds) as fallback,
28
+ *                             or pass a negative number to abort the program.
29
+ * \return Return value from osmo_fsm_inst_state_chg_ms() or osmo_fsm_inst_state_chg_keep_timer_ms().
30
  */
31
 #define osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, default_timeout) \
32
    _osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, default_timeout, \
33
libosmocore_1.9.0.122.0265.tar.xz/include/osmocom/isdn/Makefile.am -> libosmocore_1.9.0.128.85554.tar.xz/include/osmocom/isdn/Makefile.am Changed
9
 
1
@@ -2,6 +2,7 @@
2
    i460_mux.h \
3
    lapd_core.h \
4
    v110.h \
5
+   v110_ta.h \
6
    $(NULL)
7
 
8
 osmoisdndir = $(includedir)/osmocom/isdn
9
libosmocore_1.9.0.128.85554.tar.xz/include/osmocom/isdn/v110_ta.h Added
115
 
1
@@ -0,0 +1,113 @@
2
+#pragma once
3
+
4
+#include <stdint.h>
5
+#include <stdbool.h>
6
+
7
+#include <osmocom/core/utils.h>
8
+#include <osmocom/core/bits.h>
9
+#include <osmocom/isdn/v110.h>
10
+
11
+/* Definition of this struct is intentionally kept private */
12
+struct osmo_v110_ta;
13
+
14
+/*! V.110 5.4.1 Local flow control (DTE-DCE or TE-TA) mode */
15
+enum osmo_v110_local_flow_ctrl_mode {
16
+   OSMO_V110_LOCAL_FLOW_CTRL_NONE,     /*!< No local flow control */
17
+   OSMO_V110_LOCAL_FLOW_CTRL_133_106,  /*!< 5.4.1.1 133/106 operation */
18
+   OSMO_V110_LOCAL_FLOW_CTRL_105_106,  /*!< 5.4.1.2 105/106 operation */
19
+   OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF, /*!< 5.4.1.3 XON/XOFF operation */
20
+};
21
+
22
+/*! Configuration for a V.110 TA instance */
23
+struct osmo_v110_ta_cfg {
24
+   /*! Configuration flags (behavior switches and quirks) */
25
+   unsigned int flags;
26
+   /*! Synchronous user rate */
27
+   enum osmo_v100_sync_ra1_rate rate;
28
+
29
+   /*! Flow control configuration */
30
+   struct {
31
+       /*! Local TA-TE (DTE-DCE) flow control mode */
32
+       enum osmo_v110_local_flow_ctrl_mode local;
33
+       /*! End-to-end (TA-to-TA) flow control state */
34
+       bool end_to_end;
35
+   } flow_ctrl;
36
+
37
+   /*! Opaque application-private data; passed to call-backs. */
38
+   void *priv;
39
+
40
+   /*! Receive call-back of the application.
41
+    * \paramin priv opaque application-private data.
42
+    * \paramin buf output buffer for writing to be transmitted data.
43
+    * \paramin buf_size size of the output buffer. */
44
+   void (*rx_cb)(void *priv, const ubit_t *buf, size_t buf_size);
45
+
46
+   /*! Transmit call-back of the application.
47
+    * \paramin priv opaque application-private data.
48
+    * \paramout buf output buffer for writing to be transmitted data.
49
+    * \paramin buf_size size of the output buffer. */
50
+   void (*tx_cb)(void *priv, ubit_t *buf, size_t buf_size);
51
+
52
+   /*! Modem status line update call-back (optional).
53
+    * \paramin priv opaque application-private data.
54
+    * \paramin status updated status; bit-mask of OSMO_V110_TA_C_*. */
55
+   void (*status_update_cb)(void *priv, unsigned int status);
56
+};
57
+
58
+struct osmo_v110_ta *osmo_v110_ta_alloc(void *ctx, const char *name,
59
+                   const struct osmo_v110_ta_cfg *cfg);
60
+void osmo_v110_ta_free(struct osmo_v110_ta *ta);
61
+
62
+/*! Various timers for a V.110 TA instance */
63
+enum osmo_v110_ta_timer {
64
+   /*! 7.1.5 Loss of frame synchronization: sync recovery timer.
65
+    * T-number is not assigned in V.110, so we call it X1. */
66
+   OSMO_V110_TA_TIMER_X1       = -1,
67
+   /*! 7.1.2 Connect TA to line: sync establishment timer */
68
+   OSMO_V110_TA_TIMER_T1       = 1,
69
+   /*! 7.1.4 Disconnect mode: disconnect confirmation timer */
70
+   OSMO_V110_TA_TIMER_T2       = 2,
71
+};
72
+
73
+int osmo_v110_ta_set_timer_val_ms(struct osmo_v110_ta *ta,
74
+                 enum osmo_v110_ta_timer timer,
75
+                 unsigned long val_ms);
76
+
77
+int osmo_v110_ta_frame_in(struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in);
78
+int osmo_v110_ta_frame_out(struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out);
79
+
80
+int osmo_v110_ta_sync_ind(struct osmo_v110_ta *ta);
81
+int osmo_v110_ta_desync_ind(struct osmo_v110_ta *ta);
82
+
83
+/*! ITU-T Table 9 "Interchange circuit" (see also ITU-T V.24 Chapter 3).
84
+ * XXX: Not all circuits are present here, only those which we actually use.
85
+ * TODO: add human-friendly abbreviated circuit names. */
86
+enum osmo_v110_ta_circuit {
87
+   OSMO_V110_TA_C_105,     /*!< DTE->DCE | RTS (Request to Send) */
88
+   OSMO_V110_TA_C_106,     /*!< DTE<-DCE | CTS (Clear to Send) */
89
+   OSMO_V110_TA_C_107,     /*!< DTE<-DCE | DSR (Data Set Ready) */
90
+   OSMO_V110_TA_C_108,     /*!< DTE->DCE | DTR (Data Terminal Ready) */
91
+   OSMO_V110_TA_C_109,     /*!< DTE<-DCE | DCD (Data Carrier Detect) */
92
+   OSMO_V110_TA_C_133,     /*!< DTE->DCE | Ready for receiving */
93
+};
94
+
95
+extern const struct value_string osmo_v110_ta_circuit_names;
96
+extern const struct value_string osmo_v110_ta_circuit_descs;
97
+
98
+/*! Get a short name of the given TA's circuit (format: NNN/ABBR). */
99
+static inline const char *osmo_v110_ta_circuit_name(enum osmo_v110_ta_circuit circuit)
100
+{
101
+   return get_value_string(osmo_v110_ta_circuit_names, circuit);
102
+}
103
+
104
+/*! Get a brief description of the given TA's circuit. */
105
+static inline const char *osmo_v110_ta_circuit_desc(enum osmo_v110_ta_circuit circuit)
106
+{
107
+   return get_value_string(osmo_v110_ta_circuit_descs, circuit);
108
+}
109
+
110
+unsigned int osmo_v110_ta_get_status(const struct osmo_v110_ta *ta);
111
+bool osmo_v110_ta_get_circuit(const struct osmo_v110_ta *ta,
112
+                 enum osmo_v110_ta_circuit circuit);
113
+int osmo_v110_ta_set_circuit(struct osmo_v110_ta *ta,
114
+                enum osmo_v110_ta_circuit circuit, bool active);
115
libosmocore_1.9.0.122.0265.tar.xz/src/core/tdef.c -> libosmocore_1.9.0.128.85554.tar.xz/src/core/tdef.c Changed
45
 
1
@@ -337,26 +337,37 @@
2
                  const char *file, int line)
3
 {
4
    const struct osmo_tdef_state_timeout *t = osmo_tdef_get_state_timeout(state, timeouts_array);
5
-   unsigned long val = 0;
6
+   unsigned long val_ms = 0;
7
 
8
    /* No timeout defined for this state? */
9
    if (!t)
10
        return _osmo_fsm_inst_state_chg(fi, state, 0, 0, file, line);
11
 
12
-   if (t->T)
13
-       val = osmo_tdef_get(tdefs, t->T, OSMO_TDEF_S, default_timeout);
14
+   if (t->T) {
15
+       const struct osmo_tdef *tdef = osmo_tdef_get_entry((struct osmo_tdef *)tdefs, t->T);
16
+       if (tdef == NULL) {
17
+           /* emulate the old behavior: treat default_timeout as OSMO_TDEF_S */
18
+           OSMO_ASSERT(default_timeout >= 0);
19
+           val_ms = default_timeout * 1000;
20
+       } else {
21
+           val_ms = osmo_tdef_round(tdef->val, tdef->unit, OSMO_TDEF_MS);
22
+           /* emulate the old behavior: treat OSMO_TDEF_CUSTOM as OSMO_TDEF_S */
23
+           if (tdef->unit == OSMO_TDEF_CUSTOM)
24
+               val_ms *= 1000;
25
+       }
26
+   }
27
 
28
    if (t->keep_timer) {
29
        if (t->T)
30
-           return _osmo_fsm_inst_state_chg_keep_or_start_timer(fi, state, val, t->T, file, line);
31
+           return _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, state, val_ms, t->T, file, line);
32
        else
33
            return _osmo_fsm_inst_state_chg_keep_timer(fi, state, file, line);
34
    }
35
 
36
-   /* val is always initialized here, because if t->keep_timer is false, t->T must be != 0.
37
+   /* val_ms is always initialized here, because if t->keep_timer is false, t->T must be != 0.
38
     * Otherwise osmo_tdef_get_state_timeout() would have returned NULL. */
39
    OSMO_ASSERT(t->T);
40
-   return _osmo_fsm_inst_state_chg(fi, state, val, t->T, file, line);
41
+   return _osmo_fsm_inst_state_chg_ms(fi, state, val_ms, t->T, file, line);
42
 }
43
 
44
 const struct value_string osmo_tdef_unit_names = {
45
libosmocore_1.9.0.122.0265.tar.xz/src/gsm/gsm48.c -> libosmocore_1.9.0.128.85554.tar.xz/src/gsm/gsm48.c Changed
14
 
1
@@ -641,8 +641,10 @@
2
    char *str = NULL; /* initialize to avoid uninitialized false warnings on some gcc versions (11.1.0) */
3
    size_t str_size = 0; /* initialize to avoid uninitialized false warnings on some gcc versions (11.1.0) */
4
 
5
-   if (!mi_data || mi_len < 1)
6
-       return -EBADMSG;
7
+   if (!mi_data || mi_len < 1) {
8
+       rc = -EBADMSG;
9
+       goto return_error;
10
+   }
11
 
12
    nibbles_len = (mi_len - 1) * 2 + ((mi_data0 & GSM_MI_ODD) ? 1 : 0);
13
 
14
libosmocore_1.9.0.122.0265.tar.xz/src/gsm/gsm48_ie.c -> libosmocore_1.9.0.128.85554.tar.xz/src/gsm/gsm48_ie.c Changed
53
 
1
@@ -44,10 +44,11 @@
2
 };
3
 
4
 /*! Like gsm48_decode_bcd_number2() but with less airtight bounds checking.
5
- *  \paramout Caller-provided output buffer
6
+ *  \paramout output Caller-provided output buffer
7
+ *  \paramin output_len sizeof(output)
8
  *  \paramin bcd_lv Length-Value portion of to-be-decoded IE
9
  *  \paramin h_len Length of an optional heder between L and V portion
10
- *  \returns - in case of success; negative on error */
11
+ *  \returns 0 in case of success; negative on error */
12
 int gsm48_decode_bcd_number(char *output, int output_len,
13
                const uint8_t *bcd_lv, int h_len)
14
 {
15
@@ -139,7 +140,7 @@
16
  *  \paramin max_len Maximum Length of \a bcd_lv
17
  *  \paramin h_len Length of an optional heder between L and V portion
18
  *  \paramin input phone number as 0-terminated ASCII
19
- *  \returns number of bytes used in \a bcd_lv
20
+ *  \returns number of bytes used in \a bcd_lv; negative on error
21
  *
22
  * Depending on a context (e.g. called or calling party BCD number), the
23
  * optional header between L and V parts can contain TON (Type Of Number),
24
@@ -179,8 +180,8 @@
25
 }
26
 
27
 /*! Decode TS 04.08 Bearer Capability IE (10.5.4.5)
28
- *  \paramout Caller-provided memory for decoded output
29
- *  \aramin LV portion of TS 04.08 Bearer Capability
30
+ *  \paramout bcap Caller-provided memory for decoded output
31
+ *  \paramin lv LV portion of TS 04.08 Bearer Capability
32
  *  \returns 0 on success; negative on error */
33
 int gsm48_decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap,
34
                 const uint8_t *lv)
35
@@ -371,7 +372,7 @@
36
 }
37
 
38
 /*! Decode TS 04.08 Call Control Capabilities IE (10.5.4.5a)
39
- *  \paramout Caller-provided memory for decoded CC capabilities
40
+ *  \paramout ccap Caller-provided memory for decoded CC capabilities
41
  *  \paramin lv Length-Value of IE
42
  *  \returns 0 on success; negative on error */
43
 int gsm48_decode_cccap(struct gsm_mncc_cccap *ccap, const uint8_t *lv)
44
@@ -457,7 +458,7 @@
45
 }
46
 
47
 /*! Decode TS 04.08 Caller ID
48
- *  \paramout called Caller-provided memory for decoded number
49
+ *  \paramout callerid Caller-provided memory for decoded number
50
  *  \paramin lv Length-Value portion of IE
51
  *  \returns 0 on success; negative on error */
52
 int gsm48_decode_callerid(struct gsm_mncc_number *callerid,
53
libosmocore_1.9.0.122.0265.tar.xz/src/isdn/Makefile.am -> libosmocore_1.9.0.128.85554.tar.xz/src/isdn/Makefile.am Changed
10
 
1
@@ -13,7 +13,7 @@
2
 noinst_LTLIBRARIES = libisdnint.la
3
 lib_LTLIBRARIES = libosmoisdn.la
4
 
5
-libisdnint_la_SOURCES = i460_mux.c lapd_core.c v110.c
6
+libisdnint_la_SOURCES = i460_mux.c lapd_core.c v110.c v110_ta.c
7
 
8
 libisdnint_la_LDFLAGS = -no-undefined
9
 libisdnint_la_LIBADD = $(top_builddir)/src/core/libosmocore.la
10
libosmocore_1.9.0.122.0265.tar.xz/src/isdn/libosmoisdn.map -> libosmocore_1.9.0.128.85554.tar.xz/src/isdn/libosmoisdn.map Changed
21
 
1
@@ -33,5 +33,19 @@
2
 osmo_v110_sync_ra1_user_to_ir;
3
 osmo_v110_sync_ra1_ir_to_user;
4
 
5
+osmo_v110_ta_alloc;
6
+osmo_v110_ta_free;
7
+osmo_v110_ta_set_timer_val_ms;
8
+osmo_v110_ta_frame_in;
9
+osmo_v110_ta_frame_out;
10
+osmo_v110_ta_sync_ind;
11
+osmo_v110_ta_desync_ind;
12
+osmo_v110_ta_get_status;
13
+osmo_v110_ta_get_circuit;
14
+osmo_v110_ta_set_circuit;
15
+
16
+osmo_v110_ta_circuit_names;
17
+osmo_v110_ta_circuit_descs;
18
+
19
 local: *;
20
 };
21
libosmocore_1.9.0.128.85554.tar.xz/src/isdn/v110_ta.c Added
874
 
1
@@ -0,0 +1,872 @@
2
+/*! \file v110_ta.c
3
+ *  TA (Terminal Adapter) implementation as per ITU-T V.110. */
4
+/*
5
+ * (C) 2022 by Harald Welte <laforge@gnumonks.org>
6
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
7
+ *
8
+ * Initial (Work-in-Progress) implementation by Harald Welte,
9
+ * completed and co-authored by Vadim Yanitskiy.
10
+ *
11
+ * All Rights Reserved
12
+ *
13
+ * SPDX-License-Identifier: GPL-2.0+
14
+ *
15
+ * This program is free software; you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License as published by
17
+ * the Free Software Foundation; either version 2 of the License, or
18
+ * (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ */
26
+
27
+#include <stdbool.h>
28
+#include <stdint.h>
29
+#include <errno.h>
30
+
31
+#include <osmocom/core/logging.h>
32
+#include <osmocom/core/talloc.h>
33
+#include <osmocom/core/utils.h>
34
+#include <osmocom/core/bits.h>
35
+#include <osmocom/core/tdef.h>
36
+#include <osmocom/core/fsm.h>
37
+
38
+#include <osmocom/isdn/v110.h>
39
+#include <osmocom/isdn/v110_ta.h>
40
+
41
+#define S(x) (1 << (x))
42
+
43
+#define V24_FLAGMASK_IS_ON(flags, circuit) \
44
+   (((flags) & S(circuit)) != 0)
45
+
46
+#define V24_FLAGMASK_IS_OFF(flags, circuit) \
47
+   (((flags) & S(circuit)) == 0)
48
+
49
+#define V24_FLAGMASK_SET_ON(flags, circuit) \
50
+   (flags) |= S(circuit)
51
+
52
+#define V24_FLAGMASK_SET_OFF(flags, circuit) \
53
+   (flags) &= ~S(circuit)
54
+
55
+/* inverse logic: ON = binary 0; OFF = binary 1 */
56
+#define V110_SX_BIT_ON     0
57
+#define V110_SX_BIT_OFF        1
58
+
59
+const struct value_string osmo_v110_ta_circuit_names = {
60
+   { OSMO_V110_TA_C_105,   "105/RTS" },
61
+   { OSMO_V110_TA_C_106,   "106/CTS" },
62
+   { OSMO_V110_TA_C_107,   "107/DSR" },
63
+   { OSMO_V110_TA_C_108,   "108/DTR" },
64
+   { OSMO_V110_TA_C_109,   "109/DCD" },
65
+   { OSMO_V110_TA_C_133,   "133" },
66
+   { 0, NULL }
67
+};
68
+
69
+const struct value_string osmo_v110_ta_circuit_descs = {
70
+   { OSMO_V110_TA_C_105,   "Request to Send" },
71
+   { OSMO_V110_TA_C_106,   "Clear to Send" },
72
+   { OSMO_V110_TA_C_107,   "Data Set Ready" },
73
+   { OSMO_V110_TA_C_108,   "Data Terminal Ready" },
74
+   { OSMO_V110_TA_C_109,   "Data Carrier Detect" },
75
+   { OSMO_V110_TA_C_133,   "Ready for receiving" },
76
+   { 0, NULL }
77
+};
78
+
79
+static const struct osmo_tdef v110_ta_tdef = {
80
+   { .T = OSMO_V110_TA_TIMER_X1,
81
+     .unit = OSMO_TDEF_MS, .default_val = 3000, /* suggested in 7.1.5 e) */
82
+     .desc = "ITU-T V.110 7.1.5 Loss of frame synchronization: sync recovery timer" },
83
+   { .T = OSMO_V110_TA_TIMER_T1,
84
+     .unit = OSMO_TDEF_MS, .default_val = 10000, /* suggested in 7.1.2.2 */
85
+     .desc = "ITU-T V.110 7.1.2 Connect TA to line: sync establishment timer" },
86
+   { .T = OSMO_V110_TA_TIMER_T2,
87
+     .unit = OSMO_TDEF_MS, .default_val = 5000, /* suggested in 7.1.4.1 */
88
+     .desc = "ITU-T V.110 7.1.4 Disconnect mode: disconnect confirmation timer" },
89
+   { /* end of list */ }
90
+};
91
+
92
+/*********************************************************************************
93
+ * V.110 TERMINAL ADAPTER FSM
94
+ *********************************************************************************/
95
+
96
+enum v110_ta_fsm_state {
97
+   V110_TA_ST_IDLE_READY,      /* 7.1.1 Idle (or ready) state */
98
+   V110_TA_ST_CON_TA_TO_LINE,  /* 7.1.2 Connect TA to line state */
99
+   V110_TA_ST_DATA_TRANSFER,   /* 7.1.3 Data transfer state */
100
+   V110_TA_ST_DISCONNECTING,   /* 7.1.4 Disconnect mode */
101
+   V110_TA_ST_RESYNCING,       /* 7.1.5 Re-synchronizing state */
102
+};
103
+
104
+enum v110_ta_fsm_event {
105
+   V110_TA_EV_RX_FRAME_IND,    /* a V.110 frame was received by the lower layer */
106
+   V110_TA_EV_TX_FRAME_RTS,    /* a V.110 frame is to be sent by the lower layer */
107
+   V110_TA_EV_V24_STATUS_CHG,  /* V.24 flag-mask has been updated by TE */
108
+   V110_TA_EV_SYNC_IND,        /* the lower layer has synchronized to the frame clock */
109
+   V110_TA_EV_DESYNC_IND,      /* the lower layer has lost frame clock synchronization */
110
+   V110_TA_EV_TIMEOUT,     /* generic event for handling a timeout condition */
111
+};
112
+
113
+static const struct value_string v110_ta_fsm_event_names = {
114
+   { V110_TA_EV_RX_FRAME_IND,  "RX_FRAME_IND" },
115
+   { V110_TA_EV_TX_FRAME_RTS,  "TX_FRAME_RTS" },
116
+   { V110_TA_EV_V24_STATUS_CHG,    "V24_STATUS_CHG" },
117
+   { V110_TA_EV_SYNC_IND,      "SYNC_IND" },
118
+   { V110_TA_EV_DESYNC_IND,    "DESYNC_IND" },
119
+   { V110_TA_EV_TIMEOUT,       "TIMEOUT" },
120
+   { 0, NULL }
121
+};
122
+
123
+enum v110_ta_d_bit_mode {
124
+   V110_TA_DBIT_M_ALL_ZERO     = 0,    /* set all bits to binary '0' */
125
+   V110_TA_DBIT_M_ALL_ONE      = 1,    /* set all bits to binary '1' */
126
+   V110_TA_DBIT_M_FORWARD,         /* forward D-bits to/from DTE */
127
+};
128
+
129
+struct v110_ta_state {
130
+   /*! V.24 status flags shared between DTE (user) and DCE (TA, us) */
131
+   unsigned int v24_flags;
132
+   struct {
133
+       /* what kind of D-bits to transmit in V.110 frames */
134
+       enum v110_ta_d_bit_mode d_bit_mode;
135
+       /* what to put in S-bits of transmitted V.110 frames */
136
+       ubit_t s_bits;
137
+       /* what to put in X-bits of transmitted V.110 frames */
138
+       ubit_t x_bits;
139
+   } tx;
140
+   struct {
141
+       enum v110_ta_d_bit_mode d_bit_mode;
142
+   } rx;
143
+};
144
+
145
+struct osmo_v110_ta {
146
+   const char *name;
147
+   struct osmo_tdef *Tdefs;
148
+   struct osmo_fsm_inst *fi;
149
+   struct osmo_v110_ta_cfg *cfg;
150
+   struct v110_ta_state state;
151
+};
152
+
153
+static inline bool v110_df_x_bits_are(const struct osmo_v110_decoded_frame *df, ubit_t cmp)
154
+{
155
+   return (df->x_bits0 == cmp) && (df->x_bits1 == cmp);
156
+}
157
+
158
+static inline bool v110_df_s_bits_are(const struct osmo_v110_decoded_frame *df, ubit_t cmp)
159
+{
160
+   /* ITU-T Table 2/V.110 (see also 5.1.2.3) defines the following S-bits:
161
+    * S1, S3, S4, S6, S8, S9 (6 bits total).  However, fr->s_bits contains
162
+    * 9 (MAX_S_BITS) bits, including the undefined bits S2, S5, S7.
163
+    * Hence we must skip those undefined bits. */
164
+   static const uint8_t sbit_map = { 0, 2, 3, 5, 7, 8 };
165
+
166
+   for (unsigned int i = 0; i < ARRAY_SIZE(sbit_map); i++) {
167
+       uint8_t idx = sbit_mapi;
168
+       if (df->s_bitsidx != cmp)
169
+           return false;
170
+   }
171
+
172
+   return true;
173
+}
174
+
175
+static inline bool v110_df_d_bits_are(const struct osmo_v110_decoded_frame *df, ubit_t cmp)
176
+{
177
+   for (unsigned int i = 0; i < MAX_D_BITS; i++) {
178
+       if (df->d_bitsi != cmp)
179
+           return false;
180
+   }
181
+
182
+   return true;
183
+}
184
+
185
+/* handle one V.110 frame and forward user bits to the application */
186
+static void v110_ta_handle_frame(const struct osmo_v110_ta *ta,
187
+                const struct osmo_v110_decoded_frame *df)
188
+{
189
+   const struct osmo_v110_ta_cfg *cfg = ta->cfg;
190
+   const struct v110_ta_state *ts = &ta->state;
191
+   ubit_t user_bitsMAX_D_BITS;
192
+   int num_user_bits;
193
+   int rc;
194
+
195
+   switch (ts->rx.d_bit_mode) {
196
+   case V110_TA_DBIT_M_ALL_ZERO:
197
+   case V110_TA_DBIT_M_ALL_ONE:
198
+       /* generate as many user bits as needed for the configured rate */
199
+       num_user_bits = osmo_v110_sync_ra1_get_user_data_chunk_bitlen(cfg->rate);
200
+       OSMO_ASSERT(num_user_bits > 0);
201
+       /* set them all to binary '0' or binary '1' */
202
+       memset(&user_bits0, (int)ts->rx.d_bit_mode, num_user_bits);
203
+       cfg->rx_cb(cfg->priv, &user_bits0, num_user_bits);
204
+       break;
205
+   case V110_TA_DBIT_M_FORWARD:
206
+       rc = osmo_v110_sync_ra1_ir_to_user(cfg->rate, &user_bits0, sizeof(user_bits), df);
207
+       if (rc > 0)
208
+           cfg->rx_cb(cfg->priv, &user_bits0, rc);
209
+       /* XXX else: indicate an error somehow? */
210
+       break;
211
+   }
212
+}
213
+
214
+/* build one V.110 frame to transmit */
215
+static void v110_ta_build_frame(const struct osmo_v110_ta *ta,
216
+               struct osmo_v110_decoded_frame *df)
217
+{
218
+   const struct osmo_v110_ta_cfg *cfg = ta->cfg;
219
+   const struct v110_ta_state *ts = &ta->state;
220
+   ubit_t user_bitsMAX_D_BITS;
221
+   int num_user_bits;
222
+   int rc;
223
+
224
+   /* E-bits (E1/E2/E3 may be overwritten below) */
225
+   memset(df->e_bits, 1, sizeof(df->e_bits));
226
+   /* S-bits */
227
+   memset(df->s_bits, ts->tx.s_bits, sizeof(df->s_bits));
228
+   /* X-bits */
229
+   memset(df->x_bits, ts->tx.x_bits, sizeof(df->x_bits));
230
+
231
+   /* D-bits */
232
+   switch (ts->tx.d_bit_mode) {
233
+   case V110_TA_DBIT_M_ALL_ZERO:
234
+   case V110_TA_DBIT_M_ALL_ONE:
235
+       /* set them all to binary '0' or binary '1' */
236
+       memset(df->d_bits, (int)ts->tx.d_bit_mode, sizeof(df->d_bits));
237
+       break;
238
+   case V110_TA_DBIT_M_FORWARD:
239
+       /* how many user bits to retrieve */
240
+       num_user_bits = osmo_v110_sync_ra1_get_user_data_chunk_bitlen(cfg->rate);
241
+       OSMO_ASSERT(num_user_bits > 0);
242
+       /* retrieve user bits from the application */
243
+       cfg->tx_cb(cfg->priv, &user_bits0, num_user_bits);
244
+       /* convert user bits to intermediate rate (store to df) */
245
+       rc = osmo_v110_sync_ra1_user_to_ir(cfg->rate, df, &user_bits0, num_user_bits);
246
+       OSMO_ASSERT(rc == 0);
247
+       break;
248
+   }
249
+}
250
+
251
+static void v110_ta_flags_updated(const struct osmo_v110_ta *ta)
252
+{
253
+   const struct osmo_v110_ta_cfg *cfg = ta->cfg;
254
+
255
+   if (cfg->status_update_cb != NULL)
256
+       cfg->status_update_cb(cfg->priv, ta->state.v24_flags);
257
+}
258
+
259
+static const struct osmo_tdef_state_timeout v110_ta_fsm_timeouts32 = {
260
+   V110_TA_ST_RESYNCING        = { .T = OSMO_V110_TA_TIMER_X1 },
261
+   V110_TA_ST_CON_TA_TO_LINE   = { .T = OSMO_V110_TA_TIMER_T1 },
262
+   V110_TA_ST_DISCONNECTING    = { .T = OSMO_V110_TA_TIMER_T2 },
263
+};
264
+
265
+#define v110_ta_fsm_state_chg(state) \
266
+   osmo_tdef_fsm_inst_state_chg(fi, state, \
267
+                    v110_ta_fsm_timeouts, \
268
+                    ((struct osmo_v110_ta *)(fi->priv))->Tdefs, \
269
+                    0)
270
+
271
+/* ITU-T V.110 Section 7.1.1 */
272
+static void v110_ta_fsm_idle_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
273
+{
274
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
275
+   struct v110_ta_state *ts = &ta->state;
276
+
277
+   /* 7.1.1.2 During the idle (or ready) state the TA will transmit continuous binary 1s into the B-channel */
278
+   ts->tx.d_bit_mode = V110_TA_DBIT_M_ALL_ONE; /* circuit 103: continuous binary '1' */
279
+   ts->tx.s_bits = V110_SX_BIT_OFF; /* OFF is binary '1' */
280
+   ts->tx.x_bits = V110_SX_BIT_OFF; /* OFF is binary '1' */
281
+
282
+   /* 7.1.1.3 During the idle (or ready) state the TA (DCE) will transmit the following toward the DTE: */
283
+   /* - circuit 104: continuous binary '1' */
284
+   ts->rx.d_bit_mode = V110_TA_DBIT_M_ALL_ONE;
285
+   /* - circuits 107, 106, 109 = OFF */
286
+   V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_106);
287
+   V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_107);
288
+   V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_109);
289
+   v110_ta_flags_updated(ta);
290
+}
291
+
292
+/* ITU-T V.110 Section 7.1.1 */
293
+static void v110_ta_fsm_idle_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
294
+{
295
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
296
+   struct v110_ta_state *ts = &ta->state;
297
+
298
+   switch (event) {
299
+   case V110_TA_EV_V24_STATUS_CHG:
300
+       /* When the TA is to be switched to the data mode, circuit 108 must be ON */
301
+       if (V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_108)) {
302
+           /* 7.12.2: Start timer T1 when switching to CON_TA_LINE */
303
+           v110_ta_fsm_state_chg(V110_TA_ST_CON_TA_TO_LINE);
304
+       }
305
+       break;
306
+   case V110_TA_EV_RX_FRAME_IND:
307
+       v110_ta_handle_frame(ta, (const struct osmo_v110_decoded_frame *)data);
308
+       break;
309
+   case V110_TA_EV_TX_FRAME_RTS:
310
+       v110_ta_build_frame(ta, (struct osmo_v110_decoded_frame *)data);
311
+       break;
312
+   default:
313
+       OSMO_ASSERT(0);
314
+   }
315
+}
316
+
317
+/* ITU-T V.110 Section 7.1.2 */
318
+static void v110_ta_fsm_connect_ta_to_line_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
319
+{
320
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
321
+   struct v110_ta_state *ts = &ta->state;
322
+
323
+   /* 7.1.2.1 Switching to the data mode causes the TA to transmit the following towards the ISDN: */
324
+   /*  a) frame synchronization pattern as described in 5.1.3.1 and 5.2.1 (done by the API user) */
325
+   /*  b) circuit 103: continuous binary '1' */
326
+   ts->tx.d_bit_mode = V110_TA_DBIT_M_ALL_ONE;
327
+   /*  c) status bits S = OFF and X = OFF */
328
+   ts->tx.s_bits = V110_SX_BIT_OFF; /* OFF is binary '1' */
329
+   ts->tx.x_bits = V110_SX_BIT_OFF; /* OFF is binary '1' */
330
+
331
+   /* 7.1.2.2 ... the receiver in the TA will begin to search for the frame synchronization
332
+    * pattern in the received bit stream (see 5.1.3.1 and 5.2.1) and start timer T1. */
333
+   OSMO_ASSERT(fi->T == OSMO_V110_TA_TIMER_T1);
334
+}
335
+
336
+/* ITU-T V.110 Section 7.1.2 */
337
+static void v110_ta_fsm_connect_ta_to_line(struct osmo_fsm_inst *fi, uint32_t event, void *data)
338
+{
339
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
340
+   struct v110_ta_state *ts = &ta->state;
341
+
342
+   switch (event) {
343
+   case V110_TA_EV_V24_STATUS_CHG:
344
+       /* If circuit 108 is OFF, we go back to IDLE/READY */
345
+       if (V24_FLAGMASK_IS_OFF(ts->v24_flags, OSMO_V110_TA_C_108))
346
+           v110_ta_fsm_state_chg(V110_TA_ST_IDLE_READY);
347
+       break;
348
+   case V110_TA_EV_SYNC_IND:
349
+       /* 7.1.2.3 When the receiver recognizes the frame synchronization pattern, it causes the S-
350
+        * and X-bits in the transmitted frames to be turned ON (provided that circuit 108 is ON). */
351
+       OSMO_ASSERT(V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_108));
352
+       ts->tx.s_bits = V110_SX_BIT_ON;
353
+       ts->tx.x_bits = V110_SX_BIT_ON;
354
+       break;
355
+   case V110_TA_EV_RX_FRAME_IND:
356
+   {
357
+       const struct osmo_v110_decoded_frame *df = data;
358
+
359
+       /* 7.1.2.4 When the receiver recognizes that the status of bits S and X are ON */
360
+       if (v110_df_s_bits_are(df, V110_SX_BIT_ON) &&
361
+           v110_df_x_bits_are(df, V110_SX_BIT_ON)) {
362
+           /* ... it will perform the following functions: */
363
+           /*  a) Turn ON circuit 107 toward the DTE and stop timer T1 */
364
+           V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_107);
365
+           osmo_timer_del(&fi->timer);
366
+           /*  b) Then, circuit 103 may be connected to the data bits in the frame; however, the
367
+            *  DTE must maintain a binary 1 condition on circuit 103 until circuit 106 is turned
368
+            *  ON in the next portion of the sequence. */
369
+           /*  c) Turn ON circuit 109 and connect the data bits to circuit 104. */
370
+           V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_109);
371
+           ts->rx.d_bit_mode = V110_TA_DBIT_M_FORWARD;
372
+           /*  d) After an interval of N bits (see 6.3), it will turn ON circuit 106. */
373
+           V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_106);
374
+           ts->tx.d_bit_mode = V110_TA_DBIT_M_FORWARD;
375
+           v110_ta_flags_updated(ta);
376
+           /*  Circuit 106 transitioning from OFF to ON will cause the transmitted data to
377
+            *  transition from binary 1 to the data mode. */
378
+           v110_ta_fsm_state_chg(V110_TA_ST_DATA_TRANSFER);
379
+       }
380
+
381
+       v110_ta_handle_frame(ta, df);
382
+       break;
383
+   }
384
+   case V110_TA_EV_TX_FRAME_RTS:
385
+       v110_ta_build_frame(ta, (struct osmo_v110_decoded_frame *)data);
386
+       break;
387
+   case V110_TA_EV_TIMEOUT:
388
+       v110_ta_fsm_state_chg(V110_TA_ST_IDLE_READY);
389
+       break;
390
+   default:
391
+       OSMO_ASSERT(0);
392
+   }
393
+}
394
+
395
+/* ITU-T V.110 Section 7.1.3 */
396
+static void v110_ta_fsm_data_transfer_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
397
+{
398
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
399
+   struct v110_ta_state *ts = &ta->state;
400
+
401
+   /* 7.1.3.1 While in the data transfer state, the following circuit conditions exist:
402
+    *  a): 105, 107, 108, and 109 are in the ON condition */
403
+   /* XXX: OSMO_ASSERT(V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_105)); */
404
+   V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_107);
405
+   /* XXX: OSMO_ASSERT(V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_108)); */
406
+   V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_109);
407
+   /*  b) data is being transmitted on circuit 103 and received on circuit 104 */
408
+   ts->rx.d_bit_mode = V110_TA_DBIT_M_FORWARD;
409
+   ts->tx.d_bit_mode = V110_TA_DBIT_M_FORWARD;
410
+   /*  c) circuits 133 (when implemented) and 106 are in the ON condition unless local out-of-band
411
+    *  flow control is being used, either or both circuits may be in the ON or the OFF condition. */
412
+   if (!ta->cfg->flow_ctrl.end_to_end) {
413
+       /* XXX: OSMO_ASSERT(V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_133)); */
414
+       V24_FLAGMASK_SET_ON(ts->v24_flags, OSMO_V110_TA_C_106);
415
+   }
416
+   v110_ta_flags_updated(ta);
417
+
418
+   /* 7.1.3.2 While in the data transfer state, the following status bit conditions exist: */
419
+   /*  a) status bits S in both directions are in the ON condition; */
420
+   ts->tx.s_bits = V110_SX_BIT_ON;
421
+   /*  b) status bits X in both directions are in the ON condition unless end-to-end flow control
422
+    *  is being used, in which case status bit X in either or both directions may be in the
423
+    *  ON or the OFF condition. */
424
+   if (!ta->cfg->flow_ctrl.end_to_end)
425
+       ts->tx.x_bits = V110_SX_BIT_ON;
426
+}
427
+
428
+/* ITU-T V.110 Section 7.1.3 */
429
+static void v110_ta_fsm_data_transfer(struct osmo_fsm_inst *fi, uint32_t event, void *data)
430
+{
431
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
432
+   struct v110_ta_state *ts = &ta->state;
433
+
434
+   /* 7.1.3.3 While in the data transfer state: */
435
+   /*  a) the S status bits shall *not* be mapped to/from the interchange circuits */
436
+   /*  b) the X status bits shall *not* be mapped according to Table 3,
437
+    *  unless end-to-end flow control is implemented */
438
+   /* TODO: if (ta->cfg->flow_ctrl.end_to_end) { ... } */
439
+
440
+   switch (event) {
441
+   case V110_TA_EV_V24_STATUS_CHG:
442
+       /* 7.1.4.1 At the completion of the data transfer phase, the local DTE will indicate a
443
+        * disconnect request by turning OFF circuit 108 */
444
+       if (V24_FLAGMASK_IS_ON(ts->v24_flags, OSMO_V110_TA_C_108))
445
+           break;
446
+       v110_ta_fsm_state_chg(V110_TA_ST_DISCONNECTING);
447
+       break;
448
+   case V110_TA_EV_DESYNC_IND:
449
+       v110_ta_fsm_state_chg(V110_TA_ST_RESYNCING);
450
+       break;
451
+   case V110_TA_EV_TX_FRAME_RTS:
452
+       v110_ta_build_frame(ta, (struct osmo_v110_decoded_frame *)data);
453
+       break;
454
+   case V110_TA_EV_RX_FRAME_IND:
455
+   {
456
+       const struct osmo_v110_decoded_frame *df = data;
457
+
458
+       /* 7.1.4.2 ... this TA will recognize the transition of the status bits S from
459
+        * ON to OFF and the data bits from data to binary 0 as a disconnect request */
460
+       if (v110_df_s_bits_are(df, V110_SX_BIT_OFF) && v110_df_d_bits_are(df, 0)) {
461
+           /* ... and it will turn OFF circuits 107 and 109. */
462
+           V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_107);
463
+           V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_109);
464
+           v110_ta_flags_updated(ta);
465
+           /* DTE should respond by turning OFF circuit 108 */
466
+           break; /* XXX: shall we forward D-bits to DTE anyway? */
467
+       }
468
+
469
+       v110_ta_handle_frame(ta, df);
470
+       break;
471
+   }
472
+   default:
473
+       OSMO_ASSERT(0);
474
+   }
475
+}
476
+
477
+/* ITU-T V.110 Section 7.1.4 */
478
+static void v110_ta_fsm_disconnect_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
479
+{
480
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
481
+   struct v110_ta_state *ts = &ta->state;
482
+
483
+   /* 7.1.4.1 At the completion of the data transfer phase, the local DTE will indicate a
484
+    * disconnect request by turning OFF circuit 108. This will cause the following to occur: */
485
+   /*  a) the status bits S in the frame toward ISDN will turn OFF, status bits X are kept ON */
486
+   ts->tx.s_bits = V110_SX_BIT_OFF;
487
+   /*  b) circuit 106 will be turned OFF */
488
+   V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_106);
489
+   v110_ta_flags_updated(ta);
490
+   /*  c) the data bits in the frame will be set to binary 0. */
491
+   ts->tx.d_bit_mode = V110_TA_DBIT_M_ALL_ZERO;
492
+
493
+   /* To guard against the failure of the remote TA to respond to the disconnect request,
494
+    * the local TA may start a timer T2 (suggested value 5 s) which is stopped by the
495
+    * reception or transmission of any D-channel clearing message (DISCONNECT, RELEASE,
496
+    * RELEASE COMPLETE). */
497
+   OSMO_ASSERT(fi->T == OSMO_V110_TA_TIMER_T2);
498
+}
499
+
500
+/* ITU-T V.110 Section 7.1.4 */
501
+static void v110_ta_fsm_disconnect(struct osmo_fsm_inst *fi, uint32_t event, void *data)
502
+{
503
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
504
+
505
+   switch (event) {
506
+   case V110_TA_EV_V24_STATUS_CHG:
507
+       break; /* nothing to do */
508
+   case V110_TA_EV_TX_FRAME_RTS:
509
+       v110_ta_build_frame(ta, (struct osmo_v110_decoded_frame *)data);
510
+       break;
511
+   case V110_TA_EV_RX_FRAME_IND:
512
+   {
513
+       const struct osmo_v110_decoded_frame *df = data;
514
+
515
+       /* 7.1.4.3 The TA at the station that originated the disconnect request will
516
+        * recognize reception of S = OFF or the loss of framing signals as a disconnect
517
+        * acknowledgement and turn OFF circuits 107 and 109. */
518
+       if (v110_df_s_bits_are(df, V110_SX_BIT_OFF)) {
519
+           /* circuits 107 and 109 set to off in .onenter() */
520
+           v110_ta_fsm_state_chg(V110_TA_ST_IDLE_READY);
521
+       }
522
+
523
+       v110_ta_handle_frame(ta, df);
524
+       break;
525
+   }
526
+   case V110_TA_EV_DESYNC_IND:
527
+   case V110_TA_EV_TIMEOUT:
528
+       /* circuits 107 and 109 set to off in .onenter() */
529
+       v110_ta_fsm_state_chg(V110_TA_ST_IDLE_READY);
530
+       break;
531
+   default:
532
+       OSMO_ASSERT(0);
533
+   }
534
+}
535
+
536
+/* ITU-T V.110 Section 7.1.5 */
537
+static void v110_ta_fsm_resyncing_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
538
+{
539
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
540
+   struct v110_ta_state *ts = &ta->state;
541
+
542
+   /* 7.1.5 In the event of loss of frame synchronization, the (local) TA should
543
+    * attempt to resynchronize as follows: */
544
+   /*  a) Place circuit 104 in binary 1 condition (passes from the data mode) */
545
+   ts->rx.d_bit_mode = V110_TA_DBIT_M_ALL_ONE;
546
+   /*  b) Turn OFF status bit X in the transmitted frame */
547
+   ts->tx.x_bits = V110_SX_BIT_OFF;
548
+
549
+   /* guard timeout, see 7.1.5 e) */
550
+   OSMO_ASSERT(fi->T == OSMO_V110_TA_TIMER_X1);
551
+}
552
+
553
+/* ITU-T V.110 Section 7.1.5 */
554
+static void v110_ta_fsm_resyncing(struct osmo_fsm_inst *fi, uint32_t event, void *data)
555
+{
556
+   struct osmo_v110_ta *ta = (struct osmo_v110_ta *)fi->priv;
557
+   struct v110_ta_state *ts = &ta->state;
558
+
559
+   switch (event) {
560
+   case V110_TA_EV_V24_STATUS_CHG:
561
+       break; /* TODO: handle circuit 108 being set to OFF? */
562
+   case V110_TA_EV_TX_FRAME_RTS:
563
+       v110_ta_build_frame(ta, (struct osmo_v110_decoded_frame *)data);
564
+       break;
565
+   case V110_TA_EV_SYNC_IND:
566
+       /* f) If resynchronization is achieved, the local TA should turn ON status bit X */
567
+       ts->tx.x_bits = V110_SX_BIT_ON;
568
+       v110_ta_fsm_state_chg(V110_TA_ST_DATA_TRANSFER);
569
+       break;
570
+   case V110_TA_EV_TIMEOUT:
571
+       /* e) If after an interval of X1 seconds the local TA cannot attain synchronization,
572
+        * it should send a disconnect request by turning OFF all of the status bits for several
573
+        * (at least three) frames with data bits set to binary 0 and then disconnect by turning
574
+        * OFF circuit 107 and transferring to the disconnected mode as discussed in 7.1.4.2. */
575
+       ts->tx.s_bits = V110_SX_BIT_OFF;
576
+       ts->tx.x_bits = V110_SX_BIT_OFF;
577
+       ts->tx.d_bit_mode = V110_TA_DBIT_M_ALL_ZERO;
578
+       /* TODO: actually Tx those frames (delay state transition) */
579
+       V24_FLAGMASK_SET_OFF(ts->v24_flags, OSMO_V110_TA_C_107);
580
+       v110_ta_flags_updated(ta);
581
+       v110_ta_fsm_state_chg(V110_TA_ST_DISCONNECTING);
582
+       break;
583
+   default:
584
+       OSMO_ASSERT(0);
585
+   }
586
+}
587
+
588
+static int v110_ta_timer_cb(struct osmo_fsm_inst *fi)
589
+{
590
+   osmo_fsm_inst_dispatch(fi, V110_TA_EV_TIMEOUT, NULL);
591
+   return 0;
592
+}
593
+
594
+static const struct osmo_fsm_state v110_ta_states = {
595
+   V110_TA_ST_IDLE_READY = {
596
+       .name = "IDLE_READY",
597
+       .in_event_mask  = S(V110_TA_EV_V24_STATUS_CHG)
598
+               | S(V110_TA_EV_TX_FRAME_RTS)
599
+               | S(V110_TA_EV_RX_FRAME_IND),
600
+       .out_state_mask = S(V110_TA_ST_IDLE_READY)
601
+               | S(V110_TA_ST_CON_TA_TO_LINE),
602
+       .action = &v110_ta_fsm_idle_ready,
603
+       .onenter = &v110_ta_fsm_idle_ready_onenter,
604
+   },
605
+   V110_TA_ST_CON_TA_TO_LINE = {
606
+       .name = "CONNECT_TA_TO_LINE",
607
+       .in_event_mask  = S(V110_TA_EV_V24_STATUS_CHG)
608
+               | S(V110_TA_EV_TIMEOUT)
609
+               | S(V110_TA_EV_SYNC_IND)
610
+               | S(V110_TA_EV_TX_FRAME_RTS)
611
+               | S(V110_TA_EV_RX_FRAME_IND),
612
+       .out_state_mask = S(V110_TA_ST_DATA_TRANSFER)
613
+               | S(V110_TA_ST_IDLE_READY),
614
+       .action = &v110_ta_fsm_connect_ta_to_line,
615
+       .onenter = &v110_ta_fsm_connect_ta_to_line_onenter,
616
+   },
617
+   V110_TA_ST_DATA_TRANSFER = {
618
+       .name = "DATA_TRANSFER",
619
+       .in_event_mask  = S(V110_TA_EV_V24_STATUS_CHG)
620
+               | S(V110_TA_EV_DESYNC_IND)
621
+               | S(V110_TA_EV_TX_FRAME_RTS)
622
+               | S(V110_TA_EV_RX_FRAME_IND),
623
+       .out_state_mask = S(V110_TA_ST_RESYNCING)
624
+               | S(V110_TA_ST_DISCONNECTING),
625
+       .action = &v110_ta_fsm_data_transfer,
626
+       .onenter = &v110_ta_fsm_data_transfer_onenter,
627
+   },
628
+   V110_TA_ST_DISCONNECTING = {
629
+       .name = "DISCONNECTING",
630
+       .in_event_mask  = S(V110_TA_EV_V24_STATUS_CHG)
631
+               | S(V110_TA_EV_TIMEOUT)
632
+               | S(V110_TA_EV_TX_FRAME_RTS)
633
+               | S(V110_TA_EV_RX_FRAME_IND)
634
+               | S(V110_TA_EV_DESYNC_IND),
635
+       .out_state_mask = S(V110_TA_ST_IDLE_READY),
636
+       .action = &v110_ta_fsm_disconnect,
637
+       .onenter = &v110_ta_fsm_disconnect_onenter,
638
+   },
639
+   V110_TA_ST_RESYNCING = {
640
+       .name = "RESYNCING",
641
+       .in_event_mask  = S(V110_TA_EV_V24_STATUS_CHG)
642
+               | S(V110_TA_EV_TIMEOUT)
643
+               | S(V110_TA_EV_TX_FRAME_RTS)
644
+               | S(V110_TA_EV_SYNC_IND),
645
+       .out_state_mask = S(V110_TA_ST_IDLE_READY)
646
+               | S(V110_TA_ST_DATA_TRANSFER),
647
+       .action = &v110_ta_fsm_resyncing,
648
+       .onenter = &v110_ta_fsm_resyncing_onenter,
649
+   },
650
+};
651
+
652
+static struct osmo_fsm osmo_v110_ta_fsm = {
653
+   .name = "V110-TA",
654
+   .states = v110_ta_states,
655
+   .num_states = ARRAY_SIZE(v110_ta_states),
656
+   .timer_cb = v110_ta_timer_cb,
657
+   .log_subsys = DLGLOBAL,
658
+   .event_names = v110_ta_fsm_event_names,
659
+};
660
+
661
+static __attribute__((constructor)) void on_dso_load(void)
662
+{
663
+   OSMO_ASSERT(osmo_fsm_register(&osmo_v110_ta_fsm) == 0);
664
+}
665
+
666
+/*! Allocate a V.110 TA (Terminal Adapter) instance.
667
+ * \paramin ctx parent talloc context.
668
+ * \paramin name name of the TA instance.
669
+ * \paramin cfg initial configuration of the TA instance.
670
+ * \returns pointer to allocated TA instance; NULL on error. */
671
+struct osmo_v110_ta *osmo_v110_ta_alloc(void *ctx, const char *name,
672
+                   const struct osmo_v110_ta_cfg *cfg)
673
+{
674
+   struct osmo_v110_ta *ta;
675
+
676
+   OSMO_ASSERT(cfg != NULL);
677
+   OSMO_ASSERT(cfg->rx_cb != NULL);
678
+   OSMO_ASSERT(cfg->tx_cb != NULL);
679
+
680
+   /* local (TE-TA) flow control is not implemented */
681
+   if (cfg->flow_ctrl.local != OSMO_V110_LOCAL_FLOW_CTRL_NONE) {
682
+       LOGP(DLGLOBAL, LOGL_ERROR, "Local (TE-TA) flow control is not implemented\n");
683
+       return NULL;
684
+   }
685
+
686
+   ta = talloc_zero(ctx, struct osmo_v110_ta);
687
+   if (ta == NULL)
688
+       return NULL;
689
+
690
+   ta->name = talloc_strdup(ta, name);
691
+   ta->cfg = talloc_memdup(ta, cfg, sizeof(*cfg));
692
+   if (ta->name == NULL || ta->cfg == NULL)
693
+       goto exit_free;
694
+
695
+   ta->Tdefs = talloc_memdup(ta, v110_ta_tdef, sizeof(v110_ta_tdef));
696
+   if (ta->Tdefs == NULL)
697
+       goto exit_free;
698
+   osmo_tdefs_reset(ta->Tdefs); /* apply default values */
699
+
700
+   ta->fi = osmo_fsm_inst_alloc(&osmo_v110_ta_fsm, ta, ta, LOGL_DEBUG, name);
701
+   if (ta->fi == NULL)
702
+       goto exit_free;
703
+
704
+   /* perform a loop transition to init the internal state */
705
+   osmo_fsm_inst_state_chg(ta->fi, V110_TA_ST_IDLE_READY, 0, 0);
706
+
707
+   return ta;
708
+
709
+exit_free:
710
+   if (ta->fi != NULL)
711
+       osmo_fsm_inst_free(ta->fi);
712
+   talloc_free(ta);
713
+   return NULL;
714
+}
715
+
716
+/*! Release memory taken by the given V.110 TA instance.
717
+ * \paramin ta TA instance to be free()d. */
718
+void osmo_v110_ta_free(struct osmo_v110_ta *ta)
719
+{
720
+   if (ta == NULL)
721
+       return;
722
+   if (ta->fi != NULL)
723
+       osmo_fsm_inst_free(ta->fi);
724
+   talloc_free(ta); /* also free()s name and cfg */
725
+}
726
+
727
+/*! Configure a timer of the given V.110 TA instance.
728
+ * \paramin ta TA instance to be configured.
729
+ * \paramin timer a timer to be configured.
730
+ * \paramin val_ms the new timeout value to set (in milliseconds).
731
+ * \returns 0 in case of success; negative on error. */
732
+int osmo_v110_ta_set_timer_val_ms(struct osmo_v110_ta *ta,
733
+                 enum osmo_v110_ta_timer timer,
734
+                 unsigned long val_ms)
735
+{
736
+   return osmo_tdef_set(ta->Tdefs, (int)timer, val_ms, OSMO_TDEF_MS);
737
+}
738
+
739
+/*! Feed a decoded V.110 frame into the given TA instance.
740
+ *
741
+ * This function, like its _out counterpart, is intended to be used by the lower layers
742
+ * receiving V.110 frames over some medium.  The caller of this function is responsible
743
+ * for finding the synchronization pattern (if needed), aligning to the frame boundaries,
744
+ * and decoding frames using osmo_v110_decode_frame() or osmo_csd_*_decode_frame().
745
+ *
746
+ * Bits E1/E2/E3 are expected to be set by the caller (if not being transmitted
747
+ * over the medium) in accordance with the configured synchronous user rate.
748
+ *
749
+ * Bits D1..D48 are passed to the bit rate adaption function RA1.  The resulting output
750
+ * is then passed to the upper layer (application) via the configured .rx_cb().  Though,
751
+ * in certain states of the TA's FSM, bits D1..D48 are ignored and the upper layer
752
+ * gets a sequence of binary '0' or '1'.
753
+ *
754
+ * \paramin ta TA instance to feed the given frame into.
755
+ * \paramin in pointer to a decoded V.110 frame.
756
+ * \returns 0 in case of success; negative on error. */
757
+int osmo_v110_ta_frame_in(struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in)
758
+{
759
+   return osmo_fsm_inst_dispatch(ta->fi, V110_TA_EV_RX_FRAME_IND, (void *)in);
760
+}
761
+
762
+/*! Pull a decoded V.110 frame out of the given TA instance.
763
+ *
764
+ * This function, like its _in counterpart, is intended to be used by the lower layers
765
+ * transmitting V.110 frames over some medium.  The caller of this function is responsible
766
+ * for encoding the output frame using osmo_v110_encode_frame() or osmo_csd_*_encode_frame().
767
+ *
768
+ * Bits E1/E2/E3 are set in accordance with the configured synchronous user rate.
769
+ * Bits E4/E5/E6/E7 are unconditionally set to binary '1'.
770
+ *
771
+ * Bits D1..D48 are set depending on the state of TA's FSM:
772
+ *
773
+ * - In data transfer mode, the user bits are obtained from the upper layer (application)
774
+ *   via the configured .tx_cb(), and then passed to the bit rate adaption function RA1,
775
+ *   which generates bits D1..D48.
776
+ * - In other modes, bits D1..D48 are all set to binary '0' or '1'.
777
+ *
778
+ * \paramin ta TA instance to pull a frame from.
779
+ * \paramout out where to store a decoded V.110 frame.
780
+ * \returns 0 in case of success; negative on error. */
781
+int osmo_v110_ta_frame_out(struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out)
782
+{
783
+   return osmo_fsm_inst_dispatch(ta->fi, V110_TA_EV_TX_FRAME_RTS, (void *)out);
784
+}
785
+
786
+/*! Indicate a synchronization establishment event.
787
+ *
788
+ * This function is intended to be called when the lower layer
789
+ * achieves synchronization to the frame clock.
790
+ *
791
+ * \paramin ta TA instance to indicate the event to.
792
+ * \returns 0 in case of success; negative on error. */
793
+int osmo_v110_ta_sync_ind(struct osmo_v110_ta *ta)
794
+{
795
+   return osmo_fsm_inst_dispatch(ta->fi, V110_TA_EV_SYNC_IND, NULL);
796
+}
797
+
798
+/*! Indicate a synchronization loss event.
799
+ *
800
+ * This function is intended to be called when the lower layer
801
+ * experiences a loss of synchronization with the frame clock.
802
+ *
803
+ * \paramin ta TA instance to indicate the event to.
804
+ * \returns 0 in case of success; negative on error. */
805
+int osmo_v110_ta_desync_ind(struct osmo_v110_ta *ta)
806
+{
807
+   return osmo_fsm_inst_dispatch(ta->fi, V110_TA_EV_DESYNC_IND, NULL);
808
+}
809
+
810
+/*! Get the V.24 status bit-mask of the given TA instance.
811
+ * \paramin ta TA instance to get the circuit bit-mask.
812
+ * \returns bitmask of OSMO_V110_TA_C_*. */
813
+unsigned int osmo_v110_ta_get_status(const struct osmo_v110_ta *ta)
814
+{
815
+   return ta->state.v24_flags;
816
+}
817
+
818
+/*! Set the V.24 status bit-mask of the given TA instance.
819
+ * \paramin ta TA instance to update the circuit state.
820
+ * \paramin status bit-mask of OSMO_V110_TA_C_*.
821
+ * \returns 0 on success; negative on error. */
822
+static int v110_ta_set_status(struct osmo_v110_ta *ta, unsigned int status)
823
+{
824
+   const unsigned int old_status = ta->state.v24_flags;
825
+   int rc = 0;
826
+
827
+   ta->state.v24_flags = status;
828
+   if (status != old_status)
829
+       rc = osmo_fsm_inst_dispatch(ta->fi, V110_TA_EV_V24_STATUS_CHG, NULL);
830
+
831
+   return rc;
832
+}
833
+
834
+/*! Get state of a V.24 circuit of the given TA instance.
835
+ * \paramin ta TA instance to get the circuit state.
836
+ * \paramin circuit a V.24 circuit, one of OSMO_V110_TA_C_*.
837
+ * \returns circuit state: active (true) or inactive (false). */
838
+bool osmo_v110_ta_get_circuit(const struct osmo_v110_ta *ta,
839
+                 enum osmo_v110_ta_circuit circuit)
840
+{
841
+   return V24_FLAGMASK_IS_ON(ta->state.v24_flags, circuit);
842
+}
843
+
844
+/*! Activate/deactivate a V.24 circuit of the given TA instance.
845
+ * \paramin ta TA instance to update the circuit state.
846
+ * \paramin circuit a V.24 circuit, one of OSMO_V110_TA_C_* (DTE->DCE).
847
+ * \paramin active activate (true) or deactivate (false) the circuit.
848
+ * \returns 0 on success; negative on error. */
849
+int osmo_v110_ta_set_circuit(struct osmo_v110_ta *ta,
850
+                enum osmo_v110_ta_circuit circuit, bool active)
851
+{
852
+   unsigned int status = ta->state.v24_flags;
853
+
854
+   /* permit setting only DTE->DCE circuits */
855
+   switch (circuit) {
856
+   case OSMO_V110_TA_C_105:
857
+   case OSMO_V110_TA_C_108:
858
+   case OSMO_V110_TA_C_133:
859
+       break;
860
+   default:
861
+       LOGPFSML(ta->fi, LOGL_ERROR,
862
+            "Setting circuit %s is not permitted (wrong direction?)\n",
863
+            osmo_v110_ta_circuit_name(circuit));
864
+       return -EACCES;
865
+   }
866
+
867
+   if (active)
868
+       V24_FLAGMASK_SET_ON(status, circuit);
869
+   else
870
+       V24_FLAGMASK_SET_OFF(status, circuit);
871
+
872
+   return v110_ta_set_status(ta, status);
873
+}
874
libosmocore_1.9.0.122.0265.tar.xz/tests/Makefile.am -> libosmocore_1.9.0.128.85554.tar.xz/tests/Makefile.am Changed
36
 
1
@@ -54,6 +54,7 @@
2
         auth/xor2g_test                                        \
3
         v110/frame_test                                        \
4
         v110/ra1_test                                          \
5
+        v110/ta_test                                           \
6
         gsm44021/frame_csd_test                                \
7
         osmo_io/osmo_io_test                   \
8
         soft_uart/soft_uart_test               \
9
@@ -373,6 +374,9 @@
10
 v110_ra1_test_SOURCES = v110/ra1_test.c
11
 v110_ra1_test_LDADD = $(top_builddir)/src/isdn/libosmoisdn.la $(LDADD)
12
 
13
+v110_ta_test_SOURCES = v110/ta_test.c
14
+v110_ta_test_LDADD = $(top_builddir)/src/isdn/libosmoisdn.la $(LDADD)
15
+
16
 gsm44021_frame_csd_test_SOURCES = gsm44021/frame_csd_test.c
17
 gsm44021_frame_csd_test_LDADD = $(top_builddir)/src/isdn/libosmoisdn.la \
18
                $(top_builddir)/src/gsm/libosmogsm.la \
19
@@ -493,6 +497,7 @@
20
         smscb/cbsp_test.ok \
21
         v110/frame_test.ok \
22
         v110/ra1_test.ok \
23
+        v110/ta_test.err \
24
         gsm44021/frame_csd_test.ok \
25
         osmo_io/osmo_io_test.ok osmo_io/osmo_io_test.err \
26
         soft_uart/soft_uart_test.ok \
27
@@ -712,6 +717,8 @@
28
        >$(srcdir)/v110/frame_test.ok
29
    v110/ra1_test \
30
        >$(srcdir)/v110/ra1_test.ok
31
+   v110/ta_test \
32
+       2>$(srcdir)/v110/ta_test.err
33
    gsm44021/frame_csd_test \
34
        >$(srcdir)/gsm44021/frame_csd_test.ok
35
    osmo_io/osmo_io_test \
36
libosmocore_1.9.0.122.0265.tar.xz/tests/tdef/tdef_test.c -> libosmocore_1.9.0.128.85554.tar.xz/tests/tdef/tdef_test.c Changed
50
 
1
@@ -86,14 +86,15 @@
2
        printf("osmo_tdef_get(%d, %s)\t= %lu\n", T, osmo_tdef_unit_name(AS_UNIT), val); \
3
    } while (0)
4
 
5
-void print_tdef_info(unsigned int T)
6
+void print_tdef_info(int T)
7
 {
8
    const struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, T);
9
    if (!t) {
10
-       printf("T%d=NULL", T);
11
+       printf(OSMO_T_FMT "=NULL", OSMO_T_FMT_ARGS(T));
12
        return;
13
    }
14
-   printf("T%d=%lu%s", T, t->val, osmo_tdef_unit_name(t->unit));
15
+   printf(OSMO_T_FMT "=%lu%s",
16
+          OSMO_T_FMT_ARGS(T), t->val, osmo_tdef_unit_name(t->unit));
17
    if (t->val != t->default_val)
18
        printf("(def=%lu)", t->default_val);
19
    printf("\n");
20
@@ -109,7 +110,7 @@
21
    osmo_tdefs_reset(tdefs); // make all values the default
22
 
23
    for (i = 0; i < ARRAY_SIZE(tdefs)-1; i++) {
24
-       unsigned int T = tdefsi.T;
25
+       int T = tdefsi.T;
26
        print_tdef_info(T);
27
        for (as_unit = OSMO_TDEF_S; as_unit <= OSMO_TDEF_US; as_unit++) {
28
            print_tdef_get_short(tdefs, T, as_unit);
29
@@ -120,7 +121,7 @@
30
        return;
31
 
32
    for (i = 0; i < ARRAY_SIZE(tdefs_range)-1; i++) {
33
-       unsigned int T = tdefs_rangei.T;
34
+       int T = tdefs_rangei.T;
35
        print_tdef_info(T);
36
        for (as_unit = OSMO_TDEF_S; as_unit <= OSMO_TDEF_US; as_unit++) {
37
            print_tdef_get_short(tdefs_range, T, as_unit);
38
@@ -347,9 +348,9 @@
39
                   osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), rc); \
40
        } else { \
41
            struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, st->T); \
42
-           printf(" --> %s (configured as T%d%s %lu %s) rc=%d;\t", \
43
+           printf(" --> %s (configured as " OSMO_T_FMT "%s %lu %s) rc=%d;\t", \
44
                   osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), \
45
-                  st->T, st->keep_timer ? "(keep_timer)" : "", \
46
+                  OSMO_T_FMT_ARGS(st->T), st->keep_timer ? " (keep_timer)" : "", \
47
                   t? t->val : 0, t? osmo_tdef_unit_name(t->unit) : "-", \
48
                   rc); \
49
        } \
50
libosmocore_1.9.0.122.0265.tar.xz/tests/tdef/tdef_test.err -> libosmocore_1.9.0.128.85554.tar.xz/tests/tdef/tdef_test.err Changed
15
 
1
@@ -1,10 +1,10 @@
2
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: Allocated
3
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to A (T1, 100s)
4
-DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to B (T2, 1s)
5
+DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to B (T2, 100ms)
6
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){B}: State change to C (T3, 3000s)
7
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){C}: State change to D (T4, 100s)
8
-DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){D}: State change to E (X5, 1s)
9
-DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){E}: State change to F (X6, 1s)
10
+DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){D}: State change to E (X5, 100ms)
11
+DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){E}: State change to F (X6, 1ms)
12
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){F}: State change to G (T7, 50s)
13
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){G}: State change to H (T8, 300s)
14
 DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){H}: State change to I (T9, 300s)
15
libosmocore_1.9.0.122.0265.tar.xz/tests/tdef/tdef_test.ok -> libosmocore_1.9.0.128.85554.tar.xz/tests/tdef/tdef_test.ok Changed
54
 
1
@@ -24,13 +24,13 @@
2
 osmo_tdef_get(4, m)    = 100
3
 osmo_tdef_get(4, custom-unit)  = 100
4
 osmo_tdef_get(4, us)   = 100
5
-T-5=100ms
6
+X5=100ms
7
 osmo_tdef_get(-5, s)   = 1
8
 osmo_tdef_get(-5, ms)  = 100
9
 osmo_tdef_get(-5, m)   = 1
10
 osmo_tdef_get(-5, custom-unit) = 100
11
 osmo_tdef_get(-5, us)  = 100000
12
-T-6=100us
13
+X6=100us
14
 osmo_tdef_get(-6, s)   = 1
15
 osmo_tdef_get(-6, ms)  = 1
16
 osmo_tdef_get(-6, m)   = 1
17
@@ -165,11 +165,11 @@
18
 test_tdef_state_timeout()
19
 state=A T=0, no timeout
20
  --> A (configured as T1 100 s) rc=0;  state=A T=1, 100.000000 s remaining
21
- --> B (configured as T2 100 ms) rc=0; state=B T=2, 1.000000 s remaining
22
+ --> B (configured as T2 100 ms) rc=0; state=B T=2, 0.100000 s remaining
23
  --> C (configured as T3 50 m) rc=0;   state=C T=3, 3000.000000 s remaining
24
  --> D (configured as T4 100 custom-unit) rc=0;    state=D T=4, 100.000000 s remaining
25
- --> E (configured as T-5 100 ms) rc=0;    state=E T=-5, 1.000000 s remaining
26
- --> F (configured as T-6 100 us) rc=0;    state=F T=-6, 1.000000 s remaining
27
+ --> E (configured as X5 100 ms) rc=0; state=E T=-5, 0.100000 s remaining
28
+ --> F (configured as X6 100 us) rc=0; state=F T=-6, 0.001000 s remaining
29
  --> G (configured as T7 50 s) rc=0;   state=G T=7, 50.000000 s remaining
30
  --> H (configured as T8 300 s) rc=0;  state=H T=8, 300.000000 s remaining
31
  --> I (configured as T9 5 m) rc=0;    state=I T=9, 300.000000 s remaining
32
@@ -177,17 +177,17 @@
33
 - test keep_timer:
34
 Time passes: 123.045678 s
35
 state=J T=10, 1076.954322 s remaining
36
- --> K (configured as T0(keep_timer) 1 custom-unit) rc=0;  state=K T=10, 1076.954322 s remaining
37
+ --> K (configured as T0 (keep_timer) 1 custom-unit) rc=0; state=K T=10, 1076.954322 s remaining
38
  --> A (configured as T1 100 s) rc=0;  state=A T=1, 100.000000 s remaining
39
 Time passes: 23.045678 s
40
 state=A T=1, 76.954322 s remaining
41
- --> K (configured as T0(keep_timer) 1 custom-unit) rc=0;  state=K T=1, 76.954322 s remaining
42
+ --> K (configured as T0 (keep_timer) 1 custom-unit) rc=0; state=K T=1, 76.954322 s remaining
43
  --> A (configured as T1 100 s) rc=0;  state=A T=1, 100.000000 s remaining
44
 Time passes: 23.045678 s
45
 state=A T=1, 76.954322 s remaining
46
- --> L (configured as T123(keep_timer) 1 s) rc=0;  state=L T=1, 76.954322 s remaining
47
+ --> L (configured as T123 (keep_timer) 1 s) rc=0; state=L T=1, 76.954322 s remaining
48
  --> O (no timer configured for this state) rc=0;  state=O T=0, no timeout
49
- --> L (configured as T123(keep_timer) 1 s) rc=0;  state=L T=123, 1.000000 s remaining
50
+ --> L (configured as T123 (keep_timer) 1 s) rc=0; state=L T=123, 1.000000 s remaining
51
 - test T=0:
52
  --> O (no timer configured for this state) rc=0;  state=O T=0, no timeout
53
 - test no timer:
54
libosmocore_1.9.0.122.0265.tar.xz/tests/testsuite.at -> libosmocore_1.9.0.128.85554.tar.xz/tests/testsuite.at Changed
14
 
1
@@ -511,6 +511,12 @@
2
 AT_CHECK($abs_top_builddir/tests/v110/ra1_test, , expout,)
3
 AT_CLEANUP
4
 
5
+AT_SETUP(v110_ta_test)
6
+AT_KEYWORDS(v110_ta_test)
7
+cat $abs_srcdir/v110/ta_test.err > experr
8
+AT_CHECK($abs_top_builddir/tests/v110/ta_test, , , experr)
9
+AT_CLEANUP
10
+
11
 AT_SETUP(gsm44021_frame_csd_test)
12
 AT_KEYWORDS(gsm44021_frame_csd_test)
13
 cat $abs_srcdir/gsm44021/frame_csd_test.ok > expout
14
libosmocore_1.9.0.128.85554.tar.xz/tests/v110/ta_test.c Added
461
 
1
@@ -0,0 +1,459 @@
2
+/*
3
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
4
+ * Author: Vadim Yanitskiy <vyanitskiy@sysmocom.de>
5
+ *
6
+ * All Rights Reserved
7
+ *
8
+ * This program is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ */
19
+
20
+#include <stdio.h>
21
+#include <stdint.h>
22
+#include <stdbool.h>
23
+
24
+#include <osmocom/core/fsm.h>
25
+#include <osmocom/core/bits.h>
26
+#include <osmocom/core/logging.h>
27
+#include <osmocom/core/application.h>
28
+
29
+#include <osmocom/isdn/v110.h>
30
+#include <osmocom/isdn/v110_ta.h>
31
+
32
+static void *test_ctx = NULL;
33
+
34
+/* inverse logic: ON = binary 0; OFF = binary 1 */
35
+#define V110_SX_BIT_ON     0
36
+#define V110_SX_BIT_OFF        1
37
+
38
+/*********************************************************************************
39
+ * V.110 TA configuration and callbacks
40
+ *********************************************************************************/
41
+
42
+static void v110_ta_test_rx_cb(void *priv, const ubit_t *buf, size_t buf_size)
43
+{
44
+   fprintf(stderr, "%s(buf_size=%zu): %s\n",
45
+       __func__, buf_size, osmo_ubit_dump(buf, buf_size));
46
+}
47
+
48
+static void v110_ta_test_tx_cb(void *priv, ubit_t *buf, size_t buf_size)
49
+{
50
+   for (size_t i = 0; i < buf_size; i++)
51
+       bufi = (i & 1);
52
+   fprintf(stderr, "%s(buf_size=%zu): %s\n",
53
+       __func__, buf_size, osmo_ubit_dump(buf, buf_size));
54
+}
55
+
56
+static void v110_ta_test_status_update_cb(void *priv, unsigned int status)
57
+{
58
+   fprintf(stderr, "%s(status=0x%08x)\n", __func__, status);
59
+}
60
+
61
+static const struct osmo_v110_ta_cfg v110_ta_test_cfg = {
62
+   .rate = OSMO_V110_SYNC_RA1_9600,
63
+   .rx_cb = &v110_ta_test_rx_cb,
64
+   .tx_cb = &v110_ta_test_tx_cb,
65
+   .status_update_cb = &v110_ta_test_status_update_cb,
66
+};
67
+
68
+/*********************************************************************************
69
+ * various helper functions
70
+ *********************************************************************************/
71
+
72
+static void v110_ta_test_init_df(struct osmo_v110_decoded_frame *df)
73
+{
74
+   /* quickly set all the bits to binary '1' */
75
+   memset(df, 1, sizeof(*df));
76
+   /* D-bits: 0101... pattern */
77
+   for (unsigned int i = 0; i < MAX_D_BITS; i += 2)
78
+       df->d_bitsi = 0;
79
+   /* E-bits: E1/E2/E3 indicate 9600 bps */
80
+   df->e_bits0 = 0;
81
+}
82
+
83
+static void v110_ta_test_dump_df(const struct osmo_v110_decoded_frame *df)
84
+{
85
+   fprintf(stderr, "    D-bits: %s\n", osmo_ubit_dump(&df->d_bits0, MAX_D_BITS));
86
+   fprintf(stderr, "    E-bits: %s\n", osmo_ubit_dump(&df->e_bits0, MAX_E_BITS));
87
+   fprintf(stderr, "    S-bits: %s\n", osmo_ubit_dump(&df->s_bits0, MAX_S_BITS));
88
+   fprintf(stderr, "    X-bits: %s\n", osmo_ubit_dump(&df->x_bits0, MAX_X_BITS));
89
+}
90
+
91
+static void v110_ta_test_dump_circuit(const struct osmo_v110_ta *ta,
92
+                     enum osmo_v110_ta_circuit circuit,
93
+                     bool exp_state)
94
+{
95
+   bool state = osmo_v110_ta_get_circuit(ta, circuit);
96
+
97
+   fprintf(stderr, "circuit %s (%s) is %s (expected to be %s)\n",
98
+       osmo_v110_ta_circuit_name(circuit),
99
+       osmo_v110_ta_circuit_desc(circuit),
100
+       state ? "ON" : "OFF",
101
+       exp_state ? "ON" : "OFF");
102
+}
103
+
104
+static void v110_ta_test_set_circuit(struct osmo_v110_ta *ta,
105
+                    enum osmo_v110_ta_circuit circuit,
106
+                    bool active)
107
+{
108
+   int rc;
109
+
110
+   fprintf(stderr, "setting circuit %s (%s) %s\n",
111
+       osmo_v110_ta_circuit_name(circuit),
112
+       osmo_v110_ta_circuit_desc(circuit),
113
+       active ? "ON" : "OFF");
114
+
115
+   rc = osmo_v110_ta_set_circuit(ta, circuit, active);
116
+   fprintf(stderr, "osmo_v110_ta_set_circuit() returns %d\n", rc);
117
+}
118
+
119
+/*********************************************************************************
120
+ * the actual tests
121
+ *********************************************************************************/
122
+
123
+static void test_idle_ready(void)
124
+{
125
+   struct osmo_v110_decoded_frame df = { 0 };
126
+   struct osmo_v110_ta *ta;
127
+   int rc;
128
+
129
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
130
+
131
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
132
+   OSMO_ASSERT(ta != NULL);
133
+
134
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
135
+
136
+   fprintf(stderr, "Initial status: 0x%08x\n", osmo_v110_ta_get_status(ta));
137
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_106, false);
138
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, false);
139
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, false);
140
+
141
+   fprintf(stderr, "osmo_v110_ta_frame_in(): all bits set to binary '1'\n");
142
+   memset(&df, 1, sizeof(df));
143
+   v110_ta_test_dump_df(&df);
144
+   rc = osmo_v110_ta_frame_in(ta, &df);
145
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
146
+
147
+   fprintf(stderr, "osmo_v110_ta_frame_out(): expecting all bits set to binary '1'\n");
148
+   rc = osmo_v110_ta_frame_out(ta, &df);
149
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
150
+   if (rc == 0)
151
+       v110_ta_test_dump_df(&df);
152
+
153
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, true);
154
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, false);
155
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, true);
156
+
157
+   osmo_v110_ta_free(ta);
158
+}
159
+
160
+static void test_conn_ta_line(void)
161
+{
162
+   struct osmo_v110_decoded_frame df = { 0 };
163
+   struct osmo_v110_ta *ta;
164
+   int rc;
165
+
166
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
167
+
168
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
169
+   OSMO_ASSERT(ta != NULL);
170
+
171
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
172
+
173
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, true);
174
+
175
+   /* we expect the TA FSM to be in V110_TA_ST_CON_TA_TO_LINE */
176
+
177
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-/X-bits are expected to be 1 (OFF)\n");
178
+   fprintf(stderr, "osmo_v110_ta_frame_out(): D-/E-bits are all expected to be 1\n");
179
+   rc = osmo_v110_ta_frame_out(ta, &df);
180
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
181
+   if (rc == 0)
182
+       v110_ta_test_dump_df(&df);
183
+
184
+   /* TODO: test implicit sync by sending V110_TA_EV_RX_FRAME_IND */
185
+
186
+   fprintf(stderr, "osmo_v110_ta_sync_ind(): the lower layer indicates sync event\n");
187
+   osmo_v110_ta_sync_ind(ta);
188
+
189
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-/X-bits are expected to be 0 (ON)\n");
190
+   fprintf(stderr, "osmo_v110_ta_frame_out(): D-/E-bits are all expected to be 1\n");
191
+   rc = osmo_v110_ta_frame_out(ta, &df);
192
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
193
+   if (rc == 0)
194
+       v110_ta_test_dump_df(&df);
195
+
196
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-/X-bits are OFF, expect no state change\n");
197
+   v110_ta_test_init_df(&df);
198
+   v110_ta_test_dump_df(&df);
199
+   rc = osmo_v110_ta_frame_in(ta, &df);
200
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
201
+
202
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change\n");
203
+   memset(&df.s_bits0, V110_SX_BIT_ON, sizeof(df.s_bits));
204
+   memset(&df.x_bits0, V110_SX_BIT_ON, sizeof(df.x_bits));
205
+   v110_ta_test_dump_df(&df);
206
+   rc = osmo_v110_ta_frame_in(ta, &df);
207
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
208
+
209
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
210
+
211
+   osmo_v110_ta_free(ta);
212
+}
213
+
214
+static void _test_data_transfer_enter(struct osmo_v110_ta *ta)
215
+{
216
+   struct osmo_v110_decoded_frame df;
217
+   int rc;
218
+
219
+   OSMO_ASSERT(osmo_v110_ta_get_circuit(ta, OSMO_V110_TA_C_108) == false);
220
+
221
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
222
+
223
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, true);
224
+
225
+   /* we expect the TA FSM to be in V110_TA_ST_CON_TA_TO_LINE */
226
+
227
+   fprintf(stderr, "osmo_v110_ta_sync_ind(): the lower layer indicates sync event\n");
228
+   osmo_v110_ta_sync_ind(ta);
229
+
230
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change\n");
231
+   v110_ta_test_init_df(&df);
232
+   memset(&df.s_bits0, V110_SX_BIT_ON, sizeof(df.s_bits));
233
+   memset(&df.x_bits0, V110_SX_BIT_ON, sizeof(df.x_bits));
234
+   v110_ta_test_dump_df(&df);
235
+   rc = osmo_v110_ta_frame_in(ta, &df);
236
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
237
+
238
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
239
+}
240
+
241
+static void test_data_transfer(void)
242
+{
243
+   struct osmo_v110_decoded_frame df = { 0 };
244
+   struct osmo_v110_ta *ta;
245
+   int rc;
246
+
247
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
248
+
249
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
250
+   OSMO_ASSERT(ta != NULL);
251
+
252
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
253
+
254
+   _test_data_transfer_enter(ta);
255
+
256
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
257
+
258
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_106, true);
259
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, true);
260
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, true);
261
+
262
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-/X-bits are expected to be 0 (ON)\n");
263
+   fprintf(stderr, "osmo_v110_ta_frame_out(): E1..E3-bits are expected to be 011 (9600)\n");
264
+   fprintf(stderr, "osmo_v110_ta_frame_out(): we also expect the .tx_cb() to be called\n");
265
+   rc = osmo_v110_ta_frame_out(ta, &df);
266
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
267
+   if (rc == 0)
268
+       v110_ta_test_dump_df(&df);
269
+
270
+   fprintf(stderr, "osmo_v110_ta_frame_in(): feed that frame that we pulled out back into the TA\n");
271
+   rc = osmo_v110_ta_frame_in(ta, &df);
272
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
273
+
274
+   osmo_v110_ta_free(ta);
275
+}
276
+
277
+static void test_data_transfer_disc_local(void)
278
+{
279
+   struct osmo_v110_decoded_frame df = { 0 };
280
+   struct osmo_v110_ta *ta;
281
+   int rc;
282
+
283
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
284
+
285
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
286
+   OSMO_ASSERT(ta != NULL);
287
+
288
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
289
+
290
+   _test_data_transfer_enter(ta);
291
+
292
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
293
+
294
+   fprintf(stderr, "local TE initiates disconnection\n");
295
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, false);
296
+
297
+   /* we expect the TA FSM to be in V110_TA_ST_DISCONNECTING */
298
+
299
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-bits are expected to be 1 (OFF)\n");
300
+   fprintf(stderr, "osmo_v110_ta_frame_out(): X-bits are expected to be 0 (ON)\n");
301
+   fprintf(stderr, "osmo_v110_ta_frame_out(): D-bits are all expected to be 0\n");
302
+   rc = osmo_v110_ta_frame_out(ta, &df); /* TODO: what E-bits do we expect? */
303
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
304
+   if (rc == 0)
305
+       v110_ta_test_dump_df(&df);
306
+
307
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_106, false);
308
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, true);
309
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, true);
310
+
311
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-/X-bits are ON, expect no state change\n");
312
+   v110_ta_test_init_df(&df);
313
+   memset(&df.s_bits0, V110_SX_BIT_ON, sizeof(df.s_bits));
314
+   memset(&df.x_bits0, V110_SX_BIT_ON, sizeof(df.x_bits));
315
+   v110_ta_test_dump_df(&df);
316
+   rc = osmo_v110_ta_frame_in(ta, &df);
317
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
318
+
319
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-bits are OFF, expect state change\n");
320
+   v110_ta_test_init_df(&df);
321
+   memset(&df.s_bits0, V110_SX_BIT_OFF, sizeof(df.s_bits));
322
+   memset(&df.x_bits0, V110_SX_BIT_ON, sizeof(df.x_bits));
323
+   v110_ta_test_dump_df(&df);
324
+   rc = osmo_v110_ta_frame_in(ta, &df);
325
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
326
+
327
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
328
+
329
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_106, false);
330
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, false);
331
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, false);
332
+
333
+   osmo_v110_ta_free(ta);
334
+}
335
+
336
+static void test_data_transfer_disc_remote(void)
337
+{
338
+   struct osmo_v110_decoded_frame df = { 0 };
339
+   struct osmo_v110_ta *ta;
340
+   int rc;
341
+
342
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
343
+
344
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
345
+   OSMO_ASSERT(ta != NULL);
346
+
347
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
348
+
349
+   _test_data_transfer_enter(ta);
350
+
351
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
352
+
353
+   fprintf(stderr, "remote TE initiates disconnection\n");
354
+   fprintf(stderr, "osmo_v110_ta_frame_in(): S-bits are OFF, X-bits are ON\n");
355
+   fprintf(stderr, "osmo_v110_ta_frame_in(): D-bits are all set to 0\n");
356
+   v110_ta_test_init_df(&df);
357
+   memset(&df.s_bits0, V110_SX_BIT_OFF, sizeof(df.s_bits));
358
+   memset(&df.x_bits0, V110_SX_BIT_ON, sizeof(df.x_bits));
359
+   memset(&df.d_bits0, 0, sizeof(df.d_bits));
360
+   v110_ta_test_dump_df(&df);
361
+   rc = osmo_v110_ta_frame_in(ta, &df);
362
+   fprintf(stderr, "osmo_v110_ta_frame_in() returns %d\n", rc);
363
+
364
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, false);
365
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, false);
366
+
367
+   fprintf(stderr, "local TE confirms disconnection\n");
368
+   v110_ta_test_set_circuit(ta, OSMO_V110_TA_C_108, false);
369
+
370
+   /* we expect the TA FSM to be in V110_TA_ST_DISCONNECTING */
371
+
372
+   osmo_v110_ta_desync_ind(ta);
373
+
374
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
375
+
376
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_106, false);
377
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_107, false);
378
+   v110_ta_test_dump_circuit(ta, OSMO_V110_TA_C_109, false);
379
+
380
+   osmo_v110_ta_free(ta);
381
+}
382
+
383
+static void test_syncing(void)
384
+{
385
+   struct osmo_v110_decoded_frame df = { 0 };
386
+   struct osmo_v110_ta *ta;
387
+   int rc;
388
+
389
+   fprintf(stderr, "\n==== Running %s()\n", __func__);
390
+
391
+   ta = osmo_v110_ta_alloc(test_ctx, __func__, &v110_ta_test_cfg);
392
+   OSMO_ASSERT(ta != NULL);
393
+
394
+   /* we expect the TA FSM to be in V110_TA_ST_IDLE_READY */
395
+
396
+   _test_data_transfer_enter(ta);
397
+
398
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
399
+
400
+   fprintf(stderr, "osmo_v110_ta_sync_ind(): the lower layer indicates out-of-sync event\n");
401
+   osmo_v110_ta_desync_ind(ta);
402
+
403
+   /* we expect the TA FSM to be in V110_TA_ST_RESYNCING */
404
+
405
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-bits are expected to be 0 (ON)\n");
406
+   fprintf(stderr, "osmo_v110_ta_frame_out(): X-bits are expected to be 1 (OFF)\n");
407
+   fprintf(stderr, "osmo_v110_ta_frame_out(): D-bits are to be set by .tx_cb()\n");
408
+   rc = osmo_v110_ta_frame_out(ta, &df);
409
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
410
+   if (rc == 0)
411
+       v110_ta_test_dump_df(&df);
412
+
413
+   fprintf(stderr, "osmo_v110_ta_sync_ind(): the lower layer indicates sync event\n");
414
+   osmo_v110_ta_sync_ind(ta);
415
+
416
+   /* we expect the TA FSM to be in V110_TA_ST_DATA_TRANSFER */
417
+
418
+   fprintf(stderr, "osmo_v110_ta_frame_out(): S-bits are expected to be 0 (ON)\n");
419
+   fprintf(stderr, "osmo_v110_ta_frame_out(): X-bits are expected to be 0 (ON)\n");
420
+   fprintf(stderr, "osmo_v110_ta_frame_out(): D-bits are to be set by .tx_cb()\n");
421
+   rc = osmo_v110_ta_frame_out(ta, &df);
422
+   fprintf(stderr, "osmo_v110_ta_frame_out() returns %d\n", rc);
423
+   if (rc == 0)
424
+       v110_ta_test_dump_df(&df);
425
+
426
+   osmo_v110_ta_free(ta);
427
+}
428
+
429
+int main(int argc, char **argv)
430
+{
431
+   test_ctx = talloc_named_const(NULL, 0, __FILE__);
432
+
433
+   osmo_init_logging2(test_ctx, NULL);
434
+   log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
435
+   log_set_print_level(osmo_stderr_target, 1);
436
+   log_set_print_category(osmo_stderr_target, 1);
437
+   log_set_print_category_hex(osmo_stderr_target, 0);
438
+   log_set_use_color(osmo_stderr_target, 0);
439
+
440
+   osmo_fsm_log_addr(false);
441
+   osmo_fsm_log_timeouts(true);
442
+
443
+   log_set_category_filter(osmo_stderr_target, DLGLOBAL, 1, LOGL_DEBUG);
444
+
445
+   test_idle_ready();
446
+   test_conn_ta_line();
447
+   /* TODO: test_conn_ta_line_timeout() */
448
+   test_data_transfer();
449
+   test_data_transfer_disc_local();
450
+   test_data_transfer_disc_remote();
451
+   /* TODO: test_disc_timeout() */
452
+   test_syncing();
453
+   /* TODO: test_syncing_timeout() */
454
+
455
+   log_fini();
456
+   OSMO_ASSERT(talloc_total_blocks(test_ctx) == 1);
457
+   talloc_free(test_ctx);
458
+
459
+   return 0;
460
+}
461
libosmocore_1.9.0.128.85554.tar.xz/tests/v110/ta_test.err Added
286
 
1
@@ -0,0 +1,284 @@
2
+
3
+==== Running test_idle_ready()
4
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: Allocated
5
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: State change to IDLE_READY (no timeout)
6
+v110_ta_test_status_update_cb(status=0x00000000)
7
+Initial status: 0x00000000
8
+circuit 106/CTS (Clear to Send) is OFF (expected to be OFF)
9
+circuit 107/DSR (Data Set Ready) is OFF (expected to be OFF)
10
+circuit 109/DCD (Data Carrier Detect) is OFF (expected to be OFF)
11
+osmo_v110_ta_frame_in(): all bits set to binary '1'
12
+    D-bits: 111111111111111111111111111111111111111111111111
13
+    E-bits: 1111111
14
+    S-bits: 111111111
15
+    X-bits: 11
16
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: Received Event RX_FRAME_IND
17
+v110_ta_test_rx_cb(buf_size=48): 111111111111111111111111111111111111111111111111
18
+osmo_v110_ta_frame_in() returns 0
19
+osmo_v110_ta_frame_out(): expecting all bits set to binary '1'
20
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: Received Event TX_FRAME_RTS
21
+osmo_v110_ta_frame_out() returns 0
22
+    D-bits: 111111111111111111111111111111111111111111111111
23
+    E-bits: 1111111
24
+    S-bits: 111111111
25
+    X-bits: 11
26
+setting circuit 108/DTR (Data Terminal Ready) ON
27
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: Received Event V24_STATUS_CHG
28
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
29
+osmo_v110_ta_set_circuit() returns 0
30
+setting circuit 108/DTR (Data Terminal Ready) OFF
31
+DLGLOBAL DEBUG V110-TA(test_idle_ready){CONNECT_TA_TO_LINE}: Received Event V24_STATUS_CHG
32
+DLGLOBAL DEBUG V110-TA(test_idle_ready){CONNECT_TA_TO_LINE}: State change to IDLE_READY (no timeout)
33
+v110_ta_test_status_update_cb(status=0x00000000)
34
+osmo_v110_ta_set_circuit() returns 0
35
+setting circuit 108/DTR (Data Terminal Ready) ON
36
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: Received Event V24_STATUS_CHG
37
+DLGLOBAL DEBUG V110-TA(test_idle_ready){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
38
+osmo_v110_ta_set_circuit() returns 0
39
+DLGLOBAL DEBUG V110-TA(test_idle_ready){CONNECT_TA_TO_LINE}: Deallocated
40
+
41
+==== Running test_conn_ta_line()
42
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){IDLE_READY}: Allocated
43
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){IDLE_READY}: State change to IDLE_READY (no timeout)
44
+v110_ta_test_status_update_cb(status=0x00000000)
45
+setting circuit 108/DTR (Data Terminal Ready) ON
46
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){IDLE_READY}: Received Event V24_STATUS_CHG
47
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
48
+osmo_v110_ta_set_circuit() returns 0
49
+osmo_v110_ta_frame_out(): S-/X-bits are expected to be 1 (OFF)
50
+osmo_v110_ta_frame_out(): D-/E-bits are all expected to be 1
51
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: Received Event TX_FRAME_RTS
52
+osmo_v110_ta_frame_out() returns 0
53
+    D-bits: 111111111111111111111111111111111111111111111111
54
+    E-bits: 1111111
55
+    S-bits: 111111111
56
+    X-bits: 11
57
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
58
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: Received Event SYNC_IND
59
+osmo_v110_ta_frame_out(): S-/X-bits are expected to be 0 (ON)
60
+osmo_v110_ta_frame_out(): D-/E-bits are all expected to be 1
61
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: Received Event TX_FRAME_RTS
62
+osmo_v110_ta_frame_out() returns 0
63
+    D-bits: 111111111111111111111111111111111111111111111111
64
+    E-bits: 1111111
65
+    S-bits: 000000000
66
+    X-bits: 00
67
+osmo_v110_ta_frame_in(): S-/X-bits are OFF, expect no state change
68
+    D-bits: 010101010101010101010101010101010101010101010101
69
+    E-bits: 0111111
70
+    S-bits: 111111111
71
+    X-bits: 11
72
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
73
+v110_ta_test_rx_cb(buf_size=48): 111111111111111111111111111111111111111111111111
74
+osmo_v110_ta_frame_in() returns 0
75
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change
76
+    D-bits: 010101010101010101010101010101010101010101010101
77
+    E-bits: 0111111
78
+    S-bits: 000000000
79
+    X-bits: 00
80
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
81
+v110_ta_test_status_update_cb(status=0x0000001e)
82
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){CONNECT_TA_TO_LINE}: State change to DATA_TRANSFER (no timeout)
83
+v110_ta_test_status_update_cb(status=0x0000001e)
84
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
85
+osmo_v110_ta_frame_in() returns 0
86
+DLGLOBAL DEBUG V110-TA(test_conn_ta_line){DATA_TRANSFER}: Deallocated
87
+
88
+==== Running test_data_transfer()
89
+DLGLOBAL DEBUG V110-TA(test_data_transfer){IDLE_READY}: Allocated
90
+DLGLOBAL DEBUG V110-TA(test_data_transfer){IDLE_READY}: State change to IDLE_READY (no timeout)
91
+v110_ta_test_status_update_cb(status=0x00000000)
92
+setting circuit 108/DTR (Data Terminal Ready) ON
93
+DLGLOBAL DEBUG V110-TA(test_data_transfer){IDLE_READY}: Received Event V24_STATUS_CHG
94
+DLGLOBAL DEBUG V110-TA(test_data_transfer){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
95
+osmo_v110_ta_set_circuit() returns 0
96
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
97
+DLGLOBAL DEBUG V110-TA(test_data_transfer){CONNECT_TA_TO_LINE}: Received Event SYNC_IND
98
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change
99
+    D-bits: 010101010101010101010101010101010101010101010101
100
+    E-bits: 0111111
101
+    S-bits: 000000000
102
+    X-bits: 00
103
+DLGLOBAL DEBUG V110-TA(test_data_transfer){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
104
+v110_ta_test_status_update_cb(status=0x0000001e)
105
+DLGLOBAL DEBUG V110-TA(test_data_transfer){CONNECT_TA_TO_LINE}: State change to DATA_TRANSFER (no timeout)
106
+v110_ta_test_status_update_cb(status=0x0000001e)
107
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
108
+osmo_v110_ta_frame_in() returns 0
109
+circuit 106/CTS (Clear to Send) is ON (expected to be ON)
110
+circuit 107/DSR (Data Set Ready) is ON (expected to be ON)
111
+circuit 109/DCD (Data Carrier Detect) is ON (expected to be ON)
112
+osmo_v110_ta_frame_out(): S-/X-bits are expected to be 0 (ON)
113
+osmo_v110_ta_frame_out(): E1..E3-bits are expected to be 011 (9600)
114
+osmo_v110_ta_frame_out(): we also expect the .tx_cb() to be called
115
+DLGLOBAL DEBUG V110-TA(test_data_transfer){DATA_TRANSFER}: Received Event TX_FRAME_RTS
116
+v110_ta_test_tx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
117
+osmo_v110_ta_frame_out() returns 0
118
+    D-bits: 010101010101010101010101010101010101010101010101
119
+    E-bits: 0111111
120
+    S-bits: 000000000
121
+    X-bits: 00
122
+osmo_v110_ta_frame_in(): feed that frame that we pulled out back into the TA
123
+DLGLOBAL DEBUG V110-TA(test_data_transfer){DATA_TRANSFER}: Received Event RX_FRAME_IND
124
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
125
+osmo_v110_ta_frame_in() returns 0
126
+DLGLOBAL DEBUG V110-TA(test_data_transfer){DATA_TRANSFER}: Deallocated
127
+
128
+==== Running test_data_transfer_disc_local()
129
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){IDLE_READY}: Allocated
130
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){IDLE_READY}: State change to IDLE_READY (no timeout)
131
+v110_ta_test_status_update_cb(status=0x00000000)
132
+setting circuit 108/DTR (Data Terminal Ready) ON
133
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){IDLE_READY}: Received Event V24_STATUS_CHG
134
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
135
+osmo_v110_ta_set_circuit() returns 0
136
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
137
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){CONNECT_TA_TO_LINE}: Received Event SYNC_IND
138
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change
139
+    D-bits: 010101010101010101010101010101010101010101010101
140
+    E-bits: 0111111
141
+    S-bits: 000000000
142
+    X-bits: 00
143
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
144
+v110_ta_test_status_update_cb(status=0x0000001e)
145
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){CONNECT_TA_TO_LINE}: State change to DATA_TRANSFER (no timeout)
146
+v110_ta_test_status_update_cb(status=0x0000001e)
147
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
148
+osmo_v110_ta_frame_in() returns 0
149
+local TE initiates disconnection
150
+setting circuit 108/DTR (Data Terminal Ready) OFF
151
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DATA_TRANSFER}: Received Event V24_STATUS_CHG
152
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DATA_TRANSFER}: State change to DISCONNECTING (T2, 5s)
153
+v110_ta_test_status_update_cb(status=0x00000014)
154
+osmo_v110_ta_set_circuit() returns 0
155
+osmo_v110_ta_frame_out(): S-bits are expected to be 1 (OFF)
156
+osmo_v110_ta_frame_out(): X-bits are expected to be 0 (ON)
157
+osmo_v110_ta_frame_out(): D-bits are all expected to be 0
158
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DISCONNECTING}: Received Event TX_FRAME_RTS
159
+osmo_v110_ta_frame_out() returns 0
160
+    D-bits: 000000000000000000000000000000000000000000000000
161
+    E-bits: 1111111
162
+    S-bits: 111111111
163
+    X-bits: 00
164
+circuit 106/CTS (Clear to Send) is OFF (expected to be OFF)
165
+circuit 107/DSR (Data Set Ready) is ON (expected to be ON)
166
+circuit 109/DCD (Data Carrier Detect) is ON (expected to be ON)
167
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect no state change
168
+    D-bits: 010101010101010101010101010101010101010101010101
169
+    E-bits: 0111111
170
+    S-bits: 000000000
171
+    X-bits: 00
172
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DISCONNECTING}: Received Event RX_FRAME_IND
173
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
174
+osmo_v110_ta_frame_in() returns 0
175
+osmo_v110_ta_frame_in(): S-bits are OFF, expect state change
176
+    D-bits: 010101010101010101010101010101010101010101010101
177
+    E-bits: 0111111
178
+    S-bits: 111111111
179
+    X-bits: 00
180
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DISCONNECTING}: Received Event RX_FRAME_IND
181
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){DISCONNECTING}: State change to IDLE_READY (no timeout)
182
+v110_ta_test_status_update_cb(status=0x00000000)
183
+v110_ta_test_rx_cb(buf_size=48): 111111111111111111111111111111111111111111111111
184
+osmo_v110_ta_frame_in() returns 0
185
+circuit 106/CTS (Clear to Send) is OFF (expected to be OFF)
186
+circuit 107/DSR (Data Set Ready) is OFF (expected to be OFF)
187
+circuit 109/DCD (Data Carrier Detect) is OFF (expected to be OFF)
188
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_local){IDLE_READY}: Deallocated
189
+
190
+==== Running test_data_transfer_disc_remote()
191
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){IDLE_READY}: Allocated
192
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){IDLE_READY}: State change to IDLE_READY (no timeout)
193
+v110_ta_test_status_update_cb(status=0x00000000)
194
+setting circuit 108/DTR (Data Terminal Ready) ON
195
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){IDLE_READY}: Received Event V24_STATUS_CHG
196
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
197
+osmo_v110_ta_set_circuit() returns 0
198
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
199
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){CONNECT_TA_TO_LINE}: Received Event SYNC_IND
200
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change
201
+    D-bits: 010101010101010101010101010101010101010101010101
202
+    E-bits: 0111111
203
+    S-bits: 000000000
204
+    X-bits: 00
205
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
206
+v110_ta_test_status_update_cb(status=0x0000001e)
207
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){CONNECT_TA_TO_LINE}: State change to DATA_TRANSFER (no timeout)
208
+v110_ta_test_status_update_cb(status=0x0000001e)
209
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
210
+osmo_v110_ta_frame_in() returns 0
211
+remote TE initiates disconnection
212
+osmo_v110_ta_frame_in(): S-bits are OFF, X-bits are ON
213
+osmo_v110_ta_frame_in(): D-bits are all set to 0
214
+    D-bits: 000000000000000000000000000000000000000000000000
215
+    E-bits: 0111111
216
+    S-bits: 111111111
217
+    X-bits: 00
218
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){DATA_TRANSFER}: Received Event RX_FRAME_IND
219
+v110_ta_test_status_update_cb(status=0x0000000a)
220
+osmo_v110_ta_frame_in() returns 0
221
+circuit 107/DSR (Data Set Ready) is OFF (expected to be OFF)
222
+circuit 109/DCD (Data Carrier Detect) is OFF (expected to be OFF)
223
+local TE confirms disconnection
224
+setting circuit 108/DTR (Data Terminal Ready) OFF
225
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){DATA_TRANSFER}: Received Event V24_STATUS_CHG
226
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){DATA_TRANSFER}: State change to DISCONNECTING (T2, 5s)
227
+v110_ta_test_status_update_cb(status=0x00000000)
228
+osmo_v110_ta_set_circuit() returns 0
229
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){DISCONNECTING}: Received Event DESYNC_IND
230
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){DISCONNECTING}: State change to IDLE_READY (no timeout)
231
+v110_ta_test_status_update_cb(status=0x00000000)
232
+circuit 106/CTS (Clear to Send) is OFF (expected to be OFF)
233
+circuit 107/DSR (Data Set Ready) is OFF (expected to be OFF)
234
+circuit 109/DCD (Data Carrier Detect) is OFF (expected to be OFF)
235
+DLGLOBAL DEBUG V110-TA(test_data_transfer_disc_remote){IDLE_READY}: Deallocated
236
+
237
+==== Running test_syncing()
238
+DLGLOBAL DEBUG V110-TA(test_syncing){IDLE_READY}: Allocated
239
+DLGLOBAL DEBUG V110-TA(test_syncing){IDLE_READY}: State change to IDLE_READY (no timeout)
240
+v110_ta_test_status_update_cb(status=0x00000000)
241
+setting circuit 108/DTR (Data Terminal Ready) ON
242
+DLGLOBAL DEBUG V110-TA(test_syncing){IDLE_READY}: Received Event V24_STATUS_CHG
243
+DLGLOBAL DEBUG V110-TA(test_syncing){IDLE_READY}: State change to CONNECT_TA_TO_LINE (T1, 10s)
244
+osmo_v110_ta_set_circuit() returns 0
245
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
246
+DLGLOBAL DEBUG V110-TA(test_syncing){CONNECT_TA_TO_LINE}: Received Event SYNC_IND
247
+osmo_v110_ta_frame_in(): S-/X-bits are ON, expect state change
248
+    D-bits: 010101010101010101010101010101010101010101010101
249
+    E-bits: 0111111
250
+    S-bits: 000000000
251
+    X-bits: 00
252
+DLGLOBAL DEBUG V110-TA(test_syncing){CONNECT_TA_TO_LINE}: Received Event RX_FRAME_IND
253
+v110_ta_test_status_update_cb(status=0x0000001e)
254
+DLGLOBAL DEBUG V110-TA(test_syncing){CONNECT_TA_TO_LINE}: State change to DATA_TRANSFER (no timeout)
255
+v110_ta_test_status_update_cb(status=0x0000001e)
256
+v110_ta_test_rx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
257
+osmo_v110_ta_frame_in() returns 0
258
+osmo_v110_ta_sync_ind(): the lower layer indicates out-of-sync event
259
+DLGLOBAL DEBUG V110-TA(test_syncing){DATA_TRANSFER}: Received Event DESYNC_IND
260
+DLGLOBAL DEBUG V110-TA(test_syncing){DATA_TRANSFER}: State change to RESYNCING (X1, 3s)
261
+osmo_v110_ta_frame_out(): S-bits are expected to be 0 (ON)
262
+osmo_v110_ta_frame_out(): X-bits are expected to be 1 (OFF)
263
+osmo_v110_ta_frame_out(): D-bits are to be set by .tx_cb()
264
+DLGLOBAL DEBUG V110-TA(test_syncing){RESYNCING}: Received Event TX_FRAME_RTS
265
+v110_ta_test_tx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
266
+osmo_v110_ta_frame_out() returns 0
267
+    D-bits: 010101010101010101010101010101010101010101010101
268
+    E-bits: 0111111
269
+    S-bits: 000000000
270
+    X-bits: 11
271
+osmo_v110_ta_sync_ind(): the lower layer indicates sync event
272
+DLGLOBAL DEBUG V110-TA(test_syncing){RESYNCING}: Received Event SYNC_IND
273
+DLGLOBAL DEBUG V110-TA(test_syncing){RESYNCING}: State change to DATA_TRANSFER (no timeout)
274
+v110_ta_test_status_update_cb(status=0x0000001e)
275
+osmo_v110_ta_frame_out(): S-bits are expected to be 0 (ON)
276
+osmo_v110_ta_frame_out(): X-bits are expected to be 0 (ON)
277
+osmo_v110_ta_frame_out(): D-bits are to be set by .tx_cb()
278
+DLGLOBAL DEBUG V110-TA(test_syncing){DATA_TRANSFER}: Received Event TX_FRAME_RTS
279
+v110_ta_test_tx_cb(buf_size=48): 010101010101010101010101010101010101010101010101
280
+osmo_v110_ta_frame_out() returns 0
281
+    D-bits: 010101010101010101010101010101010101010101010101
282
+    E-bits: 0111111
283
+    S-bits: 000000000
284
+    X-bits: 00
285
+DLGLOBAL DEBUG V110-TA(test_syncing){DATA_TRANSFER}: Deallocated
286