[asterisk-commits] nadi: branch crichter/0.4.0 r39805 - in
/team/crichter/0.4.0/channels: ./ misdn/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Aug 15 09:33:14 MST 2006
Author: nadi
Date: Tue Aug 15 11:33:13 2006
New Revision: 39805
URL: http://svn.digium.com/view/asterisk?rev=39805&view=rev
Log:
moved the asn1 and facility portions of code to mISDNuser, so removing the files here.
Removed:
team/crichter/0.4.0/channels/misdn/asn1.c
team/crichter/0.4.0/channels/misdn/asn1.h
team/crichter/0.4.0/channels/misdn/fac.c
team/crichter/0.4.0/channels/misdn/fac.h
Modified:
team/crichter/0.4.0/channels/Makefile
team/crichter/0.4.0/channels/chan_misdn.c
team/crichter/0.4.0/channels/misdn/Makefile
team/crichter/0.4.0/channels/misdn/isdn_lib.c
team/crichter/0.4.0/channels/misdn/isdn_lib.h
team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h
team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
Modified: team/crichter/0.4.0/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/Makefile?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/Makefile (original)
+++ team/crichter/0.4.0/channels/Makefile Tue Aug 15 11:33:13 2006
@@ -243,7 +243,7 @@
make -C misdn
chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
- $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN $(MISDNECLIB)
+ $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN -lsuppserv $(MISDNECLIB)
chan_misdn.o: chan_misdn.c
$(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.4.0\" -c $< -o $@
Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Tue Aug 15 11:33:13 2006
@@ -405,20 +405,15 @@
}
-static void print_facility( struct misdn_bchannel *bc)
-{
- switch (bc->fac_type) {
- case FACILITY_CALLDEFLECT:
- chan_misdn_log(0,bc->port," --> calldeflect: %s\n",
- bc->fac.calldeflect_nr);
- break;
- case FACILITY_CENTREX:
- chan_misdn_log(0,bc->port," --> centrex: %s\n",
- bc->fac.cnip);
+static void print_facility(struct FacReqParm *fac, struct misdn_bchannel *bc)
+{
+ switch (fac->Function) {
+ case FacReq_CD:
+ chan_misdn_log(0,bc->port," --> calldeflect to: %s, screened: %s\n", fac->u.CDeflection.DeflectedToNumber,
+ fac->u.CDeflection.PresentationAllowed ? "yes" : "no");
break;
default:
chan_misdn_log(0,bc->port," --> unknown\n");
-
}
}
@@ -1111,18 +1106,23 @@
channame = argv[3];
nr = argv[4];
-
+
ast_cli(fd, "Sending Calldeflection (%s) to %s\n",nr, channame);
{
struct chan_list *tmp=get_chan_by_ast_name(channame);
if (!tmp) {
- ast_cli(fd, "Sending CD with nr %s to %s failed Channel does not exist\n",nr, channame);
+ ast_cli(fd, "Sending CD with nr %s to %s failed: Channel does not exist.\n",nr, channame);
return 0;
} else {
-
- misdn_lib_send_facility(tmp->bc, FACILITY_CALLDEFLECT, nr);
+ if (strlen(nr) >= 15) {
+ ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n",nr, channame);
+ return 0;
+ }
+ tmp->bc->fac_out.Function = FacReq_CD;
+ strncpy((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber));
+ misdn_lib_send_event(tmp->bc, EVENT_FACILITY);
}
}
@@ -4463,30 +4463,34 @@
break;
case EVENT_FACILITY:
- print_facility(bc);
-
- switch (bc->fac_type) {
- case FACILITY_CALLDEFLECT:
+ print_facility(&(bc->fac_in), bc);
+
+ switch (bc->fac_in.Function) {
+ case FacReq_CD:
{
struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
- struct chan_list *ch;
-
- misdn_lib_send_event(bc, EVENT_DISCONNECT);
-
+ struct chan_list *ch_br;
+
if (bridged && MISDN_ASTERISK_TECH_PVT(bridged)) {
- ch=MISDN_ASTERISK_TECH_PVT(bridged);
+ ch_br=MISDN_ASTERISK_TECH_PVT(bridged);
/*ch->state=MISDN_FACILITY_DEFLECTED;*/
- if (ch->bc) {
- /* todo */
+ if (ch_br->bc) {
+ if (ast_exists_extension(bridged, ch->context, (char *)bc->fac_in.u.CDeflection.DeflectedToNumber, 1, bc->oad)) {
+ ch_br->state=MISDN_DIALING;
+ if (pbx_start_chan(ch_br) < 0) {
+ chan_misdn_log(-1, ch_br->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
+ }
+ }
}
}
+ misdn_lib_send_event(bc, EVENT_DISCONNECT);
}
break;
default:
- chan_misdn_log(0, bc->port," --> not yet handled: facility type:%p\n", bc->fac_type);
+ chan_misdn_log(0, bc->port," --> not yet handled: facility type:%p\n", bc->fac_in.Function);
}
break;
@@ -4786,9 +4790,14 @@
if (!tok) {
ast_log(LOG_WARNING, "Facility: Call Defl Requires arguments\n");
}
-
- misdn_lib_send_facility(ch->bc, FACILITY_CALLDEFLECT, tok);
-
+
+ if (strlen(tok) >= sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber)) {
+ ast_log(LOG_WARNING, "Facility: Number argument too long (up to 15 digits are allowed). Ignoring.\n");
+ return 0;
+ }
+ ch->bc->fac_out.Function = FacReq_CD;
+ strncpy((char *)ch->bc->fac_out.u.CDeflection.DeflectedToNumber, tok, sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber));
+ misdn_lib_send_event(ch->bc, EVENT_FACILITY);
} else {
ast_log(LOG_WARNING, "Unknown Facility: %s\n",tok);
}
Modified: team/crichter/0.4.0/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/Makefile?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/Makefile (original)
+++ team/crichter/0.4.0/channels/misdn/Makefile Tue Aug 15 11:33:13 2006
@@ -11,15 +11,13 @@
endif
SOURCES = isdn_lib.c isdn_msg_parser.c
OBJDIR = .
-OBJS = isdn_lib.o isdn_msg_parser.o fac.o asn1.o
+OBJS = isdn_lib.o isdn_msg_parser.o
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libbnec.so),)
CFLAGS+=-DBEROEC_VERSION=1
CFLAGS+=-DWITH_BEROEC
endif
-
-CFLAGS+=-DFACILITY_DEBUG
all: chan_misdn_lib.a
Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Tue Aug 15 11:33:13 2006
@@ -619,8 +619,8 @@
bc->rad[0] = 0;
bc->orig_dad[0] = 0;
- bc->fac_type=FACILITY_NONE;
- bc->out_fac_type=FACILITY_NONE;
+ bc->fac_in.Function = FacReq_None;
+ bc->fac_out.Function = FacReq_None;
bc->te_choose_channel = 0;
@@ -1665,24 +1665,6 @@
return 0;
}
-int misdn_lib_send_facility(struct misdn_bchannel *bc, enum facility_type fac, void *data)
-{
- switch (fac) {
- case FACILITY_CALLDEFLECT:
- strcpy(bc->out_fac.calldeflect_nr,(char*)data);
- break;
- default:
- cb_log(1,bc?bc->port:0,"We don't handle this facility yet: %d\n",fac);
- return 0;
- }
-
- bc->out_fac_type=fac;
-
- misdn_lib_send_event(bc,EVENT_FACILITY);
- return 0;
-}
-
-
int misdn_lib_port_up(int port, int check)
{
struct misdn_stack *stack;
@@ -3104,22 +3086,21 @@
}
-char *fac2str (enum facility_type type) {
+char *fac2str (enum FacReqFunction func) {
struct arr_el {
- enum facility_type p;
+ enum FacReqFunction p;
char *s ;
} arr[] = {
- { FACILITY_NONE, "FAC_NONE" },
- { FACILITY_CALLDEFLECT, "FAC_CALLDEFLECT"},
- { FACILITY_CENTREX, "FAC_CENTREX"}
+ { FacReq_None, "FacReq_None" },
+ { FacReq_CD, "FacReq_CD"},
};
int i;
for (i=0; i < sizeof(arr)/sizeof( struct arr_el) ; i ++)
- if ( arr[i].p==type) return arr[i].s;
-
- return "FAC_UNKNOWN";
+ if ( arr[i].p==func) return arr[i].s;
+
+ return "unknown";
}
void misdn_lib_log_ies(struct misdn_bchannel *bc)
@@ -3147,7 +3128,7 @@
cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->addr, bc->l3_id, bc->b_stid, bc->layer_id);
- cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_type),fac2str(bc->out_fac_type));
+ cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.h?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.h Tue Aug 15 11:33:13 2006
@@ -14,6 +14,7 @@
#ifndef TE_LIB
#define TE_LIB
+#include <mISDNuser/suppserv.h>
/** For initialization usage **/
/* typedef int ie_nothing_t ;*/
@@ -187,22 +188,6 @@
-/** FACILITY STUFF **/
-
-enum facility_type {
- FACILITY_NONE,
- FACILITY_CALLDEFLECT=0x91,
- FACILITY_CENTREX=0x88
-};
-
-union facility {
- char calldeflect_nr[15];
- char cnip[256];
-};
-
-
-
-
struct misdn_bchannel {
int nt;
@@ -270,12 +255,9 @@
int progress_coding;
int progress_location;
int progress_indicator;
-
- enum facility_type fac_type;
- union facility fac;
-
- enum facility_type out_fac_type;
- union facility out_fac;
+
+ struct FacReqParm fac_in;
+ struct FacReqParm fac_out;
enum event_e evq;
@@ -433,9 +415,6 @@
int misdn_cap_is_speech(int cap);
int misdn_inband_avail(struct misdn_bchannel *bc);
-int misdn_lib_send_facility(struct misdn_bchannel *bc, enum facility_type fac, void *data);
-
-
void manager_ec_enable(struct misdn_bchannel *bc);
void manager_ec_disable(struct misdn_bchannel *bc);
Modified: team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib_intern.h Tue Aug 15 11:33:13 2006
@@ -10,6 +10,12 @@
#include <pthread.h>
#include "isdn_lib.h"
+
+
+#if !defined MISDNUSER_VERSION_CODE || (MISDNUSER_VERSION_CODE < MISDNUSER_VERSION(1, 0, 3))
+#error "You need a newer version of mISDNuser ..."
+#endif
+
#define QI_ELEMENT(a) a.off
Modified: team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c?rev=39805&r1=39804&r2=39805&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c Tue Aug 15 11:33:13 2006
@@ -19,8 +19,6 @@
#include "ie.c"
-#include "fac.h"
-
void set_channel(struct misdn_bchannel *bc, int channel) {
@@ -877,41 +875,66 @@
return msg;
}
-void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
-{
-#ifdef FACILITY_DEBUG
- int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
- FACILITY_t *facility=(FACILITY_t*)((unsigned long)(msg->data+HEADER_LEN));
- Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);
+void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
+{
+ int HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
+ FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN);
+ Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN);
+ unsigned char *p = NULL;
+ int err;
+
#if DEBUG
printf("Parsing FACILITY Msg\n");
#endif
- fac_dec(facility->FACILITY, qi, &bc->fac_type, &bc->fac, bc);
-#endif
+
+ if (!bc->nt) {
+ if (qi->QI_ELEMENT(facility))
+ p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(facility) + 1;
+ } else {
+ p = facility->FACILITY;
+ }
+ if (!p)
+ return;
+
+ err = decodeFacReq(p, &(bc->fac_in));
+ if (err) {
+ cb_log(1, bc->port, "Decoding FACILITY failed! (%d)\n", err);
+ }
}
msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
{
- int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
- FACILITY_t *facility;
- msg_t *msg =(msg_t*)create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc?bc->l3_id:-1, sizeof(FACILITY_t) ,nt);
-
- facility=(FACILITY_t*)((msg->data+HEADER_LEN));
-
- {
- if (*bc->display) {
- printf("Sending %s as Display\n", bc->display);
- enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc);
- }
-
-
- fac_enc(&facility->FACILITY, msg, bc->out_fac_type, bc->out_fac, bc);
-
- }
-
+ int len,
+ HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
+ unsigned char *ie_fac,
+ fac_tmp[256];
+ msg_t *msg =(msg_t*)create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc?bc->l3_id:-1, sizeof(FACILITY_t) ,nt);
+ FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN);
+ Q931_info_t *qi;
+
#if DEBUG
printf("Building FACILITY Msg\n");
#endif
+
+ len = encodeFacReq(fac_tmp, &(bc->fac_out));
+ if (len <= 0)
+ return NULL;
+
+ ie_fac = msg_put(msg, len);
+ if (bc->nt) {
+ facility->FACILITY = ie_fac + 1;
+ } else {
+ qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
+ qi->QI_ELEMENT(facility) = ie_fac - (unsigned char *)qi - sizeof(Q931_info_t);
+ }
+
+ memcpy(ie_fac, fac_tmp, len);
+
+ if (*bc->display) {
+ printf("Sending %s as Display\n", bc->display);
+ enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc);
+ }
+
return msg;
}
More information about the asterisk-commits
mailing list