v42.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
00065
00066 typedef struct
00067 {
00068 int handle;
00069 hdlc_rx_state_t hdlc_rx;
00070 hdlc_tx_state_t hdlc_tx;
00071
00072 v42_frame_handler_t iframe_receive;
00073 void *iframe_receive_user_data;
00074
00075 v42_status_func_t status_callback;
00076 void *status_callback_user_data;
00077
00078 int state;
00079 int tx_waiting;
00080 int debug;
00081
00082 int we_are_originator;
00083
00084 int peer_is_originator;
00085
00086 int next_tx_frame;
00087
00088 int last_frame_peer_acknowledged;
00089
00090 int next_expected_frame;
00091
00092 int last_frame_we_acknowledged;
00093
00094 int solicit_f_bit;
00095
00096 int retransmissions;
00097
00098 int busy;
00099
00100
00101 int t401_timer;
00102
00103 int t402_timer;
00104
00105 int t403_timer;
00106
00107 int n401;
00108
00109 int window_size_k;
00110
00111 lapm_frame_queue_t *txqueue;
00112 lapm_frame_queue_t *tx_next;
00113 lapm_frame_queue_t *tx_last;
00114 queue_state_t *tx_queue;
00115
00116 span_sched_state_t sched;
00117
00118 logging_state_t logging;
00119 } lapm_state_t;
00120
00121
00122
00123
00124 typedef struct
00125 {
00126
00127 int caller;
00128
00129
00130 int detect;
00131
00132
00133 int rx_negotiation_step;
00134 int rxbits;
00135 int rxstream;
00136 int rxoks;
00137 int odp_seen;
00138 int txbits;
00139 int txstream;
00140 int txadps;
00141
00142 lapm_state_t lapm;
00143
00144
00145 int t400_timer;
00146
00147 logging_state_t logging;
00148 } v42_state_t;
00149
00150
00151 #define LAPM_DEBUG_LAPM_RAW (1 << 0)
00152
00153 #define LAPM_DEBUG_LAPM_DUMP (1 << 1)
00154
00155 #define LAPM_DEBUG_LAPM_STATE (1 << 2)
00156
00157 #if defined(__cplusplus)
00158 extern "C"
00159 {
00160 #endif
00161
00162 const char *lapm_status_to_str(int status);
00163
00164
00165
00166
00167
00168
00169
00170 void lapm_dump(lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx);
00171
00172
00173
00174 void lapm_receive(void *user_data, const uint8_t *buf, int len, int ok);
00175
00176
00177
00178 int lapm_tx(lapm_state_t *s, const void *buf, int len);
00179
00180
00181
00182 int lapm_tx_iframe(lapm_state_t *s, const void *buf, int len, int cr);
00183
00184
00185
00186 int lapm_break(lapm_state_t *s, int enable);
00187
00188
00189
00190 int lapm_release(lapm_state_t *s);
00191
00192
00193
00194 int lapm_loopback(lapm_state_t *s, int enable);
00195
00196
00197
00198 void v42_set_status_callback(v42_state_t *s, v42_status_func_t callback, void *user_data);
00199
00200
00201
00202 void v42_rx_bit(void *user_data, int bit);
00203
00204
00205
00206 int v42_tx_bit(void *user_data);
00207
00208
00209
00210
00211
00212
00213
00214
00215 v42_state_t *v42_init(v42_state_t *s, int caller, int detect, v42_frame_handler_t frame_handler, void *user_data);
00216
00217
00218
00219
00220 void v42_restart(v42_state_t *s);
00221
00222
00223
00224
00225 int v42_release(v42_state_t *s);
00226
00227 #if defined(__cplusplus)
00228 }
00229 #endif
00230
00231 #endif
00232