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
00031 #define MODEM_MAX_LEN 30
00032 #define MODEM_MAX_BUF MODEM_MAX_LEN * 16
00033
00034 #define AST_MAX_INIT_STR 256
00035
00036
struct ast_modem_pvt;
00037
00038 struct ast_modem_driver {
00039 char *
name;
00040 char **
idents;
00041 int formats;
00042 int fullduplex;
00043 void (*incusecnt)(
void);
00044 void (*decusecnt)(
void);
00045
char * (*identify)(
struct ast_modem_pvt *);
00046 int (*init)(
struct ast_modem_pvt *);
00047 int (*setdev)(
struct ast_modem_pvt *,
int dev);
00048
struct ast_frame * (*read)(
struct ast_modem_pvt *);
00049 int (*write)(
struct ast_modem_pvt *,
struct ast_frame *fr);
00050 int (*dial)(
struct ast_modem_pvt *,
char *);
00051 int (*answer)(
struct ast_modem_pvt *);
00052 int (*hangup)(
struct ast_modem_pvt *);
00053 int (*startrec)(
struct ast_modem_pvt *);
00054 int (*stoprec)(
struct ast_modem_pvt *);
00055 int (*startpb)(
struct ast_modem_pvt *);
00056 int (*stoppb)(
struct ast_modem_pvt *);
00057 int (*setsilence)(
struct ast_modem_pvt *,
int onoff);
00058 int (*dialdigit)(
struct ast_modem_pvt *,
char digit);
00059 struct ast_modem_driver *
next;
00060 };
00061
00062 #define MODEM_MODE_IMMEDIATE 0
00063 #define MODEM_MODE_WAIT_RING 1
00064 #define MODEM_MODE_WAIT_ANSWER 2
00065
00066
00067 struct ast_modem_pvt {
00068
00069 int fd;
00070
00071 FILE *
f;
00072
00073 struct ast_channel *
owner;
00074
00075 char dev[256];
00076
00077 struct ast_frame fr;
00078
00079 char offset[
AST_FRIENDLY_OFFSET];
00080
00081 char obuf[
MODEM_MAX_BUF];
00082
00083 int tail;
00084
00085 char dialtype;
00086
00087 char dialtimeout;
00088
00089 int obuflen;
00090
00091 int mode;
00092
00093 int ministate;
00094
00095 int stripmsd;
00096
00097 int escape;
00098
00099 int gotclid;
00100
00101 int ringt;
00102
00103 time_t
lastring;
00104
00105 char dtmfrx;
00106
00107 char context[
AST_MAX_EXTENSION];
00108
00109 char msn[
AST_MAX_EXTENSION];
00110
00111 char incomingmsn[
AST_MAX_EXTENSION];
00112
00113 unsigned int group;
00114
00115 char cid[
AST_MAX_EXTENSION];
00116
00117 char dnid[
AST_MAX_EXTENSION];
00118
00119 char initstr[
AST_MAX_INIT_STR];
00120
00121 char language[
MAX_LANGUAGE];
00122
00123 char response[256];
00124
00125 struct ast_modem_driver *
mc;
00126
00127 struct ast_modem_pvt *
next;
00128 };
00129
00130
00131
00132
00133
extern int ast_register_modem_driver(
struct ast_modem_driver *mc);
00134
00135
00136
00137
extern int ast_unregister_modem_driver(
struct ast_modem_driver *mc);
00138
00139
00140
00141
extern int ast_modem_send(
struct ast_modem_pvt *p,
char *cmd,
int len);
00142
00143
00144
00145
00146
extern int ast_modem_expect(
struct ast_modem_pvt *p,
char *result,
int timeout);
00147
00148
00149
00150
extern int ast_modem_read_response(
struct ast_modem_pvt *p,
int timeout);
00151
00152
00153
00154
extern struct ast_channel *
ast_modem_new(
struct ast_modem_pvt *i,
int state);
00155
00156
00157
00158
extern void ast_modem_trim(
char *s);
00159
#endif