Thanks to Mihai Moldovan
master
MelwareDE 8 years ago
parent f143a92dd1
commit 955b02d460
  1. 602
      chan_capi.c
  2. 4
      chan_capi.h
  3. 46
      chan_capi_ami.c
  4. 6
      chan_capi_ami.h
  5. 65
      chan_capi_chat.c
  6. 16
      chan_capi_command.c
  7. 10
      chan_capi_fmt.h
  8. 7
      chan_capi_management_common.c
  9. 21
      chan_capi_qsig_ecma.c
  10. 20
      chan_capi_supplementary.c
  11. 68
      chan_capi_utils.c
  12. 6
      chan_capi_utils.h
  13. 19
      create_config.sh

File diff suppressed because it is too large Load Diff

@ -136,7 +136,11 @@ static inline unsigned int read_capi_dword(const void *m)
/*
* definitions for nice compatibility
*/
#ifdef CC_AST_HAS_VERSION_10_0
#define CC_CHANNEL_PVT(c) ast_channel_tech_pvt(c)
#else
#define CC_CHANNEL_PVT(c) (c)->tech_pvt
#endif /* CC_AST_HAS_VERSION_11_0 */
#define CC_BRIDGE_RETURN enum ast_bridge_result
#ifdef CC_AST_HAS_UNION_DATA_IN_FRAME

@ -94,35 +94,50 @@ static char mandescr_capicommand[] =
" *Channel: <channame>\n"
" *Capicommand: <capicommand>\n";
void pbx_capi_ami_register(void)
void pbx_capi_ami_register(struct ast_module *myself)
{
capiChatListRegistered = ast_manager_register2(CC_AMI_ACTION_NAME_CHATLIST,
EVENT_FLAG_REPORTING,
pbx_capi_ami_capichat_list,
#ifdef CC_AST_HAS_VERSION_11_0
myself,
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
"List participants in a conference",
mandescr_capichatlist) == 0;
capiChatMuteRegistered = ast_manager_register2(CC_AMI_ACTION_NAME_CHATMUTE,
EVENT_FLAG_CALL,
pbx_capi_ami_capichat_mute,
#ifdef CC_AST_HAS_VERSION_11_0
myself,
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
"Mute a conference user",
mandescr_capichatmute) == 0;
capiChatUnmuteRegistered = ast_manager_register2(CC_AMI_ACTION_NAME_CHATUNMUTE,
EVENT_FLAG_CALL,
pbx_capi_ami_capichat_unmute,
#ifdef CC_AST_HAS_VERSION_11_0
myself,
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
"Unmute a conference user",
mandescr_capichatunmute) == 0;
capiChatRemoveRegistered = ast_manager_register2(CC_AMI_ACTION_NAME_CHATREMOVE,
EVENT_FLAG_CALL,
pbx_capi_ami_capichat_remove,
#ifdef CC_AST_HAS_VERSION_11_0
myself,
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
"Remove a conference user",
mandescr_capichatremove) == 0;
capiCommandRegistered = ast_manager_register2(CC_AMI_ACTION_NAME_CAPICOMMAND,
EVENT_FLAG_CALL,
pbx_capi_ami_capicommand,
#ifdef CC_AST_HAS_VERSION_11_0
myself,
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
"Exec capicommand",
mandescr_capicommand) == 0;
}
@ -204,6 +219,11 @@ static int pbx_capi_ami_capichat_list(struct mansession *s, const struct message
}
total++;
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
astman_append(s,
"Event: "CC_AMI_ACTION_NAME_CHATLIST"\r\n"
"%s"
@ -232,7 +252,7 @@ static int pbx_capi_ami_capichat_list(struct mansession *s, const struct message
total,
(cidVisual != 0) ? cidVisual : "?",
(callerNameVisual != 0) ? callerNameVisual : "?",
c->name,
cur_name,
(isMemberOperator != 0) ? "Yes" : "No",
(isCapiChatMemberListener != 0) ? "Listen only" : "Talk and listen" /* "Talk only" */,
(isCapiChatMostRecentMember != 0) ? "Yes" : "No",
@ -379,7 +399,7 @@ static int pbx_capi_ami_capicommand(struct mansession *s, const struct message *
}
#else
void pbx_capi_ami_register(void)
void pbx_capi_ami_register(struct ast_module *myself)
{
}
void pbx_capi_ami_unregister(void)
@ -389,6 +409,14 @@ void pbx_capi_ami_unregister(void)
void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room)
{
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
const char *cur_uniqid = ast_channel_uniqueid(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
const char *cur_uniqid = c->uniqueid;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#ifdef CC_AST_HAS_VERSION_1_8
ast_manager_event(c,
#else
@ -401,7 +429,7 @@ void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * r
"Conferencenum: %u\r\n"
"CallerIDnum: %s\r\n"
"CallerIDname: %s\r\n",
c->name, c->uniqueid,
cur_name, cur_uniqid,
pbx_capi_chat_get_room_name(room),
pbx_capi_chat_get_room_number(room),
pbx_capi_get_cid (c, "<unknown>"),
@ -412,6 +440,14 @@ void pbx_capi_chat_leave_event(struct ast_channel* c,
const struct capichat_s *room,
long duration)
{
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
const char *cur_uniqid = ast_channel_uniqueid(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
const char *cur_uniqid = c->uniqueid;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#ifdef CC_AST_HAS_VERSION_1_8
ast_manager_event(c,
#else
@ -425,7 +461,7 @@ void pbx_capi_chat_leave_event(struct ast_channel* c,
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"Duration: %ld\r\n",
c->name, c->uniqueid,
cur_name, cur_uniqid,
pbx_capi_chat_get_room_name(room),
pbx_capi_chat_get_room_number(room),
pbx_capi_get_cid (c, "<unknown>"),

@ -26,13 +26,13 @@
#ifndef __CC_AMI_INTERFACE_H__
#define __CC_AMI_INTERFACE_H__
void pbx_capi_ami_register(void);
void pbx_capi_ami_register(struct ast_module *myself);
void pbx_capi_ami_unregister(void);
struct capichat_s;
void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room);
void pbx_capi_chat_leave_event(struct ast_channel* c,
const struct capichat_s *room,
long duration);
const struct capichat_s *room,
long duration);
void pbx_capi_chat_conference_end_event(const char* roomName);

@ -205,7 +205,7 @@ static struct capichat_s* update_capi_mixer_part(
if (overall_found == 1) {
/* only one left, enable DATA_B3 too */
if (ii_last->line_plci == 0) {
if (ii_last->channeltype != CAPI_CHANNELTYPE_NULL) {
if (ii_last->channeltype != CAPI_CHANNELTYPE_NULL) {
p_list[5] |= 0x0c;
} else {
p_list[5] |= 0x30;
@ -618,8 +618,13 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i,
if ((ready_fd < 0) && ms) {
if (errno == 0 || errno == EINTR)
continue;
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(chan);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = chan->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
cc_log(LOG_WARNING, "%s: Wait failed (%s).\n",
chan->name, strerror(errno));
cur_name, strerror(errno));
break;
}
}
@ -712,7 +717,17 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
options++;
}
if (c->tech == &capi_tech) {
#ifdef CC_AST_HAS_VERSION_11_0
const struct ast_channel_tech *cur_tech = ast_channel_tech(c);
const char *cur_name = ast_channel_name(c);
const enum ast_channel_state cur_state = ast_channel_state(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const struct ast_channel_tech *cur_tech = c->tech;
const char *cur_name = c->name;
const enum ast_channel_state cur_state = c->_state;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (cur_tech == &capi_tech) {
i = CC_CHANNEL_PVT(c);
} else {
/* virtual CAPI channel */
@ -740,9 +755,9 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
cc_verbose(3, 1, VERBOSE_PREFIX_3 CC_MESSAGE_NAME " chat: %s: roomname=%s group=%u group users=%u"
"options=%s hangup_timeout=%d controller=%s (0x%llx)\n",
c->name, roomname, selectedGroup, bridgeUsers, options, hangup_timeout, controller, contr);
cur_name, roomname, selectedGroup, bridgeUsers, options, hangup_timeout, controller, contr);
if (c->tech != &capi_tech) {
if (cur_tech != &capi_tech) {
if (i == NULL) {
i = capi_mknullif(c, contr);
}
@ -753,7 +768,7 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
}
if (c->_state != AST_STATE_UP) {
if (cur_state != AST_STATE_UP) {
ast_answer(c);
}
@ -888,9 +903,19 @@ int pbx_capi_chat_play(struct ast_channel *c, char *param)
contr = (unsigned long long)(tmpcntr >> 1);
}
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
const struct ast_channel_tech *cur_tech = ast_channel_tech(c);
const enum ast_channel_state cur_state = ast_channel_state(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
const struct ast_channel_tech *cur_tech = c->tech;
const enum ast_channel_state cur_state = c->_state;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
cc_verbose(3, 1, VERBOSE_PREFIX_3 CC_MESSAGE_NAME " chat_play: %s: roomname=%s "
"message=%s controller=%s (0x%llx)\n",
c->name, roomname, file_name, controller, contr);
cur_name, roomname, file_name, controller, contr);
i = capi_mknullif(c, contr);
if (i == NULL) {
@ -899,7 +924,7 @@ int pbx_capi_chat_play(struct ast_channel *c, char *param)
return (-1);
}
if (c->_state != AST_STATE_UP) {
if (cur_state != AST_STATE_UP) {
ast_answer(c);
}
@ -917,7 +942,7 @@ int pbx_capi_chat_play(struct ast_channel *c, char *param)
}
/* main loop */
chat_handle_events(c, i, room, flags, (c->tech == &capi_tech) ? (CC_CHANNEL_PVT(c)) : 0, f, 0, NULL);
chat_handle_events(c, i, room, flags, (cur_tech == &capi_tech) ? (CC_CHANNEL_PVT(c)) : 0, f, 0, NULL);
del_chat_member(room, 1);
@ -1068,7 +1093,13 @@ int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
}
}
if (c->tech != &capi_tech) {
#ifdef CC_AST_HAS_VERSION_11_0
const struct ast_channel_tech *cur_tech = ast_channel_tech(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const struct ast_channel_tech *cur_tech = c->tech;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (cur_tech != &capi_tech) {
i = capi_mkresourceif(c, contr, 0, codecs, all);
if (i != NULL) {
char buffer[24];
@ -1140,8 +1171,13 @@ int pbxcli_capi_chatinfo(int fd, int argc, char *argv[])
room->number, room->name, room->i->vname,
"?", "?");
} else {
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
ast_cli(fd, "%5d %-17s%-40s\"%s\" <%s>\n",
room->number, room->name, c->name,
room->number, room->name, cur_name,
pbx_capi_get_callername (c, ""), pbx_capi_get_cid (c, ""));
}
room = room->next;
@ -1247,7 +1283,12 @@ int pbx_capi_chat_remove_user(const char* roomName, const char* memberName)
c = room->i->used;
}
if (c != 0) {
if (strcmp (memberName, c->name) == 0) {
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (strcmp (memberName, cur_name) == 0) {
room->info |= PBX_CHAT_MEMBER_INFO_REMOVE;
ret = 0;
}

@ -79,7 +79,13 @@ int pbx_capi_voicecommand(struct ast_channel *c, char *param)
const char* key[2];
size_t length;
if (c->tech == &capi_tech) {
#ifdef CC_AST_HAS_VERSION_11_0
const struct ast_channel_tech *cur_tech = ast_channel_tech(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const struct ast_channel_tech *cur_tech = c->tech;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (cur_tech == &capi_tech) {
i = CC_CHANNEL_PVT(c);
} else {
i = pbx_check_resource_plci(c);
@ -200,7 +206,13 @@ int pbx_capi_voicecommand_transparency(struct ast_channel *c, char *param)
{
struct capi_pvt *i;
if (c->tech == &capi_tech) {
#ifdef CC_AST_HAS_VERSION_11_0
const struct ast_channel_tech *cur_tech = ast_channel_tech(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const struct ast_channel_tech *cur_tech = c->tech;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (cur_tech == &capi_tech) {
i = CC_CHANNEL_PVT(c);
} else {
i = pbx_check_resource_plci(c);

@ -122,17 +122,17 @@ static inline int cc_set_best_codec(struct ast_channel *a)
ast_format_clear(&bestCodec);
if (ast_best_codec(a->nativeformats, &bestCodec) == NULL) {
if (ast_best_codec(ast_channel_nativeformats(a), &bestCodec) == NULL) {
/*
Fallback to aLaw
*/
ast_format_set(&bestCodec, CC_FORMAT_ALAW, 0);
}
ast_format_copy(&a->rawreadformat, &bestCodec);
ast_format_copy(&a->readformat, &bestCodec);
ast_format_copy(&a->rawwriteformat, &bestCodec);
ast_format_copy(&a->writeformat, &bestCodec);
ast_format_copy(ast_channel_readformat(a), &bestCodec);
ast_format_copy(ast_channel_readformat(a), &bestCodec);
ast_format_copy(ast_channel_rawwriteformat(a), &bestCodec);
ast_format_copy(ast_channel_writeformat(a), &bestCodec);
return (int)ast_format_to_old_bitfield(&bestCodec);
}

@ -86,7 +86,12 @@ int pbx_capi_management_capicommand(const char *requiredChannelName, const char
retry_search = 1;
break;
}
if ((!ast_strlen_zero(c->name) && (strcmp(requiredChannelName, c->name) == 0)) ||
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if ((!ast_strlen_zero(cur_name) && (strcmp(requiredChannelName, cur_name) == 0)) ||
strcmp(requiredChannelName, i->vname) == 0) {
struct ast_channel* usedChannel = c;
int ret;

@ -83,9 +83,15 @@ void cc_qsig_op_ecma_isdn_namepres(struct cc_qsig_invokedata *invoke, struct cap
ast_set_callerid(i->owner, NULL, callername, NULL);
Use code from ast_set_callerid but do not update CDR
*/
#ifdef CC_AST_HAS_VERSION_11_0
ast_channel_caller(i->owner)->id.name.valid = 1;
ast_free(ast_channel_caller(i->owner)->id.name.str);
ast_channel_caller(i->owner)->id.name.str = ast_strdup(callername);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
i->owner->caller.id.name.valid = 1;
ast_free(i->owner->caller.id.name.str);
i->owner->caller.id.name.str = ast_strdup(callername);
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#else
i->owner->cid.cid_name = ast_strdup(callername); /* Save name to callerid */
#endif
@ -421,17 +427,22 @@ void cc_qsig_encode_ecma_calltransfer(unsigned char * buf, unsigned int *idx, st
if (ii) {
/* send callers name to user B */
#ifdef CC_AST_HAS_VERSION_1_8
if (ii->owner->caller.id.name.valid ) {
#ifdef CC_AST_HAS_VERSION_11_0
if (ast_channel_caller(ii->owner)->id.name.valid ) {
name = ast_strdupa(S_COR(ast_channel_caller(ii->owner)->id.name.valid, ast_channel_caller(ii->owner)->id.name.str, ""));
namelength = strlen(name);
}
#elif defined(CC_AST_HAS_VERSION_1_8)
if (ii->owner->caller.id.name.valid ) {
name = ast_strdupa(S_COR(ii->owner->caller.id.name.valid, ii->owner->caller.id.name.str, ""));
namelength = strlen(name);
}
#else
if (ii->owner->cid.cid_name) {
#else /* !(defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8)) */
if (ii->owner->cid.cid_name) {
name = ast_strdupa(ii->owner->cid.cid_name);
namelength = strlen(name);
}
#endif
#endif /* defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8) */
}
} else { /* have to build first facility - send destination number back to inbound channel */
struct capi_pvt *ii = capi_find_interface_by_plci(i->qsig_data.partner_plci);

@ -400,9 +400,21 @@ static void ccbsnr_remote_user_free(_cmsg *CMSG, char type, unsigned int PLCI, _
c->type = "CCBS/CCNR";
#endif
#ifdef CC_AST_HAS_VERSION_11_0
ast_channel_priority_set(c, ccbsnr->priority);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
c->priority = ccbsnr->priority;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#ifdef CC_AST_HAS_VERSION_1_8
#ifdef CC_AST_HAS_VERSION_11_0
/*! \todo verify if necessary/complete */
ast_channel_connected(c)->id.number.valid = 1;
ast_free (ast_channel_connected(c)->id.number.str);
ast_channel_connected(c)->id.number.str = ast_strdup(handlename);
ast_free (ast_channel_dialed(c)->number.str);
ast_channel_dialed(c)->number.str = ast_strdup (ccbsnr->exten);
#elif defined(CC_AST_HAS_VERSION_1_8)
/*! \todo verify if necessary/complete */
c->connected.id.number.valid = 1;
ast_free (c->connected.id.number.str);
@ -410,7 +422,7 @@ static void ccbsnr_remote_user_free(_cmsg *CMSG, char type, unsigned int PLCI, _
ast_free (c->dialed.number.str);
c->dialed.number.str = ast_strdup (ccbsnr->exten);
#else
#else /* !(defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8)) */
if (c->cid.cid_num) {
ast_free(c->cid.cid_num);
}
@ -419,7 +431,7 @@ static void ccbsnr_remote_user_free(_cmsg *CMSG, char type, unsigned int PLCI, _
ast_free(c->cid.cid_dnid);
}
c->cid.cid_dnid = ast_strdup(ccbsnr->exten);
#endif
#endif /* defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8) */
#ifndef CC_AST_HAS_EXT2_CHAN_ALLOC
cc_copy_string(c->context, ccbsnr->context, sizeof(c->context));
@ -624,7 +636,7 @@ int handle_facility_indication_supplementary(
cc_verbose(4, 0, VERBOSE_PREFIX_4 "CAPI%u Rx MWI %s for '%s@CAPI_Remote %s %s time '%s' %d messages ref %d service %d\n",
PLCI & 0xff,
messageStatus == 0 ? "add" : "del", mailboxName, controllingUserNumberName, controllingUserProvidedNumberName,
mwiTimeName, numberOfMessages, messageReference, basicService);
mwiTimeName, numberOfMessages, messageReference, basicService);
if (messageStatus == 0 && mailboxName[0] != 0) {
#if defined(CC_AST_HAS_EVENT_MWI)
struct ast_event *event;

@ -172,6 +172,7 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control
int channelcount = 0xffff;
int maxcontr = (CAPI_MAX_CONTROLLERS > (sizeof(controllermask)*8)) ?
(sizeof(controllermask)*8) : CAPI_MAX_CONTROLLERS;
char *cur_chan_name;
cc_verbose(3, 1, VERBOSE_PREFIX_4 "capi_mknullif: find controller for mask 0x%lx\n",
controllermask);
@ -193,8 +194,17 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control
cc_mutex_init(&tmp->lock);
ast_cond_init(&tmp->event_trigger, NULL);
snprintf(tmp->name, sizeof(tmp->name) - 1, "%s-NULLPLCI", (c != 0) ? c->name : "BRIDGE");
if (c) {
#ifdef CC_AST_HAS_VERSION_11_0
cur_chan_name = (char *)ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
cur_chan_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
}
else
cur_chan_name = "BRIDGE";
snprintf(tmp->name, sizeof(tmp->name) - 1, "%s-NULLPLCI", cur_chan_name);
snprintf(tmp->vname, sizeof(tmp->vname) - 1, "%s", tmp->name);
tmp->channeltype = CAPI_CHANNELTYPE_NULL;
@ -303,7 +313,11 @@ struct capi_pvt *capi_mkresourceif(
} else {
controller = data_plci_ifc->controller;
codecs = (all != 0) ? pbx_capi_get_controller_codecs (controller) : codecs;
#ifdef CC_AST_HAS_VERSION_11_0
fmt = pbx_capi_get_controller_codecs (controller) & codecs & cc_get_formats_as_bits(ast_channel_nativeformats(c));
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
fmt = pbx_capi_get_controller_codecs (controller) & codecs & cc_get_formats_as_bits(c->nativeformats);
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (fmt != 0)
fmt = cc_get_best_codec_as_bits(fmt);
}
@ -316,8 +330,14 @@ struct capi_pvt *capi_mkresourceif(
cc_mutex_init(&data_ifc->lock);
ast_cond_init(&data_ifc->event_trigger, NULL);
snprintf(data_ifc->name, sizeof(data_ifc->name) - 1, "%s-%sPLCI", c->name, (data_plci_ifc == 0) ? "DATA" : "LINE");
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
snprintf(data_ifc->name, sizeof(data_ifc->name) - 1, "%s-%sPLCI", cur_name, (data_plci_ifc == 0) ? "DATA" : "LINE");
snprintf(data_ifc->vname, sizeof(data_ifc->vname) - 1, "%s", data_ifc->name);
data_ifc->channeltype = CAPI_CHANNELTYPE_NULL;
@ -1312,6 +1332,7 @@ struct ast_channel *cc_get_peer_link_id(const char *p)
{
int id = -1;
struct ast_channel *chan = NULL;
char *cur_name = "unlinked";
if (p) {
id = (int)strtol(p, NULL, 0);
@ -1322,8 +1343,15 @@ struct ast_channel *cc_get_peer_link_id(const char *p)
chan = peerlinkchannel[id].channel;
peerlinkchannel[id].channel = NULL;
}
if (chan) {
#ifdef CC_AST_HAS_VERSION_11_0
cur_name = (char *)ast_channel_name(chan);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
cur_name = (char *)chan->name;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
}
cc_verbose(3, 1, VERBOSE_PREFIX_4 CC_MESSAGE_NAME
": peerlink %d allocated, peer is %s\n", id, (chan)?chan->name:"unlinked");
": peerlink %d allocated, peer is %s\n", id, cur_name);
cc_mutex_unlock(&peerlink_lock);
return chan;
}
@ -1605,15 +1633,17 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
ast_channel_lock(chan) to be held while
while accessing returned pointer
*/
const char* pbx_capi_get_cid(const struct ast_channel* c, const char* notAvailableVisual)
const char* pbx_capi_get_cid(struct ast_channel* c, const char* notAvailableVisual)
{
const char* cid;
#ifdef CC_AST_HAS_VERSION_1_8
#ifdef CC_AST_HAS_VERSION_11_0
cid = S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, notAvailableVisual);
#elif defined(CC_AST_HAS_VERSION_1_8)
cid = S_COR(c->caller.id.number.valid, c->caller.id.number.str, notAvailableVisual);
#else
#else /* !(defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8)) */
cid = c->cid.cid_num;
#endif
#endif /* defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8) */
return (cid);
}
@ -1622,15 +1652,17 @@ const char* pbx_capi_get_cid(const struct ast_channel* c, const char* notAvailab
ast_channel_lock(chan) to be held while
while accessing returned pointer
*/
const char* pbx_capi_get_callername(const struct ast_channel* c, const char* notAvailableVisual)
const char* pbx_capi_get_callername(struct ast_channel* c, const char* notAvailableVisual)
{
const char* name;
#ifdef CC_AST_HAS_VERSION_1_8
#ifdef CC_AST_HAS_VERSION_11_0
name = S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, notAvailableVisual);
#elif defined(CC_AST_HAS_VERSION_1_8)
name = S_COR(c->caller.id.name.valid, c->caller.id.name.str, notAvailableVisual);
#else
#else /* !(defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8)) */
name = (c->cid.cid_name) ? c->cid.cid_name : notAvailableVisual;
#endif
#endif /* defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8) */
return (name);
}
@ -1639,15 +1671,17 @@ const char* pbx_capi_get_callername(const struct ast_channel* c, const char* not
ast_channel_lock(chan) to be held while
while accessing returned pointer
*/
const char* pbx_capi_get_connectedname(const struct ast_channel* c, const char* notAvailableVisual)
const char* pbx_capi_get_connectedname(struct ast_channel* c, const char* notAvailableVisual)
{
const char* name;
#ifdef CC_AST_HAS_VERSION_1_8
#ifdef CC_AST_HAS_VERSION_11_0
name = S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, notAvailableVisual);
#elif defined(CC_AST_HAS_VERSION_1_8)
name = S_COR(c->connected.id.name.valid, c->connected.id.name.str, notAvailableVisual);
#else
#else /* !(defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8)) */
name = (c->cid.cid_name) ? c->cid.cid_name : notAvailableVisual;
#endif
#endif /* defined(CC_AST_HAS_VERSION_11_0) || defined(CC_AST_HAS_VERSION_1_8) */
return (name);
}

@ -59,9 +59,9 @@ extern int capi_create_reader_writer_pipe(struct capi_pvt *i);
extern struct ast_frame *capi_read_pipeframe(struct capi_pvt *i);
extern int capi_write_frame(struct capi_pvt *i, struct ast_frame *f);
extern int capi_verify_resource_plci(const struct capi_pvt *i);
extern const char* pbx_capi_get_cid (const struct ast_channel* c, const char *notAvailableVisual);
extern const char* pbx_capi_get_callername (const struct ast_channel* c, const char *notAvailableVisual);
const char* pbx_capi_get_connectedname (const struct ast_channel* c, const char *notAvailableVisual);
extern const char* pbx_capi_get_cid (struct ast_channel* c, const char *notAvailableVisual);
extern const char* pbx_capi_get_callername (struct ast_channel* c, const char *notAvailableVisual);
const char* pbx_capi_get_connectedname (struct ast_channel* c, const char *notAvailableVisual);
char* pbx_capi_strsep_controller_list (char** param);
#define capi_number(data, strip) \

@ -20,6 +20,7 @@ if [ $# -lt 1 ]; then
fi
INCLUDEDIR="$1/asterisk"
AST_BINARY="$1/../sbin/asterisk"
if [ ! -d "$INCLUDEDIR" ]; then
echo >&2 "Include directory '$INCLUDEDIR' does not exist"
@ -31,11 +32,17 @@ AVERSIONNUM=`sed -n '/.*ASTERISK_VERSION_NUM /s/^.*ASTERISK_VERSION_NUM //p' $IN
AVERSION=`sed -n '/.*ASTERISK_VERSION /s/^.*ASTERISK_VERSION //p' $INCLUDEDIR/version.h`
AVERSION=`echo $AVERSION | sed 's/\"//g'`
if [ "$AVERSION" = "" ]; then
grep "Do not include" $INCLUDEDIR/version.h >/dev/null 2>&1
# Asterisk 11 and up removed version information in its version.h header file.
# ast_get_version() and ast_get_version_num() are not usable by external
# modules like chan_capi, as there's no library implementing these functions,
# so linking will always fail.
# Workaround that by trying to run asterisk -V and parse the output.
AVERSION=$("$AST_BINARY" -V)
if [ $? -eq 0 ]; then
AVERSION="11.0"
VER="11_0"
AVERSIONNUM=110
AVERSION="$(echo "$AVERSION" | sed -e 's/Asterisk //g')"
AVERSIONNUM="$(echo "$AVERSION" |sed -e 's/\.//g')"
# Set VER later automatically based on $AVERSIONNUM.
else
AVERSION="trunk"
VER="1_6"
@ -57,7 +64,7 @@ echo "#define CHAN_CAPI_CONFIG_H" >>$CONFIGFILE
echo >>$CONFIGFILE
case "$AVERSIONNUM" in
110*)
11*)
echo "#define CC_AST_HAS_VERSION_1_6" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_1_8" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_10_0" >>$CONFIGFILE
@ -66,7 +73,7 @@ case "$AVERSIONNUM" in
echo " * found Asterisk version 11"
VER=11_0
;;
100*)
100*)
echo "#define CC_AST_HAS_VERSION_1_6" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_1_8" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_10_0" >>$CONFIGFILE

Loading…
Cancel
Save