Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/private/hdlc.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 * private/hdlc.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: hdlc.h,v 1.3 2009/02/12 12:38:39 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 #if !defined(_SPANDSP_PRIVATE_HDLC_H_) | |
| 29 #define _SPANDSP_PRIVATE_HDLC_H_ | |
| 30 | |
| 31 /*! | |
| 32 HDLC receive descriptor. This contains all the state information for an HDLC receiver. | |
| 33 */ | |
| 34 struct hdlc_rx_state_s | |
| 35 { | |
| 36 /*! 2 for CRC-16, 4 for CRC-32 */ | |
| 37 int crc_bytes; | |
| 38 /*! \brief Maximum permitted frame length. */ | |
| 39 size_t max_frame_len; | |
| 40 /*! \brief The callback routine called to process each good received frame. */ | |
| 41 hdlc_frame_handler_t frame_handler; | |
| 42 /*! \brief An opaque parameter passed to the frame callback routine. */ | |
| 43 void *frame_user_data; | |
| 44 /*! \brief The callback routine called to report status changes. */ | |
| 45 modem_rx_status_func_t status_handler; | |
| 46 /*! \brief An opaque parameter passed to the status callback routine. */ | |
| 47 void *status_user_data; | |
| 48 /*! \brief TRUE if bad frames are to be reported. */ | |
| 49 int report_bad_frames; | |
| 50 /*! \brief The number of consecutive flags which must be seen before framing is | |
| 51 declared OK. */ | |
| 52 int framing_ok_threshold; | |
| 53 /*! \brief TRUE if framing OK has been announced. */ | |
| 54 int framing_ok_announced; | |
| 55 /*! \brief Number of consecutive flags seen so far. */ | |
| 56 int flags_seen; | |
| 57 | |
| 58 /*! \brief The raw (stuffed) bit stream buffer. */ | |
| 59 unsigned int raw_bit_stream; | |
| 60 /*! \brief The destuffed bit stream buffer. */ | |
| 61 unsigned int byte_in_progress; | |
| 62 /*! \brief The current number of bits in byte_in_progress. */ | |
| 63 int num_bits; | |
| 64 /*! \brief TRUE if in octet counting mode (e.g. for MTP). */ | |
| 65 int octet_counting_mode; | |
| 66 /*! \brief Octet count, to achieve the functionality needed for things | |
| 67 like MTP. */ | |
| 68 int octet_count; | |
| 69 /*! \brief The number of octets to be allowed between octet count reports. */ | |
| 70 int octet_count_report_interval; | |
| 71 | |
| 72 /*! \brief Buffer for a frame in progress. */ | |
| 73 uint8_t buffer[HDLC_MAXFRAME_LEN + 4]; | |
| 74 /*! \brief Length of a frame in progress. */ | |
| 75 size_t len; | |
| 76 | |
| 77 /*! \brief The number of bytes of good frames received (CRC not included). */ | |
| 78 unsigned long int rx_bytes; | |
| 79 /*! \brief The number of good frames received. */ | |
| 80 unsigned long int rx_frames; | |
| 81 /*! \brief The number of frames with CRC errors received. */ | |
| 82 unsigned long int rx_crc_errors; | |
| 83 /*! \brief The number of too short and too long frames received. */ | |
| 84 unsigned long int rx_length_errors; | |
| 85 /*! \brief The number of HDLC aborts received. */ | |
| 86 unsigned long int rx_aborts; | |
| 87 }; | |
| 88 | |
| 89 /*! | |
| 90 HDLC transmit descriptor. This contains all the state information for an | |
| 91 HDLC transmitter. | |
| 92 */ | |
| 93 struct hdlc_tx_state_s | |
| 94 { | |
| 95 /*! 2 for CRC-16, 4 for CRC-32 */ | |
| 96 int crc_bytes; | |
| 97 /*! \brief The callback routine called to indicate transmit underflow. */ | |
| 98 hdlc_underflow_handler_t underflow_handler; | |
| 99 /*! \brief An opaque parameter passed to the callback routine. */ | |
| 100 void *user_data; | |
| 101 /*! \brief The minimum flag octets to insert between frames. */ | |
| 102 int inter_frame_flags; | |
| 103 /*! \brief TRUE if frame creation works in progressive mode. */ | |
| 104 int progressive; | |
| 105 /*! \brief Maximum permitted frame length. */ | |
| 106 size_t max_frame_len; | |
| 107 | |
| 108 /*! \brief The stuffed bit stream being created. */ | |
| 109 uint32_t octets_in_progress; | |
| 110 /*! \brief The number of bits currently in octets_in_progress. */ | |
| 111 int num_bits; | |
| 112 /*! \brief The currently rotated state of the flag octet. */ | |
| 113 int idle_octet; | |
| 114 /*! \brief The number of flag octets to send for a timed burst of flags. */ | |
| 115 int flag_octets; | |
| 116 /*! \brief The number of abort octets to send for a timed burst of aborts. */ | |
| 117 int abort_octets; | |
| 118 /*! \brief TRUE if the next underflow of timed flag octets should be reported */ | |
| 119 int report_flag_underflow; | |
| 120 | |
| 121 /*! \brief The current message being transmitted, with its CRC attached. */ | |
| 122 uint8_t buffer[HDLC_MAXFRAME_LEN + 4]; | |
| 123 /*! \brief The length of the message in the buffer. */ | |
| 124 size_t len; | |
| 125 /*! \brief The current send position within the buffer. */ | |
| 126 size_t pos; | |
| 127 /*! \brief The running CRC, as data fills the frame buffer. */ | |
| 128 uint32_t crc; | |
| 129 | |
| 130 /*! \brief The current byte being broken into bits for transmission. */ | |
| 131 int byte; | |
| 132 /*! \brief The number of bits remaining in byte. */ | |
| 133 int bits; | |
| 134 | |
| 135 /*! \brief TRUE if transmission should end on buffer underflow .*/ | |
| 136 int tx_end; | |
| 137 }; | |
| 138 | |
| 139 #endif | |
| 140 /*- End of file ------------------------------------------------------------*/ |
