spandsp  0.0.6
private/v42.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/v42.h
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2003, 2011 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_SPANDSP_PRIVATE_V42_H_)
27 #define _SPANDSP_PRIVATE_V42_H_
28 
29 /*! Max retries (9.2.2) */
30 #define V42_DEFAULT_N_400 5
31 /*! Default for max octets in an information field (9.2.3) */
32 #define V42_DEFAULT_N_401 128
33 /*! Maximum supported value for max octets in an information field */
34 #define V42_MAX_N_401 128
35 /*! Default window size (k) (9.2.4) */
36 #define V42_DEFAULT_WINDOW_SIZE_K 15
37 /*! Maximum supported window size (k) */
38 #define V42_MAX_WINDOW_SIZE_K 15
39 
40 /*! The number of info frames to allocate */
41 #define V42_INFO_FRAMES (V42_MAX_WINDOW_SIZE_K + 1)
42 /*! The number of control frames to allocate */
43 #define V42_CTRL_FRAMES 8
44 
45 typedef struct
46 {
47  /* V.42 LAP.M parameters */
48  uint8_t v42_tx_window_size_k;
49  uint8_t v42_rx_window_size_k;
50  uint16_t v42_tx_n401;
51  uint16_t v42_rx_n401;
52 
53  /* V.42bis compressor parameters */
54  uint8_t comp;
55  int comp_dict_size;
56  int comp_max_string;
58 
59 typedef struct frame_s
60 {
61  int len;
62  uint8_t buf[4 + V42_MAX_N_401];
63 } v42_frame_t;
64 
65 /*!
66  LAP-M descriptor. This defines the working state for a single instance of LAP-M.
67 */
68 typedef struct
69 {
70  get_msg_func_t iframe_get;
71  void *iframe_get_user_data;
72 
73  put_msg_func_t iframe_put;
74  void *iframe_put_user_data;
75 
76  modem_status_func_t status_handler;
77  void *status_user_data;
78 
79  hdlc_rx_state_t hdlc_rx;
80  hdlc_tx_state_t hdlc_tx;
81 
82  /*! Negotiated values for the window and maximum info sizes */
84  uint8_t rx_window_size_k;
85  uint16_t tx_n401;
86  uint16_t rx_n401;
87 
88  uint8_t cmd_addr;
89  uint8_t rsp_addr;
90  uint8_t vs;
91  uint8_t va;
92  uint8_t vr;
93  int state;
94  int configuring;
95  int local_busy;
96  int far_busy;
97  int rejected;
98  int retry_count;
99 
100  /* The control frame buffer, and its pointers */
101  int ctrl_put;
102  int ctrl_get;
103  v42_frame_t ctrl_buf[V42_CTRL_FRAMES];
104 
105  /* The info frame buffer, and its pointers */
106  int info_put;
107  int info_get;
108  int info_acked;
109  v42_frame_t info_buf[V42_INFO_FRAMES];
110 
111  void (*packer_process)(v42_state_t *m, int bits);
112 } lapm_state_t;
113 
114 /*! V.42 support negotiation parameters */
115 typedef struct
116 {
117  /*! Stage in negotiating V.42 support */
119  int rxbits;
120  int rxstream;
121  int rxoks;
122  int odp_seen;
123  int txbits;
124  int txstream;
125  int txadps;
127 
128 /*!
129  V.42 descriptor. This defines the working state for a single
130  instance of a V.42 error corrector.
131 */
133 {
134  /*! TRUE if we are the calling party, otherwise FALSE. */
136  /*! TRUE if we should detect whether the far end is V.42 capable. FALSE if we go
137  directly to protocol establishment. */
138  int detect;
139 
140  /*! The bit rate, used to time events */
142 
144  v42_negotiation_t neg;
145  lapm_state_t lapm;
146 
147  int bit_timer;
148  void (*bit_timer_func)(v42_state_t *m);
149 
150  /*! \brief Error and flow logging control */
152 };
153 
154 #endif
155 /*- End of file ------------------------------------------------------------*/
v29_tx_state_s::status_handler
modem_status_func_t status_handler
The callback function used to report modem status changes.
Definition: private/v29tx.h:46
v42_state_s::logging
logging_state_t logging
Error and flow logging control.
Definition: private/v42.h:151
lapm_state_t
Definition: private/v42.h:69
hdlc_tx_init
hdlc_tx_state_t * hdlc_tx_init(hdlc_tx_state_t *s, int crc32, int inter_frame_flags, int progressive, hdlc_underflow_handler_t handler, void *user_data)
Initialise an HDLC transmitter context.
Definition: hdlc.c:626
modem_status_func_t
void(* modem_status_func_t)(void *user_data, int status)
Definition: async.h:114
v42_state_s::tx_bit_rate
int tx_bit_rate
Definition: private/v42.h:141
v42_state_s::detect
int detect
Definition: private/v42.h:138
async.h
hdlc.h
v42_state_s::calling_party
int calling_party
Definition: private/v42.h:135
get_msg_func_t
int(* get_msg_func_t)(void *user_data, uint8_t *msg, int max_len)
Definition: async.h:96
signal_status_to_str
const char * signal_status_to_str(int status)
Convert a signal status to a short text description.
Definition: async.c:42
v42_init
v42_state_t * v42_init(v42_state_t *ss, int calling_party, int detect, get_msg_func_t iframe_get, put_msg_func_t iframe_put, void *user_data)
Definition: v42.c:1495
SPAN_DECLARE_NONSTD
SPAN_DECLARE_NONSTD(int) async_tx_get_bit(void *user_data)
Get the next bit of a transmitted serial bit stream.
v42_negotiation_t::rx_negotiation_step
int rx_negotiation_step
Definition: private/v42.h:118
v42_negotiation_t
Definition: private/v42.h:116
v42_set_local_busy_status
int v42_set_local_busy_status(v42_state_t *s, int busy)
Definition: v42.c:1443
v42_get_far_busy_status
int v42_get_far_busy_status(v42_state_t *s)
Definition: v42.c:1453
lapm_state_t::tx_window_size_k
uint8_t tx_window_size_k
Definition: private/v42.h:83
v42_release
int v42_release(v42_state_t *s)
Definition: v42.c:1551
SIG_STATUS_LINK_CONNECTED
@ SIG_STATUS_LINK_CONNECTED
The link protocol (e.g. V.42) has connected.
Definition: async.h:85
bit_operations.h
hdlc_rx_state_s
Definition: private/hdlc.h:33
v42_free
int v42_free(v42_state_t *s)
Definition: v42.c:1558
span_log
int span_log(logging_state_t *s, int level, const char *format,...)
Generate a log entry.
Definition: logging.c:84
hdlc_rx_init
hdlc_rx_state_t * hdlc_rx_init(hdlc_rx_state_t *s, int crc32, int report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data)
Initialise an HDLC receiver context.
Definition: hdlc.c:327
frame_s
Definition: private/v42.h:60
SIG_STATUS_LINK_DISCONNECTED
@ SIG_STATUS_LINK_DISCONNECTED
The link protocol (e.g. V.42) has disconnected.
Definition: async.h:87
logging.h
put_msg_func_t
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition: async.h:93
v42_config_parameters_t
Definition: private/v42.h:46
v42_restart
void v42_restart(v42_state_t *s)
Definition: v42.c:1466
hdlc_tx_state_s
Definition: private/hdlc.h:92
SIG_STATUS_LINK_ERROR
@ SIG_STATUS_LINK_ERROR
An error has occurred in the link protocol (e.g. V.42).
Definition: async.h:89
v42_state_s
Definition: private/v42.h:133
logging_state_s
Definition: private/logging.h:34
hdlc_tx_frame
int hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t len)
Transmit a frame.
Definition: hdlc.c:389
hdlc_tx_flags
int hdlc_tx_flags(hdlc_tx_state_t *s, int len)
Transmit a specified quantity of flag octets, typically as a preamble.
Definition: hdlc.c:424