lapm.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 #if !defined(_SPANDSP_LAPM_H_)
00035 #define _SPANDSP_LAPM_H_
00036
00037 enum
00038 {
00039 LAPM_DETECT = 0,
00040 LAPM_ESTABLISH = 1,
00041 LAPM_DATA = 2,
00042 LAPM_RELEASE = 3,
00043 LAPM_SIGNAL = 4,
00044 LAPM_SETPARM = 5,
00045 LAPM_TEST = 6,
00046 LAPM_UNSUPPORTED = 7
00047 };
00048
00049 typedef void (*v42_status_func_t)(void *user_data, int status);
00050 typedef void (*v42_frame_handler_t)(void *user_data, const uint8_t *pkt, int len);
00051
00052 typedef struct lapm_frame_queue_s
00053 {
00054 struct lapm_frame_queue_s *next;
00055 int len;
00056 uint8_t frame[];
00057 } lapm_frame_queue_t;
00058
00059
00060
00061
00062 typedef struct
00063 {
00064 int handle;
00065 hdlc_rx_state_t hdlc_rx;
00066 hdlc_tx_state_t hdlc_tx;
00067
00068 v42_frame_handler_t iframe_receive;
00069 void *iframe_receive_user_data;
00070
00071 v42_status_func_t status_callback;
00072 void *status_callback_user_data;
00073
00074 int state;
00075 int tx_waiting;
00076 int debug;
00077
00078 int we_are_originator;
00079
00080 int peer_is_originator;
00081
00082 int next_tx_frame;
00083
00084 int last_frame_peer_acknowledged;
00085
00086 int next_expected_frame;
00087
00088 int last_frame_we_acknowledged;
00089
00090 int solicit_f_bit;
00091
00092 int retransmissions;
00093
00094 int busy;
00095
00096
00097 int t401_timer;
00098
00099 int t402_timer;
00100
00101 int t403_timer;
00102
00103 int n401;
00104
00105 int window_size_k;
00106
00107 lapm_frame_queue_t *txqueue;
00108 lapm_frame_queue_t *tx_next;
00109 lapm_frame_queue_t *tx_last;
00110 queue_t tx_queue;
00111
00112 span_sched_state_t sched;
00113
00114 logging_state_t logging;
00115 } lapm_state_t;
00116
00117
00118 #define LAPM_DEBUG_LAPM_RAW (1 << 0)
00119
00120 #define LAPM_DEBUG_LAPM_DUMP (1 << 1)
00121
00122 #define LAPM_DEBUG_LAPM_STATE (1 << 2)
00123
00124 #if defined(__cplusplus)
00125 extern "C"
00126 {
00127 #endif
00128
00129 const char *lapm_status_to_str(int status);
00130
00131
00132
00133
00134
00135
00136
00137 void lapm_dump(lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx);
00138
00139
00140
00141 void lapm_receive(void *user_data, int ok, const uint8_t *buf, int len);
00142
00143
00144
00145 int lapm_tx(lapm_state_t *s, const void *buf, int len);
00146
00147
00148
00149 int lapm_tx_iframe(lapm_state_t *s, const void *buf, int len, int cr);
00150
00151
00152
00153 int lapm_break(lapm_state_t *s, int enable);
00154
00155
00156
00157 int lapm_release(lapm_state_t *s);
00158
00159
00160
00161 int lapm_loopback(lapm_state_t *s, int enable);
00162
00163 #if defined(__cplusplus)
00164 }
00165 #endif
00166
00167 #endif
00168