/* * setup to exactly one endpoint * if it fails, the calling endpoint is released. * if other outgoing endpoints already exists, they are release as well. * note: if this functions fails, it will destroy its own join object! */ int JoinPBX::out_setup(unsigned int epoint_id, int message_type, union parameter *param, char *newnumber, char *newkeypad) { struct join_relation *relation; struct lcr_msg *message; class Endpoint *epoint; PDEBUG(DEBUG_JOIN, "no endpoint found, so we will create an endpoint and send the setup message we have.\n"); /* create a new relation */ if (!(relation=add_relation())) FATAL("No memory for relation.\n"); relation->type = RELATION_TYPE_SETUP; relation->channel_state = 0; /* audio is assumed on a new join */ relation->tx_state = NOTIFY_STATE_ACTIVE; /* new joins always assumed to be active */ relation->rx_state = NOTIFY_STATE_ACTIVE; /* new joins always assumed to be active */ /* create a new endpoint */ epoint = new Endpoint(0, j_serial); if (!epoint) FATAL("No memory for Endpoint instance\n"); epoint->ep_app = new_endpointapp(epoint, 1, EAPP_TYPE_PBX); // outgoing relation->epoint_id = epoint->ep_serial; /* send setup message to new endpoint */ //printf("JOLLY DEBUG: %d\n",join_countrelations(j_serial)); //i if (options.deb & DEBUG_JOIN) // joinpbx_debug(join, "Join::message_epoint"); message = message_create(j_serial, relation->epoint_id, JOIN_TO_EPOINT, message_type); memcpy(&message->param, param, sizeof(union parameter)); if (newnumber) SCPY(message->param.setup.dialinginfo.id, newnumber); else message->param.setup.dialinginfo.id[0] = '\0'; if (newkeypad) SCPY(message->param.setup.dialinginfo.keypad, newkeypad); else message->param.setup.dialinginfo.keypad[0] = '\0'; PDEBUG(DEBUG_JOIN, "setup message sent to ep %d with number='%s' keypad='%s'.\n", relation->epoint_id, message->param.setup.dialinginfo.id, message->param.setup.dialinginfo.keypad); message_put(message); return(0); }
void JoinRemote::message_remote(int message_type, union parameter *param) { struct lcr_msg *message; PDEBUG(DEBUG_JOIN, "Message %d of endpoint %d from remote to LCR (ref=%d)\n", message_type, j_epoint_id, j_remote_ref); /* create relation if no relation exists */ if (!j_epoint_id) { class Endpoint *epoint; if (!(epoint = new Endpoint(0, j_serial))) FATAL("No memory for Endpoint instance\n"); j_epoint_id = epoint->ep_serial; PDEBUG(DEBUG_JOIN, "Created endpoint %d\n", j_epoint_id); 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); memcpy(&message->param, param, sizeof(message->param)); message_put(message); if (message_type == MESSAGE_RELEASE) { delete this; return; } }