spandsp  0.0.6
v42.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * 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 /*! \page v42_page V.42 modem error correction
27 \section v42_page_sec_1 What does it do?
28 The V.42 specification defines an error correcting protocol for PSTN modems, based on
29 HDLC and LAP. This makes it similar to an X.25 link. A special variant of LAP, known
30 as LAP-M, is defined in the V.42 specification. A means for modems to determine if the
31 far modem supports V.42 is also defined.
32 
33 \section v42_page_sec_2 How does it work?
34 */
35 
36 #if !defined(_SPANDSP_V42_H_)
37 #define _SPANDSP_V42_H_
38 
39 typedef struct v42_state_s v42_state_t;
40 
41 #if defined(__cplusplus)
42 extern "C"
43 {
44 #endif
45 
46 SPAN_DECLARE(const char *) lapm_status_to_str(int status);
47 
48 SPAN_DECLARE_NONSTD(void) lapm_receive(void *user_data, const uint8_t *frame, int len, int ok);
49 
50 SPAN_DECLARE(void) v42_start(v42_state_t *s);
51 
52 SPAN_DECLARE(void) v42_stop(v42_state_t *s);
53 
54 /*! Set the busy status of the local end of a V.42 context.
55  \param s The V.42 context.
56  \param busy The new local end busy status.
57  \return The previous local end busy status.
58 */
59 SPAN_DECLARE(int) v42_set_local_busy_status(v42_state_t *s, int busy);
60 
61 /*! Get the busy status of the far end of a V.42 context.
62  \param s The V.42 context.
63  \return The far end busy status.
64 */
65 SPAN_DECLARE(int) v42_get_far_busy_status(v42_state_t *s);
66 
67 SPAN_DECLARE(void) v42_rx_bit(void *user_data, int bit);
68 
69 SPAN_DECLARE(int) v42_tx_bit(void *user_data);
70 
71 SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, modem_status_func_t callback, void *user_data);
72 
73 /*! Get the logging context associated with a V.42 context.
74  \brief Get the logging context associated with a V.42 context.
75  \param s The V.42 context.
76  \return A pointer to the logging context */
78 
79 /*! Initialise a V.42 context.
80  \param s The V.42 context.
81  \param calling_party True if caller mode, else answerer mode.
82  \param detect True to perform the V.42 detection, else go straight into LAP.M
83  \param iframe_get A callback function to handle received frames of data.
84  \param iframe_put A callback function to get frames of data for transmission.
85  \param user_data An opaque pointer passed to the frame handler routines.
86  \return ???
87 */
88 SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s,
89  int calling_party,
90  int detect,
91  get_msg_func_t iframe_get,
92  put_msg_func_t iframe_put,
93  void *user_data);
94 
95 /*! Restart a V.42 context.
96  \param s The V.42 context.
97 */
98 SPAN_DECLARE(void) v42_restart(v42_state_t *s);
99 
100 /*! Release a V.42 context.
101  \param s The V.42 context.
102  \return 0 if OK */
103 SPAN_DECLARE(int) v42_release(v42_state_t *s);
104 
105 /*! Free a V.42 context.
106  \param s The V.42 context.
107  \return 0 if OK */
108 SPAN_DECLARE(int) v42_free(v42_state_t *s);
109 
110 #if defined(__cplusplus)
111 }
112 #endif
113 
114 #endif
115 /*- End of file ------------------------------------------------------------*/
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition: async.h:95
int calling_party
Definition: private/v42.h:135
int v42_get_far_busy_status(v42_state_t *s)
Definition: v42.c:1455
void(* modem_status_func_t)(void *user_data, int status)
Definition: async.h:116
SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data
Accept a bit from a received serial bit stream.
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:1503
int detect
Definition: private/v42.h:138
int(* get_msg_func_t)(void *user_data, uint8_t *msg, int max_len)
Definition: async.h:98
int v42_release(v42_state_t *s)
Definition: v42.c:1559
void v42_restart(v42_state_t *s)
Definition: v42.c:1474
int v42_free(v42_state_t *s)
Definition: v42.c:1566
Definition: private/v42.h:132
Definition: private/logging.h:33
int v42_set_local_busy_status(v42_state_t *s, int busy)
Definition: v42.c:1445
logging_state_t * v42_get_logging_state(v42_state_t *s)
Get the logging context associated with a V.42 context.
Definition: v42.c:1461