[svn-commits] nadi: trunk r39807 - in /trunk/channels: ./ misdn/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Tue Aug 15 09:49:27 MST 2006
Author: nadi
Date: Tue Aug 15 11:49:26 2006
New Revision: 39807
URL: http://svn.digium.com/view/asterisk?rev=39807&view=rev
Log:
moved the asn1 and facility portions of code to mISDNuser, so removing the files here.
Removed:
trunk/channels/misdn/asn1.c
trunk/channels/misdn/asn1.h
trunk/channels/misdn/fac.c
trunk/channels/misdn/fac.h
Modified:
trunk/channels/Makefile
trunk/channels/chan_misdn.c
trunk/channels/misdn/Makefile
trunk/channels/misdn/isdn_lib.c
trunk/channels/misdn/isdn_lib.h
trunk/channels/misdn/isdn_lib_intern.h
trunk/channels/misdn/isdn_msg_parser.c
Modified: trunk/channels/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/channels/Makefile?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/Makefile (original)
+++ trunk/channels/Makefile Tue Aug 15 11:49:26 2006
@@ -104,4 +104,4 @@
misdn_config.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\" $(EC_CFLAGS)
chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
-chan_misdn.so: LIBS+=-lisdnnet -lmISDN $(EC_LIBS)
+chan_misdn.so: LIBS+=-lisdnnet -lmISDN -lsuppserv $(EC_LIBS)
Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Tue Aug 15 11:49:26 2006
@@ -413,20 +413,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");
-
}
}
@@ -1119,18 +1114,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);
}
}
@@ -4477,30 +4477,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;
@@ -4781,9 +4785,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: trunk/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/Makefile?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/misdn/Makefile (original)
+++ trunk/channels/misdn/Makefile Tue Aug 15 11:49:26 2006
@@ -11,14 +11,12 @@
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: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Tue Aug 15 11:49:26 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;
@@ -1674,24 +1674,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;
@@ -3114,22 +3096,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)
@@ -3157,7 +3138,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: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Tue Aug 15 11:49:26 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: trunk/channels/misdn/isdn_lib_intern.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib_intern.h?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib_intern.h (original)
+++ trunk/channels/misdn/isdn_lib_intern.h Tue Aug 15 11:49:26 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: trunk/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_msg_parser.c?rev=39807&r1=39806&r2=39807&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_msg_parser.c (original)
+++ trunk/channels/misdn/isdn_msg_parser.c Tue Aug 15 11:49:26 2006
@@ -19,8 +19,6 @@
#include "ie.c"
-#include "fac.h"
-
void set_channel(struct misdn_bchannel *bc, int channel) {
@@ -879,42 +877,64 @@
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);
+ 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 svn-commits
mailing list