/* * Routine called on interrupt to re-invite the callee */ void re_invite(int dummy) { message("Ringing your party again"); /* force a re-announce */ msg.id_num = htonl(remote_id + 1); announce_invite(); longjmp(invitebuf, 1); }
int invite_remote (void) { int new_sockt; struct itimerval itimer; CTL_RESPONSE response; itimer.it_value.tv_sec = RING_WAIT; itimer.it_value.tv_usec = 0; itimer.it_interval = itimer.it_value; if (listen (sockt, 5) != 0) p_error ("Error on attempt to listen for caller"); msg.addr.sa_family = htons (my_addr.sin_family); memcpy (msg.addr.sa_data, ((struct sockaddr *) &my_addr)->sa_data, sizeof ((struct sockaddr *) & my_addr)->sa_data); msg.id_num = htonl (-1); /* an impossible id_num */ invitation_waiting = 1; announce_invite (); /* * Shut off the automatic messages for a while, * so we can use the interupt timer to resend the invitation */ end_msgs (); setitimer (ITIMER_REAL, &itimer, (struct itimerval *) 0); message ("Waiting for your party to respond"); signal (SIGALRM, re_invite); setjmp (invitebuf); while ((new_sockt = accept (sockt, 0, 0)) < 0) { if (errno == EINTR) continue; p_error ("Unable to connect with your party"); } close (sockt); sockt = new_sockt; /* * Have the daemons delete the invitations now that we * have connected. */ current_state = "Waiting for your party to respond"; start_msgs (); msg.id_num = htonl (local_id); ctl_transact (my_machine_addr, msg, DELETE, &response); msg.id_num = htonl (remote_id); ctl_transact (his_machine_addr, msg, DELETE, &response); invitation_waiting = 0; return 0; }
/* * Routine called on interupt to re-invite the callee */ void re_invite (int sig _GL_UNUSED_PARAMETER) { message ("Ringing your party again"); current_line++; /* force a re-announce */ msg.id_num = htonl (remote_id + 1); announce_invite (); longjmp (invitebuf, 1); }
/* ARGSUSED */ void re_invite(int signo __unused) { message("Ringing your party again"); waddch(my_win.x_win, '\n'); if (current_line < my_win.x_nlines - 1) current_line++; /* force a re-announce */ msg.id_num = htonl(remote_id + 1); announce_invite(); longjmp(invitebuf, 1); }
void invite_remote(void) { int new_sockt; struct itimerval itimer; CTL_RESPONSE response; struct sockaddr rp; socklen_t rplen = sizeof(struct sockaddr); struct hostent *rphost; char rname[STRING_LENGTH]; itimer.it_value.tv_sec = RING_WAIT; itimer.it_value.tv_usec = 0; itimer.it_interval = itimer.it_value; if (listen(sockt, 5) != 0) quit("Error on attempt to listen for caller", 1); #ifdef MSG_EOR /* copy new style sockaddr to old, swap family (short in old) */ msg.addr = *(struct osockaddr *)&my_addr; /* XXX new to old style*/ msg.addr.sa_family = htons(my_addr.sin_family); #else msg.addr = *(struct sockaddr *)&my_addr; #endif msg.id_num = htonl(-1); /* an impossible id_num */ invitation_waiting = 1; announce_invite(); /* * Shut off the automatic messages for a while, * so we can use the interrupt timer to resend the invitation. * We no longer turn automatic messages back on to avoid a bonus * message after we've connected; this is okay even though end_msgs() * gets called again in main(). */ end_msgs(); setitimer(ITIMER_REAL, &itimer, NULL); message("Waiting for your party to respond"); signal(SIGALRM, re_invite); (void) setjmp(invitebuf); while ((new_sockt = accept(sockt, &rp, &rplen)) == -1) { if (errno == EINTR || errno == EWOULDBLOCK || errno == ECONNABORTED) continue; quit("Unable to connect with your party", 1); } close(sockt); sockt = new_sockt; /* * Have the daemons delete the invitations now that we * have connected. */ msg.id_num = htonl(local_id); ctl_transact(my_machine_addr, msg, DELETE, &response); msg.id_num = htonl(remote_id); ctl_transact(his_machine_addr, msg, DELETE, &response); invitation_waiting = 0; /* * Check to see if the other guy is coming from the machine * we expect. */ if (his_machine_addr.s_addr != ((struct sockaddr_in *)&rp)->sin_addr.s_addr) { rphost = gethostbyaddr((char *) &((struct sockaddr_in *)&rp)->sin_addr, sizeof(struct in_addr), AF_INET); if (rphost) snprintf(rname, STRING_LENGTH, "Answering talk request from %s@%s", msg.r_name, rphost->h_name); else snprintf(rname, STRING_LENGTH, "Answering talk request from %s@%s", msg.r_name, inet_ntoa(((struct sockaddr_in *)&rp)->sin_addr)); message(rname); } }