From: Andreas Eversberg Date: Fri, 27 Jan 2012 06:27:52 +0000 (+0100) Subject: Adding switch to compile LCR without mISDN support X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=f851ca0d9e22673b7cc0a7c2f539c9d51b9b77f8 Adding switch to compile LCR without mISDN support Disable: --without-misdn Enable: --with-misdn Otherwise it will be enable automatically, if mISDN user is installed. --- diff --git a/Makefile.am b/Makefile.am index a5396b3..dd15966 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,6 +43,14 @@ INSTALLATION_DEFINES = \ -DLOG_DIR="\"$(LOGdir)\"" \ -DEXTENSION_DATA="\"$(EXTENSIONdir)\"" +if ENABLE_MISDN + +MISDN_INCLUDE = -DWITH_MISDN -DWITH_CRYPT +MISDN_SOURCE = mISDN.cpp dss1.cpp loop.c crypt.cpp remote.cpp joinremote.cpp +MISDN_LIB = -lmisdn + +endif + GSM_INCLUDE = GSM_SOURCE = GSM_LIB = @@ -131,17 +139,17 @@ install-exec-hook: $(INSTALL) chan_lcr.so $(astmoddir) endif -INCLUDES = $(all_includes) $(GSM_INCLUDE) $(SS5_INCLUDE) $(SIP_INCLUDE) -Wall $(INSTALLATION_DEFINES) +INCLUDES = $(all_includes) $(MISDN_INCLUDE) $(GSM_INCLUDE) $(SS5_INCLUDE) $(SIP_INCLUDE) -Wall $(INSTALLATION_DEFINES) lcr_SOURCES = \ main.c select.c trace.c options.c tones.c alawulaw.c cause.c interface.c message.c callerid.c socket_server.c \ - port.cpp vbox.cpp mISDN.cpp dss1.cpp loop.c remote.cpp \ - $(GSM_SOURCE) $(SS5_SOURCE) $(SIP_SOURCE) \ + port.cpp vbox.cpp \ + $(MISDN_SOURCE) $(GSM_SOURCE) $(SS5_SOURCE) $(SIP_SOURCE) \ endpoint.cpp endpointapp.cpp \ - appbridge.cpp apppbx.cpp route.c action.cpp action_efi.cpp action_vbox.cpp extension.c crypt.cpp mail.c \ - join.cpp joinpbx.cpp joinremote.cpp + appbridge.cpp apppbx.cpp route.c action.cpp action_efi.cpp action_vbox.cpp extension.c mail.c \ + join.cpp joinpbx.cpp -lcr_LDADD = $(LIBCRYPTO) -lmisdn -lpthread $(GSM_LIB) $(SIP_LIB) +lcr_LDADD = $(LIBCRYPTO) $(MISDN_LIB) -lpthread $(GSM_LIB) $(SIP_LIB) lcradmin_SOURCES = lcradmin.c cause.c options.c diff --git a/action.cpp b/action.cpp index e0a884d..6d6e964 100644 --- a/action.cpp +++ b/action.cpp @@ -20,8 +20,6 @@ extern char **environ; int EndpointAppPBX::_action_init_call(char *remote) { class Join *join; - struct port_list *portlist = ea_endpoint->ep_portlist; - struct admin_list *admin; /* a created call, this should never happen */ if (ea_endpoint->ep_join_id) { @@ -32,7 +30,11 @@ int EndpointAppPBX::_action_init_call(char *remote) /* create join */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Creating new join instance.\n", ea_endpoint->ep_serial); +#ifdef WITH_MISDN if (remote) { + struct port_list *portlist = ea_endpoint->ep_portlist; + struct admin_list *admin; + admin = admin_first; while(admin) { if (admin->remote_name[0] && !strcmp(admin->remote_name, remote)) @@ -50,8 +52,8 @@ int EndpointAppPBX::_action_init_call(char *remote) return(0); } join = new JoinRemote(ea_endpoint->ep_serial, remote, admin->sock); - } - else + } else +#endif join = new JoinPBX(ea_endpoint); if (!join) FATAL("No memoy for Join instance.\n"); diff --git a/apppbx.cpp b/apppbx.cpp index 75856d4..a61d108 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -30,8 +30,10 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint, int origin) : EndpointApp { class EndpointAppPBX **apppointer; +#ifdef WITH_CRYPT memset(&e_crypt_handler, 0, sizeof(e_crypt_handler)); add_timer(&e_crypt_handler, crypt_handler, this, 0); +#endif memset(&e_vbox_refresh, 0, sizeof(e_vbox_refresh)); add_timer(&e_vbox_refresh, vbox_refresh, this, 0); memset(&e_action_timeout, 0, sizeof(e_action_timeout)); @@ -104,10 +106,12 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint, int origin) : EndpointApp e_multipoint_cause = 0; e_multipoint_location = 0; e_dialing_queue[0] = '\0'; +#ifdef WITH_CRYPT e_crypt = CRYPT_OFF; e_crypt_state = CM_ST_NULL; e_crypt_keyengine_busy = 0; - e_crypt_info[0] = '\0'; + e_crypt_info[0] = '\0'; +#endif e_overlap = 0; e_vbox[0] = '\0'; e_tx_state = NOTIFY_STATE_ACTIVE; @@ -131,7 +135,9 @@ EndpointAppPBX::~EndpointAppPBX(void) { class EndpointAppPBX *temp, **tempp; +#ifdef WITH_CRYPT del_timer(&e_crypt_handler); +#endif del_timer(&e_vbox_refresh); del_timer(&e_action_timeout); del_timer(&e_match_timeout); @@ -272,10 +278,12 @@ void EndpointAppPBX::release(int release, int joinlocation, int joincause, int p e_multipoint_cause = 0; e_multipoint_location = 0; e_dialing_queue[0] = '\0'; +#ifdef WITH_CRYPT e_crypt = 0; e_crypt_state = CM_ST_NULL; e_crypt_keyengine_busy = 0; e_crypt_info[0] = '\0'; +#endif e_tone[0] = '\0'; e_overlap = 0; e_vbox[0] = '\0'; @@ -510,6 +518,7 @@ void EndpointAppPBX::keypad_function(char digit) join_join(); break; +#ifdef WITH_CRYPT /* crypt shared */ case '7': PDEBUG(DEBUG_EPOINT, "EPOINT(%d) shared key encryption selected.\n", ea_endpoint->ep_serial); @@ -527,6 +536,7 @@ void EndpointAppPBX::keypad_function(char digit) PDEBUG(DEBUG_EPOINT, "EPOINT(%d) encryption off selected.\n", ea_endpoint->ep_serial); encrypt_off(); break; +#endif default: PDEBUG(DEBUG_EPOINT, "EPOINT(%d) unsupported keypad digit '%c'.\n", ea_endpoint->ep_serial, digit); @@ -622,6 +632,7 @@ foundif: } +#ifdef WITH_MISDN /* * hunts an mISDNport that is available for an outgoing call * if no ifname was given, any interface that is not an extension @@ -872,6 +883,7 @@ foundif: return(NULL); /* no port found */ } +#endif /* outgoing setup to port(s) * ports will be created and a setup is sent if everything is ok. otherwhise @@ -888,7 +900,9 @@ void EndpointAppPBX::out_setup(int cfnr) const char *p; char cfp[64]; struct interface *interface; +#ifdef WITH_MISDN struct mISDNport *mISDNport; +#endif char portname[32]; char *dirname; class EndpointAppPBX *atemp; @@ -897,10 +911,12 @@ void EndpointAppPBX::out_setup(int cfnr) char ifname[sizeof(e_ext.interfaces)], number[256]; struct port_settings port_settings; +#ifdef WITH_MISDN int channel = 0; + struct admin_list *admin; +#endif int earlyb; int mode = B_MODE_TRANSPARENT; - struct admin_list *admin; /* set bchannel mode */ mode = e_capainfo.source_mode; @@ -1045,6 +1061,7 @@ void EndpointAppPBX::out_setup(int cfnr) } else #endif { +#ifdef WITH_MISDN /* hunt for mISDNport and create Port */ mISDNport = hunt_port(ifname, &channel); if (!mISDNport) { @@ -1077,6 +1094,12 @@ void EndpointAppPBX::out_setup(int cfnr) } else port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); earlyb = mISDNport->earlyb; +#else + trace_header("INTERFACE (has no function)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", ifname); + end_trace(); + continue; +#endif } if (!port) FATAL("Failed to create Port instance\n"); @@ -1179,6 +1202,7 @@ void EndpointAppPBX::out_setup(int cfnr) p++; /* external call */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cfp external %s\n", ea_endpoint->ep_serial, cfp); +#ifdef WITH_MISDN /* hunt for mISDNport and create Port */ mISDNport = hunt_port(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL, &channel); if (mISDNport) { @@ -1193,7 +1217,9 @@ void EndpointAppPBX::out_setup(int cfnr) if (!port) FATAL("No memory for Port instance\n"); earlyb = mISDNport->earlyb; - } else { + } else +#endif + { port = NULL; trace_header("INTERFACE (too busy)", DIRECTION_NONE); add_trace("interface", NULL, "%s", e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); @@ -1303,6 +1329,7 @@ void EndpointAppPBX::out_setup(int cfnr) } else #endif { +#ifdef WITH_MISDN /* hunt for mISDNport and create Port */ mISDNport = hunt_port(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL, &channel); if (!mISDNport) { @@ -1335,6 +1362,12 @@ void EndpointAppPBX::out_setup(int cfnr) } else port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); earlyb = mISDNport->earlyb; +#else + trace_header("INTERFACE (has no function)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", ifname); + end_trace(); + continue; +#endif } if (!port) FATAL("No memory for Port instance\n"); @@ -1941,11 +1974,13 @@ NOTE: vbox is now handled due to overlap state /* port MESSAGE_CRYPT */ void EndpointAppPBX::port_crypt(struct port_list *portlist, int message_type, union parameter *param) { +#ifdef WITH_CRYPT /* send crypt response to cryptman */ if (param->crypt.type == CR_MESSAGE_IND) cryptman_msg2man(param->crypt.data, param->crypt.len); else cryptman_message(param->crypt.type, param->crypt.data, param->crypt.len); +#endif } /* port MESSAGE_OVERLAP */ @@ -2364,8 +2399,10 @@ void EndpointAppPBX::port_disconnect_release(struct port_list *portlist, int mes message_put(message); /* disable encryption if disconnected */ //PERROR("REMOVE ME: state =%d, %d\n", e_crypt_state, e_crypt); +#ifdef WITH_CRYPT if (e_crypt_state) cryptman_message(CI_DISCONNECT_IND, NULL, 0); +#endif return; } else { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) the port has no patterns.\n", ea_endpoint->ep_serial); @@ -2867,6 +2904,7 @@ void EndpointAppPBX::ea_message_port(unsigned int port_id, int message_type, uni /* join MESSAGE_CRYPT */ void EndpointAppPBX::join_crypt(struct port_list *portlist, int message_type, union parameter *param) { +#ifdef WITH_CRYPT switch(param->crypt.type) { /* message from remote port to "crypt manager" */ case CU_ACTK_REQ: /* activate key-exchange */ @@ -2890,6 +2928,7 @@ void EndpointAppPBX::join_crypt(struct port_list *portlist, int message_type, un default: PERROR("EPOINT(%d) epoint with terminal '%s' (caller id '%s') unknown crypt message: '%d'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->crypt.type); } +#endif } /* join MESSAGE_INFORMATION */ @@ -3774,6 +3813,7 @@ reject: */ void EndpointAppPBX::join_join(void) { +#ifdef WITH_MISDN struct lcr_msg *message; struct join_relation *our_relation, *other_relation; struct join_relation **our_relation_pointer, **other_relation_pointer; @@ -3924,6 +3964,9 @@ void EndpointAppPBX::join_join(void) /* we send a retrieve to that endpoint */ // mixer will update the hold-state of the join and send it to the endpoints is changes +#else + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot join: no mISDN support anyway.\n", ea_endpoint->ep_serial); +#endif } diff --git a/apppbx.h b/apppbx.h index a37fc44..8b49506 100644 --- a/apppbx.h +++ b/apppbx.h @@ -160,7 +160,8 @@ class EndpointAppPBX : public EndpointApp /* efi */ int e_efi_state; /* current spoken sample */ int e_efi_digit; /* current spoken digit */ - + +#ifdef WITH_CRYPT /* crypt states and vars */ int e_crypt; /* current user level crypt state */ int e_crypt_state; /* current crypt manager state */ @@ -192,6 +193,7 @@ class EndpointAppPBX : public EndpointApp int e_crypt_keyengine_busy; /* current job and busy state */ int e_crypt_keyengine_return; /* return */ struct lcr_timer e_crypt_handler; /* poll timer for crypt events */ +#endif /* messages */ void hookflash(void); diff --git a/configure.ac b/configure.ac index 343409a..17361f1 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,26 @@ dnl AM_PROG_CC_C_O dnl enable this to have all special options on one place dnl AC_PRESERVE_HELP_ORDER +# check for mISDN +AC_ARG_WITH([misdn], + [AS_HELP_STRING([--with-misdn], + [compile with mISDN driver @<:@default=check@:>@]) + ], + [], + [with_misdn="check"]) + +AS_IF([test "x$with_misdn" != xno], + [AC_CHECK_HEADERS([mISDN/mISDNif.h], + [with_misdn="yes"], + [if test "x$with_misdn" != xcheck ; then + AC_MSG_FAILURE( + [--with-misdn was given, but test for header-file mISDN/mISDNif.h failed]) + fi + ]) + ]) + +AM_CONDITIONAL(ENABLE_MISDN, test "x$with_misdn" == "xyes" ) + # check for asterisk AC_ARG_WITH([asterisk], [AS_HELP_STRING([--with-asterisk], @@ -247,6 +267,7 @@ AC_CONFIG_FILES([Makefile]) AC_OUTPUT +AS_IF([test "x$with_misdn" == xyes],[AC_MSG_NOTICE( Compiled with mISDN support )],[AC_MSG_NOTICE( Not compiled with mISDN support)]) AS_IF([test "x$with_gsm_bs" == xyes],[AC_MSG_NOTICE( Compiled with GSM network side support )],[AC_MSG_NOTICE( Not compiled with GSM network side support)]) AS_IF([test "x$with_gsm_ms" == xyes],[AC_MSG_NOTICE( Compiled with GSM mobile side support )],[AC_MSG_NOTICE( Not compiled with GSM mobile side support)]) AS_IF([test "x$with_asterisk" == xyes],[AC_MSG_NOTICE( Compiled with Asterisk channel driver support )],[AC_MSG_NOTICE( Not compiled with Asterisk channel driver support)]) diff --git a/endpoint.cpp b/endpoint.cpp index cda79c2..2e2e7f3 100644 --- a/endpoint.cpp +++ b/endpoint.cpp @@ -67,8 +67,12 @@ Endpoint::Endpoint(unsigned int port_id, unsigned int join_id) if (port_id) { port = find_port_id(port_id); if (port) { +#ifdef WITH_MISDN if ((port->p_type&PORT_CLASS_MASK) == PORT_CLASS_mISDN) earlyb = ((class PmISDN *)port)->p_m_mISDNport->earlyb; +#else + earlyb = 0; +#endif if (!portlist_new(port_id, port->p_type, earlyb)) FATAL("No memory for portlist.\n"); } diff --git a/interface.c b/interface.c index ca569be..7a00735 100644 --- a/interface.c +++ b/interface.c @@ -15,6 +15,7 @@ struct interface *interface_first = NULL; /* first interface is current list */ struct interface *interface_newlist = NULL; /* first interface in new list */ +#ifdef WITH_MISDN /* set default out_channel */ void default_out_channel(struct interface_port *ifport) { @@ -22,7 +23,7 @@ void default_out_channel(struct interface_port *ifport) selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel)); memuse++; - + if (ifport->mISDNport->ntmode) selchannel->channel = CHANNEL_FREE; else @@ -53,6 +54,7 @@ void default_in_channel(struct interface_port *ifport) ifport->in_channel = selchannel; } +#endif /* parse string for a positive number */ @@ -278,6 +280,10 @@ static int inter_port(struct interface *interface, char *filename, int line, cha } static int inter_portnum(struct interface *interface, char *filename, int line, char *parameter, char *value) { +#ifndef WITH_MISDN + SPRINT(interface_error, "Error in %s (line %d): mISDN support is not compiled in.\n", filename, line); + return(-1); +#else struct interface_port *ifport, **ifportp; struct interface *searchif; int val; @@ -312,9 +318,14 @@ static int inter_portnum(struct interface *interface, char *filename, int line, ifportp = &((*ifportp)->next); *ifportp = ifport; return(0); +#endif } static int inter_portname(struct interface *interface, char *filename, int line, char *parameter, char *value) { +#ifndef WITH_MISDN + SPRINT(interface_error, "Error in %s (line %d): mISDN support is not compiled in.\n", filename, line); + return(-1); +#else struct interface_port *ifport, **ifportp; struct interface *searchif; @@ -354,6 +365,7 @@ static int inter_portname(struct interface *interface, char *filename, int line, ifportp = &((*ifportp)->next); *ifportp = ifport; return(0); +#endif } static int inter_l1hold(struct interface *interface, char *filename, int line, char *parameter, char *value) { @@ -1477,10 +1489,11 @@ void free_interfaces(struct interface *interface) } } +#ifdef WITH_MISDN /* * defaults of ports if not specified by config */ -static void set_defaults(struct interface_port *ifport) +static void set_mISDN_defaults(struct interface_port *ifport) { /* default channel selection list */ if (!ifport->out_channel) @@ -1506,6 +1519,7 @@ static void set_defaults(struct interface_port *ifport) else ifport->mISDNport->locally = 0; } +#endif /* @@ -1515,9 +1529,11 @@ static void set_defaults(struct interface_port *ifport) */ void relink_interfaces(void) { +#ifdef WITH_MISDN struct mISDNport *mISDNport; - struct interface *interface, *temp; struct interface_port *ifport; +#endif + struct interface *interface, *temp; int found; interface = interface_first; @@ -1572,6 +1588,7 @@ void relink_interfaces(void) interface = interface->next; } +#ifdef WITH_MISDN /* unlink all mISDNports */ mISDNport = mISDNport_first; while(mISDNport) { @@ -1592,7 +1609,7 @@ void relink_interfaces(void) PDEBUG(DEBUG_ISDN, "Port %d:%s relinking!\n", ifport->portnum, ifport->portname); ifport->mISDNport = mISDNport; mISDNport->ifport = ifport; - set_defaults(ifport); + set_mISDN_defaults(ifport); } mISDNport = mISDNport->next; } @@ -1621,7 +1638,7 @@ void relink_interfaces(void) while(ifport) { if (!ifport->mISDNport) { if (!interface->shutdown) { - load_port(ifport); + load_mISDN_port(ifport); } else { ifport->block = 2; } @@ -1630,14 +1647,15 @@ void relink_interfaces(void) } interface = interface->next; } - +#endif } +#ifdef WITH_MISDN /* * load port */ -void load_port(struct interface_port *ifport) +void load_mISDN_port(struct interface_port *ifport) { struct mISDNport *mISDNport; @@ -1651,13 +1669,14 @@ void load_port(struct interface_port *ifport) ifport->portnum = mISDNport->portnum; SCPY(ifport->portname, mISDNport->name); /* set defaults */ - set_defaults(ifport); + set_mISDN_defaults(ifport); /* load static port instances */ mISDNport_static(mISDNport); } else { ifport->block = 2; /* not available */ } } +#endif /* * give summary of interface syntax diff --git a/interface.h b/interface.h index 2a46c59..93fb1b6 100644 --- a/interface.h +++ b/interface.h @@ -138,7 +138,7 @@ extern char interface_error[256]; struct interface *read_interfaces(void); void free_interfaces(struct interface *interface_start); void relink_interfaces(void); -void load_port(struct interface_port *ifport); +void load_mISDN_port(struct interface_port *ifport); void doc_interface(void); void do_screen(int out, char *id, int idsize, int *type, int *present, const char *interface_name); struct interface *getinterfacebyname(const char *name); diff --git a/joinremote.cpp b/joinremote.cpp index dbeb0f9..c828400 100644 --- a/joinremote.cpp +++ b/joinremote.cpp @@ -88,12 +88,14 @@ void JoinRemote::message_remote(int message_type, union parameter *param) epoint->ep_app = new_endpointapp(epoint, 1, EAPP_TYPE_PBX); // outgoing } +#ifdef WITH_MISDN /* set serial on bchannel message * also ref is given, so we send message with ref */ if (message_type == MESSAGE_BCHANNEL) { message_bchannel_from_remote(this, param->bchannel.type, param->bchannel.handle); return; } +#endif /* cannot just forward, because param is not of container "struct lcr_msg" */ message = message_create(j_serial, j_epoint_id, JOIN_TO_EPOINT, message_type); diff --git a/main.c b/main.c index 1f5872a..7290af9 100644 --- a/main.c +++ b/main.c @@ -181,8 +181,10 @@ int main(int argc, char *argv[]) int i; struct sched_param schedp; int created_mutexd = 0,/* created_mutext = 0,*/ created_mutexe = 0, - created_lock = 0, created_signal = 0, created_debug = 0, - created_misdn = 0, created_message = 0; + created_lock = 0, created_signal = 0, created_message = 0; +#ifdef WITH_MISDN + int created_misdn = 0; +#endif char tracetext[256], lock[128]; char options_error[256]; int polling = 0; @@ -215,8 +217,10 @@ int main(int argc, char *argv[]) goto free; } +#ifdef WITH_CRYPT /* init crc */ crc_init(); +#endif /* the mutex init */ if (pthread_mutex_init(&mutexd, NULL)) { @@ -268,11 +272,12 @@ int main(int argc, char *argv[]) } polling = options.polling; +#ifdef WITH_MISDN /* init mISDN */ if (mISDN_initialize() < 0) goto free; created_misdn = 1; - created_debug = 1; +#endif /* read ruleset(s) */ if (!(ruleset_first = ruleset_parse())) @@ -543,8 +548,10 @@ free: free_interfaces(interface_first); interface_first = NULL; +#ifdef WITH_MISDN /* close isdn ports */ mISDNport_close_all(); +#endif /* flush messages */ debug_count++; @@ -593,9 +600,11 @@ free: if (pthread_mutex_destroy(&mutexd)) fprintf(stderr, "cannot destroy 'PDEBUG' mutex\n"); +#ifdef WITH_MISDN /* deinitialize mISDN */ if (created_misdn) mISDN_deinitialize(); +#endif /* free gsm */ #if 0 @@ -616,9 +625,11 @@ exit is done when interface is down sip_exit(); #endif +#ifdef WITH_MISDN /* close loopback, if used by GSM or remote */ if (mISDNloop.sock > -1) mISDNloop_close(); +#endif /* display memory leak */ #define MEMCHECK(a, b) \ diff --git a/main.h b/main.h index e0b2193..5fac1ef 100644 --- a/main.h +++ b/main.h @@ -125,12 +125,14 @@ void debug(const char *file, const char *function, int line, const char *prefix, #define BUDETECT ; #endif -#ifdef __cplusplus -extern "C" { -#endif -#include -#ifdef __cplusplus -} +#ifdef WITH_MISDN + #ifdef __cplusplus + extern "C" { + #endif + #include + #ifdef __cplusplus + } + #endif #endif #include "macro.h" #include "select.h" @@ -145,10 +147,12 @@ extern "C" { #include "callerid.h" #include "route.h" #include "port.h" +#ifdef WITH_MISDN #include "mISDN.h" #include "dss1.h" #include "loop.h" #include "remote.h" +#endif #if defined WITH_GSM_BS || defined WITH_GSM_MS #include "gsm.h" #endif diff --git a/route.c b/route.c index 3caed2b..5b42f58 100644 --- a/route.c +++ b/route.c @@ -1882,14 +1882,12 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) istrue, couldbetrue, condition, - dialing_required, - avail, - any; + dialing_required; struct route_rule *rule = ruleset->rule_first; struct route_cond *cond; struct route_action *action = NULL; unsigned long comp_len; - int j, jj; + int j; char isdn_port[10]; char *argv[11]; /* check also number of args below */ char callerid[64], callerid2[64], redirid[64]; @@ -1898,7 +1896,12 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) FILE *tfp; long long timeout, now_ll = 0, match_timeout = 0; struct timeval current_time; +#ifdef WITH_MISDN struct mISDNport *mISDNport; + int avail, + any; + int jj; +#endif struct admin_list *admin; time_t now; struct tm *now_tm; @@ -1935,11 +1938,14 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) break; case MATCH_PORT: +#ifdef WITH_MISDN if (ea_endpoint->ep_portlist) if ((ea_endpoint->ep_portlist->port_type & PORT_CLASS_MASK) != PORT_CLASS_mISDN) break; integer = e_callerinfo.isdn_port; goto match_integer; +#endif + break; case MATCH_INTERFACE: if (!e_callerinfo.interface[0]) @@ -2116,6 +2122,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) case MATCH_FREE: case MATCH_NOTFREE: +#ifdef WITH_MISDN if (!(comp_len = (unsigned long)strchr(cond->string_value, ':'))) break; comp_len = comp_len-(unsigned long)cond->string_value; @@ -2144,10 +2151,12 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) if (avail < atoi(cond->string_value + comp_len + 1)) istrue = 1; } +#endif break; case MATCH_DOWN: +#ifdef WITH_MISDN mISDNport = mISDNport_first; while(mISDNport) { if (mISDNport->ifport) @@ -2158,9 +2167,11 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) } if (!mISDNport) /* all down */ istrue = 1; +#endif break; case MATCH_UP: +#ifdef WITH_MISDN mISDNport = mISDNport_first; while(mISDNport) { if (mISDNport->ifport) @@ -2172,10 +2183,12 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) } if (mISDNport) /* one link at least */ istrue = 1; +#endif break; case MATCH_BUSY: case MATCH_IDLE: +#ifdef WITH_MISDN any = 0; mISDNport = mISDNport_first; while(mISDNport) { @@ -2189,6 +2202,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) istrue = 1; if (!mISDNport && cond->match==MATCH_IDLE) istrue = 1; +#endif break; case MATCH_REMOTE: diff --git a/socket_server.c b/socket_server.c index 800d18d..ba4ff08 100644 --- a/socket_server.c +++ b/socket_server.c @@ -82,13 +82,15 @@ void free_connection(struct admin_list *admin) { struct admin_queue *response; void *temp; +#ifdef WITH_MISDN union parameter param; class Join *join, *joinnext; struct mISDNport *mISDNport; int i, ii; - struct admin_list **adminp; class Port *port, *portnext; class Premote *remote; +#endif + struct admin_list **adminp; /* free remote joins */ if (admin->remote_name[0]) { @@ -102,6 +104,7 @@ void free_connection(struct admin_list *admin) "REMOTE APP release"); add_trace("app", "name", "%s", admin->remote_name); end_trace(); +#ifdef WITH_MISDN /* release all exported channels */ mISDNport = mISDNport_first; while(mISDNport) { @@ -118,6 +121,8 @@ void free_connection(struct admin_list *admin) } mISDNport = mISDNport->next; } +#endif +#ifdef WITH_MISDN /* release join */ join = join_first; while(join) { @@ -147,6 +152,7 @@ void free_connection(struct admin_list *admin) } port = portnext; } +#endif } if (admin->sock >= 0) { @@ -436,6 +442,7 @@ int admin_block(struct admin_queue **responsep, int portnum, int block) goto out; } +#ifdef WITH_MISDN /* no interface */ if (!ifport->mISDNport) { /* not loaded anyway */ @@ -446,7 +453,7 @@ int admin_block(struct admin_queue **responsep, int portnum, int block) /* try loading interface */ ifport->block = block; - load_port(ifport); + load_mISDN_port(ifport); /* port cannot load */ if (ifport->block >= 2) { @@ -468,6 +475,7 @@ int admin_block(struct admin_queue **responsep, int portnum, int block) ifport->block = 2; goto out; } +#endif /* port new blocking state */ ifport->block = response->am[0].u.x.block = block; @@ -609,11 +617,13 @@ void admin_call_response(int adminid, int message, const char *connected, int ca */ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) { +#ifdef WITH_MISDN struct mISDNport *mISDNport; - class Join *join; - class JoinRemote *joinremote = NULL; /* make GCC happy */ class Port *port; class Premote *remote = NULL; /* make GCC happy */ + class Join *join; + class JoinRemote *joinremote = NULL; /* make GCC happy */ +#endif struct admin_list *temp; /* hello message */ @@ -654,6 +664,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) return(-1); } +#ifdef WITH_MISDN /* new join. the reply (NEWREF assignment) is sent from constructor */ if (msg->type == MESSAGE_NEWREF) { if (msg->param.newref.mode) { @@ -695,7 +706,9 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) } return(0); } +#endif +#ifdef WITH_MISDN /* bchannel message * no ref given for *_ack */ if (msg->type == MESSAGE_BCHANNEL) @@ -706,6 +719,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) message_bchannel_from_remote(NULL, msg->param.bchannel.type, msg->param.bchannel.handle); return(0); } +#endif /* check for ref */ if (!msg->ref) { @@ -713,6 +727,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) return(-1); } +#ifdef WITH_MISDN /* find join instance */ join = join_first; while(join) { @@ -755,6 +770,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) return(0); } +#endif PDEBUG(DEBUG_LOG, "No remote instance found with ref %d. (May have been already released.)\n", msg->ref); return(0); @@ -812,14 +828,16 @@ int admin_state(struct admin_queue **responsep) class Port *port; class EndpointAppPBX *apppbx; class Join *join; +#ifdef WITH_MISDN class Pdss1 *pdss1; - struct interface *interface; - struct interface_port *ifport; struct mISDNport *mISDNport; struct select_channel *selchannel; + int anybusy; +#endif + struct interface *interface; + struct interface_port *ifport; int i; int num; - int anybusy; struct admin_queue *response; struct admin_list *admin; struct tm *now_tm; @@ -932,6 +950,7 @@ int admin_state(struct admin_queue **responsep) response->am[num].u.i.extension = interface->extension; /* block */ response->am[num].u.i.block = ifport->block; +#ifdef WITH_MISDN if (ifport->mISDNport) { mISDNport = ifport->mISDNport; @@ -1007,6 +1026,7 @@ int admin_state(struct admin_queue **responsep) i++; } } +#endif num++; ifport = ifport->next; @@ -1113,9 +1133,11 @@ int admin_state(struct admin_queue **responsep) if (apppbx->ea_endpoint->ep_park && apppbx->ea_endpoint->ep_park_len && apppbx->ea_endpoint->ep_park_len<=(int)sizeof(response->am[num].u.e.park_callid)) memcpy(response->am[num].u.e.park_callid, apppbx->ea_endpoint->ep_park_callid, apppbx->ea_endpoint->ep_park_len); response->am[num].u.e.park_len = apppbx->ea_endpoint->ep_park_len; +#ifdef WITH_CRYPT /* crypt */ if (apppbx->e_crypt == CRYPT_ON) response->am[num].u.e.crypt = 1; +#endif /* */ apppbx = apppbx->next; num++; @@ -1173,6 +1195,7 @@ int admin_state(struct admin_queue **responsep) default: response->am[num].u.p.state = ADMIN_STATE_IDLE; } +#ifdef WITH_MISDN /* isdn */ if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_DSS1) { response->am[num].u.p.isdn = 1; @@ -1181,6 +1204,7 @@ int admin_state(struct admin_queue **responsep) response->am[num].u.p.isdn_hold = pdss1->p_m_hold; response->am[num].u.p.isdn_ces = pdss1->p_m_d_ces; } +#endif /* */ port = port->next; num++; diff --git a/trace.c b/trace.c index ffecfbb..fdfa045 100644 --- a/trace.c +++ b/trace.c @@ -92,7 +92,9 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch char buffer[256]; time_t ti = trace.sec; struct tm *tm; +#ifdef WITH_MISDN struct mISDNport *mISDNport; +#endif int i; trace_string[0] = '\0'; // always clear string @@ -115,6 +117,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch /* head */ if (detail >= 3) { SCAT(trace_string, "------------------------------------------------------------------------------\n"); +#ifdef WITH_MISDN /* "Port: 1 (BRI PTMP TE)" */ if (trace.port >= 0) { mISDNport = mISDNport_first; @@ -132,6 +135,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch SPRINT(buffer, "Port: %d (does not exist)\n", trace.port); SCAT(trace_string, buffer); } else +#endif SCAT(trace_string, "Port: ---"); if (trace.interface[0]) {