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
201
 
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
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
201
 
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
libosmocore_1.9.0.128.85554.tar.xz/tests/v110/ta_test.err Added
201
 
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