summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--action.cpp74
-rw-r--r--action_efi.cpp9
-rw-r--r--action_vbox.cpp7
-rw-r--r--apppbx.cpp34
-rw-r--r--apppbx.h2
-rw-r--r--bchannel.c34
-rw-r--r--bchannel.h5
-rw-r--r--callerid.c60
-rw-r--r--callerid.h14
-rw-r--r--chan_lcr.c359
-rw-r--r--chan_lcr.h7
-rw-r--r--crypt.cpp8
-rw-r--r--endpoint.cpp1
-rw-r--r--endpointapp.cpp2
-rw-r--r--interface.c6
-rw-r--r--join.cpp9
-rw-r--r--joinpbx.cpp15
-rw-r--r--joinremote.cpp9
-rw-r--r--mISDN.cpp4
-rw-r--r--mail.c10
-rw-r--r--main.h1
-rw-r--r--message.h5
-rw-r--r--port.cpp2
-rw-r--r--route.c9
-rw-r--r--route.h1
-rw-r--r--socket_server.c19
-rw-r--r--todo.txt2
-rw-r--r--vbox.cpp12
-rw-r--r--watch.c4
30 files changed, 438 insertions, 291 deletions
diff --git a/Makefile b/Makefile
index cfee9ee..416aeee 100644
--- a/Makefile
+++ b/Makefile
@@ -127,6 +127,9 @@ endpointapp.o: endpointapp.cpp *.h Makefile
apppbx.o: apppbx.cpp *.h Makefile
$(PP) -c $(CFLAGS) apppbx.cpp -o apppbx.o
+callerid.o: callerid.c *.h Makefile
+ $(PP) -c $(CFLAGS) callerid.c -o callerid.o
+
join.o: join.cpp *.h Makefile
$(PP) -c $(CFLAGS) join.cpp -o join.o
@@ -187,6 +190,7 @@ $(LCR): main.o \
endpoint.o \
endpointapp.o \
apppbx.o \
+ callerid.o \
crypt.o \
action.o \
action_vbox.o \
@@ -214,6 +218,7 @@ $(LCR): main.o \
endpoint.o \
endpointapp.o \
apppbx.o \
+ callerid.o \
crypt.o \
action.o \
action_vbox.o \
diff --git a/action.cpp b/action.cpp
index 67c8396..ab8e586 100644
--- a/action.cpp
+++ b/action.cpp
@@ -9,63 +9,11 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <poll.h>
#include "main.h"
-#include "linux/isdnif.h"
extern char **environ;
-/* create caller id from digits by comparing with national and international
- * prefixes.
- */
-char *nationalize_callerinfo(char *string, int *ntype)
-{
- if (!strncmp(options.international, string, strlen(options.international)))
- {
- *ntype = INFO_NTYPE_INTERNATIONAL;
- return(string+strlen(options.international));
- }
- if (!strncmp(options.national, string, strlen(options.national)))
- {
- *ntype = INFO_NTYPE_NATIONAL;
- return(string+strlen(options.national));
- }
- *ntype = INFO_NTYPE_SUBSCRIBER;
- return(string);
-}
-
-/* create number (including access codes) from caller id
- * prefixes.
- */
-char *numberrize_callerinfo(char *string, int ntype)
-{
- static char result[256];
-
- switch(ntype)
- {
- case INFO_NTYPE_INTERNATIONAL:
- UCPY(result, options.international);
- SCAT(result, string);
- return(result);
- break;
-
- case INFO_NTYPE_NATIONAL:
- UCPY(result, options.national);
- SCAT(result, string);
- return(result);
- break;
-
- default:
- return(string);
- }
-}
-
-
/*
* process init 'internal' / 'external' / 'remote' / 'vbox-record' / 'partyline'...
*/
@@ -126,7 +74,8 @@ void EndpointAppPBX::action_init_remote(void)
struct caller_info callerinfo;
struct redir_info redirinfo;
struct dialing_info dialinginfo;
- char remote[32];
+ char exten[128] = "";
+ char remote[32];
if (!(rparam = routeparam(e_action, PARAM_APPLICATION)))
{
@@ -146,16 +95,23 @@ void EndpointAppPBX::action_init_remote(void)
memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
memset(&dialinginfo, 0, sizeof(dialinginfo));
+ if ((rparam = routeparam(e_action, PARAM_EXTEN)))
+ {
+ SCPY(exten, rparam->string_value);
+ }
/* send setup to remote */
trace_header("ACTION remote (setup)", DIRECTION_NONE);
add_trace("number", NULL, dialinginfo.id);
add_trace("remote", NULL, remote);
+ if (exten[0])
+ add_trace("exten", NULL, remote);
end_trace();
message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info));
memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info));
memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info));
+ SCPY(message->param.setup.exten, exten);
message_put(message);
}
@@ -839,7 +795,7 @@ void EndpointAppPBX::_action_callerid_calleridnext(int next)
(!next)?e_ext.callerid_type:e_ext.id_next_call_type = INFO_NTYPE_UNKNOWN;
} else
{
- SCPY((!next)?e_ext.callerid:e_ext.id_next_call, nationalize_callerinfo(callerid,&((!next)?e_ext.callerid_type:e_ext.id_next_call_type)));
+ SCPY((!next)?e_ext.callerid:e_ext.id_next_call, nationalize_callerinfo(callerid,&((!next)?e_ext.callerid_type:e_ext.id_next_call_type), options.national, options.international));
}
if (!next) e_ext.id_next_call_type = -1;
PDEBUG(DEBUG_EPOINT, "EPOINT(%d): nationalized callerid: '%s' type=%d\n", ea_endpoint->ep_serial, (!next)?e_ext.callerid:e_ext.id_next_call, (!next)?e_ext.callerid_type:e_ext.id_next_call_type);
@@ -855,9 +811,9 @@ void EndpointAppPBX::_action_callerid_calleridnext(int next)
trace_header("ACTION change-callerid (only next call)", DIRECTION_NONE);
else
trace_header("ACTION change-callerid (all future calls)", DIRECTION_NONE);
- add_trace("old", "caller id", "%s", numberrize_callerinfo(old_id, old_type));
+ add_trace("old", "caller id", "%s", numberrize_callerinfo(old_id, old_type, options.national, options.international));
add_trace("old", "present", "%s", (old_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed");
- add_trace("new", "caller id", "%s", numberrize_callerinfo(new_id, new_type));
+ add_trace("new", "caller id", "%s", numberrize_callerinfo(new_id, new_type, options.national, options.international));
add_trace("new", "present", "%s", (new_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed");
end_trace();
message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
@@ -2063,7 +2019,7 @@ void EndpointAppPBX::action_hangup_execute(void)
argv[i++] = rparam->string_value;
}
argv[i++] = e_extdialing;
- argv[i++] = numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype);
+ argv[i++] = numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international);
argv[i++] = e_callerinfo.extension;
argv[i++] = e_callerinfo.name;
SPRINT(isdn_port, "%d", e_callerinfo.isdn_port);
@@ -2548,7 +2504,7 @@ void EndpointAppPBX::process_hangup(int cause, int location)
}
if (e_callerinfo.id[0])
- SPRINT(callertext, "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype));
+ SPRINT(callertext, "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
else
SPRINT(callertext, "unknown");
/* allpy restriction */
@@ -2566,7 +2522,7 @@ void EndpointAppPBX::process_hangup(int cause, int location)
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));
+ SPRINT(callertext, "extern:%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
if (!!strcmp(callertext, e_ext.last_in[0]))
{
i = MAX_REMEMBER-1;
diff --git a/action_efi.cpp b/action_efi.cpp
index 76c902f..61362c5 100644
--- a/action_efi.cpp
+++ b/action_efi.cpp
@@ -9,13 +9,6 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
#include "main.h"
enum {
@@ -107,7 +100,7 @@ void EndpointAppPBX::efi_message_eof(void)
e_efi_digit = 0;
// fall through
case EFI_STATE_DIGIT:
- digit[8] = numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype)[e_efi_digit];
+ digit[8] = numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype, options.national, options.international)[e_efi_digit];
if (digit[8])
{
set_tone_efi(digit);
diff --git a/action_vbox.cpp b/action_vbox.cpp
index e069299..2cd6edc 100644
--- a/action_vbox.cpp
+++ b/action_vbox.cpp
@@ -9,13 +9,6 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
#include "main.h"
diff --git a/apppbx.cpp b/apppbx.cpp
index 691a519..3d31f8e 100644
--- a/apppbx.cpp
+++ b/apppbx.cpp
@@ -10,14 +10,6 @@
\*****************************************************************************/
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <poll.h>
#include "main.h"
class EndpointAppPBX *apppbx_first = NULL;
@@ -146,7 +138,7 @@ void EndpointAppPBX::trace_header(char *name, int direction)
/* init trace with given values */
start_trace(0,
NULL,
- numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype),
+ numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international),
e_dialinginfo.id,
direction,
CATEGORY_EP,
@@ -282,7 +274,7 @@ void EndpointAppPBX::release(int release, int joinlocation, int joincause, int p
} else
{
/* numberrize caller id and use it to dial to the callback */
- SCPY(e_dialinginfo.id, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype));
+ SCPY(e_dialinginfo.id, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype, options.national, options.international));
}
e_dialinginfo.itype = INFO_ITYPE_ISDN;
e_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
@@ -338,7 +330,7 @@ char *EndpointAppPBX::apply_callerid_display(char *id, int itype, int ntype, int
static char display[81];
display[0] = '\0';
- char *cid = numberrize_callerinfo(id, ntype);
+ char *cid = numberrize_callerinfo(id, ntype, options.national, options.international);
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");
@@ -1031,7 +1023,7 @@ void EndpointAppPBX::out_setup(void)
if (message->param.setup.callerinfo.id[0] && e_ext.clip_prefix[0])
{
SCPY(message->param.setup.callerinfo.id, e_ext.clip_prefix);
- SCAT(message->param.setup.callerinfo.id, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype));
+ SCAT(message->param.setup.callerinfo.id, numberrize_callerinfo(e_callerinfo.id,e_callerinfo.ntype, options.national, options.international));
message->param.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
}
/* use internal caller id */
@@ -1996,7 +1988,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type,
logmessage(message_type, param, portlist->port_id, DIRECTION_IN);
/* signal to call tool */
- admin_call_response(e_adminid, ADMIN_CALL_CONNECT, numberrize_callerinfo(param->connectinfo.id,param->connectinfo.ntype), 0, 0, 0);
+ admin_call_response(e_adminid, ADMIN_CALL_CONNECT, numberrize_callerinfo(param->connectinfo.id,param->connectinfo.ntype, options.national, options.international), 0, 0, 0);
memcpy(&e_connectinfo, &param->connectinfo, sizeof(e_connectinfo));
PDEBUG(DEBUG_EPOINT, "EPOINT(%d) removing all other ports (start)\n", ea_endpoint->ep_serial);
@@ -2082,7 +2074,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type,
port = find_port_id(portlist->port_id);
if (port)
{
- SCPY(e_connectinfo.id, nationalize_callerinfo(port->p_dialinginfo.id, &e_connectinfo.ntype));
+ SCPY(e_connectinfo.id, nationalize_callerinfo(port->p_dialinginfo.id, &e_connectinfo.ntype, options.national, options.international));
e_connectinfo.present = INFO_PRESENT_ALLOWED;
}
}
@@ -2415,7 +2407,7 @@ void EndpointAppPBX::port_notify(struct port_list *portlist, int message_type, u
char buffer[64];
/* signal to call tool */
- admin_call_response(e_adminid, ADMIN_CALL_NOTIFY, numberrize_callerinfo(param->notifyinfo.id,param->notifyinfo.ntype), 0, 0, param->notifyinfo.notify);
+ admin_call_response(e_adminid, ADMIN_CALL_NOTIFY, numberrize_callerinfo(param->notifyinfo.id,param->notifyinfo.ntype, options.national, options.international), 0, 0, param->notifyinfo.notify);
if (param->notifyinfo.notify)
{
e_rx_state = track_notify(e_rx_state, param->notifyinfo.notify);
@@ -2972,7 +2964,7 @@ void EndpointAppPBX::join_connect(struct port_list *portlist, int message_type,
if (e_ext.number[0] && message->param.connectinfo.id[0] && e_ext.clip_prefix[0])
{
SCPY(message->param.connectinfo.id, e_ext.clip_prefix);
- SCAT(message->param.connectinfo.id, numberrize_callerinfo(e_connectinfo.id,e_connectinfo.ntype));
+ SCAT(message->param.connectinfo.id, numberrize_callerinfo(e_connectinfo.id,e_connectinfo.ntype, options.national, options.international));
message->param.connectinfo.ntype = INFO_NTYPE_UNKNOWN;
}
@@ -3437,7 +3429,7 @@ void EndpointAppPBX::ea_message_join(unsigned long join_id, int message_type, un
join_mISDNsignal(portlist, message_type, param);
break;
-was ist hiermit
+#warning was ist hiermit
#if 0
/* JOIN requests bchannel */
case MESSAGE_BCHANNEL: /* indicates the need of own bchannel access */
@@ -4057,7 +4049,7 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign
add_trace("from", NULL, "CH(%lu)", port_id);
if (param->setup.callerinfo.extension[0])
add_trace("extension", NULL, "%s", param->setup.callerinfo.extension);
- add_trace("caller id", "number", "%s", numberrize_callerinfo(param->setup.callerinfo.id, param->setup.callerinfo.ntype));
+ add_trace("caller id", "number", "%s", numberrize_callerinfo(param->setup.callerinfo.id, param->setup.callerinfo.ntype, options.national, options.international));
switch(param->setup.callerinfo.present)
{
case INFO_PRESENT_RESTRICTED:
@@ -4071,7 +4063,7 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign
}
if (param->setup.redirinfo.id[0])
{
- add_trace("redir'ing", "number", "%s", numberrize_callerinfo(param->setup.redirinfo.id, param->setup.redirinfo.ntype));
+ add_trace("redir'ing", "number", "%s", numberrize_callerinfo(param->setup.redirinfo.id, param->setup.redirinfo.ntype, options.national, options.international));
switch(param->setup.redirinfo.present)
{
case INFO_PRESENT_RESTRICTED:
@@ -4124,7 +4116,7 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign
add_trace("from", NULL, "CH(%lu)", port_id);
if (param->connectinfo.extension[0])
add_trace("extension", NULL, "%s", param->connectinfo.extension);
- add_trace("connect id", "number", "%s", numberrize_callerinfo(param->connectinfo.id, param->connectinfo.ntype));
+ add_trace("connect id", "number", "%s", numberrize_callerinfo(param->connectinfo.id, param->connectinfo.ntype, options.national, options.international));
switch(param->connectinfo.present)
{
case INFO_PRESENT_RESTRICTED:
@@ -4271,7 +4263,7 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign
add_trace("indicator", NULL, "%s", logtext);
if (param->notifyinfo.id[0])
{
- add_trace("redir'on", "number", "%s", numberrize_callerinfo(param->notifyinfo.id, param->notifyinfo.ntype));
+ add_trace("redir'on", "number", "%s", numberrize_callerinfo(param->notifyinfo.id, param->notifyinfo.ntype, options.national, options.international));
switch(param->notifyinfo.present)
{
case INFO_PRESENT_RESTRICTED:
diff --git a/apppbx.h b/apppbx.h
index 070bce5..4afb1e8 100644
--- a/apppbx.h
+++ b/apppbx.h
@@ -350,8 +350,6 @@ class EndpointAppPBX : public EndpointApp
};
-char *nationalize_callerinfo(char *string, int *type);
-char *numberrize_callerinfo(char *string, int type);
void apply_callerid_restriction(struct extension *ext, 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);
diff --git a/bchannel.c b/bchannel.c
index dbc11d7..02b6181 100644
--- a/bchannel.c
+++ b/bchannel.c
@@ -50,36 +50,14 @@ enum {
};
#ifdef SOCKET_MISDN
-int bchannel_socket = -1;
int bchannel_initialize(void)
{
- /* try to open raw socket to check kernel */
- bchannel_socket = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
- if (bchannel_socket < 0)
- {
- PERROR("Cannot open mISDN due to %s. (Does your Kernel support socket based mISDN?)\n", strerror(errno));
- return(-1);
- }
-
- mISDN_debug_init(global_debug, NULL, NULL, NULL);
-
- bchannel_pid = get_pid();
-
- /* init mlayer3 */
- init_layer3(4); // buffer of 4
-
return(0);
}
void bchannel_deinitialize(void)
{
- cleanup_layer3();
-
- mISDN_debug_close();
-
- if (bchannel_socket > -1)
- close(bchannel_socket);
}
#else
int bchannel_entity = 0; /* used for udevice */
@@ -850,7 +828,17 @@ void free_bchannel(struct bchannel *channel)
#else
if (channel->b_stid)
#endif
- bchannel_destroy(channel);
+ bchannel_destroy(channel);
+ if (channel->call)
+ {
+ if (channel->call->channel)
+ channel->call->channel = NULL;
+ }
+ if (channel->bridge_channel)
+ {
+ if (channel->bridge_channel->bridge_channel)
+ channel->bridge_channel->bridge_channel = NULL;
+ }
free(channel);
return;
}
diff --git a/bchannel.h b/bchannel.h
index 002cdd0..20a7e78 100644
--- a/bchannel.h
+++ b/bchannel.h
@@ -12,7 +12,7 @@
struct bchannel {
struct bchannel *next;
- unsigned long ref; /* ref for link to call process */
+ struct chan_call *call; /* ink to call process */
unsigned long handle; /* handle for stack id */
#ifdef SOCKET_MISDN
int b_sock; /* socket for b-channel */
@@ -20,6 +20,9 @@ struct bchannel {
unsigned long b_stid; /* stack id */
unsigned long b_addr; /* channel address */
#endif
+ unsigned short bridge_id; /* bridge id */
+ struct bchannel *bridge_channel;
+ /* remote channel */
int b_state;
int b_txdata;
int b_delay;
diff --git a/callerid.c b/callerid.c
new file mode 100644
index 0000000..47b51da
--- /dev/null
+++ b/callerid.c
@@ -0,0 +1,60 @@
+/*****************************************************************************\
+** **
+** PBX4Linux **
+** **
+**---------------------------------------------------------------------------**
+** Copyright: Andreas Eversberg **
+** **
+** caller id support file **
+** **
+\*****************************************************************************/
+
+#include "main.h"
+
+/* create caller id from digits by comparing with national and international
+ * prefixes.
+ */
+char *nationalize_callerinfo(char *string, int *ntype, char *national, char *international)
+{
+ if (!strncmp(options.international, string, strlen(options.international)))
+ {
+ *ntype = INFO_NTYPE_INTERNATIONAL;
+ return(string+strlen(international));
+ }
+ if (!strncmp(options.national, string, strlen(options.national)))
+ {
+ *ntype = INFO_NTYPE_NATIONAL;
+ return(string+strlen(national));
+ }
+ *ntype = INFO_NTYPE_SUBSCRIBER;
+ return(string);
+}
+
+/* create number (including access codes) from caller id
+ * prefixes.
+ */
+char *numberrize_callerinfo(char *string, int ntype, char *national, char *international)
+{
+ static char result[256];
+
+ switch(ntype)
+ {
+ case INFO_NTYPE_INTERNATIONAL:
+ UCPY(result, international);
+ SCAT(result, string);
+ return(result);
+ break;
+
+ case INFO_NTYPE_NATIONAL:
+ UCPY(result, national);
+ SCAT(result, string);
+ return(result);
+ break;
+
+ default:
+ return(string);
+ }
+}
+
+
+
diff --git a/callerid.h b/callerid.h
new file mode 100644
index 0000000..6fffd07
--- /dev/null
+++ b/callerid.h
@@ -0,0 +1,14 @@
+/*****************************************************************************\
+** **
+** Linux Call Router **
+** **
+**---------------------------------------------------------------------------**
+** Copyright: Andreas Eversberg **
+** **
+** callerid header file **
+** **
+\*****************************************************************************/
+
+char *nationalize_callerinfo(char *string, int *type, char *national, char *international);
+char *numberrize_callerinfo(char *string, int type, char *national, char *international);
+
diff --git a/chan_lcr.c b/chan_lcr.c
index 2cf2ae6..c5b2ec9 100644
--- a/chan_lcr.c
+++ b/chan_lcr.c
@@ -79,46 +79,11 @@ If the ref is 0 and the state is CHAN_LCR_STATE_RELEASE, see the proceedure
*/
-locking asterisk process and handler
+todo (before first compile)
reconnect after socket closed, release all calls.
debug of call handling
-denke an alle info-elements in jeder message (from asterisk & from lcr)
ausloesen beim socket-verlust
-bei "ast_channel_alloc" kannste die Callerid und den type usw. setzten.
-da kannste auch die calledPartyNum setzen. Um asterisk ein Setup zu schicken rufst du einfach "ast_pbx_start( channel ) " auf. Die ganzen queue baren indications und Controls findest du in "include/asterisk/frame.h"
-
-Also zusammenfassend:
-
-Messages die zum Asterisk gehen:
-
-SETUP - > ast_pbx_start(ast)
- CONNECT -> ast_queue_control(ast,
- AST_CONTROL_ANSWER);
-PROCEEDING -> ast_queue_control(ast,
- AST_CONTROL_PROCEEDING);
-ALERTING -> ast_queue_control(ast,
- AST_CONTROL_RINGING);
-DISCONNECT -> ast_queue_hangup(ast);
-
-Messages die vom Asterisk kommen:
-
-lcr_request -> NEWREF
-lcr_call -> SETUP
-lcr_answer -> CONNECT
-lcr_hangup -> RELEASE_(complete)
- lcr_indicate(AST_CONTROL_RINGING) -> ALERTING
- lcr_indicate(AST_CONTROL_PROCEEDING) -> PROCEEDING
- lcr_indicate(AST_CONTROL_PROGRESS) -> PROGRESS
- lcr_indicate(AST_CONTROL_BUSY) -> DISCONNECT ( cause=17 )
-
-
-
-
-
-
-
-
#include <stdio.h>
#include <stdlib.h>
@@ -236,6 +201,11 @@ void free_call(struct chan_call *call)
if (*temp == call)
{
*temp = (*temp)->next;
+ if (call->bch)
+ {
+ if (call->bch->call)
+ call->bch->call = NULL;
+ }
free(call);
return;
}
@@ -298,6 +268,21 @@ int send_message(int message_type, unsigned long ref, union parameter *param)
}
/*
+ * in case of a bridge, the unsupported message can be forwarded directly
+ * to the remote call.
+ */
+static void bridge_message_if_bridged(struct chan_call *call, int message_type, union parameter *param)
+{
+ /* check bridge */
+ if (!call) return;
+ if (!call->channel) return;
+ if (!call->channel->bridge_channel) return;
+ if (!call->channel->bridge_channel->call) return;
+ if (!call->channel->bridge_channel->call->ref) return;
+ send_message(MESSAGE_RELEASE, call->channel->bridge_channel->call->ref, param);
+}
+
+/*
* incoming setup from LCR
*/
static void lcr_in_setup(struct chan_call *call, int message_type, union parameter *param)
@@ -320,15 +305,67 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
}
/* set ast pointer */
call->ast = ast;
+ ast->tech_pvt = call;
+ ast->tech = &lcr_tech;
/* fill setup information */
-#warning todo: setup-info reinschreiben
+ if (param->setup.exten[0])
+ strdup(ast->exten, param->setup.exten);
+ if (param->setup.callerinfo.id[0])
+ strdup(ast->cid->cid_num, param->setup.callerinfo.id);
+ if (param->setup.callerinfo.name[0])
+ strdup(ast->cid->cid_name, param->setup.callerinfo.name);
+ if (param->setup.redirinfo.id[0])
+ strdup(ast->cid->cid_name, numberrize_callerinfo(param->setup.callerinfo.name, param->setup.callerinfo.ntype, configfile->prefix_nat, configfile->prefix_inter));
+ switch (param->setup.callerinfo.present)
+ {
+ case INFO_PRESENT_ALLOWED:
+ ast->cid->cid_pres = AST_PRESENT_ALLOWED;
+ break;
+ case INFO_PRESENT_RESTRICTED:
+ ast->cid->cid_pres = AST_PRESENT_RESTRICTED;
+ break;
+ default:
+ ast->cid->cid_pres = AST_PRESENT_UNAVAILABLE;
+ }
+ switch (param->setup.callerinfo.ntype)
+ {
+ case INFO_NTYPE_SUBSCRIBER:
+ ast->cid->cid_ton = AST_wasnu;
+ break;
+ case INFO_NTYPE_NATIONAL:
+ ast->cid->cid_ton = AST_wasnu;
+ break;
+ case INFO_NTYPE_INTERNATIONAL:
+ ast->cid->cid_ton = AST_wasnu;
+ break;
+ default:
+ ast->cid->cid_ton = AST_wasnu;
+ }
+ ast->transfercapability = param->setup.bearerinfo.capability;
+
+ /* configure channel */
+ ast->state = AST_STATE_RESERVED;
+ snprintf(ast->name, sizeof(ast->name), "%s/%d", lcr_type, ++glob_channel);
+ ast->name[sizeof(ast->name)-1] = '\0';
+ ast->type = lcr_type;
+ ast->nativeformat = configfile->lawformat;
+ ast->readformat = ast->rawreadformat = configfile->lawformat;
+ ast->writeformat = ast->rawwriteformat = configfile->lawformat;
+ ast->hangupcause = 0;
+
+ /* change state */
+ call->state = CHAN_LCR_STATE_IN_SETUP;
/* send setup to asterisk */
-#warning todo: setup bei der asterisk triggern
+ ast_pbx_start(ast);
+
+ /* send setup acknowledge to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ send_message(MESSAGE_OVERLAP, call->ref, &newparam);
/* change state */
- call->state = CHAN_LCR_STATE_IN_SETUP;
+ call->state = CHAN_LCR_STATE_IN_DIALING;
}
/*
@@ -336,9 +373,11 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
*/
static void lcr_in_overlap(struct chan_call *call, int message_type, union parameter *param)
{
+ if (!call->ast) return;
+
/* send pending digits in dialque */
if (call->dialque)
- send_dialing_to_lcr(call);
+ send_dialque_to_lcr(call);
/* change to overlap state */
call->state = CHAN_LCR_STATE_OUT_DIALING;
}
@@ -351,7 +390,8 @@ static void lcr_in_proceeding(struct chan_call *call, int message_type, union pa
/* change state */
call->state = CHAN_LCR_STATE_OUT_PROCEEDING;
/* send event to asterisk */
- ast_queue_... todo
+ if (call->ast)
+ ast_queue_control(ast, AST_CONTROL_PROCEEDING);
}
/*
@@ -362,7 +402,8 @@ static void lcr_in_alerting(struct chan_call *call, int message_type, union para
/* change state */
call->state = CHAN_LCR_STATE_OUT_ALERTING;
/* send event to asterisk */
- ast_queue_... todo
+ if (call->ast)
+ ast_queue_control(ast, AST_CONTROL_RINGING);
}
/*
@@ -373,9 +414,10 @@ static void lcr_in_connect(struct chan_call *call, int message_type, union param
/* change state */
call->state = CHAN_LCR_STATE_CONNECT;
/* copy connectinfo */
- todo
+ memcpy(call->connectinfo, param->connectinfo, sizeof(struct connect_info));
/* send event to asterisk */
- ast_queue_... todo
+ if (call->ast)
+ ast_queue_control(ast, AST_CONTROL_ANSWER);
}
/*
@@ -383,12 +425,31 @@ static void lcr_in_connect(struct chan_call *call, int message_type, union param
*/
static void lcr_in_disconnect(struct chan_call *call, int message_type, union parameter *param)
{
+ union parameter newparam;
+
/* change state */
call->state = CHAN_LCR_STATE_IN_DISCONNECT;
- /* copy disconnect info */
- todo
- /* send event to asterisk */
- ast_queue_... todo
+ /* save cause */
+ call->cause = param.disconnectinfo.cause;
+ call->location = param.disconnectinfo.location;
+ /* if bridge, forward disconnect and return */
+ if (call->channel)
+ if (call->channel->bridge_channel)
+ if (call->channel->bridge_channel->call)
+ {
+ bridge_message_if_bridged(call, message_type, param);
+ return;
+ }
+ /* release lcr */
+ newparam.disconnectinfo.cause = CAUSE_NORMAL;
+ newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+ send_message(MESSAGE_RELEASE, ref, &newparam);
+ ref = 0;
+ /* release asterisk */
+ call->ast->hangupcause = call->cause;
+ ast_queue_hangup(call->ast);
+ /* change to release state */
+ call->state = CHAN_LCR_STATE_RELEASE;
}
/*
@@ -401,10 +462,12 @@ static void lcr_in_release(struct chan_call *call, int message_type, union param
/* change to release state */
call->state = CHAN_LCR_STATE_RELEASE;
/* copy release info */
- todo
+ if (!call->cause)
+ call->cause = param.disconnectinfo.cause;
/* if we have an asterisk instance, send hangup, else we are done */
if (call->ast)
{
+ call->ast->hangupcause = call->cause;
ast_queue_hangup(call->ast);
} else
{
@@ -418,10 +481,40 @@ static void lcr_in_release(struct chan_call *call, int message_type, union param
*/
static void lcr_in_information(struct chan_call *call, int message_type, union parameter *param)
{
+ struct ast_frame fr;
+ char *p;
+
+ if (!call->ast) return;
+
/* copy digits */
- todo and write them, maybe queue them for asterisk
- /* send event to asterisk */
- ast_queue_... todo
+ p = param->dialinginfo.id;
+ if (call->state == CHAN_LCR_STATE_IN_DIALING && *p)
+ {
+ while (*p)
+ {
+ /* send digit to asterisk */
+ memset(&fr, 0, sizeof(fr));
+ fr.frametype = AST_FRAME_DTMF;
+ fr.subclass = *p;
+ fr.delivery = ast_tv(0, 0);
+ ast_queue_frame(call->ast, &fr);
+ p++;
+ }
+ }
+ /* use bridge to forware message not supported by asterisk */
+ if (call->state == CHAN_LCR_STATE_CONNECT)
+ bridge_message_if_bridged(call, message_type, param);
+}
+
+/*
+ * incoming information from LCR
+ */
+static void lcr_in_notify(struct chan_call *call, int message_type, union parameter *param)
+{
+ if (!call->ast) return;
+
+ /* use bridge to forware message not supported by asterisk */
+ bridge_message_if_bridged(call, message_type, param);
}
/*
@@ -429,11 +522,10 @@ static void lcr_in_information(struct chan_call *call, int message_type, union p
*/
static void lcr_in_facility(struct chan_call *call, int message_type, union parameter *param)
{
- /* copy progress info */
- todo and write them, maybe queue them for asterisk
- /* send event to asterisk */
- ast_queue_... todo
- or maybe use bride info to forward facility.
+ if (!call->ast) return;
+
+ /* use bridge to forware message not supported by asterisk */
+ bridge_message_if_bridged(call, message_type, param);
}
/*
@@ -625,8 +717,12 @@ int receive_message(int message_type, unsigned long ref, union parameter *param)
lcr_in_disconnect(call, message_type, param);
break;
+ case MESSAGE_NOTIFY:
+ lcr_in_notify(call, message_type, param);
+ break;
+
case MESSAGE_FACILITY:
- lcr_in_disconnect(call, message_type, param);
+ lcr_in_facility(call, message_type, param);
break;
case MESSAGE_PATTERN:
@@ -826,13 +922,58 @@ static void *chan_thread(void *arg)
*/
static void send_setup_to_lcr(struct chan_call *call)
{
+ union parameter newparam;
+
if (!ast || !call->ref)
return;
/* send setup message to LCR */
memset(&newparam, 0, sizeof(union parameter));
- newparam.setup.xxxxxx =
+ newparam.setup.callerinfo.itype = INFO_ITYPE_CHAN;
+ newparam.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
+ if (ast->cid->cid_num) if (ast->cid->cid_num[0])
+ strncpy(newparam.setup.callerinfo.id, ast->cid->cid_num, sizeof(newparam.setup.callerinfo.id)-1);
+ if (ast->cid->cid_name) if (ast->cid->cid_name[0])
+ strncpy(newparam.setup.callerinfo.name, ast->cid->cid_name, sizeof(newparam.setup.callerinfo.name)-1);
+ if (ast->cid->cid_rdnis) if (ast->cid->cid_rdnis[0])
+ {
+ strncpy(newparam.setup.redirinfo.id, ast->cid->cid_rdnis, sizeof(newparam.setup.redirinfo.id)-1);
+ newparam.setup.redirinfo.itype = INFO_ITYPE_CHAN;
+ newparam.setup.redirinfo.ntype = INFO_NTYPE_UNKNOWN;
+ }
+ switch(ast->cid->cid_pres & AST_PRES_RESTRICTION)
+ {
+ case AST_PRES_ALLOWED:
+ newparam.setup.callerinfo.present = INFO_PRESENT_ALLOWED;
+ break;
+ case AST_PRES_RESTRICTED:
+ newparam.setup.callerinfo.present = INFO_PRESENT_RESTRICTED;
+ break;
+ case AST_PRES_UNAVAILABLE:
+ newparam.setup.callerinfo.present = INFO_PRESENT_NOTAVAIL;
+ break;
+ default:
+ newparam.setup.callerinfo.present = INFO_PRESENT_NULL;
+ }
+ switch(ast->cid->cid_ton)
+ {
+ case AST_wasist:
+ newparam.setup.callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
+ break;
+ case AST_wasist:
+ newparam.setup.callerinfo.ntype = INFO_NTYPE_NATIONAL;
+ break;
+ case AST_wasist:
+ newparam.setup.callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
+ break;
+ }
+ newparam.setup.capainfo.bearer_capa = ast->transfercapability;
+ newparam.setup.capainfo.bearer_user = alaw 3, ulaw 2;
+ newparam.setup.capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
+ newparam.setup.capainfo.hlc = INFO_HLC_NONE;
+ newparam.setup.capainfo.exthlc = INFO_HLC_NONE;
send_message(MESSAGE_SETUP, call->ref, &newparam);
+
/* change to outgoing setup state */
call->state = CHAN_LCR_STATE_OUT_SETUP;
}
@@ -883,8 +1024,10 @@ static struct ast_channel *lcr_request(const char *type, int format, void *data,
* this function is called, when setup acknowledge is received and dialing
* info is available.
*/
-static void send_dialing_to_lcr(struct chan_call *call)
+static void send_dialque_to_lcr(struct chan_call *call)
{
+ union parameter newparam;
+
if (!ast || !call->ref || !call->dialque)
return;
@@ -900,6 +1043,8 @@ static void send_dialing_to_lcr(struct chan_call *call)
*/
static struct ast_channel *lcr_request(const char *type, int format, void *data, int *cause)
{
+ union parameter newparam;
+
pthread_mutex_lock(&chan_lock);
/* create call instance */
@@ -920,6 +1065,16 @@ static struct ast_channel *lcr_request(const char *type, int format, void *data,
/* link together */
ast->tech_pvt = call;
call->ast = ast;
+ ast->tech = &lcr_tech;
+ /* configure channel */
+ ast->state = AST_STATE_RESERVED;
+ snprintf(ast->name, sizeof(ast->name), "%s/%d", lcr_type, ++glob_channel);
+ ast->name[sizeof(ast->name)-1] = '\0';
+ ast->type = lcr_type;
+ ast->nativeformat = configfile->lawformat;
+ ast->readformat = ast->rawreadformat = configfile->lawformat;
+ ast->writeformat = ast->rawwriteformat = configfile->lawformat;
+ ast->hangupcause = 0;
/* send MESSAGE_NEWREF */
memset(&newparam, 0, sizeof(union parameter));
newparam.direction = 0; /* request from app */
@@ -935,6 +1090,7 @@ static struct ast_channel *lcr_request(const char *type, int format, void *data,
*/
static int lcr_call(struct ast_channel *ast, char *dest, int timeout)
{
+ union parameter newparam;
struct chan_call *call=ast->tech_pvt;
char buf[128];
char *port_str, *dad, *p;
@@ -964,6 +1120,7 @@ static int lcr_call(struct ast_channel *ast, char *dest, int timeout)
static int lcr_digit(struct ast_channel *ast, char digit)
{
+ union parameter newparam;
char buf[]="x";
if (!call) return -1;
@@ -977,17 +1134,16 @@ static int lcr_digit(struct ast_channel *ast, char digit)
/* send information or queue them */
if (call->ref && call->state == CHAN_LCR_STATE_OUT_DIALING)
{
- send_dialing_to_lcr(call);
+ memset(&newparam, 0, sizeof(union parameter));
+ newparam.dialinginfo.id[0] = digit;
+ newparam.dialinginfo.id[1] = '\0';
+ send_message(MESSAGE_INFORMATION, call->ref, &newparam);
} else
if (!call->ref
&& (call->state == CHAN_LCR_STATE_OUT_PREPARE || call->state == CHAN_LCR_STATE_OUT_SETUP));
{
*buf = digit;
strncat(call->dialque, buf, strlen(char->dialque)-1);
- } else
- {
-digits kommen, koennen aber nicht verwendet werden.
- sollen wir sie als info senden (im connect zb.)
}
pthread_mutex_unlock(&chan_lock);
@@ -997,15 +1153,34 @@ digits kommen, koennen aber nicht verwendet werden.
static int lcr_answer(struct ast_channel *c)
{
+ union parameter newparam;
struct chan_call *call=c->tech_pvt;
+
if (!call) return -1;
+
pthread_mutex_lock(&chan_lock);
- pthread_mutex_unlock(&chan_lock);
+
+ /* check bridged connectinfo */
+ if (call->bchannel)
+ if (call->bchannel->bridge_channel)
+ if (call->bchannel->bridge_channel->call)
+ {
+ memcpy(call->connectinfo, call->bchannel->bridge_channel->call->connectinfo, sizeof(struct connect_info));
+ }
+ /* send connect message to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ memcpy(param->connectinfo, call->connectinfo, sizeof(struct connect_info));
+ send_message(MESSAGE_CONNECT, call->ref, &newparam);
+ /* change state */
+ call->state = CHAN_LCR_STATE_CONNECT;
+
+ pthread_mutex_unlock(&chan_lock);
return 0;
}
static int lcr_hangup(struct ast_channel *ast)
{
+ union parameter newparam;
struct chan_call *call = ast->tech_pvt;
if (!call)
@@ -1042,37 +1217,59 @@ static int lcr_hangup(struct ast_channel *ast)
return 0;
}
-static int lcr_write(struct ast_channel *c, struct ast_frame *f)
+static int lcr_write(struct ast_channel *ast, struct ast_frame *f)
{
- struct chan_call *call= c->tech_pvt;
+ struct chan_call *call= ast->tech_pvt;
if (!call) return 0;
pthread_mutex_lock(&chan_lock);
pthread_mutex_unlock(&chan_lock);
}
-static struct ast_frame *lcr_read(struct ast_channel *c)
+static struct ast_frame *lcr_read(struct ast_channel *ast)
{
- struct chan_call *call = c->tech_pvt;
+ struct chan_call *call = ast->tech_pvt;
if (!call) return 0;
pthread_mutex_lock(&chan_lock);
pthread_mutex_unlock(&chan_lock);
}
-static int lcr_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
+static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen)
{
+ union parameter newparam;
int res = -1;
+
if (!call) return -1;
pthread_mutex_lock(&chan_lock);
switch (cond) {
case AST_CONTROL_BUSY:
+ /* send message to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ newparam.disconnectinfo.cause = 17;
+ newparam.disconnectinfo.location = 5;
+ send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
+ /* change state */
+ call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+ /* return */
+ pthread_mutex_unlock(&chan_lock);
+ return 0;
case AST_CONTROL_CONGESTION:
- case AST_CONTROL_RINGING:
+ /* return */
pthread_mutex_unlock(&chan_lock);
return -1;
+ case AST_CONTROL_RINGING:
+ /* send message to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ send_message(MESSAGE_ALERTING, call->ref, &newparam);
+ /* change state */
+ call->state = CHAN_LCR_STATE_OUT_ALERTING;
+ /* return */
+ pthread_mutex_unlock(&chan_lock);
+ return 0;
case -1:
+ /* return */
pthread_mutex_unlock(&chan_lock);
return 0;
@@ -1080,20 +1277,26 @@ static int lcr_indicate(struct ast_channel *c, int cond, const void *data, size_
res = -1;
break;
case AST_CONTROL_HOLD:
- ast_verbose(" << Console Has Been Placed on Hold >> \n");
- //ast_moh_start(c, data, g->mohinterpret);
+ /* send message to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ newparam.notifyinfo.notify = INFO_NOTIFY_REMOTE_HOLD;
+ send_message(MESSAGE_NOTIFY, call->ref, &newparam);
break;
case AST_CONTROL_UNHOLD:
- ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
- //ast_moh_stop(c);
+ /* send message to lcr */
+ memset(&newparam, 0, sizeof(union parameter));
+ newparam.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL;
+ send_message(MESSAGE_NOTIFY, call->ref, &newparam);
break;
default:
ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, c->name);
+ /* return */
pthread_mutex_unlock(&chan_lock);
return -1;
}
+ /* return */
pthread_mutex_unlock(&chan_lock);
return 0;
}
@@ -1105,7 +1308,7 @@ static struct ast_channel_tech lcr_tech = {
.requester=lcr_request,
.send_digit=lcr_digit,
.call=lcr_call,
-// .bridge=lcr_bridge,
+ .bridge=lcr_bridge,
.hangup=lcr_hangup,
.answer=lcr_answer,
.read=lcr_read,
@@ -1119,6 +1322,8 @@ static struct ast_channel_tech lcr_tech = {
#warning das muss mal aus der config datei gelesen werden:
char lcr_context[]="from-lcr";
+
+TODO: muss oben ins lcr_in setup und ins lcr_request
static struct ast_channel *lcr_ast_new(struct chan_call *call, char *exten, char *callerid, int ref)
{
struct ast_channel *tmp;
diff --git a/chan_lcr.h b/chan_lcr.h
index f1842c6..29affad 100644
--- a/chan_lcr.h
+++ b/chan_lcr.h
@@ -10,16 +10,15 @@
\*****************************************************************************/
/* structure for all calls */
+struct bchannel;
struct chan_call {
struct chan_call *next; /* link to next call instance */
int state; /* current call state CHAN_LCR_STATE */
unsigned long ref; /* callref for this channel */
struct ast_channel *ast; /* current asterisk channel */
- unsigned long bchannel_handle;
+ struct bchannel *channel;
/* reference to bchannel, if set */
- unsigned short bridge_id; /* 0 = off, equal ids are bridged */
-
- struct ast_channel *ast;
+ int cause, location;
};
enum {
diff --git a/crypt.cpp b/crypt.cpp
index 92f0c10..80ece0e 100644
--- a/crypt.cpp
+++ b/crypt.cpp
@@ -140,14 +140,10 @@ the message type is encoded as element
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
+#include "main.h"
#ifdef CRYPTO
#include <openssl/rsa.h>
#endif
-#include "main.h"
/* convert key string to binary key vector
@@ -1831,7 +1827,7 @@ void EndpointAppPBX::encrypt_shared(void)
errstr = "No Remote ID";
goto reject;
}
- ret = parse_secrets((char *)e_ext.number, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype), &auth_pointer, &crypt_pointer, &key_pointer);
+ ret = parse_secrets((char *)e_ext.number, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international), &auth_pointer, &crypt_pointer, &key_pointer);
}
if (!ret)
{
diff --git a/endpoint.cpp b/endpoint.cpp
index e0f6365..48e0db6 100644
--- a/endpoint.cpp
+++ b/endpoint.cpp
@@ -9,7 +9,6 @@
** **
\*****************************************************************************/
-#include <stdio.h>
#include "main.h"
unsigned long epoint_serial = 1; /* initial value must be 1, because 0== no epoint */
diff --git a/endpointapp.cpp b/endpointapp.cpp
index 9479033..0ebd482 100644
--- a/endpointapp.cpp
+++ b/endpointapp.cpp
@@ -9,8 +9,6 @@
** **
\*****************************************************************************/
-
-#include <stdio.h>
#include "main.h"
/*
diff --git a/interface.c b/interface.c
index 6ac2871..f8f7bdc 100644
--- a/interface.c
+++ b/interface.c
@@ -1356,13 +1356,13 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in
}
if (ifmsn)
{
- start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)");
+ start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)");
add_trace("msn", NULL, "%s", id);
end_trace();
}
if (!ifmsn && msn1) // not in list, first msn given
{
- start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)");
+ start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)");
add_trace("msn", "given", "%s", id);
add_trace("msn", "used", "%s", msn1);
end_trace();
@@ -1395,7 +1395,7 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in
}
if (ifscreen) // match
{
- start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)");
+ start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)");
switch(*type)
{
case INFO_NTYPE_UNKNOWN:
diff --git a/join.cpp b/join.cpp
index df7bf67..c41ae4b 100644
--- a/join.cpp
+++ b/join.cpp
@@ -9,19 +9,10 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-//#include <string.h>
-//#include <stdlib.h>
-//#include <unistd.h>
-//#include <poll.h>
-//#include <sys/types.h>
-//#include <sys/stat.h>
-//#include <fcntl.h>
#include "main.h"
//#define __u8 unsigned char
//#define __u16 unsigned short
//#define __u32 unsigned long
-//#include "linux/isdnif.h"
unsigned long join_serial = 1; /* must be 1, because 0== no join */
diff --git a/joinpbx.cpp b/joinpbx.cpp
index 73b9f59..15bfcd8 100644
--- a/joinpbx.cpp
+++ b/joinpbx.cpp
@@ -9,19 +9,10 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "main.h"
-#define __u8 unsigned char
-#define __u16 unsigned short
-#define __u32 unsigned long
-#include "linux/isdnif.h"
+//#define __u8 unsigned char
+//#define __u16 unsigned short
+//#define __u32 unsigned long
/* notify endpoint about state change (if any) */
diff --git a/joinremote.cpp b/joinremote.cpp
index ec65f35..20c94dc 100644
--- a/joinremote.cpp
+++ b/joinremote.cpp
@@ -9,19 +9,10 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-//#include <unistd.h>
-//#include <poll.h>
-//#include <sys/types.h>
-//#include <sys/stat.h>
-//#include <fcntl.h>
#include "main.h"
//#define __u8 unsigned char
//#define __u16 unsigned short
//#define __u32 unsigned long
-//#include "linux/isdnif.h"
/*
diff --git a/mISDN.cpp b/mISDN.cpp
index 97e8ef4..c9eb114 100644
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -317,7 +317,7 @@ void chan_trace_header(struct mISDNport *mISDNport, class PmISDN *port, char *ms
/* init trace with given values */
start_trace(mISDNport?mISDNport->portnum:0,
(mISDNport)?((mISDNport->ifport)?mISDNport->ifport->interface:NULL):NULL,
- port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype):NULL,
+ port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international):NULL,
port?port->p_dialinginfo.id:NULL,
direction,
CATEGORY_CH,
@@ -428,7 +428,7 @@ void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsign
/* init trace with given values */
start_trace(mISDNport?mISDNport->portnum:0,
mISDNport?mISDNport->ifport->interface:NULL,
- port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype):NULL,
+ port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international):NULL,
port?port->p_dialinginfo.id:NULL,
direction,
CATEGORY_CH,
diff --git a/mail.c b/mail.c
index b55fc56..9acd145 100644
--- a/mail.c
+++ b/mail.c
@@ -9,16 +9,6 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-//#include <poll.h>
#include "main.h"
static char *months[] = {
diff --git a/main.h b/main.h
index 720a3c4..eff5b7e 100644
--- a/main.h
+++ b/main.h
@@ -150,6 +150,7 @@ extern "C" {
#include "endpoint.h"
#include "endpointapp.h"
#include "apppbx.h"
+#include "callerid.h"
#include "route.h"
#include "port.h"
#include "mISDN.h"
diff --git a/message.h b/message.h
index 7712cd1..f1b4e30 100644
--- a/message.h
+++ b/message.h
@@ -26,7 +26,7 @@ enum { /* number types */
};
enum { /* number presentation */
- INFO_PRESENT_NULL,
+ INFO_PRESENT_NULL = 0,
INFO_PRESENT_ALLOWED,
INFO_PRESENT_RESTRICTED,
INFO_PRESENT_NOTAVAIL,
@@ -38,7 +38,7 @@ enum { /* number presentation */
};
enum { /* redirection reason */
- INFO_REDIR_UNKNOWN,
+ INFO_REDIR_UNKNOWN = 0,
INFO_REDIR_BUSY,
INFO_REDIR_NORESPONSE,
INFO_REDIR_UNCONDITIONAL,
@@ -257,6 +257,7 @@ struct message_setup {
struct redir_info redirinfo; /* info on redirection (to the calling user) */
struct capa_info capainfo; /* info on l2,l3 capability */
struct useruser_info useruser; /* user-user */
+ char exten[128]; /* asterisk extension */
};
/* call-info structure PARK */
diff --git a/port.cpp b/port.cpp
index a44cebe..e397b31 100644
--- a/port.cpp
+++ b/port.cpp
@@ -801,7 +801,7 @@ void Port::close_record(int beep, int mute)
// apply_callerid_restriction(p_record_anon_ignore, callerinfo.id, &callerinfo.ntype, &callerinfo.present, &callerinfo.screen, callerinfo.extension, callerinfo.name);
SCPY(number, p_dialinginfo.id);
- SCPY(callerid, numberrize_callerinfo(callerinfo.id, callerinfo.ntype));
+ SCPY(callerid, numberrize_callerinfo(callerinfo.id, callerinfo.ntype, options.national, options.international));
if (callerid[0] == '\0')
{
if (callerinfo.present == INFO_PRESENT_RESTRICTED)
diff --git a/route.c b/route.c
index 1899b08..f4dcd26 100644
--- a/route.c
+++ b/route.c
@@ -231,6 +231,9 @@ struct param_defs param_defs[] = {
{ PARAM_APPLICATION,
"application",PARAM_TYPE_STRING,
"application=<name>", "Name of remote application to make call to."},
+ { PARAM_EXTEN,
+ "exten", PARAM_TYPE_STRING,
+ "exten=<extension>", "Give exten parameter to the remote application."},
{ 0, NULL, 0, NULL, NULL}
};
@@ -249,7 +252,7 @@ struct action_defs action_defs[] = {
"Same as 'extern'"},
{ ACTION_REMOTE,
"remote", &EndpointAppPBX::action_init_remote, &EndpointAppPBX::action_dialing_remote, &EndpointAppPBX::action_hangup_call,
- PARAM_CONNECT | PARAM_APPLICATION | PARAM_TIMEOUT,
+ PARAM_CONNECT | PARAM_APPLICATION | PARAM_EXTEN | PARAM_TIMEOUT,
"Call is routed to Remote application, like Asterisk."},
{ ACTION_VBOX_RECORD,
"vbox-record",&EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_vbox_record, &EndpointAppPBX::action_hangup_call,
@@ -1962,8 +1965,8 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
e_match_timeout = 0; /* no timeout */
e_match_to_action = NULL;
- SCPY(callerid, numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype));
- SCPY(redirid, numberrize_callerinfo(e_redirinfo.id, e_redirinfo.ntype));
+ SCPY(callerid, numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
+ SCPY(redirid, numberrize_callerinfo(e_redirinfo.id, e_redirinfo.ntype, options.national, options.international));
PDEBUG(DEBUG_ROUTE, "parsing ruleset '%s'\n", ruleset->name);
while(rule)
diff --git a/route.h b/route.h
index 22c68e2..551363a 100644
--- a/route.h
+++ b/route.h
@@ -136,6 +136,7 @@ enum { /* how to parse text file during startup */
#define PARAM_NOPASSWORD (1LL<<42)
#define PARAM_STRIP (1LL<<43)
#define PARAM_APPLICATION (1LL<<44)
+#define PARAM_EXTEN (1LL<<45)
/* action index
diff --git a/socket_server.c b/socket_server.c
index 6565602..b50b3e7 100644
--- a/socket_server.c
+++ b/socket_server.c
@@ -9,23 +9,10 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-//#include <stdlib.h>
-//#include <string.h>
-#include <sys/types.h>
-//#include <sys/stat.h>
-//#include <unistd.h>
-//#include <signal.h>
-//#include <fcntl.h>
-#include <sys/ioctl.h>
-//#include <sys/file.h>
-//#include <errno.h>
-//#include <sys/mman.h>
-//#include <sys/resource.h>
+#include "main.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <curses.h>
-#include "main.h"
char *socket_name = SOCKET_NAME;
@@ -274,7 +261,7 @@ int admin_route(struct admin_queue **responsep)
apppbx->release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL);
start_trace(0,
NULL,
- numberrize_callerinfo(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype),
+ numberrize_callerinfo(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype, options.national, options.international),
apppbx->e_dialinginfo.id,
DIRECTION_NONE,
CATEGORY_EP,
@@ -516,7 +503,7 @@ int admin_call(struct admin_list *admin, struct admin_message *msg)
FATAL("No memory for Endpoint Application instance\n");
apppbx->e_adminid = admin->sockserial;
admin->epointid = epoint->ep_serial;
- SCPY(apppbx->e_callerinfo.id, nationalize_callerinfo(msg->u.call.callerid, &apppbx->e_callerinfo.ntype));
+ SCPY(apppbx->e_callerinfo.id, nationalize_callerinfo(msg->u.call.callerid, &apppbx->e_callerinfo.ntype, options.national, options.international));
if (msg->u.call.present)
apppbx->e_callerinfo.present = INFO_PRESENT_ALLOWED;
else
diff --git a/todo.txt b/todo.txt
index 568abe8..325392d 100644
--- a/todo.txt
+++ b/todo.txt
@@ -37,6 +37,8 @@ wir koennen informationen, wie notifys einfach parallel zur bridge weiterreichen
call transfer
+doku: remote, exten
+
doku: action execute geht mit fork
doku: rx_vol -> rx_gain
diff --git a/vbox.cpp b/vbox.cpp
index ef05943..419c226 100644
--- a/vbox.cpp
+++ b/vbox.cpp
@@ -13,16 +13,6 @@
** **
\*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <poll.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "main.h"
/* note: recording log is written at endpoint */
@@ -60,7 +50,7 @@ static void vbox_trace_header(class VBoxPort *vbox, char *message, int direction
/* init trace with given values */
start_trace(0,
NULL,
- vbox?numberrize_callerinfo(vbox->p_callerinfo.id, vbox->p_callerinfo.ntype):NULL,
+ vbox?numberrize_callerinfo(vbox->p_callerinfo.id, vbox->p_callerinfo.ntype, options.national, options.international):NULL,
vbox?vbox->p_dialinginfo.id:NULL,
direction,
CATEGORY_CH,
diff --git a/watch.c b/watch.c
index e8d7a5e..e44062e 100644
--- a/watch.c
+++ b/watch.c
@@ -1,11 +1,11 @@
/*****************************************************************************\
** **
-** PBX4Linux **
+** Linux-Call-Router **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
** **
-** PBX Watchdog with debug function **
+** LCR Watchdog **
** **
\*****************************************************************************/