From bde5812980194086fbe233f60b371b4855de2c7c Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sat, 19 Jan 2008 22:24:44 +0000 Subject: [PATCH] - Adapt to new asterisk 1.6 API - fix compilation for asterisk 1.2 --- CHANGES | 1 + chan_capi.c | 240 +++++++++++++++++++++++++++++++------ chan_capi.h | 5 +- chan_capi_chat.c | 25 ++++ chan_capi_chat.h | 4 + chan_capi_qsig_asn197ade.c | 2 - chan_capi_qsig_asn197no.c | 2 - chan_capi_qsig_core.c | 3 - chan_capi_qsig_ecma.c | 3 - create_config.sh | 154 +++++++++++++----------- 10 files changed, 323 insertions(+), 116 deletions(-) diff --git a/CHANGES b/CHANGES index 3e25175..bdec24b 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ HEAD - fixed numberingplan for 'connected number'. - added devicestate option. - capi-chat can play music-on-hold for first caller. +- adapt to new asterisk 1.6 API chan_capi-1.0.2 ------------------ diff --git a/chan_capi.c b/chan_capi.c index 7f9b986..96ce7bb 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -5425,18 +5425,77 @@ static char *show_isdnstate(unsigned int isdnstate, char *str) return str; } +/* + * usages + */ +static char info_usage[] = +"Usage: capi info\n" +" Show info about B channels on controllers.\n"; + +static char show_channels_usage[] = +"Usage: capi show channels\n" +" Show info about B channels.\n"; + +static char debug_usage[] = +"Usage: capi debug\n" +" Enables dumping of CAPI packets for debugging purposes\n"; + +static char no_debug_usage[] = +"Usage: capi no debug\n" +" Disables dumping of CAPI packets for debugging purposes\n"; + +static char qsig_debug_usage[] = +"Usage: capi qsig debug\n" +" Enables dumping of CAPI QSIG facilities for debugging purposes\n"; + +static char qsig_no_debug_usage[] = +"Usage: capi qsig no debug\n" +" Disables dumping of CAPI QSIG facilities for debugging purposes\n"; + +#ifndef CC_AST_HAS_VERSION_1_6 +static +#endif +char chatinfo_usage[] = +"Usage: capi chatinfo\n" +" Show info about chat status.\n"; + +#define CC_CLI_TEXT_INFO "Show CAPI info" +#define CC_CLI_TEXT_SHOW_CHANNELS "Show B-channel info" +#define CC_CLI_TEXT_DEBUG "Enable CAPI debugging" +#define CC_CLI_TEXT_NO_DEBUG "Disable CAPI debugging" +#define CC_CLI_TEXT_QSIG_DEBUG "Enable CAPI QSIG debugging" +#define CC_CLI_TEXT_QSIG_NO_DEBUG "Disable CAPI QSIG debugging" +#define CC_CLI_TEXT_CHATINFO "Show CAPI chat info" + /* * do command capi show channels */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_show_channels(int fd, int argc, char *argv[]) +#endif { struct capi_pvt *i; char iochar; char i_state[80]; char b3q[32]; +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi show channels"; + e->usage = show_channels_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 3) return RESULT_SHOWUSAGE; +#endif ast_cli(fd, "CAPI B-channel information:\n"); ast_cli(fd, "Line-Name NTmode state i/o bproto isdnstate ton number\n"); @@ -5479,18 +5538,39 @@ static int pbxcli_capi_show_channels(int fd, int argc, char *argv[]) cc_mutex_unlock(&iflock); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } /* * do command capi info */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_info(int fd, int argc, char *argv[]) +#endif { int i = 0; +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi info"; + e->usage = info_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 2) return RESULT_SHOWUSAGE; +#endif ast_cli(fd, "%s www.chan-capi.org\n", tdesc); @@ -5501,113 +5581,182 @@ static int pbxcli_capi_info(int fd, int argc, char *argv[]) capi_controllers[i]->nfreebchannels); } } +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } /* * enable debugging */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_do_debug(int fd, int argc, char *argv[]) +#endif { +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi debug"; + e->usage = debug_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 2) return RESULT_SHOWUSAGE; +#endif capidebug = 1; ast_cli(fd, "CAPI Debugging Enabled\n"); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } /* * disable debugging */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_no_debug(int fd, int argc, char *argv[]) +#endif { +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi no debug"; + e->usage = no_debug_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 3) return RESULT_SHOWUSAGE; +#endif capidebug = 0; ast_cli(fd, "CAPI Debugging Disabled\n"); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } /* * enable QSIG debugging */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_qsig_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_qsig_do_debug(int fd, int argc, char *argv[]) +#endif { +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi qsig debug"; + e->usage = qsig_debug_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 3) return RESULT_SHOWUSAGE; +#endif capiqsigdebug = 1; ast_cli(fd, "CAPI QSIG Debugging Enabled\n"); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } /* * disable QSIG debugging */ +#ifdef CC_AST_HAS_VERSION_1_6 +static char *pbxcli_capi_qsig_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else static int pbxcli_capi_qsig_no_debug(int fd, int argc, char *argv[]) +#endif { +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi qsig no debug"; + e->usage = qsig_no_debug_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 4) return RESULT_SHOWUSAGE; +#endif capiqsigdebug = 0; ast_cli(fd, "CAPI QSIG Debugging Disabled\n"); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } -/* - * usages - */ -static char info_usage[] = -"Usage: capi info\n" -" Show info about B channels on controllers.\n"; - -static char show_channels_usage[] = -"Usage: capi show channels\n" -" Show info about B channels.\n"; - -static char debug_usage[] = -"Usage: capi debug\n" -" Enables dumping of CAPI packets for debugging purposes\n"; - -static char no_debug_usage[] = -"Usage: capi no debug\n" -" Disables dumping of CAPI packets for debugging purposes\n"; - -static char qsig_debug_usage[] = -"Usage: capi qsig debug\n" -" Enables dumping of CAPI QSIG facilities for debugging purposes\n"; - -static char qsig_no_debug_usage[] = -"Usage: capi qsig no debug\n" -" Disables dumping of CAPI QSIG facilities for debugging purposes\n"; - -static char chatinfo_usage[] = -"Usage: capi chatinfo\n" -" Show info about chat status.\n"; - /* * define commands */ +#ifdef CC_AST_HAS_VERSION_1_6 +static struct ast_cli_entry cc_cli_cmd[] = { + AST_CLI_DEFINE(pbxcli_capi_info, CC_CLI_TEXT_INFO), + AST_CLI_DEFINE(pbxcli_capi_show_channels, CC_CLI_TEXT_SHOW_CHANNELS), + AST_CLI_DEFINE(pbxcli_capi_do_debug, CC_CLI_TEXT_DEBUG), + AST_CLI_DEFINE(pbxcli_capi_no_debug, CC_CLI_TEXT_NO_DEBUG), + AST_CLI_DEFINE(pbxcli_capi_qsig_do_debug, CC_CLI_TEXT_QSIG_DEBUG), + AST_CLI_DEFINE(pbxcli_capi_qsig_no_debug, CC_CLI_TEXT_QSIG_NO_DEBUG), + AST_CLI_DEFINE(pbxcli_capi_chatinfo, CC_CLI_TEXT_CHATINFO), +}; +#else static struct ast_cli_entry cli_info = - { { "capi", "info", NULL }, pbxcli_capi_info, "Show CAPI info", info_usage }; + { { "capi", "info", NULL }, pbxcli_capi_info, CC_CLI_TEXT_INFO, info_usage }; static struct ast_cli_entry cli_show_channels = - { { "capi", "show", "channels", NULL }, pbxcli_capi_show_channels, "Show B-channel info", show_channels_usage }; + { { "capi", "show", "channels", NULL }, pbxcli_capi_show_channels, CC_CLI_TEXT_SHOW_CHANNELS, show_channels_usage }; static struct ast_cli_entry cli_debug = - { { "capi", "debug", NULL }, pbxcli_capi_do_debug, "Enable CAPI debugging", debug_usage }; + { { "capi", "debug", NULL }, pbxcli_capi_do_debug, CC_CLI_TEXT_DEBUG, debug_usage }; static struct ast_cli_entry cli_no_debug = - { { "capi", "no", "debug", NULL }, pbxcli_capi_no_debug, "Disable CAPI debugging", no_debug_usage }; + { { "capi", "no", "debug", NULL }, pbxcli_capi_no_debug, CC_CLI_TEXT_NO_DEBUG, no_debug_usage }; static struct ast_cli_entry cli_qsig_debug = - { { "capi", "qsig", "debug", NULL }, pbxcli_capi_qsig_do_debug, "Enable CAPI QSIG debugging", qsig_debug_usage }; + { { "capi", "qsig", "debug", NULL }, pbxcli_capi_qsig_do_debug, CC_CLI_TEXT_QSIG_DEBUG, qsig_debug_usage }; static struct ast_cli_entry cli_qsig_no_debug = - { { "capi", "qsig", "no", "debug", NULL }, pbxcli_capi_qsig_no_debug, "Disable CAPI QSIG debugging", qsig_no_debug_usage }; + { { "capi", "qsig", "no", "debug", NULL }, pbxcli_capi_qsig_no_debug, CC_CLI_TEXT_QSIG_NO_DEBUG, qsig_no_debug_usage }; static struct ast_cli_entry cli_chatinfo = - { { "capi", "chatinfo", NULL }, pbxcli_capi_chatinfo, "Show CAPI chat info", chatinfo_usage }; + { { "capi", "chatinfo", NULL }, pbxcli_capi_chatinfo, CC_CLI_TEXT_CHATINFO, chatinfo_usage }; +#endif const struct ast_channel_tech capi_tech = { .type = channeltype, @@ -6130,6 +6279,9 @@ int unload_module(void) ast_unregister_application(commandapp); +#ifdef CC_AST_HAS_VERSION_1_6 + ast_cli_unregister_multiple(cc_cli_cmd, sizeof(cc_cli_cmd)/ sizeof(struct ast_cli_entry)); +#else ast_cli_unregister(&cli_info); ast_cli_unregister(&cli_show_channels); ast_cli_unregister(&cli_debug); @@ -6137,6 +6289,7 @@ int unload_module(void) ast_cli_unregister(&cli_qsig_debug); ast_cli_unregister(&cli_qsig_no_debug); ast_cli_unregister(&cli_chatinfo); +#endif #ifdef CC_AST_HAS_VERSION_1_4 ast_module_user_hangup_all(); @@ -6198,8 +6351,15 @@ int load_module(void) struct ast_config *cfg; char *config = "capi.conf"; int res = 0; +#ifdef CC_AST_HAS_VERSION_1_6 + struct ast_flags config_flags = { 0 }; +#endif +#ifdef CC_AST_HAS_VERSION_1_6 + cfg = ast_config_load(config, config_flags); +#else cfg = ast_config_load(config); +#endif /* We *must* have a config file otherwise stop immediately, well no */ if (!cfg) { @@ -6239,6 +6399,9 @@ int load_module(void) return -1; } +#ifdef CC_AST_HAS_VERSION_1_6 + ast_cli_register_multiple(cc_cli_cmd, sizeof(cc_cli_cmd)/ sizeof(struct ast_cli_entry)); +#else ast_cli_register(&cli_info); ast_cli_register(&cli_show_channels); ast_cli_register(&cli_debug); @@ -6246,6 +6409,7 @@ int load_module(void) ast_cli_register(&cli_qsig_debug); ast_cli_register(&cli_qsig_no_debug); ast_cli_register(&cli_chatinfo); +#endif ast_register_application(commandapp, pbx_capicommand_exec, commandsynopsis, commandtdesc); diff --git a/chan_capi.h b/chan_capi.h index c877a19..d8bb214 100644 --- a/chan_capi.h +++ b/chan_capi.h @@ -40,8 +40,8 @@ #include #ifdef CC_AST_HAS_VERSION_1_4 #include "asterisk/abstract_jb.h" -#include "asterisk/musiconhold.h" #endif +#include "asterisk/musiconhold.h" #ifndef _PBX_CAPI_H #define _PBX_CAPI_H @@ -603,5 +603,8 @@ extern void capi_wait_for_answered(struct capi_pvt *i); extern int capi_wait_for_b3_up(struct capi_pvt *i); extern void capi_activehangup(struct capi_pvt *i, int state); extern void capi_gains(struct cc_capi_gains *g, float rxgain, float txgain); +#ifdef CC_AST_HAS_VERSION_1_6 +extern char chatinfo_usage[]; +#endif #endif diff --git a/chan_capi_chat.c b/chan_capi_chat.c index 21e2e5d..a50feb9 100644 --- a/chan_capi_chat.c +++ b/chan_capi_chat.c @@ -233,7 +233,11 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i, } if ((flags & CHAT_FLAG_MOH) && (room->active < 2)) { +#if defined(CC_AST_HAS_VERSION_1_6) || defined(CC_AST_HAS_VERSION_1_4) ast_moh_start(chan, NULL, NULL); +#else + ast_moh_start(chan, NULL); +#endif moh_active = 1; } @@ -385,13 +389,30 @@ out: /* * do command capi chatinfo */ +#ifdef CC_AST_HAS_VERSION_1_6 +char *pbxcli_capi_chatinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +#else int pbxcli_capi_chatinfo(int fd, int argc, char *argv[]) +#endif { struct capichat_s *room = NULL; struct ast_channel *c; +#ifdef CC_AST_HAS_VERSION_1_6 + int fd = a->fd; + + if (cmd == CLI_INIT) { + e->command = "capi chatinfo"; + e->usage = chatinfo_usage; + return NULL; + } else if (cmd == CLI_GENERATE) + return NULL; + if (a->argc != e->args) + return CLI_SHOWUSAGE; +#else if (argc != 2) return RESULT_SHOWUSAGE; +#endif if (chat_list == NULL) { ast_cli(fd, "There are no members in CAPI CHAT.\n"); @@ -421,6 +442,10 @@ int pbxcli_capi_chatinfo(int fd, int argc, char *argv[]) } cc_mutex_unlock(&chat_lock); +#ifdef CC_AST_HAS_VERSION_1_6 + return CLI_SUCCESS; +#else return RESULT_SUCCESS; +#endif } diff --git a/chan_capi_chat.h b/chan_capi_chat.h index 4638f2f..388a399 100644 --- a/chan_capi_chat.h +++ b/chan_capi_chat.h @@ -18,6 +18,10 @@ * prototypes */ extern int pbx_capi_chat(struct ast_channel *c, char *param); +#ifdef CC_AST_HAS_VERSION_1_6 +extern char *pbxcli_capi_chatinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +#else extern int pbxcli_capi_chatinfo(int fd, int argc, char *argv[]); +#endif #endif diff --git a/chan_capi_qsig_asn197ade.c b/chan_capi_qsig_asn197ade.c index a4c6202..6c58ffa 100644 --- a/chan_capi_qsig_asn197ade.c +++ b/chan_capi_qsig_asn197ade.c @@ -21,8 +21,6 @@ #include #include -#include -#include #include "chan_capi20.h" #include "chan_capi.h" #include "chan_capi_utils.h" diff --git a/chan_capi_qsig_asn197no.c b/chan_capi_qsig_asn197no.c index 2dc324a..b2a114f 100644 --- a/chan_capi_qsig_asn197no.c +++ b/chan_capi_qsig_asn197no.c @@ -21,8 +21,6 @@ #include #include -#include -#include #include "chan_capi20.h" #include "chan_capi.h" #include "chan_capi_utils.h" diff --git a/chan_capi_qsig_core.c b/chan_capi_qsig_core.c index ac5a94c..2303a73 100644 --- a/chan_capi_qsig_core.c +++ b/chan_capi_qsig_core.c @@ -17,9 +17,6 @@ #include #include -#include -#include -#include #include "chan_capi20.h" #include "chan_capi.h" #include "chan_capi_utils.h" diff --git a/chan_capi_qsig_ecma.c b/chan_capi_qsig_ecma.c index 54d8060..40bab25 100644 --- a/chan_capi_qsig_ecma.c +++ b/chan_capi_qsig_ecma.c @@ -17,9 +17,6 @@ #include #include -#include -#include -#include #include "chan_capi20.h" #include "chan_capi.h" #include "chan_capi_utils.h" diff --git a/create_config.sh b/create_config.sh index e3092cf..50d0021 100755 --- a/create_config.sh +++ b/create_config.sh @@ -28,7 +28,7 @@ fi echo -n "Checking Asterisk version... " if grep -q "ast_get_version_num" $INCLUDEDIR/version.h; then -AVERSION=TRUNK +AVERSION="not found, assuming 1.6.x" VER=1_6 else AVERSION=`sed -n '/.*ASTERISK_VERSION /s/^.*ASTERISK_VERSION //p' $INCLUDEDIR/version.h` @@ -55,87 +55,107 @@ else VER=1_4 else if [ "$VER" = "1_6" ]; then - echo "#define CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE echo "#define CC_AST_HAS_VERSION_1_6" >>$CONFIGFILE - echo " * assuming Asterisk trunk version (1.6)" + echo " * assuming Asterisk version 1.6" else echo "#undef CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE fi fi fi -if [ "$VER" = "1_2" ]; then - echo "Using Asterisk 1.2 API" -else - if [ "$VER" = "1_6" ]; then - echo "Using Asterisk 1.6 API" +check_two_and_four() +{ + if grep -q "AST_STRING_FIELD(name)" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE + echo " * found stringfield in ast_channel" else - echo "Using Asterisk 1.4 API" + echo "#undef CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE + echo " * no stringfield in ast_channel" fi -fi - -if grep -q "AST_STRING_FIELD(name)" $INCLUDEDIR/channel.h; then - echo "#define CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE - echo " * found stringfield in ast_channel" -else - echo "#undef CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE - echo " * no stringfield in ast_channel" -fi - -if grep -q "const indicate.*datalen" $INCLUDEDIR/channel.h; then - echo "#define CC_AST_HAS_INDICATE_DATA" >>$CONFIGFILE - echo " * found 'indicate' with data" -else - echo "#undef CC_AST_HAS_INDICATE_DATA" >>$CONFIGFILE - echo " * no data on 'indicate'" -fi - -if grep -q "ast_channel_alloc.*name_fmt" $INCLUDEDIR/channel.h; then - echo "#define CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE - echo " * found extended ast_channel_alloc" -else - echo "#undef CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE - echo " * no extended ast_channel_alloc" -fi - -if grep -q "ast_channel_alloc.*amaflag" $INCLUDEDIR/channel.h; then - echo "#define CC_AST_HAS_EXT2_CHAN_ALLOC" >>$CONFIGFILE - echo " * found second extended ast_channel_alloc" -else - echo "#undef CC_AST_HAS_EXT2_CHAN_ALLOC" >>$CONFIGFILE - echo " * no second extended ast_channel_alloc" -fi - - -if grep -q "send_digit_end.*duration" $INCLUDEDIR/channel.h; then - echo "#define CC_AST_HAS_SEND_DIGIT_END_DURATION" >>$CONFIGFILE - echo " * found send_digit_end with duration" -else - echo "#undef CC_AST_HAS_SEND_DIGIT_END_DURATION" >>$CONFIGFILE - echo " * no duration with send_digit_end" -fi - -if [ "$VER" = "1_2" ]; then -if grep -q "AST_JB" $INCLUDEDIR/channel.h; then - if [ ! -f "$INCLUDEDIR/../../lib/asterisk/modules/chan_sip.so" ]; then - echo "/* AST_JB */" >>$CONFIGFILE - echo "#define CC_AST_HAS_JB_PATCH" >>$CONFIGFILE - echo " * assuming generic jitter-buffer patch" + + if grep -q "const indicate.*datalen" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_INDICATE_DATA" >>$CONFIGFILE + echo " * found 'indicate' with data" else - if grep -q "ast_jb" "$INCLUDEDIR/../../lib/asterisk/modules/chan_sip.so"; then + echo "#undef CC_AST_HAS_INDICATE_DATA" >>$CONFIGFILE + echo " * no data on 'indicate'" + fi + + if grep -q "ast_channel_alloc.*name_fmt" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE + echo " * found extended ast_channel_alloc" + else + echo "#undef CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE + echo " * no extended ast_channel_alloc" + fi + + if grep -q "ast_channel_alloc.*amaflag" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_EXT2_CHAN_ALLOC" >>$CONFIGFILE + echo " * found second extended ast_channel_alloc" + else + echo "#undef CC_AST_HAS_EXT2_CHAN_ALLOC" >>$CONFIGFILE + echo " * no second extended ast_channel_alloc" + fi + + if grep -q "send_digit_end.*duration" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_SEND_DIGIT_END_DURATION" >>$CONFIGFILE + echo " * found send_digit_end with duration" + else + echo "#undef CC_AST_HAS_SEND_DIGIT_END_DURATION" >>$CONFIGFILE + echo " * no duration with send_digit_end" + fi + + if [ "$VER" = "1_2" ]; then + if grep -q "AST_JB" $INCLUDEDIR/channel.h; then + if [ ! -f "$INCLUDEDIR/../../lib/asterisk/modules/chan_sip.so" ]; then echo "/* AST_JB */" >>$CONFIGFILE echo "#define CC_AST_HAS_JB_PATCH" >>$CONFIGFILE - echo " * found generic jitter-buffer patch" + echo " * assuming generic jitter-buffer patch" else - echo "#undef CC_AST_HAS_JB_PATCH" >>$CONFIGFILE - echo " * found DISABLED generic jitter-buffer patch" + if grep -q "ast_jb" "$INCLUDEDIR/../../lib/asterisk/modules/chan_sip.so"; then + echo "/* AST_JB */" >>$CONFIGFILE + echo "#define CC_AST_HAS_JB_PATCH" >>$CONFIGFILE + echo " * found generic jitter-buffer patch" + else + echo "#undef CC_AST_HAS_JB_PATCH" >>$CONFIGFILE + echo " * found DISABLED generic jitter-buffer patch" + fi fi + else + echo "#undef CC_AST_HAS_JB_PATCH" >>$CONFIGFILE + echo " * without generic jitter-buffer patch" fi -else - echo "#undef CC_AST_HAS_JB_PATCH" >>$CONFIGFILE - echo " * without generic jitter-buffer patch" -fi -fi + fi +} + +check_version_onesix() +{ + echo "#define CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE + echo "#define CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE + echo "#define CC_AST_HAS_INDICATE_DATA" >>$CONFIGFILE + echo "#define CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE + echo "#define CC_AST_HAS_EXT2_CHAN_ALLOC" >>$CONFIGFILE + echo "#define CC_AST_HAS_SEND_DIGIT_END_DURATION" >>$CONFIGFILE +} + +case $VER in + 1_2) + echo "Using Asterisk 1.2 API" + check_two_and_four + ;; + 1_4) + echo "Using Asterisk 1.4 API" + check_two_and_four + ;; + 1_6) + echo "Using Asterisk 1.6 API" + check_version_onesix + ;; + *) + echo >&2 "Asterisk version invalid." + exit 1 + ;; +esac echo "" >>$CONFIGFILE echo "#endif /* CHAN_CAPI_CONFIG_H */" >>$CONFIGFILE