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