spandsp: v42.h Source File

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;
57} v42_config_parameters_t;
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 */
83 uint8_t tx_window_size_k;
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 */
118 int rx_negotiation_step;
119 int rxbits;
120 int rxstream;
121 int rxoks;
122 int odp_seen;
123 int txbits;
124 int txstream;
125 int txadps;
126} v42_negotiation_t;
127
128/*!
129 V.42 descriptor. This defines the working state for a single
130 instance of a V.42 error corrector.
131*/
132 struct v42_state_s
133{
134 /*! TRUE if we are the calling party, otherwise FALSE. */
135 int calling_party;
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 */
141 int tx_bit_rate;
142
143 v42_config_parameters_t config;
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 */
151 logging_state_t logging;
152};
153
154#endif
155/*- End of file ------------------------------------------------------------*/
get_msg_func_t
int(* get_msg_func_t)(void *user_data, uint8_t *msg, int max_len)
Definition async.h:96
modem_status_func_t
void(* modem_status_func_t)(void *user_data, int status)
Definition async.h:114
put_msg_func_t
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:93
hdlc_rx_state_t
struct hdlc_rx_state_s hdlc_rx_state_t
Definition hdlc.h:54
hdlc_tx_state_t
struct hdlc_tx_state_s hdlc_tx_state_t
Definition hdlc.h:77
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
frame_s
Definition private/v42.h:60
lapm_state_t
Definition private/v42.h:69
lapm_state_t::tx_window_size_k
uint8_t tx_window_size_k
Definition private/v42.h:83
v42_config_parameters_t
Definition private/v42.h:46
v42_negotiation_t
Definition private/v42.h:116
v42_negotiation_t::rx_negotiation_step
int rx_negotiation_step
Definition private/v42.h:118
v42_state_s
Definition private/v42.h:133
v42_state_s::logging
logging_state_t logging
Error and flow logging control.
Definition private/v42.h:151
v42_state_s::calling_party
int calling_party
Definition private/v42.h:135
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