Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

vmodem.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Voice Modem Definitions
00005  * 
00006  * Copyright (C) 1999, Mark Spencer
00007  *
00008  * Mark Spencer <markster@digium.com>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
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 /* Thirty millisecond sections */
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 //! Private data that needs to be filled by modem driver
00071 struct ast_modem_pvt {
00072    /*! Raw file descriptor for this device */
00073    int fd;                    
00074    /*! FILE * representation of device */
00075    FILE *f;                
00076    /*! Channel we belong to, possibly NULL */
00077    struct ast_channel *owner;    
00078    /* Device name */
00079    char dev[256];             
00080    /*! Frame */
00081    struct ast_frame fr;       
00082    
00083    char offset[AST_FRIENDLY_OFFSET];
00084    /*! Outgoing buffer */
00085    char obuf[MODEM_MAX_BUF];     
00086    
00087    int tail;
00088    /*! Pulse or tone dialling */
00089    char dialtype;             
00090    /*! Time to wait for dial timeout */
00091    char dialtimeout;          
00092    
00093    int obuflen;
00094    /*! Immediate, or wait for an answer */
00095    int mode;                  
00096    /*! State of modem in miniature */
00097    int ministate;             
00098    /*! Digits to strip on outgoing numbers */
00099    int stripmsd;              
00100    /*! Is the last thing we saw an escape */
00101    int escape;             
00102    /*! flag to say if has caller*id yet*/
00103    int gotclid;            
00104    /*! ringer timeout */
00105    int ringt;           
00106    /*! actual time of last ring */
00107    time_t lastring;        
00108    /*! dtmf receive state/data */
00109    char dtmfrx;            
00110    
00111    char context[AST_MAX_EXTENSION];
00112    /*! Multiple Subscriber Number */
00113    char msn[AST_MAX_EXTENSION];  
00114    /*! Multiple Subscriber Number we listen to (; separated list) */
00115    char incomingmsn[AST_MAX_EXTENSION];   
00116    /*! Multiple Subscriber Number we accept for outgoing calls (; separated list) */
00117    char outgoingmsn[AST_MAX_EXTENSION];   
00118    /*! Group(s) we belong to if available */
00119    unsigned int group;
00120    /*! Caller ID if available */
00121    char cid[AST_MAX_EXTENSION];  
00122    /*! DTMF-detection mode (i4l/asterisk) */
00123    int dtmfmode;
00124    /*! DTMF-generation mode (i4l (outband) / asterisk (inband) */
00125    int dtmfmodegen;
00126    /*! DSP for DTMF detection */
00127    struct ast_dsp *dsp;
00128    /*! Dialed Number if available */
00129    char dnid[AST_MAX_EXTENSION]; 
00130    /*! Modem initialization String */
00131    char initstr[AST_MAX_INIT_STR];  
00132    /*! default language */
00133    char language[MAX_LANGUAGE];  
00134    /*! Static response buffer */
00135    char response[256];           
00136    /*! Modem Capability */
00137    struct ast_modem_driver *mc;  
00138    /*! Next channel in list */
00139    struct ast_modem_pvt *next;         
00140 };
00141 
00142 
00143 //! Register a modem driver
00144 /*! Register a driver */
00145 extern int ast_register_modem_driver(struct ast_modem_driver *mc);
00146 
00147 //! Unregisters a modem driver
00148 /*! Unregister a driver */
00149 extern int ast_unregister_modem_driver(struct ast_modem_driver *mc);
00150 
00151 //! Sends command
00152 /*! Send the command cmd (length len, or 0 if pure ascii) on modem */
00153 extern int ast_modem_send(struct ast_modem_pvt *p, char *cmd, int len);
00154 
00155 //! Waits for result
00156 /*! Wait for result to occur.  Return non-zero if times out or error, last
00157    response is stored in p->response  */
00158 extern int ast_modem_expect(struct ast_modem_pvt *p,  char *result, int timeout);
00159 
00160 //! Waits for result
00161 /*! Wait for result to occur.    response is stored in p->response  */
00162 extern int ast_modem_read_response(struct ast_modem_pvt *p,  int timeout);
00163 
00164 //! Used to start up the PBX on a RING
00165 /*! Used by modem drivers to start up the PBX on a RING */
00166 extern struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state);
00167 
00168 //! Trim string of trailing stuff
00169 /*! Trim off trailing mess */
00170 extern void ast_modem_trim(char *s);
00171 #endif

Generated on Sat Nov 25 19:09:50 2006 for Asterisk by  doxygen 1.4.2