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

cdr.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Call Detail Record API 
00005  * 
00006  * Copyright (C) 1999, Mark Spencer
00007  *
00008  * Mark Spencer <markster@linux-support.net>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License.
00012  *
00013  * Includes code and algorithms from the Zapata library.
00014  *
00015  */
00016 
00017 #ifndef _CDR_H
00018 #define _CDR_H
00019 
00020 #include <asterisk/channel.h>
00021 #include <sys/time.h>
00022 
00023 #define AST_CDR_NOANSWER         (1 << 0)
00024 #define AST_CDR_BUSY          (1 << 1)
00025 #define AST_CDR_ANSWERED         (1 << 2)
00026 
00027 //! AMA Flags
00028 #define AST_CDR_OMIT          (1)
00029 #define AST_CDR_BILLING          (2)
00030 #define AST_CDR_DOCUMENTATION    (3)
00031 
00032 struct ast_channel;
00033 
00034 //! Responsible for call detail data
00035 struct ast_cdr {
00036    /*! Caller*ID with text */
00037    char clid[AST_MAX_EXTENSION];    
00038    /*! Caller*ID number */
00039    char src[AST_MAX_EXTENSION];     
00040    /*! Destination extension */
00041    char dst[AST_MAX_EXTENSION];     
00042    /*! Destination context */
00043    char dcontext[AST_MAX_EXTENSION];   
00044    
00045    char channel[AST_MAX_EXTENSION];
00046    /*! Destination channel if appropriate */
00047    char dstchannel[AST_MAX_EXTENSION]; 
00048    /*! Last application if appropriate */
00049    char lastapp[AST_MAX_EXTENSION]; 
00050    /*! Last application data */
00051    char lastdata[AST_MAX_EXTENSION];   
00052    
00053    struct timeval start;
00054    
00055    struct timeval answer;
00056    
00057    struct timeval end;
00058    /*! Total time in system, in seconds */
00059    int duration;           
00060    /*! Total time call is up, in seconds */
00061    int billsec;            
00062    /*! What happened to the call */
00063    int disposition;        
00064    /*! What flags to use */
00065    int amaflags;           
00066    /*! What account number to use */
00067    char accountcode[20];         
00068    /*! Whether or not the record has been posted */
00069    int posted;          
00070         /* Unique Channel Identifier */
00071         char uniqueid[32];
00072 };
00073 
00074 typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
00075 
00076 //! Allocate a record
00077 /*! 
00078  * Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
00079  */
00080 extern struct ast_cdr *ast_cdr_alloc(void);
00081 
00082 //! Free a record
00083 /* \param cdr ast_cdr structure to free
00084  * Returns nothing important
00085  */
00086 extern void ast_cdr_free(struct ast_cdr *cdr);
00087 
00088 //! Initialize based on a channel
00089 /*! 
00090  * \param cdr Call Detail Record to use for channel
00091  * \param chan Channel to bind CDR with
00092  * Initializes a CDR and associates it with a particular channel
00093  * Return is negligible.  (returns 0 by default)
00094  */
00095 extern int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
00096 
00097 //! Initialize based on a channel
00098 /*! 
00099  * \param cdr Call Detail Record to use for channel
00100  * \param chan Channel to bind CDR with
00101  * Initializes a CDR and associates it with a particular channel
00102  * Return is negligible.  (returns 0 by default)
00103  */
00104 extern int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
00105 
00106 //! Register a CDR handling engine
00107 /*!
00108  * \param name name associated with the particular CDR handler
00109  * \param desc description of the CDR handler
00110  * \param be function pointer to a CDR handler
00111  * Used to register a Call Detail Record handler.
00112  * Returns -1 on error, 0 on success.
00113  */
00114 extern int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
00115 
00116 //! Unregister a CDR handling engine
00117 /*!
00118  * \param name name of CDR handler to unregister
00119  * Unregisters a CDR by it's name
00120  */
00121 extern void ast_cdr_unregister(char *name);
00122 
00123 //! Start a call
00124 /*!
00125  * \param cdr the cdr you wish to associate with the call
00126  * Starts all CDR stuff necessary for monitoring a call
00127  * Returns nothing important
00128  */
00129 extern void ast_cdr_start(struct ast_cdr *cdr);
00130 
00131 //! Answer a call
00132 /*!
00133  * \param cdr the cdr you wish to associate with the call
00134  * Starts all CDR stuff necessary for doing CDR when answering a call
00135  */
00136 extern void ast_cdr_answer(struct ast_cdr *cdr);
00137 
00138 //! Busy a call
00139 /*!
00140  * \param cdr the cdr you wish to associate with the call
00141  * Returns nothing important
00142  */
00143 extern void ast_cdr_busy(struct ast_cdr *cdr);
00144 
00145 //! End a call
00146 /*!
00147  * \param cdr the cdr you have associated the call with
00148  * Registers the end of call time in the cdr structure.
00149  * Returns nothing important
00150  */
00151 extern void ast_cdr_end(struct ast_cdr *cdr);
00152 
00153 //! Post the detail record
00154 /*! 
00155  * \param cdr Which cdr to post
00156  * Actually outputs the CDR record to the CDR plugins installed
00157  * Returns nothing
00158  */
00159 extern void ast_cdr_post(struct ast_cdr *cdr);
00160 
00161 //! Set the destination channel, if there was one
00162 /*!
00163  * \param cdr Which cdr it's applied to
00164  * Sets the destination channel the CDR is applied to
00165  * Returns nothing
00166  */
00167 extern void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chan);
00168 
00169 //! Set the last executed application
00170 /*!
00171  * \param cdr which cdr to act upon
00172  * \param app the name of the app you wish to change it to
00173  * \param data the data you want in the data field of app you set it to
00174  * Changes the value of the last executed app
00175  * Returns nothing
00176  */
00177 extern void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
00178 
00179 //! Convert a string to a detail record AMA flag
00180 /*!
00181  * \param flag string form of flag
00182  * Converts the string form of the flag to the binary form.
00183  * Returns the binary form of the flag
00184  */
00185 extern int ast_cdr_amaflags2int(char *flag);
00186 
00187 //! Disposition to a string
00188 /*!
00189  * \param flag input binary form
00190  * Converts the binary form of a disposition to string form.
00191  * Returns a pointer to the string form
00192  */
00193 extern char *ast_cdr_disp2str(int disposition);
00194 
00195 //! Reset the detail record, optionally posting it first
00196 /*!
00197  * \param cdr which cdr to act upon
00198  * \param post whether or not to post the cdr first before resetting it
00199  */
00200 extern void ast_cdr_reset(struct ast_cdr *cdr, int post);
00201 
00202 //! Flags to a string
00203 /*!
00204  * \param flags binary flag
00205  * Converts binary flags to string flags
00206  * Returns string with flag name
00207  */
00208 extern char *ast_cdr_flags2str(int flags);
00209 
00210 extern int ast_cdr_setaccount(struct ast_channel *chan, char *account);
00211 /* Update CDR on a channel */
00212 extern int ast_cdr_update(struct ast_channel *chan);
00213 
00214 
00215 extern int ast_default_amaflags;
00216 
00217 extern char ast_default_accountcode[20];
00218 
00219 #endif /* _CDR_H */

Generated on Fri Oct 31 07:05:05 2003 for Asterisk by doxygen 1.3.4