=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/talk/invite.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/talk/invite.c 1996/06/26 05:40:23 1.3 --- src/usr.bin/talk/invite.c 1998/04/27 15:45:49 1.4 *************** *** 1,4 **** ! /* $OpenBSD: invite.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $ */ /* $NetBSD: invite.c,v 1.3 1994/12/09 02:14:18 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: invite.c,v 1.4 1998/04/27 15:45:49 pjanzen Exp $ */ /* $NetBSD: invite.c,v 1.3 1994/12/09 02:14:18 jtc Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)invite.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: invite.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $"; #endif /* not lint */ #include --- 38,44 ---- #if 0 static char sccsid[] = "@(#)invite.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: invite.c,v 1.4 1998/04/27 15:45:49 pjanzen Exp $"; #endif /* not lint */ #include *************** *** 46,57 **** --- 46,60 ---- #include #include #include + #include #include #include #include #include "talk_ctl.h" #include "talk.h" + #define STRING_LENGTH 158 + /* * There wasn't an invitation waiting, so send a request containing * our sockt address to the remote talk daemon so it can invite *************** *** 73,78 **** --- 76,85 ---- int nfd, read_mask, template, new_sockt; struct itimerval itimer; 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_usec = 0; *************** *** 91,104 **** 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); (void) setjmp(invitebuf); ! while ((new_sockt = accept(sockt, 0, 0)) < 0) { if (errno == EINTR) continue; p_error("Unable to connect with your party"); --- 98,114 ---- 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, (struct itimerval *)0); message("Waiting for your party to respond"); signal(SIGALRM, re_invite); (void) setjmp(invitebuf); ! while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) { if (errno == EINTR) continue; p_error("Unable to connect with your party"); *************** *** 110,123 **** * 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; } /* --- 120,149 ---- * 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); + } } /*