version 1.3, 1996/06/26 05:40:23 |
version 1.4, 1998/04/27 15:45:49 |
|
|
#include <sys/time.h> |
#include <sys/time.h> |
#include <signal.h> |
#include <signal.h> |
#include <netinet/in.h> |
#include <netinet/in.h> |
|
#include <netdb.h> |
#include <protocols/talkd.h> |
#include <protocols/talkd.h> |
#include <errno.h> |
#include <errno.h> |
#include <setjmp.h> |
#include <setjmp.h> |
#include "talk_ctl.h" |
#include "talk_ctl.h" |
#include "talk.h" |
#include "talk.h" |
|
|
|
#define STRING_LENGTH 158 |
|
|
/* |
/* |
* There wasn't an invitation waiting, so send a request containing |
* There wasn't an invitation waiting, so send a request containing |
* our sockt address to the remote talk daemon so it can invite |
* our sockt address to the remote talk daemon so it can invite |
|
|
int nfd, read_mask, template, new_sockt; |
int nfd, read_mask, template, new_sockt; |
struct itimerval itimer; |
struct itimerval itimer; |
CTL_RESPONSE response; |
CTL_RESPONSE response; |
|
struct sockaddr rp; |
|
int rplen = sizeof(struct sockaddr); |
|
struct hostent *rphost; |
|
char rname[STRING_LENGTH]; |
|
|
itimer.it_value.tv_sec = RING_WAIT; |
itimer.it_value.tv_sec = RING_WAIT; |
itimer.it_value.tv_usec = 0; |
itimer.it_value.tv_usec = 0; |
|
|
announce_invite(); |
announce_invite(); |
/* |
/* |
* Shut off the automatic messages for a while, |
* Shut off the automatic messages for a while, |
* so we can use the interupt timer to resend the invitation |
* 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(); |
end_msgs(); |
setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); |
setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); |
message("Waiting for your party to respond"); |
message("Waiting for your party to respond"); |
signal(SIGALRM, re_invite); |
signal(SIGALRM, re_invite); |
(void) setjmp(invitebuf); |
(void) setjmp(invitebuf); |
while ((new_sockt = accept(sockt, 0, 0)) < 0) { |
while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) { |
if (errno == EINTR) |
if (errno == EINTR) |
continue; |
continue; |
p_error("Unable to connect with your party"); |
p_error("Unable to connect with your party"); |
|
|
* Have the daemons delete the invitations now that we |
* Have the daemons delete the invitations now that we |
* have connected. |
* have connected. |
*/ |
*/ |
current_state = "Waiting for your party to respond"; |
|
start_msgs(); |
|
|
|
msg.id_num = htonl(local_id); |
msg.id_num = htonl(local_id); |
ctl_transact(my_machine_addr, msg, DELETE, &response); |
ctl_transact(my_machine_addr, msg, DELETE, &response); |
msg.id_num = htonl(remote_id); |
msg.id_num = htonl(remote_id); |
ctl_transact(his_machine_addr, msg, DELETE, &response); |
ctl_transact(his_machine_addr, msg, DELETE, &response); |
invitation_waiting = 0; |
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); |
|
} |
} |
} |
|
|
/* |
/* |