libosmoisdn 1.13.1.1-afb4 Osmocom ISDN library

v110_ta.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5
6#include <osmocom/core/utils.h>
7#include <osmocom/core/bits.h>
8#include <osmocom/isdn/v110.h>
9
10/* Definition of this struct is [intentionally] kept private */
11 struct osmo_v110_ta;
12
14 enum osmo_v110_local_flow_ctrl_mode {
15 OSMO_V110_LOCAL_FLOW_CTRL_NONE,
16 OSMO_V110_LOCAL_FLOW_CTRL_133_106,
17 OSMO_V110_LOCAL_FLOW_CTRL_105_106,
18 OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF,
19};
20
22 struct osmo_v110_ta_cfg {
24 unsigned int flags;
26 enum osmo_v100_sync_ra1_rate rate;
27
29 struct {
31 enum osmo_v110_local_flow_ctrl_mode local;
33 bool end_to_end;
34 } flow_ctrl;
35
37 void *priv;
38
43 void (*rx_cb)(void *priv, const ubit_t *buf, size_t buf_size);
44
49 void (*tx_cb)(void *priv, ubit_t *buf, size_t buf_size);
50
54 void (*status_update_cb)(void *priv, unsigned int status);
55};
56
57 struct osmo_v110_ta *osmo_v110_ta_alloc(void *ctx, const char *name,
58 const struct osmo_v110_ta_cfg *cfg);
59 void osmo_v110_ta_free(struct osmo_v110_ta *ta);
60
62 enum osmo_v110_ta_timer {
65 OSMO_V110_TA_TIMER_X1 = -1,
67 OSMO_V110_TA_TIMER_T1 = 1,
69 OSMO_V110_TA_TIMER_T2 = 2,
70};
71
72 int osmo_v110_ta_set_timer_val_ms(struct osmo_v110_ta *ta,
73 enum osmo_v110_ta_timer timer,
74 unsigned long val_ms);
75
76 int osmo_v110_ta_frame_in(struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in);
77 int osmo_v110_ta_frame_out(struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out);
78
79 int osmo_v110_ta_sync_ind(struct osmo_v110_ta *ta);
80 int osmo_v110_ta_desync_ind(struct osmo_v110_ta *ta);
81
85 enum osmo_v110_ta_circuit {
86 OSMO_V110_TA_C_105,
87 OSMO_V110_TA_C_106,
88 OSMO_V110_TA_C_107,
89 OSMO_V110_TA_C_108,
90 OSMO_V110_TA_C_109,
91 OSMO_V110_TA_C_133,
92};
93
94 extern const struct value_string osmo_v110_ta_circuit_names[];
95 extern const struct value_string osmo_v110_ta_circuit_descs[];
96
98 static inline const char *osmo_v110_ta_circuit_name(enum osmo_v110_ta_circuit circuit)
99{
100 return get_value_string(osmo_v110_ta_circuit_names, circuit);
101}
102
104 static inline const char *osmo_v110_ta_circuit_desc(enum osmo_v110_ta_circuit circuit)
105{
106 return get_value_string(osmo_v110_ta_circuit_descs, circuit);
107}
108
109 unsigned int osmo_v110_ta_get_status(const struct osmo_v110_ta *ta);
110 bool osmo_v110_ta_get_circuit(const struct osmo_v110_ta *ta,
111 enum osmo_v110_ta_circuit circuit);
112 int osmo_v110_ta_set_circuit(struct osmo_v110_ta *ta,
113 enum osmo_v110_ta_circuit circuit, bool active);
bits.h
ubit_t
uint8_t ubit_t
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
osmo_v110_decoded_frame
a 'decoded' representation of a single V.110 frame.
Definition: v110.h:12
osmo_v110_ta_cfg
Configuration for a V.110 TA instance.
Definition: v110_ta.h:22
osmo_v110_ta_cfg::flow_ctrl
struct osmo_v110_ta_cfg::@4 flow_ctrl
Flow control configuration.
osmo_v110_ta_cfg::rate
enum osmo_v100_sync_ra1_rate rate
Synchronous user rate.
Definition: v110_ta.h:26
osmo_v110_ta_cfg::tx_cb
void(* tx_cb)(void *priv, ubit_t *buf, size_t buf_size)
Transmit call-back of the application.
Definition: v110_ta.h:49
osmo_v110_ta_cfg::priv
void * priv
Opaque application-private data; passed to call-backs.
Definition: v110_ta.h:37
osmo_v110_ta_cfg::rx_cb
void(* rx_cb)(void *priv, const ubit_t *buf, size_t buf_size)
Receive call-back of the application.
Definition: v110_ta.h:43
osmo_v110_ta_cfg::end_to_end
bool end_to_end
End-to-end (TA-to-TA) flow control state.
Definition: v110_ta.h:33
osmo_v110_ta_cfg::status_update_cb
void(* status_update_cb)(void *priv, unsigned int status)
Modem status line update call-back (optional).
Definition: v110_ta.h:54
osmo_v110_ta_cfg::local
enum osmo_v110_local_flow_ctrl_mode local
Local TA-TE (DTE-DCE) flow control mode.
Definition: v110_ta.h:31
osmo_v110_ta_cfg::flags
unsigned int flags
Configuration flags (behavior switches and quirks)
Definition: v110_ta.h:24
osmo_v110_ta
Definition: v110_ta.c:144
osmo_v110_ta::cfg
struct osmo_v110_ta_cfg * cfg
Definition: v110_ta.c:148
osmo_v110_ta::name
const char * name
Definition: v110_ta.c:145
value_string
utils.h
v110.h
osmo_v100_sync_ra1_rate
osmo_v100_sync_ra1_rate
enum for each supported V.110 synchronous RA1 function (one for each user bitrate)
Definition: v110.h:26
osmo_v110_ta_circuit_descs
const struct value_string osmo_v110_ta_circuit_descs[]
Definition: v110_ta.c:68
osmo_v110_ta_circuit_names
const struct value_string osmo_v110_ta_circuit_names[]
Definition: v110_ta.c:58
osmo_v110_ta_get_circuit
bool osmo_v110_ta_get_circuit(const struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit)
Get state of a V.24 circuit of the given TA instance.
Definition: v110_ta.c:846
osmo_v110_ta_timer
osmo_v110_ta_timer
Various timers for a V.110 TA instance.
Definition: v110_ta.h:62
OSMO_V110_TA_TIMER_T1
@ OSMO_V110_TA_TIMER_T1
7.1.2 Connect TA to line: sync establishment timer
Definition: v110_ta.h:67
OSMO_V110_TA_TIMER_T2
@ OSMO_V110_TA_TIMER_T2
7.1.4 Disconnect mode: disconnect confirmation timer
Definition: v110_ta.h:69
OSMO_V110_TA_TIMER_X1
@ OSMO_V110_TA_TIMER_X1
7.1.5 Loss of frame synchronization: sync recovery timer.
Definition: v110_ta.h:65
osmo_v110_ta_circuit_desc
static const char * osmo_v110_ta_circuit_desc(enum osmo_v110_ta_circuit circuit)
Get a brief description of the given TA's circuit.
Definition: v110_ta.h:104
osmo_v110_ta_circuit_name
static const char * osmo_v110_ta_circuit_name(enum osmo_v110_ta_circuit circuit)
Get a short name of the given TA's circuit (format: NNN[/ABBR]).
Definition: v110_ta.h:98
osmo_v110_ta_set_timer_val_ms
int osmo_v110_ta_set_timer_val_ms(struct osmo_v110_ta *ta, enum osmo_v110_ta_timer timer, unsigned long val_ms)
Configure a timer of the given V.110 TA instance.
Definition: v110_ta.c:740
osmo_v110_ta_free
void osmo_v110_ta_free(struct osmo_v110_ta *ta)
Release memory taken by the given V.110 TA instance.
Definition: v110_ta.c:726
osmo_v110_ta_circuit
osmo_v110_ta_circuit
ITU-T Table 9 "Interchange circuit" (see also ITU-T V.24 Chapter 3).
Definition: v110_ta.h:85
OSMO_V110_TA_C_107
@ OSMO_V110_TA_C_107
DTE<-DCE | DSR (Data Set Ready)
Definition: v110_ta.h:88
OSMO_V110_TA_C_109
@ OSMO_V110_TA_C_109
DTE<-DCE | DCD (Data Carrier Detect)
Definition: v110_ta.h:90
OSMO_V110_TA_C_106
@ OSMO_V110_TA_C_106
DTE<-DCE | CTS (Clear to Send)
Definition: v110_ta.h:87
OSMO_V110_TA_C_108
@ OSMO_V110_TA_C_108
DTE->DCE | DTR (Data Terminal Ready)
Definition: v110_ta.h:89
OSMO_V110_TA_C_105
@ OSMO_V110_TA_C_105
DTE->DCE | RTS (Request to Send)
Definition: v110_ta.h:86
OSMO_V110_TA_C_133
@ OSMO_V110_TA_C_133
DTE->DCE | Ready for receiving.
Definition: v110_ta.h:91
osmo_v110_local_flow_ctrl_mode
osmo_v110_local_flow_ctrl_mode
V.110 5.4.1 Local flow control (DTE-DCE or TE-TA) mode.
Definition: v110_ta.h:14
OSMO_V110_LOCAL_FLOW_CTRL_NONE
@ OSMO_V110_LOCAL_FLOW_CTRL_NONE
No local flow control.
Definition: v110_ta.h:15
OSMO_V110_LOCAL_FLOW_CTRL_133_106
@ OSMO_V110_LOCAL_FLOW_CTRL_133_106
5.4.1.1 133/106 operation
Definition: v110_ta.h:16
OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF
@ OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF
5.4.1.3 XON/XOFF operation
Definition: v110_ta.h:18
OSMO_V110_LOCAL_FLOW_CTRL_105_106
@ OSMO_V110_LOCAL_FLOW_CTRL_105_106
5.4.1.2 105/106 operation
Definition: v110_ta.h:17
osmo_v110_ta_get_status
unsigned int osmo_v110_ta_get_status(const struct osmo_v110_ta *ta)
Get the V.24 status bit-mask of the given TA instance.
Definition: v110_ta.c:821
osmo_v110_ta_frame_in
int osmo_v110_ta_frame_in(struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in)
Feed a [decoded] V.110 frame into the given TA instance.
Definition: v110_ta.c:765
osmo_v110_ta_frame_out
int osmo_v110_ta_frame_out(struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out)
Pull a [decoded] V.110 frame out of the given TA instance.
Definition: v110_ta.c:789
osmo_v110_ta_alloc
struct osmo_v110_ta * osmo_v110_ta_alloc(void *ctx, const char *name, const struct osmo_v110_ta_cfg *cfg)
Allocate a V.110 TA (Terminal Adapter) instance.
Definition: v110_ta.c:679
osmo_v110_ta_desync_ind
int osmo_v110_ta_desync_ind(struct osmo_v110_ta *ta)
Indicate a synchronization loss event.
Definition: v110_ta.c:813
osmo_v110_ta_set_circuit
int osmo_v110_ta_set_circuit(struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit, bool active)
Activate/deactivate a V.24 circuit of the given TA instance.
Definition: v110_ta.c:857
osmo_v110_ta_sync_ind
int osmo_v110_ta_sync_ind(struct osmo_v110_ta *ta)
Indicate a synchronization establishment event.
Definition: v110_ta.c:801