- /* new join */
- if (msg->type == MESSAGE_NEWREF)
- {
- /* create new join instance */
- 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);
- }
+ /* new remote instance. the reply (NEWREF assignment) is sent from constructor */
+ if (msg->type == MESSAGE_NEWREF) {
+ char name[32];
+ /* find remote port */
+ interface = interface_first;
+ while(interface) {
+ /* interface must match the remote application */
+ if (interface->remote && !strcmp(interface->remote_app, admin->remote_name)) {
+ /* interface must match the name, if given */
+ if (!msg->param.newref.interface[0] || !strcmp(msg->param.newref.interface, interface->name))
+ break;
+ }
+ interface = interface->next;
+ }
+ if (!interface) {
+ union parameter param;
+ unsigned int ref = new_remote++;
+
+ start_trace(-1,
+ NULL,
+ NULL,
+ NULL,
+ DIRECTION_NONE,
+ 0,
+ 0,
+ "REMOTE APP illegal interface");
+ add_trace("app", "name", "%s", admin->remote_name);
+ add_trace("interface", "name", "%s", msg->param.newref.interface);
+ end_trace();
+ memset(¶m, 0, sizeof(union parameter));
+ param.newref.direction = 0;
+ admin_message_from_lcr(admin->sock, ref, MESSAGE_NEWREF, ¶m);
+ memset(¶m, 0, sizeof(union parameter));
+ param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+ param.disconnectinfo.cause = CAUSE_RESSOURCEUNAVAIL;
+ admin_message_from_lcr(admin->sock, ref, MESSAGE_RELEASE, ¶m);
+ return 0;
+ }
+ /* creating port object, transparent until setup with hdlc */
+ SPRINT(name, "%s-%s-in", interface->name, interface->remote_app);
+ if (!(remote = new Premote(PORT_TYPE_REMOTE_IN, name, NULL, interface, admin->sock)))