00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#ifndef _ASTERISK_VMODEM_H
00015
#define _ASTERISK_VMODEM_H
00016
00017
#include <asterisk/frame.h>
00018
#include <asterisk/channel.h>
00019
#include <asterisk/channel_pvt.h>
00020
00021 #define CHAR_DLE 0x10
00022 #define CHAR_ETX 0x03
00023 #define CHAR_DC4 0x14
00024
00025 #define MODEM_DEV_TELCO 0
00026 #define MODEM_DEV_TELCO_SPK 4
00027 #define MODEM_DEV_SPKRPHONE 6
00028 #define MODEM_DEV_HANDSET 9
00029
00030 #define MODEM_DTMF_NONE (1 << 0)
00031 #define MODEM_DTMF_AST (1 << 1)
00032 #define MODEM_DTMF_I4L (1 << 2)
00033
00034
00035 #define MODEM_MAX_LEN 30
00036 #define MODEM_MAX_BUF MODEM_MAX_LEN * 16
00037
00038 #define AST_MAX_INIT_STR 256
00039
00040
struct ast_modem_pvt;
00041
00042 struct ast_modem_driver {
00043 char *
name;
00044 char **
idents;
00045 int formats;
00046 int fullduplex;
00047 void (*incusecnt)(
void);
00048 void (*decusecnt)(
void);
00049
char * (*identify)(
struct ast_modem_pvt *);
00050 int (*init)(
struct ast_modem_pvt *);
00051 int (*setdev)(
struct ast_modem_pvt *,
int dev);
00052
struct ast_frame * (*read)(
struct ast_modem_pvt *);
00053 int (*write)(
struct ast_modem_pvt *,
struct ast_frame *fr);
00054 int (*dial)(
struct ast_modem_pvt *,
char *);
00055 int (*answer)(
struct ast_modem_pvt *);
00056 int (*hangup)(
struct ast_modem_pvt *);
00057 int (*startrec)(
struct ast_modem_pvt *);
00058 int (*stoprec)(
struct ast_modem_pvt *);
00059 int (*startpb)(
struct ast_modem_pvt *);
00060 int (*stoppb)(
struct ast_modem_pvt *);
00061 int (*setsilence)(
struct ast_modem_pvt *,
int onoff);
00062 int (*dialdigit)(
struct ast_modem_pvt *,
char digit);
00063 struct ast_modem_driver *
next;
00064 };
00065
00066 #define MODEM_MODE_IMMEDIATE 0
00067 #define MODEM_MODE_WAIT_RING 1
00068 #define MODEM_MODE_WAIT_ANSWER 2
00069
00070
00071 struct ast_modem_pvt {
00072
00073 int fd;
00074
00075 FILE *
f;
00076
00077 struct ast_channel *
owner;
00078
00079 char dev[256];
00080
00081 struct ast_frame fr;
00082
00083 char offset[
AST_FRIENDLY_OFFSET];
00084
00085 char obuf[
MODEM_MAX_BUF];
00086
00087 int tail;
00088
00089 char dialtype;
00090
00091 char dialtimeout;
00092
00093 int obuflen;
00094
00095 int mode;
00096
00097 int ministate;
00098
00099 int stripmsd;
00100
00101 int escape;
00102
00103 int gotclid;
00104
00105 int ringt;
00106
00107 time_t
lastring;
00108
00109 char dtmfrx;
00110
00111 char context[
AST_MAX_EXTENSION];
00112
00113 char msn[
AST_MAX_EXTENSION];
00114
00115 char incomingmsn[
AST_MAX_EXTENSION];
00116
00117 char outgoingmsn[
AST_MAX_EXTENSION];
00118
00119 unsigned int group;
00120
00121 char cid[
AST_MAX_EXTENSION];
00122
00123 int dtmfmode;
00124
00125 int dtmfmodegen;
00126
00127 struct ast_dsp *
dsp;
00128
00129 char dnid[
AST_MAX_EXTENSION];
00130
00131 char initstr[
AST_MAX_INIT_STR];
00132
00133 char language[
MAX_LANGUAGE];
00134
00135 char response[256];
00136
00137 struct ast_modem_driver *
mc;
00138
00139 struct ast_modem_pvt *
next;
00140 };
00141
00142
00143
00144
00145
extern int ast_register_modem_driver(
struct ast_modem_driver *mc);
00146
00147
00148
00149
extern int ast_unregister_modem_driver(
struct ast_modem_driver *mc);
00150
00151
00152
00153
extern int ast_modem_send(
struct ast_modem_pvt *p,
char *cmd,
int len);
00154
00155
00156
00157
00158
extern int ast_modem_expect(
struct ast_modem_pvt *p,
char *result,
int timeout);
00159
00160
00161
00162
extern int ast_modem_read_response(
struct ast_modem_pvt *p,
int timeout);
00163
00164
00165
00166
extern struct ast_channel *
ast_modem_new(
struct ast_modem_pvt *i,
int state);
00167
00168
00169
00170
extern void ast_modem_trim(
char *s);
00171
#endif