v42.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * v42.h
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2003 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  *
00025  * $Id: v42.h,v 1.30 2009/02/10 13:06:47 steveu Exp $
00026  */
00027 
00028 /*! \page v42_page V.42 modem error correction
00029 \section v42_page_sec_1 What does it do?
00030 The V.42 specification defines an error correcting protocol for PSTN modems, based on
00031 HDLC and LAP. This makes it similar to an X.25 link. A special variant of LAP, known
00032 as LAP-M, is defined in the V.42 specification. A means for modems to determine if the
00033 far modem supports V.42 is also defined.
00034 
00035 \section v42_page_sec_2 How does it work?
00036 */
00037 
00038 #if !defined(_SPANDSP_V42_H_)
00039 #define _SPANDSP_V42_H_
00040 
00041 enum
00042 {
00043     LAPM_DETECT = 0,
00044     LAPM_ESTABLISH = 1,
00045     LAPM_DATA = 2,
00046     LAPM_RELEASE = 3,
00047     LAPM_SIGNAL = 4,
00048     LAPM_SETPARM = 5,
00049     LAPM_TEST = 6,
00050     LAPM_UNSUPPORTED = 7
00051 };
00052 
00053 typedef void (*v42_status_func_t)(void *user_data, int status);
00054 typedef void (*v42_frame_handler_t)(void *user_data, const uint8_t *pkt, int len);
00055 
00056 typedef struct lapm_frame_queue_s
00057 {
00058     struct lapm_frame_queue_s *next;
00059     int len;
00060     uint8_t frame[];
00061 } lapm_frame_queue_t;
00062 
00063 /*!
00064     LAP-M descriptor. This defines the working state for a single instance of LAP-M.
00065 */
00066 typedef struct lapm_state_s lapm_state_t;
00067 
00068 /*!
00069     V.42 descriptor. This defines the working state for a single instance of V.42.
00070 */
00071 typedef struct v42_state_s v42_state_t;
00072 
00073 /*! Log the raw HDLC frames */
00074 #define LAPM_DEBUG_LAPM_RAW         (1 << 0)
00075 /*! Log the interpreted frames */
00076 #define LAPM_DEBUG_LAPM_DUMP        (1 << 1)
00077 /*! Log state machine changes */
00078 #define LAPM_DEBUG_LAPM_STATE       (1 << 2)
00079 
00080 #if defined(__cplusplus)
00081 extern "C"
00082 {
00083 #endif
00084 
00085 SPAN_DECLARE(const char *) lapm_status_to_str(int status);
00086 
00087 /*! Dump LAP.M frames in a raw and/or decoded forms
00088     \param frame The frame itself
00089     \param len The length of the frame, in octets
00090     \param showraw TRUE if the raw octets should be dumped
00091     \param txrx TRUE if tx, FALSE if rx. Used to highlight the packet's direction.
00092 */
00093 SPAN_DECLARE(void) lapm_dump(lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx);
00094 
00095 /*! Accept an HDLC packet
00096 */
00097 SPAN_DECLARE_NONSTD(void) lapm_receive(void *user_data, const uint8_t *buf, int len, int ok);
00098 
00099 /*! Transmit a LAP.M frame
00100 */
00101 SPAN_DECLARE(int) lapm_tx(lapm_state_t *s, const void *buf, int len);
00102 
00103 /*! Transmit a LAP.M information frame
00104 */
00105 SPAN_DECLARE(int) lapm_tx_iframe(lapm_state_t *s, const void *buf, int len, int cr);
00106 
00107 /*! Send a break over a LAP.M connection
00108 */
00109 SPAN_DECLARE(int) lapm_break(lapm_state_t *s, int enable);
00110 
00111 /*! Initiate an orderly release of a LAP.M connection
00112 */
00113 SPAN_DECLARE(int) lapm_release(lapm_state_t *s);
00114 
00115 /*! Enable or disable loopback of a LAP.M connection
00116 */
00117 SPAN_DECLARE(int) lapm_loopback(lapm_state_t *s, int enable);
00118 
00119 /*! Assign or remove a callback routine used to deal with V.42 status changes.
00120 */
00121 SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, v42_status_func_t callback, void *user_data);
00122 
00123 /*! Process a newly received bit for a V.42 context.
00124 */
00125 SPAN_DECLARE(void) v42_rx_bit(void *user_data, int bit);
00126 
00127 /*! Get the next transmit bit for a V.42 context.
00128 */
00129 SPAN_DECLARE(int) v42_tx_bit(void *user_data);
00130 
00131 /*! Initialise a V.42 context.
00132     \param s The V.42 context.
00133     \param caller TRUE if caller mode, else answerer mode.
00134     \param frame_handler A callback function to handle received frames of data.
00135     \param user_data An opaque pointer passed to the frame handler routine.
00136     \return ???
00137 */
00138 SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int caller, int detect, v42_frame_handler_t frame_handler, void *user_data);
00139 
00140 /*! Restart a V.42 context.
00141     \param s The V.42 context.
00142 */
00143 SPAN_DECLARE(void) v42_restart(v42_state_t *s);
00144 
00145 /*! Release a V.42 context.
00146     \param s The V.42 context.
00147     \return 0 if OK */
00148 SPAN_DECLARE(int) v42_release(v42_state_t *s);
00149 
00150 /*! Free a V.42 context.
00151     \param s The V.42 context.
00152     \return 0 if OK */
00153 SPAN_DECLARE(int) v42_free(v42_state_t *s);
00154 
00155 #if defined(__cplusplus)
00156 }
00157 #endif
00158 
00159 #endif
00160 /*- End of file ------------------------------------------------------------*/

Generated on Tue Aug 4 03:36:16 2009 for spandsp by  doxygen 1.5.9