class Join *join, *joinnext;
/* free remote joins */
- if (admin->remote[0])
+ if (admin->remote_name[0])
{
join = join_first;
while(join)
{
joinnext = join->next;
- if (join->j_type==JOIN_TYPE_REMOTE && !strcmp(((class JoinRemote *)join)->j_remote, admin->remote))
+ if (join->j_type==JOIN_TYPE_REMOTE) if (((class JoinRemote *)join)->j_remote_id == admin->sock)
{
memset(¶m, 0, sizeof(param));
param.disconnectinfo.cause = CAUSE_OUTOFORDER;
param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
- ((class JoinRemote *)join)->message_remote(0, MESSAGE_RELEASE, ¶m);
+ ((class JoinRemote *)join)->message_remote(MESSAGE_RELEASE, ¶m);
/* join is now destroyed, so we go to next join */
}
join = joinnext;
class Endpoint *epoint;
class EndpointAppPBX *apppbx;
- if (!(epoint = new Endpoint(0, 0, 0)))
+ if (!(epoint = new Endpoint(0, 0)))
FATAL("No memory for Endpoint instance\n");
if (!(epoint->ep_app = apppbx = new DEFAULT_ENDPOINT_APP(epoint)))
FATAL("No memory for Endpoint Application instance\n");
/*
* send data to the remote socket join instance
*/
-int admin_message_to_join(struct admin_msg *msg, char *remote)
+int admin_message_to_join(struct admin_msg *msg, char *remote_name, int sock_id)
{
class Join *join;
struct admin_list *admin;
/* hello message */
if (msg->type == MESSAGE_HELLO)
{
- if (remote[0])
+ if (remote_name[0])
{
PERROR("Remote application repeats hello message.\n");
return(-1);
admin = admin_first;
while(admin)
{
- if (!strcmp(admin->remote, msg->param.hello.application))
+ if (!strcmp(admin->remote_name, msg->param.hello.application))
break;
admin = admin->next;
}
PERROR("Remote application connects twice??? (ignoring)\n");
return(-1);
}
- /* set asterisk socket instance */
- SCPY(remote, msg->param.hello.application);
+ /* set remote socket instance */
+ SCPY(remote_name, msg->param.hello.application);
return(0);
}
- /* check we already have no application name */
- if (!remote[0])
+ /* check we have no application name */
+ if (remote_name[0])
{
PERROR("Remote application did not send us a hello message.\n");
return(-1);
if (msg->type == MESSAGE_NEWREF)
{
/* create new join instance */
- join = new JoinRemote(0, remote); // must have no serial, because no endpoint is connected
+ join = new JoinRemote(0, remote_name, sock_id); // must have no serial, because no endpoint is connected
if (!join)
FATAL("No memory for remote join instance\n");
return(0);
}
+ /* bchannel message
+ * no ref given for *_ack */
+ if (msg->type == MESSAGE_BCHANNEL)
+ if (msg->param.bchannel.type == BCHANNEL_ASSIGN_ACK
+ || msg->param.bchannel.type == BCHANNEL_REMOVE_ACK)
+ {
+ /* no ref, but address */
+ message_bchannel_from_join(NULL, msg->param.bchannel.type, msg->param.bchannel.addr);
+ return(0);
+ }
+
/* check for ref */
if (!msg->ref)
{
break;
join = join->next;
}
+ if (!join)
+ {
+ PERROR("No join found with serial %d.\n", msg->ref);
+ return(-1);
+ }
/* check application */
if (join->j_type != JOIN_TYPE_REMOTE)
PERROR("Ref %d does not belong to a remote join instance.\n", msg->ref);
return(-1);
}
- if (!!strcmp(remote, ((class JoinRemote *)join)->j_remote))
+ if (sock_id != ((class JoinRemote *)join)->j_remote_id)
{
- PERROR("Ref %d belongs to remote application %s, but not to sending application %s.\n", msg->ref, ((class JoinRemote *)join)->j_remote, remote);
+ PERROR("Ref %d belongs to remote application %s, but not to sending application %s.\n", msg->ref, ((class JoinRemote *)join)->j_remote_name, remote_name);
return(-1);
}
/* send message */
- ((class JoinRemote *)join)->message_remote(msg->ref, msg->type, &msg->param);
+ ((class JoinRemote *)join)->message_remote(msg->type, &msg->param);
return(0);
}
/*
* this function is called for every message to remote socket
*/
-int admin_message_from_join(char *remote, unsigned long ref, int message_type, union parameter *param)
+int admin_message_from_join(int remote_id, unsigned long ref, int message_type, union parameter *param)
{
struct admin_list *admin;
struct admin_queue *response, **responsep; /* response pointer */
admin = admin_first;
while(admin)
{
- if (admin->remote[0] && !strcmp(admin->remote, remote))
+ if (admin->remote_name[0] && admin->sock==remote_id)
break;
admin = admin->next;
}
admin = admin_first;
while(admin)
{
- if (admin->remote[0])
+ if (admin->remote_name[0])
i++;
admin = admin->next;
}
admin = admin_first;
while(admin)
{
- if (admin->remote[0])
+ if (admin->remote_name[0])
{
/* message */
response->am[num].message = ADMIN_RESPONSE_S_REMOTE;
/* name */
- SCPY(response->am[num].u.r.name, admin->remote);
+ SCPY(response->am[num].u.r.name, admin->remote_name);
/* */
num++;
}
response->am[num].u.j.partyline = ((class JoinPBX *)join)->j_partyline;
/* remote application */
if (join->j_type == JOIN_TYPE_REMOTE)
- SCPY(response->am[num].u.j.remote, ((class JoinRemote *)join)->j_remote);
+ SCPY(response->am[num].u.j.remote, ((class JoinRemote *)join)->j_remote_name);
/* */
join = join->next;
num++;
break;
case ADMIN_MESSAGE:
- if (admin_message_to_join(&msg.u.msg, admin->remote) < 0)
+ if (admin_message_to_join(&msg.u.msg, admin->remote_name, admin->sock) < 0)
{
PERROR("Failed to deliver message for socket %d.\n", admin->sock);
goto response_error;