#*****************************************************************************\
#* **
-#* PBX4Linux **
+#* Linux Call Router **
#* **
#*---------------------------------------------------------------------------**
#* Copyright: Andreas Eversberg **
# select location to install
INSTALL_BIN = /usr/local/bin
-INSTALL_DATA = /usr/local/pbx
+INSTALL_DATA = /usr/local/lcr
# give locations for the libraries
LINUX_INCLUDE = -I/usr/src/linux/include
# give location of the mISDN libraries
-MISDNUSER_INCLUDE = -I../mISDNuser/include
+MISDNUSER_INCLUDE = -I../mISDNuser/include -I../mISDNuser/i4lnet
MISDNUSER_LIB = -L../mISDNuser/lib -L../mISDNuser/i4lnet
LIBS += -lisdnnet -lmISDN -lpthread
CC = g++
LD = $(CC)
WIZZARD = ./wizzard
-PBX = ./pbx
-PBXADMIN = ./pbxadmin
-PBXWATCH = ./pbxwatch
+LCR = ./lcr
+LCRADMIN = ./lcradmin
+LCRWATCH = ./lcrwatch
GEN = ./gentones
GENW = ./genwave
GENRC = ./genrc
# @echo Please report any bug. To compile use \"make beta\".
# @exit
-all: $(PBXADMIN) $(PBX) $(GEN) $(GENW) $(GENRC) $(GENEXT)
+all: $(LCR) $(LCRADMIN) $(GEN) $(GENW) $(GENRC) $(GENEXT)
@sh -c 'grep -n strcpy *.c* ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
@sh -c 'grep -n strncpy *.c* ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
@sh -c 'grep -n strcat *.c* ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
@sh -c 'grep -n strncat *.c* ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
@sh -c 'grep -n sprintf *.c* ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
@sh -c 'grep -n snprintf *.c* ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
- @echo "All PBX binaries done"
+ @echo "All LCR binaries done"
@sync
@exit
dss1.o: dss1.cpp ie.cpp *.h Makefile
$(CC) -c $(CFLAGS) dss1.cpp -o dss1.o
-opal.o: opal.cpp *.h Makefile
- $(CC) -c $(CFLAGS) opal.cpp -o opal.o
-
-opal_mgr.o: opal_mgr.cpp *.h Makefile
- $(CC) -c $(CFLAGS) opal_mgr.cpp -o opal_mgr.o
-
-opal_pbxep.o: opal_pbxep.cpp *.h Makefile
- $(CC) -c $(CFLAGS) opal_pbxep.cpp -o opal_pbxep.o
-
-opal_pbxcon.o: opal_pbxcon.cpp *.h Makefile
- $(CC) -c $(CFLAGS) opal_pbxcon.cpp -o opal_pbxcon.o
-
-opal_pbxms.o: opal_pbxms.cpp *.h Makefile
- $(CC) -c $(CFLAGS) opal_pbxms.cpp -o opal_pbxms.o
-
#knock.o: knock.cpp *.h Makefile
# $(CC) -c $(CFLAGS) knock.cpp -o knock.o
#
# $(CC) $(LIBDIR) $(CFLAGS) -lm wizzard.c \
# -o $(WIZZARD)
-$(PBX): main.o \
+$(LCR): main.o \
options.o \
interface.o \
extension.o \
callchan.o \
admin_server.o \
trace.o \
- $(LIBS) -o $(PBX)
+ $(LIBS) -o $(LCR)
-$(PBXADMIN): admin_client.c cause.c *.h Makefile
+$(LCRADMIN): admin_client.c cause.c *.h Makefile
$(CC) $(LIBDIR) $(CFLAGS) $(CURSES) -lm admin_client.c cause.c \
- -o $(PBXADMIN)
+ -o $(LCRADMIN)
-$(PBXWATCH): watch.c *.h Makefile
+$(LCRWATCH): watch.c *.h Makefile
$(CC) $(LIBDIR) $(CFLAGS) -lm watch.c \
- -o $(PBXWATCH)
+ -o $(LCRWATCH)
$(GEN): gentones.c *.h Makefile
$(CC) $(LIBDIR) $(CFLAGS) -lm gentones.c \
# @exit
install:
- -killall -9 -w -q pbx # the following error must be ignored
- cp $(PBX) $(INSTALL_BIN)
- cp $(PBXADMIN) $(INSTALL_BIN)
-# cp $(PBXWATCH) $(INSTALL_BIN)
+ -killall -9 -w -q lcr # the following error must be ignored
+ cp $(LCR) $(INSTALL_BIN)
+ cp $(LCRADMIN) $(INSTALL_BIN)
+# cp $(LCRWATCH) $(INSTALL_BIN)
cp $(GEN) $(INSTALL_BIN)
cp $(GENW) $(INSTALL_BIN)
cp $(GENRC) $(INSTALL_BIN)
clean:
touch *
- rm -f $(PBX) $(PBXADMIN) $(PBXWATCH) $(GEN) $(GENW) $(GENRC) $(GENEXT)
+ rm -f $(LCR) $(LCRADMIN) $(LCRWATCH) $(GEN) $(GENW) $(GENRC) $(GENEXT)
rm -f *.o
rm -f .*.c.sw* .*.cpp.sw* .*.h.sw*
rm -f bla nohup.out
tar:
make clean
- cd .. && tar -cvzf pbx4linux_`date +%Y%m%d`.tar.gz pbx4linux
+ cd .. && tar -cvzf lcr_`date +%Y%m%d`.tar.gz lcr
-start: $(PBX)
+start: $(LCR)
sync
- -killall -9 -w -q pbx # the following error must be ignored
- $(PBX) start
+ -killall -9 -w -q lcr # the following error must be ignored
+ $(LCR) start
-s: $(PBX)
+s: $(LCR)
sync
- -killall -9 -w -q pbx # the following error must be ignored
- $(PBX) start
+ -killall -9 -w -q lcr # the following error must be ignored
+ $(LCR) start
-fork: $(PBX)
+fork: $(LCR)
sync
- -killall -9 -w -q pbx # the following error must be ignored
- $(PBX) fork
+ -killall -9 -w -q lcr # the following error must be ignored
+ $(LCR) fork
memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
memset(&dialinginfo, 0, sizeof(dialinginfo));
- dialinginfo.itype = INFO_ITYPE_INTERN;
- SCPY(dialinginfo.number, e_dialinginfo.number);
+ dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION;
+ SCPY(dialinginfo.id, e_dialinginfo.id);
/* process extension */
if ((rparam = routeparam(e_action, PARAM_EXTENSION)))
- SCPY(dialinginfo.number, rparam->string_value);
+ SCPY(dialinginfo.id, rparam->string_value);
/* process number type */
if ((rparam = routeparam(e_action, PARAM_TYPE)))
}
/* check if extension exists AND only if not multiple extensions */
- if (!read_extension(&ext, dialinginfo.number) && !strchr(dialinginfo.number,','))
+ if (!read_extension(&ext, dialinginfo.id) && !strchr(dialinginfo.id,','))
{
trace_header("ACTION extension (extension doesn't exist)", DIRECTION_NONE);
- add_trace("extension", NULL, dialinginfo.number);
+ add_trace("extension", NULL, dialinginfo.id);
end_trace();
new_state(EPOINT_STATE_OUT_DISCONNECT);
message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, "");
if (e_ext.rights < 1)
{
trace_header("ACTION extension (dialing to extension denied)", DIRECTION_NONE);
- add_trace("extension", NULL, dialinginfo.number);
+ add_trace("extension", NULL, dialinginfo.id);
end_trace();
new_state(EPOINT_STATE_OUT_DISCONNECT);
message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, "");
/* add or update internal call */
trace_header("ACTION extension (calling)", DIRECTION_NONE);
- add_trace("extension", NULL, dialinginfo.number);
+ add_trace("extension", NULL, dialinginfo.id);
end_trace();
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
memset(&dialinginfo, 0, sizeof(dialinginfo));
- dialinginfo.itype = INFO_ITYPE_EXTERN;
+ dialinginfo.itype = INFO_ITYPE_ISDN;
dialinginfo.sending_complete = 0;
- SCPY(dialinginfo.number, e_extdialing);
+ SCPY(dialinginfo.id, e_extdialing);
/* process prefix */
if ((rparam = routeparam(e_action, PARAM_PREFIX)))
- SPRINT(dialinginfo.number, "%s%s", rparam->string_value, e_extdialing);
+ SPRINT(dialinginfo.id, "%s%s", rparam->string_value, e_extdialing);
/* process number complete */
if ((rparam = routeparam(e_action, PARAM_COMPLETE)))
if ((rparam = routeparam(e_action, PARAM_PREFIX)))
- SCPY(dialinginfo.number, rparam->string_value);
+ SCPY(dialinginfo.id, rparam->string_value);
dialinginfo.sending_complete = 1;
/* process number type */
return;
}
- if (!strncmp(dialinginfo.number, options.national, strlen(options.national))
+ if (!strncmp(dialinginfo.id, options.national, strlen(options.national))
|| dialinginfo.ntype == INFO_NTYPE_NATIONAL
|| dialinginfo.ntype == INFO_NTYPE_INTERNATIONAL)
{
}
}
- if (!strncmp(dialinginfo.number, options.international, strlen(options.international))
+ if (!strncmp(dialinginfo.id, options.international, strlen(options.international))
|| dialinginfo.ntype == INFO_NTYPE_INTERNATIONAL)
{
/* check if international calls are denied */
/* add or update outgoing call */
trace_header("ACTION extern (calling)", DIRECTION_NONE);
- add_trace("number", NULL, dialinginfo.number);
+ add_trace("number", NULL, dialinginfo.id);
if (dialinginfo.interfaces[0])
add_trace("interfaces", NULL, dialinginfo.interfaces);
end_trace();
memset(&dialinginfo, 0, sizeof(dialinginfo));
dialinginfo.itype = INFO_ITYPE_VBOX;
dialinginfo.sending_complete = 1;
- SCPY(dialinginfo.number, rparam->string_value);
+ SCPY(dialinginfo.id, rparam->string_value);
/* append special announcement (if given) */
if ((rparam = routeparam(e_action, PARAM_ANNOUNCEMENT)))
if (rparam->string_value[0])
{
- SCAT(dialinginfo.number, ",");
- SCAT(dialinginfo.number, rparam->string_value);
+ SCAT(dialinginfo.id, ",");
+ SCAT(dialinginfo.id, rparam->string_value);
}
/* add or update internal call */
trace_header("ACTION vbox-record (calling)", DIRECTION_NONE);
- add_trace("extension", NULL, "%s", dailinginfo.number);
+ add_trace("extension", NULL, "%s", dialinginfo.id);
end_trace();
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
/* send setup to call */
trace_header("ACTION partyline (calling)", DIRECTION_NONE);
- add_trace("room", NULL, "%d", partylind);
+ add_trace("room", NULL, "%d", partyline);
end_trace();
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP);
message->param.setup.partyline = partyline;
/* check */
if (e_ext.number[0] == '\0')
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because caller is unknown (not internal).\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because caller is unknown (not internal).\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
return;
}
if (!(read_extension(&e_ext, e_ext.number)))
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because cannot read settings.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because cannot read settings.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
return;
}
- if (e_dialinginfo.number[0] == '\0')
+ if (e_dialinginfo.id[0] == '\0')
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number because nothing was dialed.\n", ea_endpoint->ep_serial, e_ext.number);
return;
}
- if (!strcmp(e_dialinginfo.number, e_ext.last_out[0]))
+ if (!strcmp(e_dialinginfo.id, e_ext.last_out[0]))
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
return;
}
/* insert */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
i = MAX_REMEMBER-1;
while(i)
{
UCPY(e_ext.last_out[i], e_ext.last_out[i-1]);
i--;
}
- SCPY(e_ext.last_out[0], e_dialinginfo.number);
+ SCPY(e_ext.last_out[0], e_dialinginfo.id);
/* write extension */
write_extension(&e_ext, e_ext.number);
message->param.connectinfo.present = INFO_PRESENT_RESTRICTED;
else message->param.connectinfo.present = e_ext.callerid_present;
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, portlist->port_type, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
/* display callerid if desired for extension */
- SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name));
+ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
message->param.connectinfo.ntype = e_ext.callerid_type;
message_put(message);
logmessage(message);
e_action = &action_password;
e_match_timeout = 0;
e_match_to_action = NULL;
- e_dialinginfo.number[0] = '\0';
- e_extdialing = strchr(e_dialinginfo.number, '\0');
+ e_dialinginfo.id[0] = '\0';
+ e_extdialing = strchr(e_dialinginfo.id, '\0');
/* set timeout */
e_password_timeout = now+20;
if (e_ruleset)
e_rule = e_ruleset->rule_first;
e_action = NULL;
- e_dialinginfo.number[0] = '\0';
- e_extdialing = e_dialinginfo.number;
+ e_dialinginfo.id[0] = '\0';
+ e_extdialing = e_dialinginfo.id;
set_tone(portlist, "dialpbx");
}
}
add_trace("number", NULL, "%s", last);
add_trace("last but", NULL, "%d", e_select);
end_trace();
- SCPY(e_dialinginfo.number, last);
- e_extdialing = e_dialinginfo.number;
+ SCPY(e_dialinginfo.id, last);
+ e_extdialing = e_dialinginfo.id;
e_action = NULL;
process_dialing();
return;
logmessage(message);
/* do dialing */
- SCPY(e_dialinginfo.number, e_ext.last_out[0]);
+ SCPY(e_dialinginfo.id, e_ext.last_out[0]);
e_powerdialing = -1; /* indicates the existence of powerdialing but no redial time given */
e_powercount = 0;
e_action = NULL;
if (name) if (name[0])
add_trace("name", NULL, "%s", name);
end_trace();
- SCPY(e_dialinginfo.number, phone);
- e_extdialing = e_dialinginfo.number;
+ SCPY(e_dialinginfo.id, phone);
+ e_extdialing = e_dialinginfo.id;
e_action = NULL;
process_dialing();
}
set_tone(portlist, NULL);
memset(&e_connectinfo, 0, sizeof(e_connectinfo));
SCPY(e_connectinfo.id, e_callerinfo.id);
- SCPY(e_connectinfo.intern, e_callerinfo.intern);
- SCPY(e_connectinfo.voip, e_callerinfo.voip);
+ SCPY(e_connectinfo.extension, e_callerinfo.extension);
e_connectinfo.itype = e_callerinfo.itype;
e_connectinfo.ntype = e_callerinfo.ntype;
e_connectinfo.present = e_callerinfo.present;
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(struct connect_info));
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, portlist->port_type, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
/* display callerid if desired for extension */
- SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name));
+ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
message_put(message);
logmessage(message);
switch(mode)
{
case 0: /* multiply */
- UNPRINT(e_extdialing, sizeof(e_dialinginfo.number)-strlen(e_dialinginfo.number), "%.8f", sign1*value1*value2);
+ UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1*value2);
break;
case 1: /* divide */
- UNPRINT(e_extdialing, sizeof(e_dialinginfo.number)-strlen(e_dialinginfo.number), "%.8f", sign1*value1/value2);
+ UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1/value2);
break;
case 2: /* add */
- UNPRINT(e_extdialing, sizeof(e_dialinginfo.number)-strlen(e_dialinginfo.number), "%.8f", sign1*value1+value2);
+ UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1+value2);
break;
case 3: /* substract */
- UNPRINT(e_extdialing, sizeof(e_dialinginfo.number)-strlen(e_dialinginfo.number), "%.8f", sign1*value1-value2);
+ UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1-value2);
break;
}
- e_dialinginfo.number[sizeof(e_dialinginfo.number)-1] = '\0';
+ e_dialinginfo.id[sizeof(e_dialinginfo.id)-1] = '\0';
if (strchr(e_extdialing, '.')) /* remove zeroes */
{
while (e_extdialing[strlen(e_extdialing)-1] == '0')
if (!e_ruleset)
{
trace_header("ACTION goto/menu (ruleset not found)", DIRECTION_NONE);
- add_trace("ruleset", "NULL", "%s", praram->string_value);
+ add_trace("ruleset", NULL, "%s", rparam->string_value);
end_trace();
goto disconnect;
}
/* if the 'menu' was selected, we will flush all digits */
if (mode)
{
- e_dialinginfo.number[0] = 0;
- e_extdialing = e_dialinginfo.number;
+ e_dialinginfo.id[0] = 0;
+ e_extdialing = e_dialinginfo.id;
} else
{
/* remove digits that are required to match the rule */
if (!(rparam = routeparam(e_action, PARAM_STRIP)))
{
if (e_extdialing)
- SCPY(e_dialinginfo.number, e_extdialing);
- e_extdialing = e_dialinginfo.number;
+ SCPY(e_dialinginfo.id, e_extdialing);
+ e_extdialing = e_dialinginfo.id;
}
}
/* play sample */
trace_header("ACTION goto/menu (change to)", DIRECTION_NONE);
- add_trace("ruleset", "NULL", "%s", e_ruleset->name);
- if (e_dialinginfo.number[0])
- add_trace("dialing", "NULL", "%s", e_dialinginfo.number);
+ add_trace("ruleset", NULL, "%s", e_ruleset->name);
+ if (e_dialinginfo.id[0])
+ add_trace("dialing", NULL, "%s", e_dialinginfo.id);
if ((rparam = routeparam(e_action, PARAM_SAMPLE)))
{
- add_trace("sample", "NULL", "%s", praram->string_value);
+ add_trace("sample", NULL, "%s", rparam->string_value);
set_tone(ea_endpoint->ep_portlist, rparam->string_value);
}
end_trace();
/* show all things that would match */
#if 0
struct numbering *numbering = numbering_int;
- char dialing[sizeof(e_dialinginfo.number)];
+ char dialing[sizeof(e_dialinginfo.id)];
int i;
struct message *message;
struct route_param *rparam;
return;
/* scroll menu */
- if (strchr(e_dialinginfo.number,'*'))
+ if (strchr(e_dialinginfo.id,'*'))
{
e_menu--;
- e_dialinginfo.number[0] = '\0';
+ e_dialinginfo.id[0] = '\0';
}
- if (strchr(e_dialinginfo.number,'#'))
+ if (strchr(e_dialinginfo.id,'#'))
{
e_menu++;
- e_dialinginfo.number[0] = '\0';
+ e_dialinginfo.id[0] = '\0';
}
/* get position in menu */
}
/* if we dial something else we need to add the prefix and change the action */
- if (e_dialinginfo.number[0])
+ if (e_dialinginfo.id[0])
{
e_action = NUMB_ACTION_NONE;
SCPY(dialing, numbering->prefix);
//we ignore the first digit after selecting
- //SCAT(dialing, e_dialinginfo.number);
- SCPY(e_dialinginfo.number, dialing);
- e_extdialing = e_dialinginfo.number+strlen(numbering->prefix);
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' dialing: %s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], e_dialinginfo.number);
+ //SCAT(dialing, e_dialinginfo.id);
+ SCPY(e_dialinginfo.id, dialing);
+ e_extdialing = e_dialinginfo.id+strlen(numbering->prefix);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' dialing: %s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], e_dialinginfo.id);
nesting?:
process_dialing();
return;
{
struct route_param *rparam;
char *command = "", isdn_port[10];
- char *argv[8+1]; /* check also number of args below */
+ char *argv[7+1]; /* check also number of args below */
int i = 0;
/* get script / command */
}
argv[1+i] = e_extdialing;
argv[2+i] = numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype);
- argv[3+i] = e_callerinfo.intern;
- argv[4+i] = e_callerinfo.voip;
- argv[5+i] = e_callerinfo.name;
+ argv[3+i] = e_callerinfo.extension;
+ argv[4+i] = e_callerinfo.name;
SPRINT(isdn_port, "%d", e_callerinfo.isdn_port);
- argv[6+i] = isdn_port;
- argv[7+i] = NULL; /* check also number of args above */
+ argv[5+i] = isdn_port;
+ argv[6+i] = NULL; /* check also number of args above */
execve("/bin/sh", argv, environ);
}
trace_header("ACTION pick", DIRECTION_NONE);
if (extensions) if (extensions[0])
- add_trace("extensions", NULL, "%s", file);
+ add_trace("extensions", NULL, "%s", extensions);
end_trace();
pick_call(extensions);
}
if (e_ruleset)
e_rule = e_ruleset->rule_first;
e_action = NULL;
- e_dialinginfo.number[0] = '\0';
- e_extdialing = e_dialinginfo.number;
+ e_dialinginfo.id[0] = '\0';
+ e_extdialing = e_dialinginfo.id;
set_tone(portlist, "dialpbx");
}
#if 0
/* check if we do menu selection */
- if (e_action==NUMB_ACTION_NONE && (e_dialinginfo.number[0]=='*' || e_dialinginfo.number[0]=='#'))
+ if (e_action==NUMB_ACTION_NONE && (e_dialinginfo.id[0]=='*' || e_dialinginfo.id[0]=='#'))
/* do menu selection */
if (e_ext.display_menu)
{
if (portlist->port_type==PORT_TYPE_DSS1_NT_IN || portlist->port_type==PORT_TYPE_DSS1_NT_OUT) /* only if the dialing terminal is an isdn telephone connected to an internal port */
{
- e_dialinginfo.number[0] = '\0';
+ e_dialinginfo.id[0] = '\0';
e_action = NUMB_ACTION_MENU;
e_menu = 0;
process_dialing();
e_select = 0;
/* check for external call */
- if (!strncmp(e_dialinginfo.number, "extern:", 7))
+ if (!strncmp(e_dialinginfo.id, "extern:", 7))
{
- e_extdialing = e_dialinginfo.number+7;
+ e_extdialing = e_dialinginfo.id+7;
e_action = &action_external;
goto process_action;
}
/* check for internal call */
- if (!strncmp(e_dialinginfo.number, "intern:", 7))
+ if (!strncmp(e_dialinginfo.id, "intern:", 7))
{
- e_extdialing = e_dialinginfo.number+7;
+ e_extdialing = e_dialinginfo.id+7;
e_action = &action_internal;
goto process_action;
}
/* check for chan call */
- if (!strncmp(e_dialinginfo.number, "chan:", 5))
+ if (!strncmp(e_dialinginfo.id, "chan:", 5))
{
- e_extdialing = e_dialinginfo.number+4;
+ e_extdialing = e_dialinginfo.id+4;
e_action = &action_chan;
goto process_action;
}
/* check for vbox call */
- if (!strncmp(e_dialinginfo.number, "vbox:", 5))
+ if (!strncmp(e_dialinginfo.id, "vbox:", 5))
{
- e_extdialing = e_dialinginfo.number+5;
+ e_extdialing = e_dialinginfo.id+5;
e_action = &action_vbox;
goto process_action;
}
if (e_match_timeout && now_d>=e_match_timeout)
{
/* return timeout rule */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', timeout in ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number, e_ruleset->name);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', timeout in ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id, e_ruleset->name);
e_match_timeout = 0;
e_action = e_match_to_action;
e_extdialing = e_match_to_extdialing;
{
//PDEBUG(~0, "HANG-BUG-DEBUGGING: before routing\n");
/* check for matching rule */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', checking matching rule of ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number, e_ruleset->name);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', checking matching rule of ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id, e_ruleset->name);
if (e_ruleset)
{
e_action = route(e_ruleset);
if (!e_action)
{
- SPRINT(message->param.notifyinfo.display, "> %s", e_dialinginfo.number);
+ SPRINT(message->param.notifyinfo.display, "> %s", e_dialinginfo.id);
} else
{
SPRINT(message->param.notifyinfo.display, "%s%s%s", action_defs[e_action->index].name, (e_extdialing[0])?" ":"", e_extdialing);
} else
if (!e_stop)
time(&e_stop);
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): writing connect from %s to %s into logfile of %s\n", ea_endpoint->ep_serial, e_callerinfo.id, e_dialinginfo.number, e_ext.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): writing connect from %s to %s into logfile of %s\n", ea_endpoint->ep_serial, e_callerinfo.id, e_dialinginfo.id, e_ext.number);
switch(e_dialinginfo.itype)
{
case INFO_ITYPE_CHAN:
- SPRINT(dialingtext, "chan:%s", e_dialinginfo.number);
+ SPRINT(dialingtext, "chan:%s", e_dialinginfo.id);
break;
- case INFO_ITYPE_INTERN:
- SPRINT(dialingtext, "intern:%s", e_dialinginfo.number);
+ case INFO_ITYPE_ISDN_EXTENSION:
+ SPRINT(dialingtext, "intern:%s", e_dialinginfo.id);
break;
case INFO_ITYPE_VBOX:
- SPRINT(dialingtext, "vbox:%s", e_dialinginfo.number);
+ SPRINT(dialingtext, "vbox:%s", e_dialinginfo.id);
break;
default:
- SPRINT(dialingtext, "%s", e_dialinginfo.number);
+ SPRINT(dialingtext, "%s", e_dialinginfo.id);
}
if (e_callerinfo.id[0])
/* allpy restriction */
if (!e_ext.anon_ignore && e_callerinfo.present==INFO_PRESENT_RESTRICTED)
SPRINT(callertext, "anonymous");
- if (e_callerinfo.intern[0]) /* add intern if present */
- UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (intern %s)", e_callerinfo.intern);
- if (e_callerinfo.voip[0]) /* add voip if present */
- UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (voip %s)", e_callerinfo.voip);
+ if (e_callerinfo.extension[0]) /* add intern if present */
+ UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (intern %s)", e_callerinfo.extension);
write_log(e_ext.number, callertext, dialingtext, e_start, e_stop, 0, cause, location);
/* store last received call for reply-list */
- if (e_callerinfo.id[0] || e_callerinfo.intern[0])
+ if (e_callerinfo.id[0] || e_callerinfo.extension[0])
if (e_ext.anon_ignore || e_callerinfo.present!=INFO_PRESENT_RESTRICTED)
{
- if (e_callerinfo.intern[0])
- SPRINT(callertext, "intern:%s", e_callerinfo.intern);
+ if (e_callerinfo.extension[0])
+ SPRINT(callertext, "intern:%s", e_callerinfo.extension);
else
SPRINT(callertext, "extern:%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype));
if (!!strcmp(callertext, e_ext.last_in[0]))
if (e_vbox_index_callerid[0]!='\0' && !!strcmp(e_vbox_index_callerid,"anonymous") && !!strcmp(e_vbox_index_callerid,"unknown"))
{
set_tone(portlist, "dialing");
- SPRINT(e_dialinginfo.number, "extern:%s", e_vbox_index_callerid);
- e_extdialing = e_dialinginfo.number;
+ SPRINT(e_dialinginfo.id, "extern:%s", e_vbox_index_callerid);
+ e_extdialing = e_dialinginfo.id;
e_action = NULL;
process_dialing();
return;
** **
\*****************************************************************************/
-#define SOCKET_NAME "/var/run/PBX4Linux.socket"
+#define SOCKET_NAME "/var/run/LCR.socket"
/* structures that define message between admin-tool and pbx */
ADMIN_RESPONSE_CMD_DIAL,
ADMIN_REQUEST_CMD_RELEASE,
ADMIN_RESPONSE_CMD_RELEASE,
+ ADMIN_REQUEST_CMD_BLOCK,
+ ADMIN_RESPONSE_CMD_BLOCK,
ADMIN_REQUEST_STATE,
ADMIN_RESPONSE_STATE,
ADMIN_RESPONSE_S_INTERFACE,
struct admin_response_cmd {
int error; /* error code 0 = ok*/
char message[256]; /* info / response text */
+ int block;
+ int portnum;
};
struct admin_response_state {
};
struct admin_response_interface {
- int portnum;
char interface_name[32];
+ int portnum;
+ int block;
int ntmode;
int ptp;
int pri;
- int iftype;
+ int extension;
int use; /* number of ports that use this interface */
int l1link; /* down(0) or up(1) */
int l2link; /* down(0) or up(1) */
/*****************************************************************************\
** **
-** PBX4Linux **
+** LCR **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
#include "admin.h"
#include "cause.h"
-#define LTEE {addch(/*ACS_LTEE*/'t');addch(/*ACS_HLINE*/'q');addch(/*ACS_HLINE*/'q');}
-#define LLCORNER {addch(/*ACS_LLCORNER*/'m');addch(/*ACS_HLINE*/'q');addch(/*ACS_HLINE*/'q');}
-#define VLINE {addch(/*ACS_VLINE*/'x');addstr(" ");}
+#define LTEE {addch(ACS_LTEE);addch(ACS_HLINE);addch(ACS_HLINE);}
+#define LLCORNER {addch(ACS_LLCORNER);addch(ACS_HLINE);addch(ACS_HLINE);}
+#define VLINE {addch(ACS_VLINE);addstr(" ");}
#define EMPTY {addstr(" ");}
//char rotator[] = {'-', '\\', '|', '/'};
int lastlines, lastcols;
MODE_ROUTE,
MODE_DIAL,
MODE_RELEASE,
+ MODE_UNBLOCK,
+ MODE_BLOCK,
+ MODE_UNLOAD,
MODE_TESTCALL,
MODE_TRACE,
};
/* send reload command */
memset(&msg, 0, sizeof(msg));
msg.message = ADMIN_REQUEST_STATE;
-// printf("sizeof=%d\n",sizeof(msg));
+// printf("sizeof=%d\n",sizeof(msg));fflush(stdout);
if (write(sock, &msg, sizeof(msg)) != sizeof(msg))
{
cleanup_curses();
cleanup_curses();
return("Broken pipe while receiving response.");
}
+
if (msg.message != ADMIN_RESPONSE_STATE)
{
cleanup_curses();
return("Not enough memory for messages.");
}
off=0;
-readagain:
- if ((len = read(sock, ((unsigned char *)(m))+off, num*sizeof(struct admin_message)-off)) != num*(int)sizeof(struct admin_message)-off)
+ if (num)
{
- if (len <= 0) {
- free(m);
-// fprintf(stderr, "got=%d expected=%d\n", i, num*sizeof(struct admin_message));
- cleanup_curses();
- return("Broken pipe while receiving state infos.");
- }
- if (len < num*(int)sizeof(struct admin_message))
+ readagain:
+ if ((len = read(sock, ((unsigned char *)(m))+off, num*sizeof(struct admin_message)-off)) != num*(int)sizeof(struct admin_message)-off)
{
- off+=len;
- goto readagain;
+ if (len <= 0) {
+ free(m);
+ // fprintf(stderr, "got=%d expected=%d\n", i, num*sizeof(struct admin_message));
+ cleanup_curses();
+ return("Broken pipe while receiving state infos.");
+ }
+ if (len < num*(int)sizeof(struct admin_message))
+ {
+ off+=len;
+ goto readagain;
+ }
}
}
j = 0;
/* show interface summary */
move(++line>1?line:1, 0);
color(white);
-
- SPRINT(buffer, "%s(%d) '%s' %s use:%d ", (m[i].u.i.ntmode)?"NT":"TE", m[i].u.i.portnum, m[i].u.i.interface_name, (m[i].u.i.ptp)?"ptp ":"ptmp", m[i].u.i.use);
- addstr(buffer);
- if (m[i].u.i.ptp || !m[i].u.i.ntmode)
+ if (m[i].u.i.block >= 2)
{
- color((m[i].u.i.l2link)?green:red);
- addstr((m[i].u.i.l2link)?" L2 UP":" L2 down");
- }
- color((m[i].u.i.l1link)?green:blue);
- addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
- if (line+2 >= LINES) goto end;
- /* show channels */
- if (show_interfaces > 1)
+ SPRINT(buffer, "%s (%d)%s", m[i].u.i.interface_name, m[i].u.i.portnum, (m[i].u.i.extension)?" (extension)":"");
+ addstr(buffer);
+ color(red);
+ addstr(" not loaded");
+ } else
{
- ltee = 0;
- j = k =0;
- jj = m[i].u.i.channels;
- while(j < jj)
+ SPRINT(buffer, "%s (%d) %s %s%s use:%d", m[i].u.i.interface_name, m[i].u.i.portnum, (m[i].u.i.ntmode)?"NT-mode":"TE-mode", (m[i].u.i.ptp)?"ptp ":"ptmp", (m[i].u.i.extension)?" extension":"", m[i].u.i.use);
+ addstr(buffer);
+ if (m[i].u.i.ptp || !m[i].u.i.ntmode)
+ {
+ color((m[i].u.i.l2link)?green:red);
+ addstr((m[i].u.i.l2link)?" L2 UP":" L2 down");
+ }
+ color((m[i].u.i.l1link)?green:blue);
+ addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
+ if (m[i].u.i.block)
{
- /* show all channels */
- if (show_interfaces>2 || m[i].u.i.busy[j]>0)
+ color(red);
+ addstr(" blocked");
+ }
+ if (line+2 >= LINES) goto end;
+ /* show channels */
+ if (show_interfaces > 1)
+ {
+ ltee = 0;
+ j = k =0;
+ jj = m[i].u.i.channels;
+ while(j < jj)
{
- color(cyan);
- /* show left side / right side */
- if ((k & 1) && (COLS > 70))
+ /* show all channels */
+ if (show_interfaces>2 || m[i].u.i.busy[j]>0)
{
- move(line>1?line:1,4+((COLS-4)/2));
- } else
- {
- move(++line>1?line:1, 1);
- LTEE
- ltee = 1;
- }
- k++;
- color(white);
- if (m[i].u.i.pri)
- SPRINT(buffer,"S%2d: ", j+1+(j>=15));
- else
- SPRINT(buffer,"B%2d: ", j+1);
- addstr(buffer);
- if (!m[i].u.i.ptp)
- goto ptmp;
- if (m[i].u.i.l2link)
- {
- ptmp:
- color((m[i].u.i.busy[j])?yellow:blue);
- addstr((m[i].u.i.busy[j])?"busy":"idle");
- } else
- {
- color(red);
- addstr("blk ");
- }
- if (m[i].u.i.port[j])
- {
- /* search for port */
- l = msg.u.s.interfaces+msg.u.s.calls+msg.u.s.epoints;
- ll = l+msg.u.s.ports;
- while(l < ll)
+ color(cyan);
+ /* show left side / right side */
+ if ((k & 1) && (COLS > 70))
{
- if (m[l].u.p.serial == m[i].u.i.port[j])
+ move(line>1?line:1,4+((COLS-4)/2));
+ } else
+ {
+ move(++line>1?line:1, 1);
+ LTEE
+ ltee = 1;
+ }
+ k++;
+ color(white);
+ if (m[i].u.i.pri)
+ SPRINT(buffer,"S%2d: ", j+1+(j>=15));
+ else
+ SPRINT(buffer,"B%2d: ", j+1);
+ addstr(buffer);
+ if (!m[i].u.i.ptp)
+ goto ptmp;
+ if (m[i].u.i.l2link && m[i].u.i.block==0)
+ {
+ ptmp:
+ color((m[i].u.i.busy[j])?yellow:blue);
+ addstr((m[i].u.i.busy[j])?"busy":"idle");
+ } else
+ {
+ color(red);
+ addstr("blk ");
+ }
+ if (m[i].u.i.port[j])
+ {
+ /* search for port */
+ l = msg.u.s.interfaces+msg.u.s.calls+msg.u.s.epoints;
+ ll = l+msg.u.s.ports;
+ while(l < ll)
{
- SPRINT(buffer, " %s(%ld)", m[l].u.p.name, m[l].u.p.serial);
- addstr(buffer);
+ if (m[l].u.p.serial == m[i].u.i.port[j])
+ {
+ SPRINT(buffer, " %s(%ld)", m[l].u.p.name, m[l].u.p.serial);
+ addstr(buffer);
+ }
+ l++;
}
- l++;
}
- }
- if (line+2 >= LINES)
- {
- if (ltee)
+ if (line+2 >= LINES)
{
- color(cyan);
- move(line>1?line:1, 1);
- LLCORNER
+ if (ltee)
+ {
+ color(cyan);
+ move(line>1?line:1, 1);
+ LLCORNER
+ }
+ goto end;
}
- goto end;
}
+ j++;
}
- j++;
- }
- if (ltee)
- {
- color(cyan);
- move(line>1?line:1, 1);
- LLCORNER
- }
- if (line+2 >= LINES) goto end;
- /* show summary if no channels were shown */
- if (show_interfaces<2 && ltee==0)
- {
- color(cyan);
- move(++line>1?line:1, 1);
- LLCORNER
-
- if (m[i].u.i.l2link)
+ if (ltee)
{
- color(green);
- SPRINT(buffer,"all %d channels free", m[i].u.i.channels);
- } else
+ color(cyan);
+ move(line>1?line:1, 1);
+ LLCORNER
+ }
+ if (line+2 >= LINES) goto end;
+ /* show summary if no channels were shown */
+ if (show_interfaces<2 && ltee==0)
{
- color(red);
- SPRINT(buffer,"all %d channels blocked", m[i].u.i.channels);
+ color(cyan);
+ move(++line>1?line:1, 1);
+ LLCORNER
+
+ if (m[i].u.i.l2link && m[i].u.i.block==0)
+ {
+ color(green);
+ SPRINT(buffer,"all %d channels free", m[i].u.i.channels);
+ } else
+ {
+ color(red);
+ SPRINT(buffer,"all %d channels blocked", m[i].u.i.channels);
+ }
+ addstr(buffer);
}
- addstr(buffer);
+ if (line+2 >= LINES) goto end;
}
- if (line+2 >= LINES) goto end;
}
i++;
anything = 1;
{
move(line++>1?line-1:1, 0);
color(blue);
- hline(/*ACS_HLINE*/'q', COLS);
+ hline(ACS_HLINE, COLS);
color(white);
l = logcur-(LINES-line-2);
move(0, 0);
color(white);
msg.u.s.version_string[sizeof(msg.u.s.version_string)-1] = '\0';
- SPRINT(buffer, "PBX4Linux %s", msg.u.s.version_string);
+ SPRINT(buffer, "LCR %s", msg.u.s.version_string);
addstr(buffer);
if (COLS>50)
{
/* displeay head line */
move(1, 0);
color(blue);
- hline(/*ACS_HLINE*/'q', COLS);
+ hline(ACS_HLINE, COLS);
if (offset)
{
move(1, 1);
/* display end */
move(LINES-2, 0);
color(white);
- hline(/*ACS_HLINE*/'q', COLS);
+ hline(ACS_HLINE, COLS);
move(LINES-1, 0);
color(white);
SPRINT(buffer, "i = interfaces '%s' c = calls '%s' l = log q = quit +/- = scroll", text_interfaces[show_interfaces], text_calls[show_calls]);
msg.message = ADMIN_REQUEST_CMD_RELEASE;
SCPY(msg.u.x.message, number);
break;
+ case MODE_UNBLOCK:
+ msg.message = ADMIN_REQUEST_CMD_BLOCK;
+ msg.u.x.portnum = atoi(number);
+ msg.u.x.block = 0;
+ break;
+ case MODE_BLOCK:
+ msg.message = ADMIN_REQUEST_CMD_BLOCK;
+ msg.u.x.portnum = atoi(number);
+ msg.u.x.block = 1;
+ break;
+ case MODE_UNLOAD:
+ msg.message = ADMIN_REQUEST_CMD_BLOCK;
+ msg.u.x.portnum = atoi(number);
+ msg.u.x.block = 2;
+ break;
}
if (write(sock, &msg, sizeof(msg)) != sizeof(msg))
if (msg.message != ADMIN_RESPONSE_CMD_RELEASE)
return("Response not valid.");
break;
+ case MODE_UNBLOCK:
+ case MODE_BLOCK:
+ case MODE_UNLOAD:
+ if (msg.message != ADMIN_RESPONSE_CMD_BLOCK)
+ return("Response not valid.");
+ break;
}
/* process response */
printf("\n");
printf("Usage: %s state | interface | route | dial ...\n", argv[0]);
printf("state - View current states using graphical console output.\n");
- printf("interface - Tell PBX to reload \"interface.conf\".\n");
- printf("route - Tell PBX to reload \"route.conf\".\n");
- printf("dial <extension> <number> - Tell PBX the next number to dial for extension.\n");
- printf("release <number> - Tell PBX to release endpoint with given number.\n");
+ printf("interface - Tell LCR to reload \"interface.conf\".\n");
+ printf("route - Tell LCR to reload \"route.conf\".\n");
+ printf("dial <extension> <number> - Tell LCR the next number to dial for extension.\n");
+ printf("release <number> - Tell LCR to release endpoint with given number.\n");
+ printf("block <port> - Block given port.\n");
+ printf("unblock <port> - Unblock given port.\n");
+ printf("unload <port> - Unload port. To load port use 'block' or 'unblock'.\n");
printf("testcall <interface> <callerid> <number> [present|restrict [<capability>]] - Testcall\n");
printf(" -> capability = <bc> <mode> <codec> <hlc> <exthlc> (Values must be numbers, -1 to omit.)\n");
printf("trace [brief|short] [<filter> [...]] - Shows call trace. Use filter to reduce output.\n");
goto usage;
mode = MODE_RELEASE;
} else
+ if (!(strcasecmp(argv[1],"unblock")))
+ {
+ if (argc <= 2)
+ goto usage;
+ mode = MODE_UNBLOCK;
+ } else
+ if (!(strcasecmp(argv[1],"block")))
+ {
+ if (argc <= 2)
+ goto usage;
+ mode = MODE_BLOCK;
+ } else
+ if (!(strcasecmp(argv[1],"unload")))
+ {
+ if (argc <= 2)
+ goto usage;
+ mode = MODE_UNLOAD;
+ } else
if (!(strcasecmp(argv[1],"testcall")))
{
if (argc <= 4)
if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
{
close(sock);
- fprintf(stderr, "Failed to connect to socket \"%s\".\nIs PBX4Linux running?\n", sock_address.sun_path);
+ fprintf(stderr, "Failed to connect to socket \"%s\".\nIs LCR running?\n", sock_address.sun_path);
exit(EXIT_FAILURE);
}
break;
case MODE_RELEASE:
+ case MODE_UNBLOCK:
+ case MODE_BLOCK:
+ case MODE_UNLOAD:
ret = admin_cmd(sock, mode, NULL, argv[2]);
break;
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = ADMIN_RESPONSE_CMD_INTERFACE;
apppbx->release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL);
start_trace(0,
NULL,
- nationalize(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype),
- apppbx->e_dialinginfo.number,
+ numberrize_callerinfo(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype),
+ apppbx->e_dialinginfo.id,
DIRECTION_NONE,
CATEGORY_EP,
- apppbx->e_serial,
+ apppbx->ea_endpoint->ep_serial,
"KICK (reload routing)");
}
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = ADMIN_RESPONSE_CMD_ROUTE;
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = ADMIN_RESPONSE_CMD_DIAL;
/*
+ * do blocking
+ *
+ * 0 = make port available
+ * 1 = make port administratively blocked
+ * 2 = unload port
+ * the result is returned:
+ * 0 = port is now available
+ * 1 = port is now blocked
+ * 2 = port cannot be loaded or has been unloaded
+ * -1 = port doesn't exist
+ */
+int admin_block(struct admin_queue **responsep, int portnum, int block)
+{
+ struct admin_queue *response; /* response pointer */
+ struct interface *interface;
+ struct interface_port *ifport;
+
+ /* create block response */
+ response = (struct admin_queue *)malloc(sizeof(struct admin_queue)+sizeof(admin_message));
+ if (!response)
+ return(-1);
+ memuse++;
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
+ response->num = 1;
+ /* message */
+ response->am[0].message = ADMIN_RESPONSE_CMD_BLOCK;
+ response->am[0].u.x.portnum = portnum;
+
+ /* search for port */
+ interface = interface_first;
+ while(interface)
+ {
+ ifport = interface->ifport;
+ while(ifport)
+ {
+ if (ifport->portnum == portnum)
+ break;
+ ifport = ifport->next;
+ }
+ if (ifport)
+ break;
+ interface = interface->next;
+ }
+ /* not found, we return -1 */
+ if (!ifport)
+ {
+ response->am[0].u.x.block = -1;
+ response->am[0].u.x.error = 1;
+ SPRINT(response->am[0].u.x.message, "Port %d does not exist.", portnum);
+ goto out;
+ }
+
+ /* no interface */
+ if (!ifport->mISDNport)
+ {
+ /* not loaded anyway */
+ if (block >= 2)
+ {
+ response->am[0].u.x.block = 2;
+ goto out;
+ }
+
+ /* try loading interface */
+ ifport->block = block;
+ load_port(ifport);
+
+ /* port cannot load */
+ if (ifport->block >= 2)
+ {
+ response->am[0].u.x.block = 2;
+ response->am[0].u.x.error = 1;
+ SPRINT(response->am[0].u.x.message, "Port %d will not load.", portnum);
+ goto out;
+ }
+
+ /* port loaded */
+ response->am[0].u.x.block = ifport->block;
+ goto out;
+ }
+
+ /* if we shall unload interface */
+ if (block >= 2)
+ {
+ mISDNport_close(ifport->mISDNport);
+ ifport->mISDNport = 0;
+ ifport->block = 2;
+ goto out;
+ }
+
+ /* port new blocking state */
+ ifport->block = response->am[0].u.x.block = block;
+
+ out:
+ /* attach to response chain */
+ *responsep = response;
+ responsep = &response->next;
+ return(0);
+}
+
+
+/*
* do release
*/
int admin_release(struct admin_queue **responsep, char *message)
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = ADMIN_RESPONSE_CMD_RELEASE;
apppbx->e_capainfo.bearer_info1 = msg->u.call.bc_info1;
apppbx->e_capainfo.hlc = msg->u.call.hlc;
apppbx->e_capainfo.exthlc = msg->u.call.exthlc;
- SCPY(apppbx->e_dialinginfo.number, msg->u.call.dialing);
+ SCPY(apppbx->e_dialinginfo.id, msg->u.call.dialing);
SCPY(apppbx->e_dialinginfo.interfaces, msg->u.call.interface);
apppbx->e_dialinginfo.sending_complete = 1;
if (!response)
return;
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = message;
class EndpointAppPBX *apppbx;
class Call *call;
class Pdss1 *pdss1;
+ struct interface *interface;
+ struct interface_port *ifport;
struct mISDNport *mISDNport;
int i;
int num;
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue));
+ memset(response, 0, sizeof(admin_queue)+sizeof(admin_message));
response->num = 1;
/* message */
response->am[0].message = ADMIN_RESPONSE_STATE;
/* log file */
SCPY(response->am[0].u.s.logfile, options.log);
/* interface count */
- mISDNport = mISDNport_first;
i = 0;
- while(mISDNport)
+ interface = interface_first;
+ while(interface)
{
- i++;
- mISDNport = mISDNport->next;
+ ifport = interface->ifport;
+ while(ifport)
+ {
+ i++;
+ ifport = ifport->next;
+ }
+ interface = interface->next;
}
response->am[0].u.s.interfaces = i;
/* call count */
}
response->am[0].u.s.epoints = i;
/* port count */
- port = port_first;
i = 0;
+ port = port_first;
while(port)
{
i++;
/* create response for all interfaces */
num = (response->am[0].u.s.interfaces)+(response->am[0].u.s.calls)+(response->am[0].u.s.epoints)+(response->am[0].u.s.ports);
+ if (num == 0)
+ return(0);
response = (struct admin_queue *)malloc(sizeof(admin_queue)+(num*sizeof(admin_message)));
if (!response)
return(-1);
memuse++;
- memset(response, 0, sizeof(admin_queue)+(num*sizeof(admin_queue)));
+ memset(response, 0, sizeof(admin_queue)+(num*sizeof(admin_message)));
response->num = num;
*responsep = response;
responsep = &response->next;
- mISDNport = mISDNport_first;
+ interface = interface_first;
num = 0;
- while(mISDNport)
+ while(interface)
{
- /* message */
- response->am[num].message = ADMIN_RESPONSE_S_INTERFACE;
- /* portnum */
- response->am[num].u.i.portnum = mISDNport->portnum;
- /* interface */
- SCPY(response->am[num].u.i.interface_name, mISDNport->interface_name);
- /* iftype */
- response->am[num].u.i.iftype = mISDNport->iftype;
- /* ptp */
- response->am[num].u.i.ptp = mISDNport->ptp;
- /* ntmode */
- response->am[num].u.i.ntmode = mISDNport->ntmode;
- /* pri */
- response->am[num].u.i.pri = mISDNport->pri;
- /* use */
- response->am[num].u.i.use = mISDNport->use;
- /* l1link */
- response->am[num].u.i.l1link = mISDNport->l1link;
- /* l2link */
- response->am[num].u.i.l2link = mISDNport->l2link;
- /* channels */
- response->am[num].u.i.channels = mISDNport->b_num;
- /* channel info */
- i = 0;
- anybusy = 0;
- while(i < mISDNport->b_num)
+ ifport = interface->ifport;
+ while(ifport)
{
- response->am[num].u.i.busy[i] = mISDNport->b_state[i];
- if (mISDNport->b_port[i])
- response->am[num].u.i.port[i] = mISDNport->b_port[i]->p_serial;
- i++;
+ /* message */
+ response->am[num].message = ADMIN_RESPONSE_S_INTERFACE;
+ /* interface */
+ SCPY(response->am[num].u.i.interface_name, interface->name);
+ /* portnum */
+ response->am[num].u.i.portnum = ifport->portnum;
+ /* iftype */
+ response->am[num].u.i.extension = interface->extension;
+ /* block */
+ response->am[num].u.i.block = ifport->block;
+ if (ifport->mISDNport)
+ {
+ mISDNport = ifport->mISDNport;
+
+ /* ptp */
+ response->am[num].u.i.ptp = mISDNport->ptp;
+ /* ntmode */
+ response->am[num].u.i.ntmode = mISDNport->ntmode;
+ /* pri */
+ response->am[num].u.i.pri = mISDNport->pri;
+ /* use */
+ response->am[num].u.i.use = mISDNport->use;
+ /* l1link */
+ response->am[num].u.i.l1link = mISDNport->l1link;
+ /* l2link */
+ response->am[num].u.i.l2link = mISDNport->l2link;
+ /* channels */
+ response->am[num].u.i.channels = mISDNport->b_num;
+ /* channel info */
+ i = 0;
+ anybusy = 0;
+ while(i < mISDNport->b_num)
+ {
+ response->am[num].u.i.busy[i] = mISDNport->b_state[i];
+ if (mISDNport->b_port[i])
+ response->am[num].u.i.port[i] = mISDNport->b_port[i]->p_serial;
+ i++;
+ }
+ }
+ num++;
+
+ ifport = ifport->next;
}
- mISDNport = mISDNport->next;
- num++;
+ interface = interface->next;
}
/* create response for all calls */
/* callerid */
SCPY(response->am[num].u.e.callerid, apppbx->e_callerinfo.id);
/* dialing */
- SCPY(response->am[num].u.e.dialing, apppbx->e_dialinginfo.number);
+ SCPY(response->am[num].u.e.dialing, apppbx->e_dialinginfo.id);
/* action string */
if (apppbx->e_action)
SCPY(response->am[num].u.e.action, action_defs[apppbx->e_action->index].name);
PERROR("Failed to create state response for socket %d.\n", admin->sock);
goto response_error;
}
- case ADMIN_REQUEST_MESSAGE:
+ break;
+
+ case ADMIN_REQUEST_CMD_BLOCK:
+ if (admin_block(&admin->response, msg.u.x.portnum, msg.u.x.block) < 0)
+ {
+ PERROR("Failed to create block response for socket %d.\n", admin->sock);
+ goto response_error;
+ }
+ break;
+
+#warning interface tbd
+#if 0
+ case ADMIN_MESSAGE:
if (admin_message(&admin->response) < 0)
{
PERROR("Failed to create message response for socket %d.\n", admin->sock);
- response_error:
- *adminp = admin->next;
- free_connection(admin);
- admin = *adminp;
- continue;
+ goto response_error;
}
+#endif
#if 0
#warning DEBUGGING
{
if (admin_call(admin, &msg))
{
PERROR("Failed to create call for socket %d.\n", admin->sock);
- goto response_error;
+ response_error:
+ *adminp = admin->next;
+ free_connection(admin);
+ admin = *adminp;
+ continue;
}
break;
e_match_timeout = 0;
e_match_to_action = NULL;
e_select = 0;
- e_extdialing = e_dialinginfo.number;
+ e_extdialing = e_dialinginfo.id;
// e_knocking = 0;
// e_knocktime = 0;
e_hold = 0;
start_trace(ea_endpoint->ep_serial,
NULL,
numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype),
- e_dialinginfo.number,
+ e_dialinginfo.id,
direction,
CATEGORY_EP,
ea_endpoint->ep_serial,
e_match_timeout = 0;
e_match_to_action = NULL;
//e_select = 0;
- e_extdialing = e_dialinginfo.number;
+ e_extdialing = e_dialinginfo.id;
e_connectedmode = 0;
e_dtmf = 0;
e_dtmf_time = 0;
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) preparing callback to internal: %s interface %s\n", ea_endpoint->ep_serial, e_ext.number, e_extension_interface);
/* create callback to the current terminal */
- SCPY(e_dialinginfo.number, e_ext.number);
+ SCPY(e_dialinginfo.id, e_ext.number);
SCPY(e_dialinginfo.interfaces, e_extension_interface);
e_dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION;
e_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
{
if (e_cbto[0])
{
- SCPY(e_dialinginfo.number, e_cbto);
+ SCPY(e_dialinginfo.id, e_cbto);
} else
{
/* numberrize caller id and use it to dial to the callback */
- SCPY(e_dialinginfo.number, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype));
+ SCPY(e_dialinginfo.id, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype));
}
e_dialinginfo.itype = INFO_ITYPE_ISDN;
e_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) preparing callback to external: %s\n", ea_endpoint->ep_serial, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) preparing callback to external: %s\n", ea_endpoint->ep_serial, e_dialinginfo.id);
}
return;
}
/* cancel callerid if restricted, unless anon-ignore is enabled at extension or port is of type external (so called police gets caller id :)*/
-void apply_callerid_restriction(int anon_ignore, int port_type, char *id, int *ntype, int *present, int *screen, char *voip, char *extension, char *name)
+void apply_callerid_restriction(int anon_ignore, char *id, int *ntype, int *present, int *screen, char *extension, char *name)
{
- PDEBUG(DEBUG_EPOINT, "id='%s' ntype=%d present=%d screen=%d voip='%s' extension='%s' name='%s'\n", (id)?id:"NULL", (ntype)?*ntype:-1, (present)?*present:-1, (screen)?*screen:-1, (voip)?voip:"NULL", (extension)?extension:"NULL", (name)?name:"NULL");
+ PDEBUG(DEBUG_EPOINT, "id='%s' ntype=%d present=%d screen=%d extension='%s' name='%s'\n", (id)?id:"NULL", (ntype)?*ntype:-1, (present)?*present:-1, (screen)?*screen:-1, (extension)?extension:"NULL", (name)?name:"NULL");
/* caller id is not restricted, so we do nothing */
if (*present != INFO_PRESENT_RESTRICTED)
}
/* used display message to display callerid as available */
-char *EndpointAppPBX::apply_callerid_display(char *id, int itype, int ntype, int present, int screen, char *voip, char *extension, char *name)
+char *EndpointAppPBX::apply_callerid_display(char *id, int itype, int ntype, int present, int screen, char *extension, char *name)
{
static char display[81];
display[0] = '\0';
char *cid = numberrize_callerinfo(id, ntype);
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) id='%s' itype=%d ntype=%d present=%d screen=%d voip='%s' extension='%s' name='%s'\n", ea_endpoint->ep_serial, (id)?id:"NULL", itype, ntype, present, screen, (voip)?voip:"NULL", (extension)?extension:"NULL", (name)?name:"NULL");
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) id='%s' itype=%d ntype=%d present=%d screen=%d extension='%s' name='%s'\n", ea_endpoint->ep_serial, (id)?id:"NULL", itype, ntype, present, screen, (extension)?extension:"NULL", (name)?name:"NULL");
if (!id)
id = "";
- if (!voip)
- voip = "";
if (!extension)
extension = "";
if (!name)
}
/* external caller id */
- if (!extension[0] && !voip[0] && e_ext.display_ext)
+ if (!extension[0] && e_ext.display_ext)
{
if (!display[0])
{
}
}
- /* voip caller id */
- if (voip[0] && e_ext.display_voip)
- {
- if (!display[0] && cid[0])
- SCAT(display, cid);
- if (display[0])
- SCAT(display, " ");
- SCAT(display, voip);
- }
-
/* display if callerid is anonymouse but available due anon-ignore */
if (e_ext.display_anon && present==INFO_PRESENT_RESTRICTED)
{
{
struct interface *interface;
struct interface_port *ifport, *ifport_start;
+ struct select_channel *selchannel;
struct mISDNport *mISDNport;
+ int index, i;
interface = interface_first;
trace_header("CHANNEL SELECTION (found interface)", DIRECTION_NONE);
add_trace("interface", NULL, "%s", ifname);
end_trace();
- goto found;
+ goto foundif;
}
} else
trace_header("CHANNEL SELECTION (found non extension interface)", DIRECTION_NONE);
add_trace("interface", NULL, "%s", interface->name);
end_trace();
- goto found;
+ goto foundif;
}
}
interface = interface->next;
goto checknext;
+foundif:
/* see if interface has ports */
if (!interface->ifport)
}
/* select port by algorithm */
- ifport_start = interface->port;
+ ifport_start = interface->ifport;
index = 0;
if (interface->hunt == HUNT_ROUNDROBIN)
{
while(ifport_start->next && index<interface->hunt_next)
{
ifport_start = ifport_start->next;
- i++;
+ index++;
}
trace_header("CHANNEL SELECTION (starting round-robin)", DIRECTION_NONE);
add_trace("port", NULL, "%d", ifport_start->portnum);
}
mISDNport = ifport->mISDNport;
-#warning admin block auch bei incomming calls
-#warning calls releasen, wenn port entfernt wird, geblockt wird
/* see if port is administratively blocked */
if (ifport->block)
{
/* check for channel form selection list */
*channel = 0;
- selchannel = ifport->selchannel;
+ selchannel = ifport->out_channel;
while(selchannel)
{
switch(selchannel->channel)
{
case CHANNEL_FREE: /* free channel */
- if (mISDNport->b_inuse >= mISDNport->b_num)
+ if (mISDNport->b_reserved >= mISDNport->b_num)
break; /* all channel in use or reserverd */
/* find channel */
i = 0;
break;
case CHANNEL_ANY: /* don't ask for channel */
- if (mISDNport->b_inuse >= mISDNport->b_num)
+ if (mISDNport->b_reserved >= mISDNport->b_num)
{
break; /* all channel in use or reserverd */
}
add_trace("port", NULL, "%d", ifport->portnum);
add_trace("position", NULL, "%d", index);
end_trace();
- *channel = SEL_CHANNEL_ANY;
+ *channel = CHANNEL_ANY;
break;
case CHANNEL_NO: /* call waiting */
add_trace("port", NULL, "%d", ifport->portnum);
add_trace("position", NULL, "%d", index);
end_trace();
- *channel = SEL_CHANNEL_NO;
+ *channel = CHANNEL_NO;
break;
default:
class EndpointAppPBX *atemp;
// char allowed_ports[256];
// char exten[256];
- int i, ii;
- int use;
char ifname[sizeof(e_ext.interfaces)],
number[256];
struct port_settings port_settings;
int channel = 0;
+ int earlyb;
/* create settings for creating port */
memset(&port_settings, 0, sizeof(port_settings));
/* FALL THROUGH !!!! */
case INFO_ITYPE_VBOX:
/* get dialed extension's info */
-// SCPY(exten, e_dialinginfo.number);
+// SCPY(exten, e_dialinginfo.id);
// if (strchr(exten, ','))
// *strchr(exten, ',') = '\0';
// if (!read_extension(&e_ext, exten))
- if (!read_extension(&e_ext, e_dialinginfo.number))
+ if (!read_extension(&e_ext, e_dialinginfo.id))
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) extension %s not configured\n", ea_endpoint->ep_serial, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) extension %s not configured\n", ea_endpoint->ep_serial, e_dialinginfo.id);
release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_OUTOFORDER, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); /* RELEASE_TYPE, call, port */
return; /* must exit here */
}
/* call to all internal interfaces */
p = e_ext.interfaces;
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) generating multiple calls for extension %s to interfaces %s\n", ea_endpoint->ep_serial, e_dialinginfo.number, p);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) generating multiple calls for extension %s to interfaces %s\n", ea_endpoint->ep_serial, e_dialinginfo.id, p);
while(*p)
{
ifname[0] = '\0';
continue;
}
/* creating INTERNAL port */
- SPRINT(portname, "%s-%d-out", mISDNport->interface_name, mISDNport->portnum);
- port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport.channel_force);
+ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum);
+ port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force);
if (!port)
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) port '%s' failed to create\n", ea_endpoint->ep_serial, mISDNport->interface_name);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) port '%s' failed to create\n", ea_endpoint->ep_serial, mISDNport->ifport->interface->name);
goto check_anycall_intern;
}
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) got port %s\n", ea_endpoint->ep_serial, port->p_name);
memset(&dialinginfo, 0, sizeof(dialinginfo));
- SCPY(dialinginfo.number, e_dialinginfo.number);
+ SCPY(dialinginfo.id, e_dialinginfo.id);
dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION;
dialinginfo.ntype = e_dialinginfo.ntype;
/* create port_list relation */
- portlist = ea_endpoint->portlist_new(port->p_serial, port->p_type, mISDNport->is_earlyb);
+ portlist = ea_endpoint->portlist_new(port->p_serial, port->p_type, mISDNport->earlyb);
if (!portlist)
{
PERROR("EPOINT(%d) cannot allocate port_list relation\n", ea_endpoint->ep_serial);
}
// dss1 = (class Pdss1 *)port;
/* message */
-//printf("INTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.number);
+//printf("INTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.id);
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info));
memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info));
memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info));
//terminal SCPY(message->param.setup.from_terminal, e_ext.number);
-//terminal if (e_dialinginfo.number)
-//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number);
+//terminal if (e_dialinginfo.id)
+//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id);
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name);
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, NULL, message->param.setup.redirinfo.voip, message->param.setup.redirinfo.intern, 0);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL);
/* display callerid if desired for extension */
- SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name));
+ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name));
//printf("\n\ndisplay = %s\n\n\n",message->param.setup.callerinfo.display);
/* use cnip, if enabld */
if (!e_ext.centrex)
message->param.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
}
/* use internal caller id */
- if (e_callerinfo.intern[0] && (message->param.setup.callerinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore))
+ if (e_callerinfo.extension[0] && (message->param.setup.callerinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore))
{
- SCPY(message->param.setup.callerinfo.id, e_callerinfo.intern);
+ SCPY(message->param.setup.callerinfo.id, e_callerinfo.extension);
message->param.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
}
message_put(message);
cfu_only: /* entry point for cfu */
cfb_only: /* entry point for cfb */
cfnr_only: /* entry point for cfnr */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call extension %s for external destiantion(s) '%s'\n", ea_endpoint->ep_serial, e_dialinginfo.number, p);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call extension %s for external destiantion(s) '%s'\n", ea_endpoint->ep_serial, e_dialinginfo.id, p);
// i=0;
while(*p)
{
- /* only if vbox should be dialed, and terminal is given */
earlyb = 0;
+ /* only if vbox should be dialed, and terminal is given */
if (!strcmp(p, "vbox") && e_ext.number[0])
{
/* go to the end of p */
SCCAT(cfp, *p++);
if (*p == ',')
p++;
- hier auch wie oben
/* external call */
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cfp external %s\n", ea_endpoint->ep_serial, cfp);
/* hunt for mISDNport and create Port */
- mISDNport = mISDNport_first;
- port = NULL;
- while(mISDNport)
- {
- /* check for external or given interface */
- if (((!e_dialinginfo.interfaces[0])&&mISDNport->iftype==IF_EXTERN) || !strcmp(mISDNport->interface_name, e_dialinginfo.interfaces))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) interface '%s' found\n", ea_endpoint->ep_serial, mISDNport->interface_name);
- cause = CAUSE_NOCHANNEL; /* when failing: out of channels */
- /* if PTP, skip all down links */
- if (mISDNport->ptp && !mISDNport->l2link)
- {
- trace_header("INTERFACE (layer 2 is down)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- /* if no channel is available */
- if (mISDNport->multilink || !mISDNport->ntmode || mISDNport->ptp)
- {
- use = 0;
- i = 0;
- ii = mISDNport->b_num;
- while(i < ii)
- {
- if (mISDNport->b_state[i])
- use++;
- i++;
- }
- if (use >= mISDNport->b_num)
- {
- trace_header("INTERFACE (no free channel)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- }
- /* found interface */
- trace_header("INTERFACE (found)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- break;
- }
- mISDNport = mISDNport->next;
- }
+ mISDNport = hunt_port(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL, &channel);
if (mISDNport)
{
/* creating EXTERNAL port*/
- SPRINT(portname, "%s-%d-out", mISDNport->interface_name, mISDNport->portnum);
- port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings);
- earlyb = mISDNport->is_earlyb;
+ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum);
+ port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force);
+ earlyb = mISDNport->earlyb;
} else
{
port = NULL;
}
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) found or created port %s\n", ea_endpoint->ep_serial, port->p_name);
memset(&dialinginfo, 0, sizeof(dialinginfo));
- SCPY(dialinginfo.number, cfp);
- dialinginfo.itype = INFO_ITYPE_EXTERN;
+ SCPY(dialinginfo.id, cfp);
+ dialinginfo.itype = INFO_ITYPE_ISDN;
dialinginfo.ntype = e_dialinginfo.ntype;
portlist = ea_endpoint->portlist_new(port->p_serial, port->p_type, earlyb);
if (!portlist)
delete port;
goto check_anycall_intern;
}
-//printf("EXTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.number);
+//printf("EXTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.id);
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info));
if (e_ext.clip==CLIP_HIDE && port->p_type!=PORT_TYPE_VBOX_OUT)
{
SCPY(message->param.setup.callerinfo.id, e_ext.callerid);
- SCPY(message->param.setup.callerinfo.intern, e_ext.number);
+ SCPY(message->param.setup.callerinfo.extension, e_ext.number);
message->param.setup.callerinfo.ntype = e_ext.callerid_type;
message->param.setup.callerinfo.present = e_ext.callerid_present;
}
memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info));
//terminal SCPY(message->param.setup.from_terminal, e_ext.number);
-//terminal if (e_dialinginfo.number)
-//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number);
+//terminal if (e_dialinginfo.id)
+//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id);
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name);
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, NULL, message->param.setup.redirinfo.voip, message->param.setup.redirinfo.intern, 0);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL);
/* display callerid if desired for extension */
- SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name));
+ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name));
message_put(message);
logmessage(message);
anycall = 1;
/* *********************** external call */
default:
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dialing external: '%s'\n", ea_endpoint->ep_serial, e_dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dialing external: '%s'\n", ea_endpoint->ep_serial, e_dialinginfo.id);
/* call to extenal interfaces */
- p = e_dialinginfo.number;
+ p = e_dialinginfo.id;
do
{
number[0] = '\0';
/* found number */
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) calling to number '%s' interface '%s'\n", ea_endpoint->ep_serial, number, e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface");
/* hunt for mISDNport and create Port */
- mISDNport = mISDNport_first;
- port = NULL;
- while(mISDNport)
+ /* hunt for mISDNport and create Port */
+ mISDNport = hunt_port(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL, &channel);
+ if (mISDNport)
{
- /* check for external or given interface */
- if ((!e_dialinginfo.interfaces[0]&&mISDNport->iftype==IF_EXTERN) || !strcmp(mISDNport->interface_name, e_dialinginfo.interfaces))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) interface '%s' found\n", ea_endpoint->ep_serial, mISDNport->interface_name);
- cause = CAUSE_NOCHANNEL; /* when failing: out of channels */
- /* if PTP, skip all down links */
- if (mISDNport->ptp && !mISDNport->l2link)
- {
- trace_header("INTERFACE (layer 2 is down)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- /* if no channel is available */
- if (mISDNport->multilink || !mISDNport->ntmode || mISDNport->ptp)
- {
- use = 0;
- i = 0;
- ii = mISDNport->b_num;
- while(i < ii)
- {
- if (mISDNport->b_state[i])
- use++;
- i++;
- }
- if (use >= mISDNport->b_num)
- {
- trace_header("INTERFACE (no free channel)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- }
- /* found interface */
- trace_header("INTERFACE (found)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- break;
- }
- mISDNport = mISDNport->next;
- }
- if (!mISDNport)
+ /* creating EXTERNAL port*/
+ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum);
+ port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force);
+ earlyb = mISDNport->earlyb;
+ } else
{
trace_header("INTERFACE (too busy)", DIRECTION_NONE);
add_trace("interface", NULL, "%s", e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface");
end_trace();
goto check_anycall_extern;
}
- /* creating EXTERNAL port*/
- SPRINT(portname, "%s-%d-out", mISDNport->interface_name, mISDNport->portnum);
- port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings);
if (!port)
{
PERROR("EPOINT(%d) no memory for external port, exitting\n", ea_endpoint->ep_serial);
}
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) created port %s\n", ea_endpoint->ep_serial, port->p_name);
memset(&dialinginfo, 0, sizeof(dialinginfo));
- SCPY(dialinginfo.number, number);
- dialinginfo.itype = INFO_ITYPE_EXTERN;
+ SCPY(dialinginfo.id, number);
+ dialinginfo.itype = INFO_ITYPE_ISDN;
dialinginfo.ntype = e_dialinginfo.ntype;
- portlist = ea_endpoint->portlist_new(port->p_serial, port->p_type, mISDNport->is_earlyb);
+ portlist = ea_endpoint->portlist_new(port->p_serial, port->p_type, mISDNport->earlyb);
if (!portlist)
{
PERROR("EPOINT(%d) cannot allocate port_list relation\n", ea_endpoint->ep_serial);
goto check_anycall_extern;
}
// dss1 = (class Pdss1 *)port;
-//printf("EXTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.number);
+//printf("EXTERNAL caller=%s,id=%s,dial=%s\n", param.setup.networkid, param.setup.callerinfo.id, param.setup.dialinginfo.id);
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
- SCPY(message->param.setup.dialinginfo.number, number);
+ SCPY(message->param.setup.dialinginfo.id, number);
memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info));
memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info));
memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info));
//terminal SCPY(message->param.setup.from_terminal, e_ext.number);
-//terminal if (e_dialinginfo.number)
-//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number);
+//terminal if (e_dialinginfo.id)
+//terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id);
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name);
- apply_callerid_restriction(e_ext.anon_ignore, port->p_type, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, NULL, message->param.setup.redirinfo.voip, message->param.setup.redirinfo.intern, 0);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL);
/* display callerid if desired for extension */
- SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.voip, message->param.setup.callerinfo.intern, message->param.setup.callerinfo.name));
+ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name));
message_put(message);
logmessage(message);
anycall = 1;
e_action = NULL;
new_state(EPOINT_STATE_IN_OVERLAP);
e_connectedmode = 1;
- SCPY(e_dialinginfo.number, e_ext.prefix);
- e_extdialing = e_dialinginfo.number;
+ SCPY(e_dialinginfo.id, e_ext.prefix);
+ e_extdialing = e_dialinginfo.id;
e_call_pattern = 0;
- if (e_dialinginfo.number[0])
+ if (e_dialinginfo.id[0])
{
set_tone(ea_endpoint->ep_portlist, "dialing");
process_dialing();
{
struct message *message;
char buffer[256];
- char extension[32];
- char extension1[32];
- char *p;
int writeext; /* flags need to write extension after modification */
class Port *port;
/* screen incoming caller id */
screen(0, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present);
-colp, outclip, outcolp
/* process extension */
- if (e_callerinfo.itype == INFO_ITYPE_INTERN)
+ if (e_callerinfo.itype == INFO_ITYPE_ISDN_EXTENSION)
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call is extension\n", ea_endpoint->ep_serial);
/* port makes call from extension */
- SCPY(e_callerinfo.intern, e_callerinfo.id);
- SCPY(e_ext.number, e_callerinfo.intern);
+ SCPY(e_callerinfo.extension, e_callerinfo.id);
+ SCPY(e_ext.number, e_callerinfo.extension);
SCPY(e_extension_interface, e_callerinfo.interface);
} else
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call is external or voip\n", ea_endpoint->ep_serial);
}
trace_header("SETUP", DIRECTION_IN);
- if (e_callerinfo.intern[0])
- add_trace("extension", NULL, "%s", e_callerinfo.intern);
+ if (e_callerinfo.extension[0])
+ add_trace("extension", NULL, "%s", e_callerinfo.extension);
add_trace("caller id", "number", "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype));
if (e_callerinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("caller id", "present", "restricted");
if (e_redirinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("redir'ing", "present", "restricted");
}
- if (e_dialinginfo.number)
- add_trace("dialing", "number", "%s", e_dialinginfo.number));
+ if (e_dialinginfo.id)
+ add_trace("dialing", "number", "%s", e_dialinginfo.id);
end_trace();
- if (e_callerinfo.itype == INFO_ITYPE_INTERN)
+ if (e_callerinfo.itype == INFO_ITYPE_ISDN_EXTENSION)
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call from extension '%s'\n", ea_endpoint->ep_serial, e_ext.number);
}
writeext = 0;
- /* put prefix (next) in front of e_dialinginfo.number */
+ /* put prefix (next) in front of e_dialinginfo.id */
if (e_ext.next[0])
{
- SPRINT(buffer, "%s%s", e_ext.next, e_dialinginfo.number);
- SCPY(e_dialinginfo.number, buffer);
+ SPRINT(buffer, "%s%s", e_ext.next, e_dialinginfo.id);
+ SCPY(e_dialinginfo.id, buffer);
e_ext.next[0] = '\0';
writeext = 1;
} else if (e_ext.prefix[0])
{
- SPRINT(buffer, "%s%s", e_ext.prefix, e_dialinginfo.number);
- SCPY(e_dialinginfo.number, buffer);
+ SPRINT(buffer, "%s%s", e_ext.prefix, e_dialinginfo.id);
+ SCPY(e_dialinginfo.id, buffer);
}
- /* screen caller id */
+ /* screen caller id by extension's config */
e_callerinfo.screen = INFO_SCREEN_NETWORK;
if (e_ext.name[0])
SCPY(e_callerinfo.name, e_ext.name);
write_extension(&e_ext, e_ext.number);
/* set volume of rx and tx */
- if (param->setup.callerinfo.itype == INFO_ITYPE_INTERN)
+ if (param->setup.callerinfo.itype == INFO_ITYPE_ISDN_EXTENSION)
if (e_ext.txvol!=256 || e_ext.rxvol!=256)
{
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_mISDNSIGNAL);
if (e_ruleset)
e_rule = e_ruleset->rule_first;
e_action = NULL;
- e_extdialing = e_dialinginfo.number;
+ e_extdialing = e_dialinginfo.id;
new_state(EPOINT_STATE_IN_SETUP);
- if (e_dialinginfo.number[0])
+ if (e_dialinginfo.id[0])
{
set_tone(portlist, "dialing");
} else
void EndpointAppPBX::port_information(struct port_list *portlist, int message_type, union parameter *param)
{
trace_header("INFORMATION", DIRECTION_IN);
- add_trace("dialing", NULL, "%s", param->information.number);
+ add_trace("dialing", NULL, "%s", param->information.id);
if (param->information.sending_complete)
add_trace("complete", NULL, NULL);
end_trace();
/* turn off dtmf detection, in case dtmf is sent with keypad information */
if (e_dtmf)
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received dialing information, so dtmf is now disabled, to prevent double detection by keypad+dtmf.\n", ea_endpoint->ep_serial, param->information.number, e_ext.number, e_callerinfo.id);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received dialing information, so dtmf is now disabled, to prevent double detection by keypad+dtmf.\n", ea_endpoint->ep_serial, param->information.id, e_ext.number, e_callerinfo.id);
e_dtmf = 0;
}
if (e_action->index == ACTION_VBOX_PLAY)
{
/* concat dialing string */
- SCAT(e_dialinginfo.number, param->information.number);
+ SCAT(e_dialinginfo.id, param->information.id);
process_dialing();
return;
}
/* keypad when disconnect but in connected mode */
if (e_state==EPOINT_STATE_OUT_DISCONNECT && e_connectedmode)
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received after disconnect: %s.\n", ea_endpoint->ep_serial, param->information.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received after disconnect: %s.\n", ea_endpoint->ep_serial, param->information.id);
/* processing keypad function */
- if (param->information.number[0] == '0')
+ if (param->information.id[0] == '0')
{
hookflash();
}
/* keypad when connected */
if (e_state == EPOINT_STATE_CONNECT && e_ext.keypad)
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received during connect: %s.\n", ea_endpoint->ep_serial, param->information.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received during connect: %s.\n", ea_endpoint->ep_serial, param->information.id);
/* processing keypad function */
- if (param->information.number[0] == '0')
+ if (param->information.id[0] == '0')
{
hookflash();
}
- if (param->information.number[0])
- keypad_function(param->information.number[0]);
+ if (param->information.id[0])
+ keypad_function(param->information.id[0]);
return;
}
if (e_state != EPOINT_STATE_IN_OVERLAP)
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) ignored because we are not in overlap, or connect state.\n", ea_endpoint->ep_serial);
return;
}
- if (!param->information.number[0])
+ if (!param->information.id[0])
return;
- if (e_dialinginfo.number[0]=='\0' && !e_action)
+ if (e_dialinginfo.id[0]=='\0' && !e_action)
{
set_tone(portlist, "dialing");
}
set_tone(portlist, "dialing");
}
/* concat dialing string */
- SCAT(e_dialinginfo.number, param->information.number);
+ SCAT(e_dialinginfo.id, param->information.id);
process_dialing();
}
if (e_action->index == ACTION_VBOX_PLAY)
{
/* concat dialing string */
- if (strlen(e_dialinginfo.number)+1 < sizeof(e_dialinginfo.number))
+ if (strlen(e_dialinginfo.id)+1 < sizeof(e_dialinginfo.id))
{
- e_dialinginfo.number[strlen(e_dialinginfo.number)+1] = '\0';
- e_dialinginfo.number[strlen(e_dialinginfo.number)] = param->dtmf;
+ e_dialinginfo.id[strlen(e_dialinginfo.id)+1] = '\0';
+ e_dialinginfo.id[strlen(e_dialinginfo.id)] = param->dtmf;
process_dialing();
}
/* continue to process *X# sequences */
/* dialing using dtmf digit */
if (e_state==EPOINT_STATE_IN_OVERLAP)// && e_state==e_connectedmode)
{
- if (e_dialinginfo.number[0]=='\0' && !e_action)
+ if (e_dialinginfo.id[0]=='\0' && !e_action)
{
set_tone(portlist, "dialing");
}
/* concat dialing string */
- if (strlen(e_dialinginfo.number)+1 < sizeof(e_dialinginfo.number))
+ if (strlen(e_dialinginfo.id)+1 < sizeof(e_dialinginfo.id))
{
- e_dialinginfo.number[strlen(e_dialinginfo.number)+1] = '\0';
- e_dialinginfo.number[strlen(e_dialinginfo.number)] = param->dtmf;
+ e_dialinginfo.id[strlen(e_dialinginfo.id)+1] = '\0';
+ e_dialinginfo.id[strlen(e_dialinginfo.id)] = param->dtmf;
process_dialing();
}
}
/* send what we have not dialed yet, because we had no setup complete */
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dialing pending digits: '%s'\n", ea_endpoint->ep_serial, e_dialing_queue);
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_INFORMATION);
- SCPY(message->param.information.number, e_dialing_queue);
+ SCPY(message->param.information.id, e_dialing_queue);
message->param.information.ntype = INFO_NTYPE_UNKNOWN;
message_put(message);
logmessage(message);
e_dialing_queue[0] = '\0';
}
/* check if pattern is available */
- if (!ea_endpoint->ep_portlist->next && portlist->earlyb) /* one port_list relation and tones available */
+ if (!ea_endpoint->ep_portlist->next && portlist->early_b) /* one port_list relation and tones available */
{
/* indicate patterns */
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_PATTERN);
end_trace();
e_state = EPOINT_STATE_OUT_PROCEEDING;
/* check if pattern is availatle */
- if (!ea_endpoint->ep_portlist->next && (portlist->earlyb || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */
+ if (!ea_endpoint->ep_portlist->next && (portlist->early_b || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */
{
/* indicate patterns */
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_PATTERN);
end_trace();
new_state(EPOINT_STATE_OUT_ALERTING);
/* check if pattern is available */
- if (!ea_endpoint->ep_portlist->next && (portlist->earlyb || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */
+ if (!ea_endpoint->ep_portlist->next && (portlist->early_b || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */
{
/* indicate patterns */
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_PATTERN);
memcpy(&e_connectinfo, ¶m->connectinfo, sizeof(e_connectinfo));
trace_header("CONNECT", DIRECTION_IN);
- if (e_connectinfo.intern[0])
- add_trace("extension", NULL, "%s", e_connectinfo.intern);
+ if (e_connectinfo.extension[0])
+ add_trace("extension", NULL, "%s", e_connectinfo.extension);
add_trace("connect id", "number", "%s", numberrize_callerinfo(e_connectinfo.id, e_connectinfo.ntype));
if (e_connectinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("connect id", "present", "restricted");
e_start = now;
- /* screen incoming caller id */
+ /* screen incoming connected id */
screen(0, e_connectinfo.id, sizeof(e_connectinfo.id), &e_connectinfo.ntype, &e_connectinfo.present);
/* screen connected name */
SCPY(e_connectinfo.name, e_ext.name);
/* add internal id to colp */
- SCPY(e_connectinfo.intern, e_ext.number);
+ SCPY(e_connectinfo.extension, e_ext.number);
/* we store the connected port number */
SCPY(e_extension_interface, e_connectinfo.interfaces);
if (portlist->port_type==PORT_TYPE_VBOX_OUT || e_ext.colp==COLP_HIDE)
{
SCPY(e_connectinfo.id, e_ext.callerid);
- SCPY(e_connectinfo.intern, e_ext.number);
- e_connectinfo.itype = INFO_ITYPE_INTERN;
+ SCPY(e_connectinfo.extension, e_ext.number);
+ e_connectinfo.itype = INFO_ITYPE_ISDN_EXTENSION;
e_connectinfo.ntype = e_ext.callerid_type;
e_connectinfo.present = e_ext.callerid_present;
}
port = find_port_id(portlist->port_id);
if (port)
{
- SCPY(e_connectinfo.id, nationalize_callerinfo(port->p_dialinginfo.number, &e_connectinfo.ntype));
+ SCPY(e_connectinfo.id, nationalize_callerinfo(port->p_dialinginfo.id, &e_connectinfo.ntype));
e_connectinfo.present = INFO_PRESENT_ALLOWED;
}
}
/* put prefix in front of e_cbdialing */
SPRINT(buffer, "%s%s", e_ext.prefix, e_cbdialing);
- SCPY(e_dialinginfo.number, buffer);
- e_dialinginfo.itype = INFO_ITYPE_EXTERN;
+ SCPY(e_dialinginfo.id, buffer);
+ e_dialinginfo.itype = INFO_ITYPE_ISDN;
e_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
/* use caller id (or if exist: id_next_call) for this call */
e_callerinfo.screen = INFO_SCREEN_NETWORK;
- SCPY(e_callerinfo.intern, e_ext.number);
+ SCPY(e_callerinfo.extension, e_ext.number);
if (e_ext.id_next_call_present >= 0)
{
SCPY(e_callerinfo.id, e_ext.id_next_call);
e_action = &action_password_write;
e_match_timeout = 0;
e_match_to_action = NULL;
- e_dialinginfo.number[0] = '\0';
- e_extdialing = strchr(e_dialinginfo.number, '\0');
+ e_dialinginfo.id[0] = '\0';
+ e_extdialing = strchr(e_dialinginfo.id, '\0');
e_password_timeout = now+20;
process_dialing();
} else
if (e_ruleset)
e_rule = e_ruleset->rule_first;
e_action = NULL;
- e_extdialing = e_dialinginfo.number;
- if (e_dialinginfo.number[0])
+ e_extdialing = e_dialinginfo.id;
+ if (e_dialinginfo.id[0])
{
set_tone(portlist, "dialing");
process_dialing();
/* signal to call tool */
admin_call_response(e_adminid, (message_type==MESSAGE_DISCONNECT)?ADMIN_CALL_DISCONNECT:ADMIN_CALL_RELEASE, "", param->disconnectinfo.cause, param->disconnectinfo.location, 0);
- trace_header((message_type==MESSAGE_DISCONNECT)?"DISCONNECT":"RELEASE", DIRECTION_IN);
+ trace_header((message_type==MESSAGE_DISCONNECT)?(char *)"DISCONNECT":(char *)"RELEASE", DIRECTION_IN);
add_trace("cause", "value", "%d", param->disconnectinfo.cause);
add_trace("cause", "location", "%d", param->disconnectinfo.location);
end_trace();
int haspatterns = 0;
/* check if pattern is available */
if (ea_endpoint->ep_portlist)
- if (!ea_endpoint->ep_portlist->next && ea_endpoint->ep_portlist->earlyb)
-#warning wie ist das bei einem asterisk, gibts auch tones?
- if (callpbx_countrelations(ea_endpoint->ep_call_id)==2 // we must count relations, in order not to disturb the conference ; NOTE:
+ if (!ea_endpoint->ep_portlist->next && ea_endpoint->ep_portlist->early_b)
+ if (callpbx_countrelations(ea_endpoint->ep_call_id)==2 // we must count relations, in order not to disturb the conference ; NOTE: asterisk always counts two, since it is a point to point call
&& message_type != MESSAGE_RELEASE) // if we release, we are done
haspatterns = 1;
if (haspatterns)
case INFO_NOTIFY_REMOTE_RETRIEVAL:
case INFO_NOTIFY_USER_RESUMED:
/* set volume of rx and tx */
- if (param->setup.callerinfo.itype == INFO_ITYPE_INTERN)
+ if (param->setup.callerinfo.itype == INFO_ITYPE_ISDN_EXTENSION)
if (e_ext.txvol!=256 || e_ext.rxvol!=256)
if (portlist)
{
{
struct port_list *portlist;
struct message *message;
- class Port *port;
portlist = ea_endpoint->ep_portlist;
while(portlist)
/* PORT sends SETUP message */
case MESSAGE_SETUP:
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call from callerid=%s, dialing=%s\n", ea_endpoint->ep_serial, param->setup.callerinfo.id, param->setup.dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call from callerid=%s, dialing=%s\n", ea_endpoint->ep_serial, param->setup.callerinfo.id, param->setup.dialinginfo.id);
if (e_state!=EPOINT_STATE_IDLE)
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) ignored because we are not in idle state.\n", ea_endpoint->ep_serial);
/* PORT sends INFORMATION message */
case MESSAGE_INFORMATION: /* additional digits received */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call dialing more=%s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->information.number, e_ext.number, e_callerinfo.id);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call dialing more=%s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->information.id, e_ext.number, e_callerinfo.id);
port_information(portlist, message_type, param);
break;
memcpy(&message->param, param, sizeof(union parameter));
/* screen incoming caller id */
screen(1, e_connectinfo.id, sizeof(e_connectinfo.id), &e_connectinfo.ntype, &e_connectinfo.present);
- memcpy(&message->param.connnectinfo, e_connectinfo);
+ memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(e_connectinfo));
/* screen clip if prefix is required */
if (e_ext.number[0] && message->param.connectinfo.id[0] && e_ext.clip_prefix[0])
}
/* use internal caller id */
- if (e_ext.number[0] && e_connectinfo.intern[0] && (message->param.connectinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore))
+ if (e_ext.number[0] && e_connectinfo.extension[0] && (message->param.connectinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore))
{
- SCPY(message->param.connectinfo.id, e_connectinfo.intern);
+ SCPY(message->param.connectinfo.id, e_connectinfo.extension);
message->param.connectinfo.ntype = INFO_NTYPE_UNKNOWN;
}
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, portlist->port_type, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
/* display callerid if desired for extension */
- SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name));
+ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
/* use conp, if enabld */
if (!e_ext.centrex)
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) we are in setup state, so we do overlap dialing.\n", ea_endpoint->ep_serial);
/* if digits changed, what we have already dialed */
- if (!!strncmp(e_dialinginfo.number,param->setup.dialinginfo.number,strlen(e_dialinginfo.number)))
+ if (!!strncmp(e_dialinginfo.id,param->setup.dialinginfo.id,strlen(e_dialinginfo.id)))
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) we have dialed digits which have been changed or we have a new multidial, so we must redial.\n", ea_endpoint->ep_serial);
/* release all ports */
/* if we have a pending redial, so we just adjust the dialing number */
if (e_redial)
{
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) redial in progress, so we update the dialing number to %s.\n", ea_endpoint->ep_serial, param->setup.dialinginfo.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) redial in progress, so we update the dialing number to %s.\n", ea_endpoint->ep_serial, param->setup.dialinginfo.id);
memcpy(&e_dialinginfo, ¶m->setup.dialinginfo, sizeof(e_dialinginfo));
return;
}
if (e_state == EPOINT_STATE_OUT_SETUP)
{
/* queue digits */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) digits '%s' are queued because we didn't receive a setup acknowledge.\n", ea_endpoint->ep_serial, param->setup.dialinginfo.number);
- SCAT(e_dialing_queue, param->setup.dialinginfo.number + strlen(e_dialinginfo.number));
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) digits '%s' are queued because we didn't receive a setup acknowledge.\n", ea_endpoint->ep_serial, param->setup.dialinginfo.id);
+ SCAT(e_dialing_queue, param->setup.dialinginfo.id + strlen(e_dialinginfo.id));
} else
{
/* get what we have not dialed yet */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) we have already dialed '%s', we received '%s', what's left '%s'.\n", ea_endpoint->ep_serial, e_dialinginfo.number, param->setup.dialinginfo.number, param->setup.dialinginfo.number+strlen(e_dialinginfo.number));
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) we have already dialed '%s', we received '%s', what's left '%s'.\n", ea_endpoint->ep_serial, e_dialinginfo.id, param->setup.dialinginfo.id, param->setup.dialinginfo.id+strlen(e_dialinginfo.id));
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_INFORMATION);
- SCPY(message->param.information.number, param->setup.dialinginfo.number + strlen(e_dialinginfo.number));
+ SCPY(message->param.information.id, param->setup.dialinginfo.id + strlen(e_dialinginfo.id));
message->param.information.ntype = INFO_NTYPE_UNKNOWN;
message_put(message);
logmessage(message);
return;
}
/* if an internal extension is dialed, copy that number */
- if (param->setup.dialinginfo.itype==INFO_ITYPE_INTERN || param->setup.dialinginfo.itype==INFO_ITYPE_VBOX)
- SCPY(e_ext.number, param->setup.dialinginfo.number);
+ if (param->setup.dialinginfo.itype==INFO_ITYPE_ISDN_EXTENSION || param->setup.dialinginfo.itype==INFO_ITYPE_VBOX)
+ SCPY(e_ext.number, param->setup.dialinginfo.id);
/* if an internal extension is dialed, get extension's info about caller */
if (e_ext.number[0])
{
message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
memcpy(&message->param.notifyinfo, ¶m->notifyinfo, sizeof(struct notify_info));
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, portlist->port_type, message->param.notifyinfo.id, &message->param.notifyinfo.ntype, &message->param.notifyinfo.present, NULL, message->param.notifyinfo.voip, message->param.notifyinfo.intern, 0);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.notifyinfo.id, &message->param.notifyinfo.ntype, &message->param.notifyinfo.present, 0, message->param.notifyinfo.extension, NULL);
/* display callerid if desired for extension */
- SCPY(message->param.notifyinfo.display, apply_callerid_display(message->param.notifyinfo.id, message->param.notifyinfo.itype, message->param.notifyinfo.ntype, message->param.notifyinfo.present, 0, message->param.notifyinfo.voip, message->param.notifyinfo.intern, NULL));
+ SCPY(message->param.notifyinfo.display, apply_callerid_display(message->param.notifyinfo.id, message->param.notifyinfo.itype, message->param.notifyinfo.ntype, message->param.notifyinfo.present, 0, message->param.notifyinfo.extension, NULL));
message_put(message);
logmessage(message);
portlist = portlist->next;
/* CALL sends INFORMATION message */
case MESSAGE_INFORMATION:
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received more digits: '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->information.number);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received more digits: '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->information.id);
call_information(portlist, message_type, param);
break;
/* CALL sends SETUP message */
case MESSAGE_SETUP:
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint received setup from terminal='%s',id='%s' to id='%s' (dialing itype=%d)\n", ea_endpoint->ep_serial, param->setup.callerinfo.intern, param->setup.callerinfo.id, param->setup.dialinginfo.number, param->setup.dialinginfo.itype);
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint received setup from terminal='%s',id='%s' to id='%s' (dialing itype=%d)\n", ea_endpoint->ep_serial, param->setup.callerinfo.extension, param->setup.callerinfo.id, param->setup.dialinginfo.id, param->setup.dialinginfo.itype);
call_setup(portlist, message_type, param);
return;
break;
message->param.connectinfo.itype = eapp->e_callerinfo.itype;
message->param.connectinfo.ntype = eapp->e_callerinfo.ntype;
/* handle restricted caller ids */
- apply_callerid_restriction(e_ext.anon_ignore, ea_endpoint->ep_portlist->port_type, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name);
+ apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
/* display callerid if desired for extension */
- SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.voip, message->param.connectinfo.intern, message->param.connectinfo.name));
+ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
message_put(message);
/* we send a connect to the audio path (not for vbox) */
message_put(message);
/* beeing paranoid, we make call update */
- callpbx->c_mixer = 1;
+ callpbx->c_updatebridge = 1;
if (options.deb & DEBUG_EPOINT)
{
PDEBUG(DEBUG_EPOINT, "EPOINT(%d)d-call completely removed!\n");
/* mixer must update */
- our_callpbx->c_mixer = 1; /* update mixer flag */
+ our_callpbx->c_updatebridge = 1; /* update mixer flag */
/* we send a retrieve to that endpoint */
// mixer will update the hold-state of the call and send it to the endpoints is changes
void EndpointAppPBX::logmessage(struct message *message)
{
- class Port *port;
- class Pdss1 *pdss1;
char *logtext = "unknown";
char buffer[64];
{
case MESSAGE_SETUP:
trace_header("SETUP", DIRECTION_OUT);
- if (message->param.setup.callerinfo.intern[0])
- add_trace("extension", NULL, "%s", message->param.setup.callerinfo.intern);
+ if (message->param.setup.callerinfo.extension[0])
+ add_trace("extension", NULL, "%s", message->param.setup.callerinfo.extension);
add_trace("caller id", "number", "%s", numberrize_callerinfo(message->param.setup.callerinfo.id, message->param.setup.callerinfo.ntype));
if (message->param.setup.callerinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("caller id", "present", "restricted");
- if (message->param.setup.redirinfo.number[0])
+ if (message->param.setup.redirinfo.id[0])
{
add_trace("redir'ing", "number", "%s", numberrize_callerinfo(message->param.setup.redirinfo.id, message->param.setup.redirinfo.ntype));
if (message->param.setup.redirinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("redir'ing", "present", "restricted");
}
- if (message->param.setup.dialinginfo.number[0])
- add_trace("dialing", NULL, "%s", message->param.setup.dialinginfo.number);
+ if (message->param.setup.dialinginfo.id[0])
+ add_trace("dialing", NULL, "%s", message->param.setup.dialinginfo.id);
end_trace();
break;
case MESSAGE_CONNECT:
trace_header("CONNECT", DIRECTION_OUT);
- if (message->param.connectinfo.intern[0])
- add_trace("extension", NULL, "%s", message->param.connectinfo.intern);
+ if (message->param.connectinfo.extension[0])
+ add_trace("extension", NULL, "%s", message->param.connectinfo.extension);
add_trace("connect id", "number", "%s", numberrize_callerinfo(message->param.connectinfo.id, message->param.connectinfo.ntype));
if (message->param.connectinfo.present == INFO_PRESENT_RESTRICTED)
add_trace("connect id", "present", "restricted");
trace_header("NOTIFY", DIRECTION_OUT);
if (message->param.notifyinfo.notify)
add_trace("indicator", NULL, "%s", logtext);
- if (message->param.notifyinfo.number[0])
+ if (message->param.notifyinfo.id[0])
{
add_trace("redir'on", "number", "%s", numberrize_callerinfo(message->param.notifyinfo.id, message->param.notifyinfo.ntype));
if (message->param.notifyinfo.present == INFO_PRESENT_RESTRICTED)
case MESSAGE_INFORMATION:
trace_header("INFORMATION", DIRECTION_OUT);
- add_trace("dialing", NULL, "%s", message->param.information.number);
+ add_trace("dialing", NULL, "%s", message->param.information.id);
end_trace();
break;
void keypad_function(char digit);
void set_tone(struct port_list *portlist, char *tone);
void out_setup(void);
- char *apply_callerid_display(char *id, int itype, int ntype, int present, int screen, char *h323, char *intern, char *name);
+ struct mISDNport *hunt_port(char *ifname, int *channel);
+ char *apply_callerid_display(char *id, int itype, int ntype, int present, int screen, char *extension, char *name);
void auth(int job, int bit_num);
/* vbox playback stuff */
char *nationalize_callerinfo(char *string, int *type);
char *numberrize_callerinfo(char *string, int type);
-void apply_callerid_restriction(int anon_ignore, int port_type, char *id, int *ntype, int *present, int *screen, char *voip, char *intern, char *name);
+void apply_callerid_restriction(int anon_ignore, char *id, int *ntype, int *present, int *screen, char *extension, char *name);
void send_mail(char *filename, char *callerid, char *callerintern, char *callername, char *vbox_email, int vbox_year, int vbox_mon, int vbox_mday, int vbox_hour, int vbox_min, char *terminal);
** **
\*****************************************************************************/
-enum { CALL_TYPE_NONE, CALL_TYPE_PBX, CALL_TYPE_CHAN};
+enum { CALL_TYPE_NONE, CALL_TYPE_PBX, CALL_TYPE_ASTERISK};
/* call
*
PDEBUG(DEBUG_CALL, "creating new call and connecting it to the endpoint.\n");
- c_type = CALL_TYPE_CHAN;
+ c_type = CALL_TYPE_ASTERISK;
c_epoint_id = epoint->ep_serial;
PDEBUG(DEBUG_CALL, "Constructor(new call)");
*/
message = message_create(c_serial, relation->epoint_id, CALL_TO_EPOINT, MESSAGE_mISDNSIGNAL);
message->param.mISDNsignal.message = mISDNSIGNAL_CALLDATA;
- message->param.mISDNsignal.calldata = (relnum==2 && !allmISDN);
- PDEBUG(DEBUG_CALL, "call %d sets 'calldata' on port %s to %d\n", c_serial, port->p_name, calldata);
+ message->param.mISDNsignal.calldata = (relations==2 && !allmISDN);
+ PDEBUG(DEBUG_CALL, "call %d sets 'calldata' on port %s to %d\n", c_serial, port->p_name, message->param.mISDNsignal.calldata);
message_put(message);
relation = relation->next;
if (!call)
return(0);
+ if (call->c_type != CALL_TYPE_ASTERISK)
+ return(2);
+
if (call->c_type != CALL_TYPE_PBX)
return(0);
callpbx = (class CallPBX *)call;
int new_state;
struct message *message;
// int size, writesize, oldpointer;
- class Endpoint *epoint;
- char *number;
+ char *number, *numbers;
if (!epoint_id)
{
switch(message_type)
{
case MESSAGE_SETUP:
- if (param->dialinginfo.itype == INFO_ITYPE_ISDN_EXTENSION)
+ if (param->setup.dialinginfo.itype == INFO_ITYPE_ISDN_EXTENSION)
{
- while(number = strsep(¶m->dialinginfo.number, ','))
+ numbers = param->setup.dialinginfo.id;
+ while((number = strsep(&numbers, ",")))
{
if (out_setup(epoint_id, message_type, param, number))
return; // call destroyed
relation = c_relation;
while(relation)
{
- message = message_create(c_serial, releation->epoint_id, CALL_TO_EPOINT, MESSAGE_RELEASE);
- message->param.disconnectinfo.cause = (relation->epoint_id==epoint_id)CAUSE_RESSOURCEUNAVAIL?:CAUSE_NORMAL;
+ message = message_create(c_serial, relation->epoint_id, CALL_TO_EPOINT, MESSAGE_RELEASE);
+ message->param.disconnectinfo.cause = (relation->epoint_id==epoint_id)?CAUSE_RESSOURCEUNAVAIL:CAUSE_NORMAL;
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
relation = relation->next;
message = message_create(c_serial, relation->epoint_id, CALL_TO_EPOINT, message_type);
memcpy(&message->param, param, sizeof(union parameter));
if (newnumber)
- SCPY(message->param.setup.dialinginfo.number, newnumber);
- PDEBUG(DEBUG_CALL, "setup message sent to ep %d with number='%s'.\n", relation->epoint_id, message->param.setup.dialinginfo.number);
+ SCPY(message->param.setup.dialinginfo.id, newnumber);
+ PDEBUG(DEBUG_CALL, "setup message sent to ep %d with number='%s'.\n", relation->epoint_id, message->param.setup.dialinginfo.id);
message_put(message);
return(0);
}
-todo: beim release von einem relation_type_setup muss der cause gesammelt werden, bis keine weitere setup-relation mehr existiert
-beim letzten den collected cause senden
-bridge kann ruhig loslegen, das aber dokumentieren
-bridge überdenken: wer sendet, welche töne verfügbar sind, u.s.w
-
char c_dialed[1024]; /* dial string of (all) number(s) */
char c_todial[32]; /* overlap dialing (part not signalled yet) */
+ int c_pid; /* pid of call to generate bridge id */
int c_updatebridge; /* bridge must be updated */
struct call_relation *c_relation; /* list of endpoints that are related to the call */
}
/* check the key for the call */
- if (port->p_type==PORT_TYPE_DSS1_TE_OUT || port->p_type==PORT_TYPE_DSS1_NT_OUT || port->p_type==PORT_TYPE_SIP_OUT)
- ret = parse_secrets((char *)e_ext.number, (char *)port->p_dialinginfo.number, &auth_pointer, &crypt_pointer, &key_pointer);
+ if (port->p_type==PORT_TYPE_DSS1_TE_OUT || port->p_type==PORT_TYPE_DSS1_NT_OUT)
+ ret = parse_secrets((char *)e_ext.number, (char *)port->p_dialinginfo.id, &auth_pointer, &crypt_pointer, &key_pointer);
else
{
if (!port->p_callerinfo.id[0])
*/
Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive) : PmISDN(type, mISDNport, portname, settings, channel, exclusive)
{
- p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN:INFO_ITYPE_ISDN_EXTENSION;
+ p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
p_m_d_ntmode = mISDNport->ntmode;
p_m_d_l3id = 0;
p_m_d_ces = -1;
}
use_channel:
add_trace("conclusion", NULL, "channel available");
- add_trace("connect", "channel", "%d", p_m_b_channel);
+ add_trace("connect", "channel", "%d", channel);
end_trace();
return(channel);
}
l1l2l3_trace_header(p_m_mISDNport, this, prim, DIRECTION_IN);
dec_ie_calling_pn(setup->CALLING_PN, (Q931_info_t *)((unsigned long)data+headerlen), &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
- dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.number, sizeof(p_dialinginfo.number));
+ dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
#ifdef CENTREX
/* te-mode: CNIP (calling name identification presentation) */
SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
/* dialing information */
- SCAT(p_dialinginfo.number, (char *)keypad);
+ SCAT(p_dialinginfo.id, (char *)keypad);
switch (called_type)
{
case 0x1:
struct message *message;
l1l2l3_trace_header(p_m_mISDNport, this, prim, DIRECTION_IN);
- dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, (unsigned char *)p_dialinginfo.number, sizeof(p_dialinginfo.number));
+ dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
dec_ie_keypad(information->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
dec_ie_complete(information->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete);
end_trace();
- SCAT(p_dialinginfo.number, (char *)keypad);
+ SCAT(p_dialinginfo.id, (char *)keypad);
switch (type)
{
case 0x1:
p_connectinfo.isdn_port = p_m_portnum;
SCPY(p_connectinfo.interfaces, p_m_mISDNport->ifport->interface->name);
- /* send connect acknowledge */
- dmsg = create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, dinfo, sizeof(CONNECT_ACKNOWLEDGE_t), p_m_d_ntmode);
- connect_acknowledge = (CONNECT_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
- l1l2l3_trace_header(p_m_mISDNport, this, CC_CONNECT | RESPONSE, DIRECTION_OUT);
- /* if we had no bchannel before, we send it now */
- if (!bchannel_before && p_m_b_channel)
- enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
- end_trace();
- msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-
+ /* only in nt-mode we send connect ack. in te-mode it is done by stack itself or optional */
+ if (p_m_d_ntmode)
+ {
+ /* send connect acknowledge */
+ dmsg = create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, dinfo, sizeof(CONNECT_ACKNOWLEDGE_t), p_m_d_ntmode);
+ connect_acknowledge = (CONNECT_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
+ l1l2l3_trace_header(p_m_mISDNport, this, CC_CONNECT | RESPONSE, DIRECTION_OUT);
+ /* if we had no bchannel before, we send it now */
+ if (!bchannel_before && p_m_b_channel)
+ enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
+ end_trace();
+ msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
+ }
+
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
message_put(message);
cause = 16;
/* release if we are remote sends us no tones */
- if (p_m_mISDNport->is_earlyb)
+ if (p_m_mISDNport->earlyb)
{
RELEASE_t *release;
msg_t *dmsg;
PERROR("no memory for epointlist\n");
exit(-1);
}
- if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->is_earlyb)))
+ if (!(epoint->portlist_new(p_serial, p_type, p_m_mISDNport->earlyb)))
{
PERROR("no memory for portlist\n");
exit(-1);
{
int ret;
- if ((ret = Port::handler()))
+ if ((ret = PmISDN::handler()))
return(ret);
/* handle destruction */
INFORMATION_t *information;
msg_t *dmsg;
- if (param->information.number[0]) /* only if we have something to dial */
+ if (param->information.id[0]) /* only if we have something to dial */
{
dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode);
information = (INFORMATION_t *)(dmsg->data + headerlen);
l1l2l3_trace_header(p_m_mISDNport, this, CC_INFORMATION | REQUEST, DIRECTION_OUT);
- enc_ie_called_pn(&information->CALLED_PN, dmsg, 0, 1, (unsigned char *)param->information.number);
+ enc_ie_called_pn(&information->CALLED_PN, dmsg, 0, 1, (unsigned char *)param->information.id);
end_trace();
msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
}
if (type >= 0)
enc_ie_calling_pn(&setup->CALLING_PN, dmsg, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
/* dialing information */
- if (p_dialinginfo.number[0]) /* only if we have something to dial */
+ if (p_dialinginfo.id[0]) /* only if we have something to dial */
{
- enc_ie_called_pn(&setup->CALLED_PN, dmsg, 0, 1, (unsigned char *)p_dialinginfo.number);
+ enc_ie_called_pn(&setup->CALLED_PN, dmsg, 0, 1, (unsigned char *)p_dialinginfo.id);
}
/* sending complete */
if (p_dialinginfo.sending_complete)
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- if (p_m_mISDNport->is_tones)
+ if (p_m_mISDNport->tones)
enc_ie_progress(&setup_acknowledge->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
end_trace();
msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- if (p_m_mISDNport->is_tones)
+ if (p_m_mISDNport->tones)
enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
end_trace();
msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- if (p_m_mISDNport->is_tones)
+ if (p_m_mISDNport->tones)
enc_ie_progress(&alerting->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
end_trace();
msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
char *p = NULL;
/* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
- if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->is_tones)
+ if ((p_state==PORT_STATE_IN_SETUP && !p_m_mISDNport->tones)
|| p_state==PORT_STATE_OUT_SETUP)
{
/* sending release to endpoint */
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- if (p_m_mISDNport->is_tones)
+ if (p_m_mISDNport->tones)
enc_ie_progress(&disconnect->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
/* send cause */
enc_ie_cause(&disconnect->CAUSE, dmsg, (p_m_d_ntmode && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- if (p_m_mISDNport->is_tones)
+ if (p_m_mISDNport->tones)
enc_ie_progress(&disconnect->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
/* send cause */
enc_ie_cause(&disconnect->CAUSE, dmsg, (p_m_d_ntmode && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
if (port)
{
if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
- earlyb = ((class PmISDN *)port)->p_m_mISDNport->is_earlyb;
+ earlyb = ((class PmISDN *)port)->p_m_mISDNport->earlyb;
if (!portlist_new(port_id, port->p_type, earlyb))
{
PERROR("no mem for portlist, exitting...\n");
int display_cause; /* clear cause using display message */
int display_ext; /* display external caller ids */
int display_int; /* display internal caller ids */
- int display_voip; /* display h323 caller ids */
int display_fake; /* display fake caller ids */
int display_anon; /* display anonymouse caller ids */
int display_menu; /* display menu */
/*****************************************************************************\
** **
-** PBX4Linux **
+** LCR **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
/*****************************************************************************\
** **
-** PBX4Linux **
+** LCR **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
char protocol[1024], layermask[1024], types[256];
printf("\n\nThis program generates a script, which is used to start/stop/restart mISDN\n");
- printf("driver. All configuration of cards is done for using with the PBX.\n");
+ printf("driver. All configuration of cards is done for using with the LCR.\n");
while(i < (int)sizeof(mode)) /* number of cards */
{
ptp[i] = 0;
do
{
- printf("\nIs your port #%d connected to point-to-multipoint line/phone, which supports multiple\ntelephones (Mehrgeräteanschluss) OR is it a point-to-point link which is used\nfor PBX and supports extension dialing (Anlagenanschluss)?\n[ptp | ptm]: ", i+1); fflush(stdout);
+ printf("\nIs your port #%d connected to point-to-multipoint line/phone, which supports multiple\ntelephones (Mehrgeräteanschluss) OR is it a point-to-point link which is used\nfor LCR and supports extension dialing (Anlagenanschluss)?\n[ptp | ptm]: ", i+1); fflush(stdout);
scanf("%s", input);
} while (!!strcmp(input,"ptp") && !!strcmp(input,"ptm"));
ptp[i] = (input[2]=='p')?1:0;
n = i;
- printf("\nWhere do you like to load the modules from, enter 0 for default, 1 for\n'/usr/local/pbx/modules/' or the full path.\n[0 | 1 | <path>]: "); fflush(stdout);
+ printf("\nWhere do you like to load the modules from, enter 0 for default, 1 for\n'/usr/local/lcr/modules/' or the full path.\n[0 | 1 | <path>]: "); fflush(stdout);
scanf("%s", input);
if (!strcmp(input, "0"))
SCPY(input, "");
if (!strcmp(input, "1"))
- SCPY(input, "/usr/local/pbx/modules");
+ SCPY(input, "/usr/local/lcr/modules");
if (input[0]) if (input[strlen(input)-1] != '/')
SCAT(input, "/");
- printf("\n\nFinally tell me where to write the mISDN rc file.\Enter the name 'mISDN' for current directory.\nYou may want to say '/usr/local/pbx/mISDN' or '/etc/rc.d/mISDN'\n: "); fflush(stdout);
+ printf("\n\nFinally tell me where to write the mISDN rc file.\Enter the name 'mISDN' for current directory.\nYou may want to say '/usr/local/lcr/mISDN' or '/etc/rc.d/mISDN'\n: "); fflush(stdout);
scanf("%s", name);
if (!(fp=fopen(name, "w")))
{
add_trace("calling_pn", "plan", "%d", *plan);
add_trace("calling_pn", "present", "%d", *present);
add_trace("calling_pn", "screen", "%d", *screen);
- add_trace("calling_pn", "number", "%s", *number);
+ add_trace("calling_pn", "number", "%s", number);
}
{
struct interface_port *ifport, **ifportp;
struct interface *searchif;
- struct interface_port *searchport;
int val;
val = get_number(value);
searchif = interface_newlist;
while(searchif)
{
- searchport = searchif->ifport;
+ ifport = searchif->ifport;
while(ifport)
{
if (ifport->portnum == val)
parameter[strlen(parameter)-1] = '\0';
/* check if interface name already exists */
- interface = interface_first;
+ interface = interface_newlist;
while(interface)
{
if (!strcasecmp(interface->name, parameter+1))
{
if (ifparam->func(interface, filename, line, parameter, value))
goto error;
- continue;
+ break;
}
ifparam++;
}
+ if (ifparam->name)
+ continue;
SPRINT(interface_error, "Error in %s (line %d): unknown parameter: '%s'.\n", filename, line, parameter);
goto error;
{
if (!ifport->mISDNport)
{
- /* open new port */
- mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->ptmp);
- if (mISDNport)
- {
- ifport->mISDNport = mISDNport;
- mISDNport->ifport = ifport;
- }
- }
- if (ifport->mISDNport)
- {
- /* default channel selection list */
- if (!ifport->out_channel)
- default_out_channel(ifport);
- if (!ifport->in_channel)
- default_in_channel(ifport);
- /* default is_tones */
- if (ifport->interface->is_tones)
- ifport->mISDNport->is_tones = (ifport->interface->is_tones==IS_YES);
- else
- ifport->mISDNport->is_tones = (ifport->mISDNport->ntmode)?1:0;
- /* default is_earlyb */
- if (ifport->interface->is_earlyb)
- ifport->mISDNport->is_earlyb = (ifport->interface->is_earlyb==IS_YES);
- else
- ifport->mISDNport->is_earlyb = (ifport->mISDNport->ntmode)?0:1;
+ load_port(ifport);
}
+ ifport = ifport->next;
}
interface = interface->next;
}
}
+
+/*
+ * load port
+ */
+void load_port(struct interface_port *ifport)
+{
+ struct mISDNport *mISDNport;
+
+ /* open new port */
+ mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->ptmp, ifport->interface);
+ if (mISDNport)
+ {
+ /* link port */
+ ifport->mISDNport = mISDNport;
+ mISDNport->ifport = ifport;
+
+ /* default channel selection list */
+ if (!ifport->out_channel)
+ default_out_channel(ifport);
+ if (!ifport->in_channel)
+ default_in_channel(ifport);
+ /* default is_tones */
+ if (ifport->interface->is_tones)
+ ifport->mISDNport->tones = (ifport->interface->is_tones==IS_YES);
+ else
+ ifport->mISDNport->tones = (ifport->mISDNport->ntmode)?1:0;
+ /* default is_earlyb */
+ if (ifport->interface->is_earlyb)
+ ifport->mISDNport->earlyb = (ifport->interface->is_earlyb==IS_YES);
+ else
+ ifport->mISDNport->earlyb = (ifport->mISDNport->ntmode)?0:1;
+ } else
+ {
+ ifport->block = 2; /* not available */
+ }
+}
+
/*
* give summary of interface syntax
*/
}
}
-
struct interface *read_interfaces(void);
void free_interfaces(struct interface *interface_start);
void relink_interfaces(void);
+void load_port(struct interface_port *ifport);
void doc_interface(void);
{
/* init trace with given values */
start_trace(mISDNport?mISDNport->portnum:0,
- mISDNport?mISDNport->ifport->interface:NULL,
+ (mISDNport)?((mISDNport->ifport)?mISDNport->ifport->interface:NULL):NULL,
port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype):NULL,
- port?port->p_dialinginfo.number:NULL,
+ port?port->p_dialinginfo.id:NULL,
direction,
CATEGORY_CH,
port?port->p_serial:0,
start_trace(mISDNport?mISDNport->portnum:0,
mISDNport?mISDNport->ifport->interface:NULL,
port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype):NULL,
- port?port->p_dialinginfo.number:NULL,
+ port?port->p_dialinginfo.id:NULL,
direction,
CATEGORY_CH,
port?port->p_serial:0,
mISDN_pid_t pid;
int ret;
- if (mISDNport->b_stid[i])
+ if (!mISDNport->b_stid[i])
{
- PERROR("Error: no stack for index");
- return(-1);
+ PERROR("Error: no stack for index %d\n", i);
+ return(0);
}
if (mISDNport->b_addr[i])
{
- PERROR("Error: stack already created");
- return(-1);
+ PERROR("Error: stack already created for index %d\n", i);
+ return(0);
}
/* create new layer */
goto stack_error;
chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL create stack", DIRECTION_OUT);
add_trace("channel", NULL, "%d", i+1+(i>=15));
- add_trace("stack", "id", "%d", mISDNport->b_stid[i]);
- add_trace("stack", "address", "%d", mISDNport->b_addr[i]);
+ add_trace("stack", "id", "0x%8x", mISDNport->b_stid[i]);
+ add_trace("stack", "address", "0x%8x", mISDNport->b_addr[i]);
end_trace();
- return(0);
+ return(1);
failed:
mISDNport->b_addr[i] = 0;
- return(-1);
+ return(0);
}
chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove stack", DIRECTION_OUT);
add_trace("channel", NULL, "%d", i+1+(i>=15));
- add_trace("stack", "id", "%d", mISDNport->b_stid[i]);
- add_trace("stack", "address", "%d", mISDNport->b_addr[i]);
+ add_trace("stack", "id", "0x%8x", mISDNport->b_stid[i]);
+ add_trace("stack", "address", "0x%8x", mISDNport->b_addr[i]);
end_trace();
/* remove our stack only if set */
PDEBUG(DEBUG_BCHANNEL, "free stack (b_addr=0x%x)\n", mISDNport->b_addr[i]);
void bchannel_event(struct mISDNport *mISDNport, int i, int event)
{
int state = mISDNport->b_state[i];
-
+
+printf("event=%d state=%d\n", event, state);
switch(event)
{
case B_EVENT_ACTIVATE:
- /* port may not be used by any other bchannel */
- if (mISDNport->b_port[i])
+ /* port must be linked in order to allow activation */
+ if (!mISDNport->b_port[i])
{
- PERROR("SOFTWARE ERROR: bchannel must not be linked to a Port class\n");
+ PERROR("SOFTWARE ERROR: bchannel must be linked to a Port class\n");
exit(-1);
}
switch(state)
inbuffer = (p_m_fromup_buffer_writep - p_m_fromup_buffer_readp) & FROMUP_BUFFER_MASK;
/* send tone data to isdn device only if we have data */
- if (p_tone_fh>=0 || p_tone_fetched || p_m_crypt_msg_loops || inbuffer)
+ if (p_tone_name[0] || p_m_crypt_msg_loops || inbuffer)
{
/* calculate how much to transmit */
if (!p_last_tv_sec)
}
if (elapsed >= ISDN_TRANSMIT)
{
- unsigned char buf[mISDN_HEADER_LEN+ISDN_PRELOAD], *p = buf;
+ unsigned char buf[mISDN_HEADER_LEN+ISDN_PRELOAD];
iframe_t *frm = (iframe_t *)buf;
+ unsigned char *p = buf+mISDN_HEADER_LEN;
p_last_tv_sec = now_tv.tv_sec;
p_last_tv_msec = now_tv.tv_usec/1000;
- /* read tones */
+ /* read tones or fill with silence */
length = read_audio(p, elapsed);
/*
*/
if (inbuffer)
{
+ printf("nix\n");
/* inbuffer might be less than we skip due to audio */
if (inbuffer <= length)
{
/* overwrite buffer with crypto stuff */
if (p_m_crypt_msg_loops)
{
+ printf("nix2\n");
/* send pending message */
int tosend;
length = tosend;
/* copy message (part) to buffer */
- memcpy(buf, p_m_crypt_msg+p_m_crypt_msg_current, tosend);
+ memcpy(p, p_m_crypt_msg+p_m_crypt_msg_current, tosend);
p_m_crypt_msg_current += tosend;
if (p_m_crypt_msg_current == p_m_crypt_msg_len)
{
frm->addr = p_m_mISDNport->b_addr[p_m_b_index] | FLG_MSG_DOWN;
frm->dinfo = 0;
frm->len = length;
- memcpy(&frm->data.p, buf, length);
mISDN_write(mISDNdevice, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
if (p_debug_nothingtosend)
* the call is connected OR tones feature is enabled.
*/
if (p_state!=PORT_STATE_CONNECT
- && !p_m_mISDNport->is_tones)
+ && !p_m_mISDNport->tones)
return;
#if 0
mISDNport = mISDNport->next;
}
+ /* no device, no read */
+ if (mISDNdevice < 0)
+ return(0);
+
/* get message from kernel */
if (!(msg = alloc_msg(MAX_MSG_SIZE)))
return(1);
/* global prim */
switch(frm->prim)
{
+ case MGR_DELLAYER | CONFIRM:
case MGR_INITTIMER | CONFIRM:
case MGR_ADDTIMER | CONFIRM:
case MGR_DELTIMER | CONFIRM:
/*
* global function to add a new card (port)
*/
-struct mISDNport *mISDNport_open(int port, int ptp, int ptmp)
+struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, struct interface *interface)
{
int ret;
unsigned char buff[1025];
/* add mISDNport structure */
mISDNportp = &mISDNport_first;
while(*mISDNportp)
- mISDNportp = &mISDNport->next;
+ mISDNportp = &((*mISDNportp)->next);
mISDNport = (struct mISDNport *)calloc(1, sizeof(struct mISDNport));
if (!mISDNport)
{
PDEBUG(DEBUG_BCHANNEL, "using 'mISDN_dsp.o' module\n");
start_trace(mISDNport->portnum,
- mISDNport->ifport->interface,
+ interface,
NULL,
NULL,
DIRECTION_NONE,
port = port->next;
}
- start_trace(mISDNport->portnum,
- mISDNport->ifport->interface,
- NULL,
- NULL,
- DIRECTION_NONE,
- CATEGORY_CH,
- 0,
- "PORT (close)");
- end_trace();
+ /* only if we are already part of interface */
+ if (mISDNport->ifport)
+ {
+ start_trace(mISDNport->portnum,
+ mISDNport->ifport->interface,
+ NULL,
+ NULL,
+ DIRECTION_NONE,
+ CATEGORY_CH,
+ 0,
+ "PORT (close)");
+ end_trace();
+ }
/* free bchannels */
i = 0;
while(i < mISDNport->b_num)
{
- if (mISDNport->b_stid[i])
+ if (mISDNport->b_addr[i])
{
_bchannel_destroy(mISDNport, i);
PDEBUG(DEBUG_BCHANNEL, "freeing %s port %d bchannel (index %d).\n", (mISDNport->ntmode)?"NT":"TE", mISDNport->portnum, i);
PDEBUG(DEBUG_BCHANNEL, "freeing d-stack.\n");
if (mISDNport->d_stid)
{
-// mISDN_clear_stack(mISDNdevice, mISDNport->d_stid);
- if (mISDNport->lower_id)
- mISDN_write_frame(mISDNdevice, buf, mISDNport->lower_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
+ if (mISDNport->upper_id)
+ mISDN_write_frame(mISDNdevice, buf, mISDNport->upper_id | FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
}
/* remove from list */
if (*mISDNportp == mISDNport)
{
*mISDNportp = (*mISDNportp)->next;
+ mISDNportp = NULL;
break;
}
mISDNportp = &((*mISDNportp)->next);
}
- if (!(*mISDNportp))
+ if (mISDNportp)
{
PERROR("software error, mISDNport not in list\n");
exit(-1);
int use; /* counts the number of port that uses this port */
int ntmode; /* is TRUE if port is nt mode */
int pri; /* is TRUE if port is a primary rate interface */
- int is_tones; /* TRUE if tones are sent outside connect state */
- int is_earlyb; /* TRUE if tones are received outside connect state */
+ int tones; /* TRUE if tones are sent outside connect state */
+ int earlyb; /* TRUE if tones are received outside connect state */
int upper_id; /* id to transfer data down */
int lower_id; /* id to transfer data up */
int d_stid;
/* mISDN none-object functions */
void mISDN_port_info(void);
-struct mISDNport *mISDNport_open(int port, int ptp, int ptmp);
+struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, struct interface *interface);
void mISDNport_close_all(void);
void mISDNport_close(struct mISDNport *mISDNport);
void mISDN_port_reorder(void);
int debug_newline = 1;
int nooutput = 0;
-static void debug(const char *function, int line, char *prefix, char *buffer)
+void debug(const char *function, int line, char *prefix, char *buffer)
{
/* if we have a new debug count, we add a mark */
if (last_debug != debug_count)
schedp.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, &schedp);
}
- fprintf(stderr, "PBX: Signal received: %d\n", sigset);
+ fprintf(stderr, "LCR: Signal received: %d\n", sigset);
PERROR("Signal received: %d\n", sigset);
}
}
/*
* the main
*/
-#ifdef VOIP
-#define ARGC (args.GetCount()+1)
-#define ARGV(a) (args[a-1])
-void PBXMain::Main(void)
-{
- PArgList &args = GetArguments();
-#else
-#define ARGC (argc)
-#define ARGV(a) (argv[a])
int main(int argc, char *argv[])
{
-#endif
int ret = -1;
int lockfd = -1; /* file lock */
struct message *message;
printf("\n** %s Version %s\n\n", NAME, VERSION_STRING);
/* show options */
- if (ARGC <= 1)
+ if (argc <= 1)
{
usage:
printf("\n");
- printf("Usage: pbx (query | start | fork | rules | route)\n");
+ printf("Usage: lcr (query | start | fork | rules | route)\n");
printf("query = Show available isdn ports.\n");
- printf("start = Run pbx normally, abort with CTRL+C.\n");
+ printf("start = Run lcr normally, abort with CTRL+C.\n");
printf("fork = Do daemon fork and run as background process.\n");
printf("interface = Get help of available interface syntax.\n");
printf("rules = Get help of available routing rule syntax.\n");
created_mutexe = 1;
/* show interface */
- if (!(strcasecmp(ARGV(1),"interface")))
+ if (!(strcasecmp(argv[1],"interface")))
{
doc_interface();
ret = 0;
}
/* show rules */
- if (!(strcasecmp(ARGV(1),"rules")))
+ if (!(strcasecmp(argv[1],"rules")))
{
- if (ARGC <= 2)
+ if (argc <= 2)
doc_rules(NULL);
else
- doc_rules(ARGV(2));
+ doc_rules(argv[2]);
ret = 0;
goto free;
}
/* query available isdn ports */
- if (!(strcasecmp(ARGV(1),"query")))
+ if (!(strcasecmp(argv[1],"query")))
{
mISDN_port_info();
ret = 0;
#if 0
/* query available isdn ports */
- if (!(strcasecmp(ARGV(1),"route")))
+ if (!(strcasecmp(argv[1],"route")))
{
ruleset_debug(ruleset_first);
ret = 0;
#endif
/* do fork in special cases */
- if (!(strcasecmp(ARGV(1),"fork")))
+ if (!(strcasecmp(argv[1],"fork")))
{
pid_t pid;
}
if (pid != 0)
{
- printf("PBX: Starting daemon.\n");
+ printf("LCR: Starting daemon.\n");
exit(0);
}
nooutput = 1;
} else
/* if not start */
- if (!!strcasecmp(ARGV(1),"start"))
+ if (!!strcasecmp(argv[1],"start"))
{
goto usage;
}
/* create lock and lock! */
- if ((lockfd = open("/var/run/pbx.lock", O_CREAT, 0)) < 0)
+ if ((lockfd = open("/var/run/lcr.lock", O_CREAT, 0)) < 0)
{
- fprintf(stderr, "Cannot create lock file: /var/run/pbx.lock\n");
+ fprintf(stderr, "Cannot create lock file: /var/run/lcr.lock\n");
goto free;
}
if (flock(lockfd, LOCK_EX|LOCK_NB) < 0)
{
if (errno == EWOULDBLOCK)
- fprintf(stderr, "PBX: Another PBX process is running. Please kill the other one.\n");
+ fprintf(stderr, "LCR: Another LCR process is running. Please kill the other one.\n");
else fprintf(stderr, "Locking process failed: errno=%d\n", errno);
goto free;
}
}
relink_interfaces();
interface_first = interface_newlist;
- free_interfaces(interface_newlist);
interface_newlist = NULL;
/* locking memory paging */
idletime += 4000;
}
}
- printf("PBX terminated\n");
+ printf("LCR terminated\n");
ret=0;
/* free all */
/* take me out */
if (ret)
- printf("PBX: Exit (code %d)\n", ret);
+ printf("LCR: Exit (code %d)\n", ret);
#ifdef VOIP
return;
#else
/*****************************************************************************\
** **
-** PBX4Linux **
+** LCR **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
** **
\*****************************************************************************/
-#define NAME "PBX4Linux"
+#define NAME "LCR"
#define DEFAULT_ENDPOINT_APP EndpointAppPBX
-#define VERSION_STRING "3.6 (Januar 2006)"
+#define VERSION_STRING "0.1 (August 2007)"
extern int memuse;
extern int mmemuse;
#define PERROR_RUNTIME(fmt, arg...) _printerror(NULL, 0, fmt, ## arg)
void _printdebug(const char *function, int line, unsigned long mask, const char *fmt, ...);
void _printerror(const char *function, int line, const char *fmt, ...);
+void debug(const char *function, int line, char *prefix, char *buffer);
#define DEBUG_CONFIG 0x0001
#define DEBUG_MSG 0x0002
/* call-info structure DIALING */
struct dialing_info {
- char number[256]; /* number dialing (so far) */
+ char id[256]; /* number dialing (so far) */
char interfaces[128]; /* interfaces for extenal calls */
int itype; /* type of interface */
int ntype; /* type of number */
/* call-info structure CONNECT */
struct connect_info {
char id[32]; /* id of caller (user number) */
- char voip[64]; /* URI of voip (or gateway) */
char extension[32]; /* internal id */
char name[16];
int isdn_port; /* internal/external port (if call is isdn) */
/* call-info structure REDIR */
struct redir_info {
char id[32]; /* id of caller (user number) */
- char voip[64]; /* host of voip (or gateway) */
- char intern[32]; /* internal id */
+ char extension[32]; /* internal id */
int isdn_port; /* internal/external port (if call is isdn) */
int itype; /* type of interface */
int ntype; /* type of number */
struct notify_info {
int notify; /* notifications (see INFO_NOTIFY_*) */
char id[32]; /* redirection id (user number) */
- char voip[64]; /* host of voip (or gateway) */
- char intern[32]; /* internal id */
+ char extension[32]; /* internal id */
int isdn_port; /* internal/external port (if call is isdn) */
int itype; /* type of interface */
int ntype; /* type of number */
#include "main.h"
struct options options = {
- "/usr/local/pbx/log", /* log file */
+ "/usr/local/lcr/log", /* log file */
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
PDEBUG(DEBUG_PORT, "data still in record buffer: %d (dir %d)\n", (p_record_buffer_writep - p_record_buffer_readp) & RECORD_BUFFER_MASK, p_record_buffer_dir);
memcpy(&callerinfo, &p_callerinfo, sizeof(struct caller_info));
- apply_callerid_restriction(p_record_anon_ignore, -1, callerinfo.id, &callerinfo.ntype, &callerinfo.present, &callerinfo.screen, NULL/*callerinfo.voip*/, callerinfo.extension, callerinfo.name);
+ apply_callerid_restriction(p_record_anon_ignore, callerinfo.id, &callerinfo.ntype, &callerinfo.present, &callerinfo.screen, callerinfo.extension, callerinfo.name);
- SCPY(number, p_dialinginfo.number);
+ SCPY(number, p_dialinginfo.id);
SCPY(callerid, numberrize_callerinfo(callerinfo.id, callerinfo.ntype));
if (callerid[0] == '\0')
{
goto match_string;
case MATCH_DIALING:
- string = e_dialinginfo.number;
+ string = e_dialinginfo.id;
goto match_string_prefix;
case MATCH_ENBLOCK:
/* set timeout in the furture */
e_match_timeout = timeout;
e_match_to_action = rule->action_first;
- e_match_to_extdialing = e_dialinginfo.number + dialing_required;
+ e_match_to_extdialing = e_dialinginfo.id + dialing_required;
match = 0; /* matches in the future */
}
if (match == 1)
action = rule->action_first;
e_match_timeout = 0; /* no timeout */
e_match_to_action = NULL;
- e_extdialing = e_dialinginfo.number + dialing_required;
+ e_extdialing = e_dialinginfo.id + dialing_required;
break;
}
if (match == 2)
Port -> Channel
Call -> Link
+connect_acknowledge
+
+
+maybe:
+
+delay - per param setzen, lokal als mISDNsignal und remote mittels setup
+
old stuff....
#include "main.h"
-trace auch ein printdebug
struct trace trace;
-char trace_string[MX_TRACE_ELEMENTS * 100 + 400];
+char trace_string[MAX_TRACE_ELEMENTS * 100 + 400];
static char *spaces[11] = {
" ",
{
if (trace.name[0])
PERROR("trace already started (name=%s)\n", trace.name);
- memset(trace, 0, sizeof(struct trace));
+ memset(&trace, 0, sizeof(struct trace));
trace.port = port;
- if (interface) if (interface[0])
- SCPY(trace.interface, interface);
+ if (interface)
+ SCPY(trace.interface, interface->name);
if (caller) if (caller[0])
SCPY(trace.caller, caller);
if (dialing) if (dialing[0])
* if subelement is given, element will also contain a subelement
* if multiple subelements belong to same element, name must be equal for all subelements
*/
-void add_trace(char *name, char *sub, const char *fmt, ...);
+void add_trace(char *name, char *sub, const char *fmt, ...)
{
va_list args;
if (!name[0])
{
nostring:
- PERROR("trace with name=%s gets element with no string\n", trace->name);
+ PERROR("trace with name=%s gets element with no string\n", trace.name);
return;
}
if (fmt) if (fmt[0])
{
va_start(args, fmt);
- VUNPRINT(trace.element[trace.element].value, sizeof(trace.element[trace.elements].value)-1, fmt, args);
+ VUNPRINT(trace.element[trace.elements].value, sizeof(trace.element[trace.elements].value)-1, fmt, args);
va_end(args);
}
/*
- * trace ends
- * this function will put the trace to sockets and logfile, if requested
- */
-void end_trace(void);
-{
- if (!trace.name[0])
- PERROR("trace not started\n");
-
- /* process log file */
- if (options.log[0])
- {
- string = print_trace(1, 0, NULL, NULL, NULL, -1, "AP", CATEGORY_EP);
- fwrite(string, strlen(string), 1, fp);
- if (options.deb)
- debug(NULL, 0, "trace", string);
- }
-
- memset(trace, 0, sizeof(struct trace));
-}
-
-
-/*
* prints trace to socket or log
* detail: 1 = brief, 2=short, 3=long
*/
-static char *print_trace(int detail, int port, char *interface, char *caller, char *dialing, int category);
+static char *print_trace(int detail, int port, char *interface, char *caller, char *dialing, int category)
{
- trace_string[0] = '\0';
char buffer[256];
+ time_t ti = trace.sec;
struct tm *tm;
+ struct mISDNport *mISDNport;
+ int i;
+
+ trace_string[0] = '\0'; // always clear string
if (detail < 1)
- return;
+ return(NULL);
/* filter trace */
if (port && trace.port)
- if (port != trace.port) return;
- if (interface && interface[0] && trace.interface[0])
- if (!!strcasecmp(interface, trace.interface)) return;
- if (caller && caller[0] && trace.caller[0])
- if (!!strcasecmp(caller, trace.caller)) return;
- if (dialing && dialing[0] && trace.dialing[0])
- if (!!strcasecmp(dialing, trace.dialing)) return;
- if (category && category[0] && trace.category[0])
- if (!!strcasecmp(category, trace.category)) return;
+ if (port != trace.port) return(NULL);
+ if (interface) if (interface[0] && trace.interface[0])
+ if (!!strcasecmp(interface, trace.interface)) return(NULL);
+ if (caller) if (caller[0] && trace.caller[0])
+ if (!!strcasecmp(caller, trace.caller)) return(NULL);
+ if (dialing) if (dialing[0] && trace.dialing[0])
+ if (!!strcasecmp(dialing, trace.dialing)) return(NULL);
+ if (category && trace.category)
+ if (category != trace.category) return(NULL);
/* head */
if (detail >= 3)
mISDNport = mISDNport_first;
while(mISDNport)
{
- if (mISDNport->number == trace.port)
+ if (mISDNport->portnum == trace.port)
break;
mISDNport = mISDNport->next;
}
if (mISDNport)
- SPRINT(buffer, "Port: %d (%s %s %s)", port, (mISDNport->pri)?"PRI":"BRI", (mISDNport->ptp)?"PTP":"PTMP", (mISDNport->nt)?"NT":"TE");
+ SPRINT(buffer, "Port: %d (%s %s %s)", port, (mISDNport->pri)?"PRI":"BRI", (mISDNport->ptp)?"PTP":"PTMP", (mISDNport->ntmode)?"NT":"TE");
else
SPRINT(buffer, "Port: %d (does not exist}\n", port);
SCAT(trace_string, buffer);
SCAT(trace_string, " Caller: ---\n");
/* "Time: 25.08.73 05:14:39.282" */
- tm = localtime(&trace.sec);
- SPRINT(buffer, "Time: %02d.%02d.%02d %02d:%02d:%02d.%03d", tm->tm_mday, tm->tm_mon+1, tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec, trace->usec/1000);
+ tm = localtime(&ti);
+ SPRINT(buffer, "Time: %02d.%02d.%02d %02d:%02d:%02d.%03d", tm->tm_mday, tm->tm_mon+1, tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec, trace.usec/1000);
SCAT(trace_string, buffer);
if (trace.direction)
buffer[0] = '\0';
SCAT(trace_string, buffer);
if (trace.element[i].sub[0])
- SPRINT(buffer, " %s=", trace.element[i].sub, value);
+ SPRINT(buffer, " %s=", trace.element[i].sub);
else
- SPRINT(buffer, " ", value);
+ SPRINT(buffer, " ");
SCAT(trace_string, buffer);
- if (strchr(value, ' '))
- SPRINT(buffer, "'%s'", value);
+ if (strchr(trace.element[i].value, ' '))
+ SPRINT(buffer, "'%s'", trace.element[i].value);
else
- SPRINT(buffer, "%s", value);
+ SPRINT(buffer, "%s", trace.element[i].value);
SCAT(trace_string, buffer);
i++;
}
SPRINT(buffer, " ");
SCAT(trace_string, buffer);
if (trace.element[i].sub[0])
- SPRINT(buffer, " : %s%s = ", trace.element[i].sub, spaces[strlen(trace.element[i].sub)], value);
+ SPRINT(buffer, " : %s%s = ", trace.element[i].sub, spaces[strlen(trace.element[i].sub)]);
else
- SPRINT(buffer, " : ", value);
+ SPRINT(buffer, " : ");
SCAT(trace_string, buffer);
- if (strchr(value, ' '))
- SPRINT(buffer, "'%s'\n", value);
+ if (strchr(trace.element[i].value, ' '))
+ SPRINT(buffer, "'%s'\n", trace.element[i].value);
else
- SPRINT(buffer, "%s\n", value);
+ SPRINT(buffer, "%s\n", trace.element[i].value);
SCAT(trace_string, buffer);
i++;
}
/* end */
if (detail >= 3)
SCAT(trace_string, "\n");
+ return(trace_string);
+}
+
+
+/*
+ * trace ends
+ * this function will put the trace to sockets and logfile, if requested
+ */
+void end_trace(void)
+{
+ char *string;
+
+ if (!trace.name[0])
+ PERROR("trace not started\n");
+
+ /* process log file */
+ if (options.deb)
+ {
+ string = print_trace(1, 0, NULL, NULL, NULL, 0);
+ if (string)
+ {
+ debug(NULL, 0, "trace", string);
+ }
+ }
+printf("%s", print_trace(3, 0, NULL, NULL, NULL, 0));
+#warning trace auch zum socket
+// fwrite(string, strlen(string), 1, fp);
+
+ memset(&trace, 0, sizeof(struct trace));
}
-^todo:
-socket
-file open
\*****************************************************************************/
struct trace_element {
- char name[10];
- char sub[10];
+ char name[11];
+ char sub[11];
char value[64];
};
unsigned long sec, usec;
/* type */
- char category[4];
+ int category;
int serial;
char name[64];
/* get apppbx */
memcpy(&p_vbox_ext, &((class EndpointAppPBX *)(epoint->ep_app))->e_ext, sizeof(p_vbox_ext));
/* extract optional announcement file */
- if ((c = strchr(param->setup.dialinginfo.number, ',')))
+ if ((c = strchr(param->setup.dialinginfo.id, ',')))
{
if (c[1] == '/')
SPRINT(filename, c+1);
{
SPRINT(filename, "%s/%s/%s/vbox/announcement", INSTALL_DATA, options.extensions_dir, p_vbox_ext.number);
}
- PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port received setup from '%s' to '%s'\n", p_name, param->setup.callerinfo.id, param->setup.dialinginfo.number);
+ PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port received setup from '%s' to '%s'\n", p_name, param->setup.callerinfo.id, param->setup.dialinginfo.id);
memcpy(&p_callerinfo, ¶m->setup.callerinfo, sizeof(p_callerinfo));
memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
/* link relation */
}
/* copy setup infos to port */
- SCPY(p_vbox_extension, param->setup.dialinginfo.number);
+ SCPY(p_vbox_extension, param->setup.dialinginfo.id);
/* create connect info */
SCPY(p_connectinfo.id, p_vbox_extension);