00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <string.h>
00027 #include <stdlib.h>
00028
00029 #include "asterisk.h"
00030
00031 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00032
00033 #include "asterisk/logger.h"
00034 #include "asterisk/channel.h"
00035 #include "asterisk/pbx.h"
00036 #include "asterisk/module.h"
00037 #include "asterisk/options.h"
00038 #include "asterisk/transcap.h"
00039
00040
00041 static char *app = "SetTransferCapability";
00042
00043 static char *synopsis = "Set ISDN Transfer Capability";
00044
00045 STANDARD_LOCAL_USER;
00046
00047 LOCAL_USER_DECL;
00048
00049 static struct { int val; char *name; } transcaps[] = {
00050 { AST_TRANS_CAP_SPEECH, "SPEECH" },
00051 { AST_TRANS_CAP_DIGITAL, "DIGITAL" },
00052 { AST_TRANS_CAP_RESTRICTED_DIGITAL, "RESTRICTED_DIGITAL" },
00053 { AST_TRANS_CAP_3_1K_AUDIO, "3K1AUDIO" },
00054 { AST_TRANS_CAP_DIGITAL_W_TONES, "DIGITAL_W_TONES" },
00055 { AST_TRANS_CAP_VIDEO, "VIDEO" },
00056 };
00057
00058 static char *descrip =
00059 " SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
00060 "Capability of a call to a new value.\n"
00061 "Valid Transfer Capabilities are:\n"
00062 "\n"
00063 " SPEECH : 0x00 - Speech (default, voice calls)\n"
00064 " DIGITAL : 0x08 - Unrestricted digital information (data calls)\n"
00065 " RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
00066 " 3K1AUDIO : 0x10 - 3.1kHz Audio (fax calls)\n"
00067 " DIGITAL_W_TONES : 0x11 - Unrestricted digital information with tones/announcements\n"
00068 " VIDEO : 0x18 - Video:\n"
00069 "\n"
00070 ;
00071
00072 static int settransfercapability_exec(struct ast_channel *chan, void *data)
00073 {
00074 char *tmp = NULL;
00075 struct localuser *u;
00076 int x;
00077 char *opts;
00078 int transfercapability = -1;
00079
00080 LOCAL_USER_ADD(u);
00081
00082 if (data)
00083 tmp = ast_strdupa(data);
00084 else
00085 tmp = "";
00086
00087 opts = strchr(tmp, '|');
00088 if (opts)
00089 *opts = '\0';
00090
00091 for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
00092 if (!strcasecmp(transcaps[x].name, tmp)) {
00093 transfercapability = transcaps[x].val;
00094 break;
00095 }
00096 }
00097 if (transfercapability < 0) {
00098 ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
00099 LOCAL_USER_REMOVE(u);
00100 return 0;
00101 }
00102
00103 chan->transfercapability = (unsigned short)transfercapability;
00104
00105 if (option_verbose > 2)
00106 ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);
00107
00108 LOCAL_USER_REMOVE(u);
00109
00110 return 0;
00111 }
00112
00113
00114 int unload_module(void)
00115 {
00116 int res;
00117
00118 res = ast_unregister_application(app);
00119
00120 STANDARD_HANGUP_LOCALUSERS;
00121
00122 return res;
00123 }
00124
00125 int load_module(void)
00126 {
00127 return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
00128 }
00129
00130 char *description(void)
00131 {
00132 return synopsis;
00133 }
00134
00135 int usecount(void)
00136 {
00137 int res;
00138 STANDARD_USECOUNT(res);
00139 return res;
00140 }
00141
00142 char *key()
00143 {
00144 return ASTERISK_GPL_KEY;
00145 }