X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=socket_server.c;h=800d18d345167b00c13f5e8e60189a9f1b42266f;hp=9922dc696e9091ec6de2c4473ebade7ad2766991;hb=74a7fe54a81bb7e996ea45203bbc8cc0ff6b8dda;hpb=3a8f58ec8946b7f1683208d1cc3b054486f12e6c diff --git a/socket_server.c b/socket_server.c index 9922dc6..800d18d 100644 --- a/socket_server.c +++ b/socket_server.c @@ -13,13 +13,15 @@ #include #include #include +#ifdef PACKAGE_VERSION +#undef PACKAGE_VERSION +#endif #include "config.h" char socket_name[128]; int sock = -1; struct sockaddr_un sock_address; -extern unsigned int new_remote; struct admin_list *admin_first = NULL; static struct lcr_fd admin_fd; @@ -528,7 +530,7 @@ int admin_call(struct admin_list *admin, struct admin_message *msg) if (!(epoint = new Endpoint(0, 0))) FATAL("No memory for Endpoint instance\n"); - if (!(epoint->ep_app = apppbx = new DEFAULT_ENDPOINT_APP(epoint, 1))) // outgoing + if (!(epoint->ep_app = apppbx = new EndpointAppPBX(epoint, 1))) // outgoing FATAL("No memory for Endpoint Application instance\n"); apppbx->e_adminid = admin->sockserial; admin->epointid = epoint->ep_serial; @@ -664,15 +666,18 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) mISDNport = mISDNport->next; } if (!mISDNport) { - unsigned int remote_ref = new_remote++; union parameter param; - memset(¶m, 0, sizeof(union parameter)); - admin_message_from_lcr(mISDNport->ifport->remote, remote_ref, MESSAGE_NEWREF, ¶m); + /* create new join instance */ + join = joinremote = new JoinRemote(0, admin->remote_name, admin->sock); // must have no serial, because no endpoint is connected + if (!join) { + FATAL("No memory for remote join instance\n"); + return(-1); + } memset(¶m, 0, sizeof(union parameter)); param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL; param.disconnectinfo.cause = CAUSE_RESSOURCEUNAVAIL; - admin_message_from_lcr(mISDNport->ifport->remote, remote_ref, MESSAGE_RELEASE, ¶m); + admin_message_from_lcr(joinremote->j_remote_id, joinremote->j_remote_ref, MESSAGE_RELEASE, ¶m); return 0; } /* creating port object, transparent until setup with hdlc */ @@ -697,7 +702,6 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) if (msg->param.bchannel.type == BCHANNEL_ASSIGN_ACK || msg->param.bchannel.type == BCHANNEL_REMOVE_ACK || msg->param.bchannel.type == BCHANNEL_RELEASE) { -#warning TODO: depending on the mode (join / remoteport) forward message /* no ref, but address */ message_bchannel_from_remote(NULL, msg->param.bchannel.type, msg->param.bchannel.handle); return(0); @@ -712,7 +716,7 @@ int admin_message_to_lcr(struct admin_msg *msg, struct admin_list *admin) /* find join instance */ join = join_first; while(join) { - if (join->j_type != JOIN_TYPE_REMOTE) { + if (join->j_type == JOIN_TYPE_REMOTE) { joinremote = (class JoinRemote *)join; if (joinremote->j_remote_ref == msg->ref) break; @@ -840,6 +844,8 @@ int admin_state(struct admin_queue **responsep) interface = interface_first; while(interface) { ifport = interface->ifport; + if (!ifport) + i++; while(ifport) { i++; ifport = ifport->next; @@ -901,6 +907,18 @@ int admin_state(struct admin_queue **responsep) num = 0; while(interface) { ifport = interface->ifport; + if (!ifport) { + /* 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 = -100; /* indicate: no ifport */ + /* iftype */ + response->am[num].u.i.extension = interface->extension; + /* block */ + num++; + } while(ifport) { /* message */ response->am[num].message = ADMIN_RESPONSE_S_INTERFACE; @@ -1228,8 +1246,8 @@ int admin_handle_con(struct lcr_fd *fd, unsigned int what, void *instance, int i /*release endpoint if exists */ if (admin->epointid) { epoint = find_epoint_id(admin->epointid); - if (epoint) { - ((class DEFAULT_ENDPOINT_APP *)epoint->ep_app)-> + if (epoint && epoint->ep_app_type == EAPP_TYPE_PBX) { + ((class EndpointAppPBX *)epoint->ep_app)-> release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0); } }