app_settransfercapability.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2005, Frank Sautter, levigo holding gmbh, www.levigo.de
  5. *
  6. * Frank Sautter - asterisk+at+sautter+dot+com
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. *
  20. * \brief App to set the ISDN Transfer Capability
  21. *
  22. * \ingroup applications
  23. */
  24. #include <string.h>
  25. #include <stdlib.h>
  26. #include "asterisk.h"
  27. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  28. #include "asterisk/logger.h"
  29. #include "asterisk/channel.h"
  30. #include "asterisk/pbx.h"
  31. #include "asterisk/module.h"
  32. #include "asterisk/options.h"
  33. #include "asterisk/transcap.h"
  34. static char *app = "SetTransferCapability";
  35. static char *synopsis = "Set ISDN Transfer Capability";
  36. STANDARD_LOCAL_USER;
  37. LOCAL_USER_DECL;
  38. static struct { int val; char *name; } transcaps[] = {
  39. { AST_TRANS_CAP_SPEECH, "SPEECH" },
  40. { AST_TRANS_CAP_DIGITAL, "DIGITAL" },
  41. { AST_TRANS_CAP_RESTRICTED_DIGITAL, "RESTRICTED_DIGITAL" },
  42. { AST_TRANS_CAP_3_1K_AUDIO, "3K1AUDIO" },
  43. { AST_TRANS_CAP_DIGITAL_W_TONES, "DIGITAL_W_TONES" },
  44. { AST_TRANS_CAP_VIDEO, "VIDEO" },
  45. };
  46. static char *descrip =
  47. " SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
  48. "Capability of a call to a new value.\n"
  49. "Valid Transfer Capabilities are:\n"
  50. "\n"
  51. " SPEECH : 0x00 - Speech (default, voice calls)\n"
  52. " DIGITAL : 0x08 - Unrestricted digital information (data calls)\n"
  53. " RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
  54. " 3K1AUDIO : 0x10 - 3.1kHz Audio (fax calls)\n"
  55. " DIGITAL_W_TONES : 0x11 - Unrestricted digital information with tones/announcements\n"
  56. " VIDEO : 0x18 - Video:\n"
  57. "\n"
  58. ;
  59. static int settransfercapability_exec(struct ast_channel *chan, void *data)
  60. {
  61. char *tmp = NULL;
  62. struct localuser *u;
  63. int x;
  64. char *opts;
  65. int transfercapability = -1;
  66. LOCAL_USER_ADD(u);
  67. if (data)
  68. tmp = ast_strdupa(data);
  69. else
  70. tmp = "";
  71. opts = strchr(tmp, '|');
  72. if (opts)
  73. *opts = '\0';
  74. for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
  75. if (!strcasecmp(transcaps[x].name, tmp)) {
  76. transfercapability = transcaps[x].val;
  77. break;
  78. }
  79. }
  80. if (transfercapability < 0) {
  81. ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
  82. LOCAL_USER_REMOVE(u);
  83. return 0;
  84. }
  85. chan->transfercapability = (unsigned short)transfercapability;
  86. if (option_verbose > 2)
  87. ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);
  88. LOCAL_USER_REMOVE(u);
  89. return 0;
  90. }
  91. int unload_module(void)
  92. {
  93. int res;
  94. res = ast_unregister_application(app);
  95. STANDARD_HANGUP_LOCALUSERS;
  96. return res;
  97. }
  98. int load_module(void)
  99. {
  100. return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
  101. }
  102. char *description(void)
  103. {
  104. return synopsis;
  105. }
  106. int usecount(void)
  107. {
  108. int res;
  109. STANDARD_USECOUNT(res);
  110. return res;
  111. }
  112. char *key()
  113. {
  114. return ASTERISK_GPL_KEY;
  115. }