Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/v42.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 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 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 * $Id: v42.h,v 1.31 2009/11/04 15:52:06 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \page v42_page V.42 modem error correction | |
| 29 \section v42_page_sec_1 What does it do? | |
| 30 The V.42 specification defines an error correcting protocol for PSTN modems, based on | |
| 31 HDLC and LAP. This makes it similar to an X.25 link. A special variant of LAP, known | |
| 32 as LAP-M, is defined in the V.42 specification. A means for modems to determine if the | |
| 33 far modem supports V.42 is also defined. | |
| 34 | |
| 35 \section v42_page_sec_2 How does it work? | |
| 36 */ | |
| 37 | |
| 38 #if !defined(_SPANDSP_V42_H_) | |
| 39 #define _SPANDSP_V42_H_ | |
| 40 | |
| 41 enum | |
| 42 { | |
| 43 LAPM_DETECT = 0, | |
| 44 LAPM_ESTABLISH = 1, | |
| 45 LAPM_DATA = 2, | |
| 46 LAPM_RELEASE = 3, | |
| 47 LAPM_SIGNAL = 4, | |
| 48 LAPM_SETPARM = 5, | |
| 49 LAPM_TEST = 6, | |
| 50 LAPM_UNSUPPORTED = 7 | |
| 51 }; | |
| 52 | |
| 53 typedef void (*v42_status_func_t)(void *user_data, int status); | |
| 54 typedef void (*v42_frame_handler_t)(void *user_data, const uint8_t *pkt, int len); | |
| 55 | |
| 56 typedef struct lapm_frame_queue_s | |
| 57 { | |
| 58 struct lapm_frame_queue_s *next; | |
| 59 int len; | |
| 60 uint8_t frame[]; | |
| 61 } lapm_frame_queue_t; | |
| 62 | |
| 63 /*! | |
| 64 LAP-M descriptor. This defines the working state for a single instance of LAP-M. | |
| 65 */ | |
| 66 typedef struct lapm_state_s lapm_state_t; | |
| 67 | |
| 68 /*! | |
| 69 V.42 descriptor. This defines the working state for a single instance of V.42. | |
| 70 */ | |
| 71 typedef struct v42_state_s v42_state_t; | |
| 72 | |
| 73 /*! Log the raw HDLC frames */ | |
| 74 #define LAPM_DEBUG_LAPM_RAW (1 << 0) | |
| 75 /*! Log the interpreted frames */ | |
| 76 #define LAPM_DEBUG_LAPM_DUMP (1 << 1) | |
| 77 /*! Log state machine changes */ | |
| 78 #define LAPM_DEBUG_LAPM_STATE (1 << 2) | |
| 79 | |
| 80 #if defined(__cplusplus) | |
| 81 extern "C" | |
| 82 { | |
| 83 #endif | |
| 84 | |
| 85 SPAN_DECLARE(const char *) lapm_status_to_str(int status); | |
| 86 | |
| 87 /*! Dump LAP.M frames in a raw and/or decoded forms | |
| 88 \param frame The frame itself | |
| 89 \param len The length of the frame, in octets | |
| 90 \param showraw TRUE if the raw octets should be dumped | |
| 91 \param txrx TRUE if tx, FALSE if rx. Used to highlight the packet's direction. | |
| 92 */ | |
| 93 SPAN_DECLARE(void) lapm_dump(lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx); | |
| 94 | |
| 95 /*! Accept an HDLC packet | |
| 96 */ | |
| 97 SPAN_DECLARE_NONSTD(void) lapm_receive(void *user_data, const uint8_t *buf, int len, int ok); | |
| 98 | |
| 99 /*! Transmit a LAP.M frame | |
| 100 */ | |
| 101 SPAN_DECLARE(int) lapm_tx(lapm_state_t *s, const void *buf, int len); | |
| 102 | |
| 103 /*! Transmit a LAP.M information frame | |
| 104 */ | |
| 105 SPAN_DECLARE(int) lapm_tx_iframe(lapm_state_t *s, const void *buf, int len, int cr); | |
| 106 | |
| 107 /*! Send a break over a LAP.M connection | |
| 108 */ | |
| 109 SPAN_DECLARE(int) lapm_break(lapm_state_t *s, int enable); | |
| 110 | |
| 111 /*! Initiate an orderly release of a LAP.M connection | |
| 112 */ | |
| 113 SPAN_DECLARE(int) lapm_release(lapm_state_t *s); | |
| 114 | |
| 115 /*! Enable or disable loopback of a LAP.M connection | |
| 116 */ | |
| 117 SPAN_DECLARE(int) lapm_loopback(lapm_state_t *s, int enable); | |
| 118 | |
| 119 /*! Assign or remove a callback routine used to deal with V.42 status changes. | |
| 120 */ | |
| 121 SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, v42_status_func_t callback, void *user_data); | |
| 122 | |
| 123 /*! Process a newly received bit for a V.42 context. | |
| 124 */ | |
| 125 SPAN_DECLARE(void) v42_rx_bit(void *user_data, int bit); | |
| 126 | |
| 127 /*! Get the next transmit bit for a V.42 context. | |
| 128 */ | |
| 129 SPAN_DECLARE(int) v42_tx_bit(void *user_data); | |
| 130 | |
| 131 /*! Initialise a V.42 context. | |
| 132 \param s The V.42 context. | |
| 133 \param calling_party TRUE if caller mode, else answerer mode. | |
| 134 \param frame_handler A callback function to handle received frames of data. | |
| 135 \param user_data An opaque pointer passed to the frame handler routine. | |
| 136 \return ??? | |
| 137 */ | |
| 138 SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int calling_party, int detect, v42_frame_handler_t frame_handler, void *user_data); | |
| 139 | |
| 140 /*! Restart a V.42 context. | |
| 141 \param s The V.42 context. | |
| 142 */ | |
| 143 SPAN_DECLARE(void) v42_restart(v42_state_t *s); | |
| 144 | |
| 145 /*! Release a V.42 context. | |
| 146 \param s The V.42 context. | |
| 147 \return 0 if OK */ | |
| 148 SPAN_DECLARE(int) v42_release(v42_state_t *s); | |
| 149 | |
| 150 /*! Free a V.42 context. | |
| 151 \param s The V.42 context. | |
| 152 \return 0 if OK */ | |
| 153 SPAN_DECLARE(int) v42_free(v42_state_t *s); | |
| 154 | |
| 155 #if defined(__cplusplus) | |
| 156 } | |
| 157 #endif | |
| 158 | |
| 159 #endif | |
| 160 /*- End of file ------------------------------------------------------------*/ |
