Hg$ NTALK.SAV NTALK.SAV7BACKUP [NTALK...]*.* [HALL]NTALK.SAV/SAV/LOG/BLOCK=2048 HALL Fe,V6.1 _SYBIL:: 6 _DKA100: V6.1  *[NTALK]$README.;1+,w./F 4--v0123KPWO56ӢX7`g\҃89GFHJ----------------------------------------------------------------------- 11/11/91 To compile talk: cd talk vi Makefile define switches for your system (-DHPUX for HP-UX) make talk make install puts talk in /usr/local/bin To compile talkd: cd talkd vi Makefile define switches for your system (-DHPUX for HP-UX) make talkd make install puts talkd in /usr/local/etc Edit /etc/inetd.conf, add the following line: ntalk dgram udp wait root /usr/local/etc/talkd talkd Edit /etc/services, add the following line: ntalk 518/udp talk # new talk protocol ---------------------------------------------------------------------- 11/12/91 To compile talk on Suns, add the -Dsun switch to the CFLAGS variable in the Makefiles for talk and talkd. Also, since SUNOS has a version of talk that is incompatible with BSD talk, you must install BSD talk and BSD talkd as ntalk and ntalkd respectively. Then, your /etc/inetd.conf should have the following line: ntalk dgram udp wait g' NTALK.SAVwv[NTALK]$README.;1~ root /usr/local/etc/ntalkd ntalkd *[NTALK]INCLUDE.DIR;1+,x./F 4-v0123 KPWO56G7`~R89GFHJIARPA.DIR{NETDB.H PROTOCOLS.DIRRESOLV.H SYSEXITS.H*[NTALK.INCLUDE]ARPA.DIR;1+,{./F 4-x0123 KPWO56@W7`^89GFHJIQ  NTALK.SAV{x[NTALK.INCLUDE]ARPA.DIR;1FTP.HINET.H NAMESER.HTELNET.HTFTP.H*[NTALK.INCLUDE.ARPA]FTP.H;1+,./F 4%-{0123KPWO56U7`]҃89GFHJ/* * Copyright (c) 1983, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be uѧv NTALK.SAV{TALK.INCLUDE.ARPA]FTP.H;1esed to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)ftp.h 5.4 (Berkeley) 2/21/89 */ /* * Definitions for FTP * See RFC-765 */ /* * Reply codes. */ #define PRELIM 1 /* positive preliminary */ #define COMPLETE 2 /* positive completion */ #define CONTINUE 3 /* positive intermediate */ #define TRANSIENT 4 /* transient negative completion */ #define ERROR 5 /* permanent negative completion */ /* * Type codes */ #define TYPE_A 1 /* ASCII */ #define TYPE_E 2 /* EBCDIC */ #define TYPE_I 3 /* image */ #define TYPE_L 4 /* local byte size */ #ifdef FTP_NAMES char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; #endif /* * Form codes */ #define FORM_N 1 /* non-print */ #define FORM_T 2 /* telnet format effectors */ #define FORM_C 3 /* carriage control (ASA) */ #ifdef FTP_NAMES char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; #endif /* * Structure codes */ #define STRU_F 1 /* file (no record structure) */ #define STRU_R 2 /* record structure */ #define STRU_P 3 /* page structure */ #ifdef FTP_NAMES char *strunames[] = {"0", "File", "Record", "Page" }; #endif /* * Mode types */ #define MODE_S 1 /* stream */ #define MODE_B 2 /* block */ #define MODE_C 3 /* compressed */ #ifdef FTP_NAMES charˊ= NTALK.SAV{TALK.INCLUDE.ARPA]FTP.H;1{ *modenames[] = {"0", "Stream", "Block", "Compressed" }; #endif /* * Record Tokens */ #define REC_ESC '\377' /* Record-mode Escape */ #define REC_EOR '\001' /* Record-mode End-of-Record */ #define REC_EOF '\002' /* Record-mode End-of-File */ /* * Block Header */ #define BLK_EOR 0x80 /* Block is End-of-Record */ #define BLK_EOF 0x40 /* Block is End-of-File */ #define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ #define BLK_RESTART 0x10 /* Block is Restart Marker */ #define BLK_BYTECOUNT 2 /* Bytes in this block */ *[NTALK.INCLUDE.ARPA]INET.H;1+,./F 4-{0123KPWO569V7)]҃89GFHJ31 NTALK.SAV{[NTALK.INCLUDE.ARPA]INET.H;1h/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)inet.h 5.2 (Berkeley) 6/27/88 */ /* * External definitions for * functions in inet(3N) */ unsigned long inet_addr(); char *inet_ntoa(); struct in_addr inet_makeaddr(); unsigned long inet_network(); A NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1h*[NTALK.INCLUDE.ARPA]NAMESER.H;1+,./F 4A-{0123KPWO56(V72]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)nameser.h 5.20 (Berkeley) 10/7/88 */ /* * Define constants based on rfc883 */ #define PACKETSZ 512 /* maximum packet size */ #define MAXDNAME 256 /* maximum domain name */ #define MAXCDNAME 2^K NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1Yb55 /* maximum compressed domain name */ #define MAXLABEL 63 /* maximum length of domain label */ /* Number of bytes of fixed size data in query structure */ #define QFIXEDSZ 4 /* number of bytes of fixed size data in resource record */ #define RRFIXEDSZ 10 /* * Internet nameserver port number */ #define NAMESERVER_PORT 53 /* * Currently defined opcodes */ #define QUERY 0x0 /* standard query */ #define IQUERY 0x1 /* inverse query */ #define STATUS 0x2 /* nameserver status query */ /*#define xxx 0x3 /* 0x3 reserved */ /* non standard */ #define UPDATEA 0x9 /* add resource record */ #define UPDATED 0xa /* delete a specific resource record */ #define UPDATEDA 0xb /* delete all nemed resource record */ #define UPDATEM 0xc /* modify a specific resource record */ #define UPDATEMA 0xd /* modify all named resource record */ #define ZONEINIT 0xe /* initial zone transfer */ #define ZONEREF 0xf /* incremental zone referesh */ /* * Currently defined response codes */ #define NOERROR 0 /* no error */ #define FORMERR 1 /* format error */ #define SERVFAIL 2 /* server failure */ #define NXDOMAIN 3 /* non existent domain */ #define NOTIMP 4 /* not implemented */ #define REFUSED 5 /* query refused */ /* non standard */ #define NOCHANGE 0xf /* update failed to change db */ /* * Type values for resources and queries */ #define T_A 1 /* host address */ #define T_NS 2 /* authoritative server */ #define T_MD 3 /* mail destination */ #define T_MF 4 /* mail forwarder */ #define T_ I(R NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1CNAME 5 /* connonical name */ #define T_SOA 6 /* start of authority zone */ #define T_MB 7 /* mailbox domain name */ #define T_MG 8 /* mail group member */ #define T_MR 9 /* mail rename name */ #define T_NULL 10 /* null resource record */ #define T_WKS 11 /* well known service */ #define T_PTR 12 /* domain name pointer */ #define T_HINFO 13 /* host information */ #define T_MINFO 14 /* mailbox information */ #define T_MX 15 /* mail routing information */ /* non standard */ #define T_UINFO 100 /* user (finger) information */ #define T_UID 101 /* user ID */ #define T_GID 102 /* group ID */ #define T_UNSPEC 103 /* Unspecified format (binary data) */ /* Query type values which do not appear in resource records */ #define T_AXFR 252 /* transfer zone of authority */ #define T_MAILB 253 /* transfer mailbox records */ #define T_MAILA 254 /* transfer mail agent records */ #define T_ANY 255 /* wildcard match */ /* * Values for class field */ #define C_IN 1 /* the arpa internet */ #define C_CHAOS 3 /* for chaos net at MIT */ /* Query class values which do not appear in resource records */ #define C_ANY 255 /* wildcard match */ /* * Status return codes for T_UNSPEC conversion routines */ #define CONV_SUCCESS 0 #define CONV_OVERFLOW -1 #define CONV_BADFMT -2 #define CONV_BADCKSUM -3 #define CONV_BADBUFLEN -4 #ifndef BYTE_ORDER #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ #define PD \z NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1` P_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ #if defined(vax) || defined(ns32000) || defined(sun386) || \ defined(BIT_ZERO_ON_RIGHT) #define BYTE_ORDER LITTLE_ENDIAN #endif #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ defined(is68k) || defined (tahoe) || defined (BIT_ZERO_ON_LEFT) #define BYTE_ORDER BIG_ENDIAN #endif #endif /* BYTE_ORDER */ #ifndef BYTE_ORDER /* you must determine what the correct bit order is for your compiler */ UNDEFINED_BIT_ORDER; #endif /* * Structure for query header, the order of the fields is machine and * compiler dependent, in our case, the bits within a byte are assignd * least significant first, while the order of transmition is most * significant first. This requires a somewhat confusing rearrangement. */ typedef struct { u_short id; /* query identification number */ #if BYTE_ORDER == BIG_ENDIAN /* fields in third byte */ u_char qr:1; /* response flag */ u_char opcode:4; /* purpose of message */ u_char aa:1; /* authoritive answer */ u_char tc:1; /* truncated message */ u_char rd:1; /* recursion desired */ /* fields in fourth byte */ u_char ra:1; /* recursion available */ u_char pr:1; /* primary server required (non standard) */ u_char unused:2; /* unused bits */ u_char rcode:4; /* response code */ #endif #if BYTE_ORDER == LITTLE_ENDIAN /* fields in third byte */ u_char rd:1; /* recursion desired */ u_char tc:1; /* truncated message */ u_char aa:1; /* authoritive answer */ u_char  4u[NTALK]$README];1s oH;1`0hahP*Bw9s|'QyN]K!\g|&u0HXpWH<4<s5kiDj`i,O?`&q7%B$mg?]q^bCP}t*gn7+7Oz%X{gf_?b qF@{Mlh1/0^ RoDR-Sg/ R*{3%zgX5e"ML}UteD~\KF~te>T@LvZ>eK}&Y( 3`) R6s> }!hdK)Jc\;GL-W.B=$^{mXj F?f7~X('t2$-1b 0?1P] z3u7Hv r,`*δ7= VoMJk8EK$4|m|Cx %Hf4V0wKP<8YAd9h1J1)c*-ULTAc^U'MK{nt3%1 ]\Y=5r"{7q*b O}3)T2~+^ckHs_moe-QiZ QBH`wqvEp$GT6l&)s_v=X4mx-W3MVA)Lr$?z]!d[>{~4BK$# nZ7_XbYvdI+$:N]AJ*W O}}k(D+c M?_sj`/ s:\zN=WiGHZ)"AL! zH}` } {Eb6Br.bdZZa{YMwN(-0|Z_J\\(iV@I0e/2/K ]]Dk;CX 1y G*/Yl^*" .k+%` B#Fjm,"?,|_,<_ZZnqy8L8e5F@ c$ ?I}svW zp|g7?"%BTQ %:vFipqvFy|<-:wjq3FTI8o 8O .f^Z0xi]G%z C p|u,liO<]2 ;}F,;_" k>;SR5A-h"Qy!eB<H\AVPmLzjB+Q7#>x];Sk"Ah v57&,Ew 8z-"U #SCd4l/sxD+!eM ;+] eU?y61~m-tUzX)L(/$znE~ 2n"r$|*ePECAXY 'd0\)8(.%*&ÕnMV_df4lJ~^|<)NILS8ZPX' IQ+G|EM= `jCC$/g,tQN6myDI{,P,xsK6[C( gr0)'7!U@H+s8nc?8-QBcn*;qVex{ AcD?0-|2+*yE:q EXL}JHbU\;@L)h}w-hb?PsGx;ICa4>m'CD}$pC!SgEXT !):AqU#u?DE1> 2v~ 'v~n/InUm q?,uH )mQ}B- 'P&K):?6]HOCtwjW  #&tu&KQ0Ji _`JI  NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1+ opcode:4; /* purpose of message */ u_char qr:1; /* response flag */ /* fields in fourth byte */ u_char rcode:4; /* response code */ u_char unused:2; /* unused bits */ u_char pr:1; /* primary server required (non standard) */ u_char ra:1; /* recursion available */ #endif /* remaining bytes */ u_short qdcount; /* number of question entries */ u_short ancount; /* number of answer entries */ u_short nscount; /* number of authority entries */ u_short arcount; /* number of resource entries */ } HEADER; /* * Defines for handling compressed domain names */ #define INDIR_MASK 0xc0 /* * Structure for passing resource records around. */ struct rrec { short r_zone; /* zone number */ short r_class; /* class number */ short r_type; /* type number */ u_long r_ttl; /* time to live */ int r_size; /* size of data area */ char *r_data; /* pointer to data */ }; extern u_short _getshort(); extern u_long _getlong(); /* * Inline versions of get/put short/long. * Pointer is advanced; we assume that both arguments * are lvalues and will already be in registers. * cp MUST be u_char *. */ #define GETSHORT(s, cp) { \ (s) = *(cp)++ << 8; \ (s) |= *(cp)++; \ } #define GETLONG(l, cp) { \ (l) = *(cp)++ << 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ *(cp)++ = (s) >> 8; \ *(cp)++ = (s); \ } /* * Warning: PUTLONG destroys its first argument. */ #define PUTLONG(l, cp) { \ (cp)[3] = l; \ (cp)[2] = (l >>= 8); \ (cp)[1]  KF ] NTALK.SAV{[NTALK.INCLUDE.ARPA]NAMESER.H;1= (l >>= 8); \ (cp)[0] = l >> 8; \ (cp) += sizeof(u_long); \ } *[NTALK.INCLUDE.ARPA]TELNET.H;1+,. /F 4 /-{0123KPWO 560>V7j:]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used toY| NTALK.SAV{[NTALK.INCLUDE.ARPA]TELNET.H;1  endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)telnet.h 5.3 (Berkeley) 6/27/88 */ /* * Definitions for the TELNET protocol. */ #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /* please, you use option */ #define WONT 252 /* I won't use option */ #define WILL 251 /* I will use option */ #define SB 250 /* interpret as subnegotiation */ #define GA 249 /* you may reverse the line */ #define EL 248 /* erase the current line */ #define EC 247 /* erase the current character */ #define AYT 246 /* are you there */ #define AO 245 /* abort output--but let prog finish */ #define IP 244 /* interrupt process--permanently */ #define BREAK 243 /* break */ #define DM 242 /* data mark--for connect. cleaning */ #define NOP 241 /* nop */ #define SE 240 /* end sub negotiation */ #define EOR 239 /* end of record (transparent mode) */ #define SYNCH 242 /* for telfunc calls */ #ifdef TELCMDS char *telcmds[] = { "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", }; #endif /* telnet options */ #define TELOPT_BINARY 0 /* 8-bit data path */ #define TELOPT_ECHO 1 /* echo */ #define TELOPT_RCP 2 /* prepare to reconnect *0d NTALK.SAV{[NTALK.INCLUDE.ARPA]TELNET.H;1 T/ #define TELOPT_SGA 3 /* suppress go ahead */ #define TELOPT_NAMS 4 /* approximate message size */ #define TELOPT_STATUS 5 /* give status */ #define TELOPT_TM 6 /* timing mark */ #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ #define TELOPT_NAOL 8 /* negotiate about output line width */ #define TELOPT_NAOP 9 /* negotiate about output page size */ #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ #define TELOPT_XASCII 17 /* extended ascic character set */ #define TELOPT_LOGOUT 18 /* force logout */ #define TELOPT_BM 19 /* byte macro */ #define TELOPT_DET 20 /* data entry terminal */ #define TELOPT_SUPDUP 21 /* supdup protocol */ #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ #define TELOPT_SNDLOC 23 /* send location */ #define TELOPT_TTYPE 24 /* terminal type */ #define TELOPT_EOR 25 /* end or record */ #define TELOPT_EXOPL 255 /* extended-options-list */ #ifdef TELOPTS #define NTELOPTS (1+TELOPT_EOR) char *telopts[NTELOPTS] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "EdQ0 NTALK.SAV{[NTALK.INCLUDE.ARPA]TELNET.H;1 NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", }; #endif /* sub-option qualifiers */ #define TELQUAL_IS 0 /* option is... */ #define TELQUAL_SEND 1 /* send option */ *[NTALK.INCLUDE.ARPA]TFTP.H;1+,./F 4o-{0123KPWO560]WV7`C]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to NTALK.SAV{[NTALK.INCLUDE.ARPA]TFTP.H;1; endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)tftp.h 5.2 (Berkeley) 6/27/88 */ /* * Trivial File Transfer Protocol (IEN-133) */ #define SEGSIZE 512 /* data segment size */ /* * Packet types. */ #define RRQ 01 /* read request */ #define WRQ 02 /* write request */ #define DATA 03 /* data packet */ #define ACK 04 /* acknowledgement */ #define ERROR 05 /* error code */ struct tftphdr { short th_opcode; /* packet type */ union { short tu_block; /* block # */ short tu_code; /* error code */ char tu_stuff[1]; /* request packet stuff */ } th_u; char th_data[1]; /* data or error string */ }; #define th_block th_u.tu_block #define th_code th_u.tu_code #define th_stuff th_u.tu_stuff #define th_msg th_data /* * Error codes. */ #define EUNDEF 0 /* not defined */ #define ENOTFOUND 1 /* file not found */ #define EACCESS 2 /* access violation */ #define ENOSPACE 3 /* disk full or allocation exceeded */ #define EBADOP 4 /* illegal TFTP operation */ #define EBADID 5 /* unknown transfer ID */ #define EEXISTS 6 /* file already exists */ #define ENOUSER 7 /* no such user */ y&[ NTALK.SAVx[NTALK.INCLUDE]NETDB.H;1D*[NTALK.INCLUDE]NETDB.H;1+,./F 4h-x0123KPWO56lV7`\҃89GFHJ/* * Copyright (c) 1980, 1983, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)netdb.h 5.10 (Berkeley) 6/27/88 */ /* * Structures returned by network * data base library. All addresses * are supplied in host order, and * returned in network order (suitable ) NTALK.SAVx[NTALK.INCLUDE]NETDB.H;1= * for use in system calls). */ struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ #define h_addr h_addr_list[0] /* address, for backward compatiblity */ }; /* * Assumption here is that a network number * fits in 32 bits -- probably a poor one. */ struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ unsigned long n_net; /* network # */ }; struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; struct protoent { char *p_name; /* official protocol name */ char **p_aliases; /* alias list */ int p_proto; /* protocol # */ }; struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent(); struct netent *getnetbyname(), *getnetbyaddr(), *getnetent(); struct servent *getservbyname(), *getservbyport(), *getservent(); struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent(); /* * Error return codes from gethostbyname() and gethostbyaddr() * (left in extern int h_errno). */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid namILV NTALK.SAVx[NTALK.INCLUDE]NETDB.H;11e, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ *[NTALK.INCLUDE]PROTOCOLS.DIR;1+,./F 4-x0123 KPWO56@7h89GFHJIROUTED.HRWHOD.HTALKD.HTIMED.H#*[NTALK.INCLUDE.PROTOCOLS]ROUTED.H;1+,./F 4`-0123KPWO56ߒV7U]҃89GFHJ3՞ NTALK.SAV#[NTALK.INCLUDE.PROTOCOLS]ROUTED.H;1/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * %W% (Berkeley) %G% */ /* * Routing Information Protocol * * Derived from Xerox NS Routing Information Protocol * by changing 32-bit net numbers to sockaddr's and * padding stuff to 32-bit boundaries. */ #define RIPVERSION 1 struct netinfo { struct sockaddr rip_dst; /* destination net/host */ int rip_metric; /* cost of route */ }; struct rip { u_char rip_cmd; /* request/response */ u_char rip_vers; /* protocol version # */ u_char rip_res1[2]; /* pad to 32-bit boundary */ union { struct netinfo ru_nets[1]; /* variable length... */ char ru_tracefile[1]; /* ditto ... */ } ripun; #define rip_nets ripun.ru_nets #define rip_tracefile ripun.ru_tracefile }; /* * Packet types. */ #defi\Kx9s mo|6NZ,otD.H;1 X65 g ~}&",AW]V)jfp1=hewq =bEp,Rq.C>bsT t%|J]O$hnbNx2U"U#3r~d}b#G{]ZvWu|3?[6A.vqr+&k',S00gtwaWe\ 37jE]D16HD"UF>7b?y)8.>)S'e{O642@N5#;)SP|/- C66 BaoVJQ e}j]AWBxtAL"Lt#4+j'JytsaDP*IZz\L@xhisAr4v/% *a7+/AR0$_(4(D+b7f<);-=ls.(@|3j9vmp:(D,)CmKD~KL3Ul <O7+ot{.d]RIZDd@bT1SkeTqT4MnJg0d{.MVa&n;Eod5HedL31VcG#7ab4KYst3Kd{H I5Ow~ec-BJ ^ڢ^/P+ C"$z`k:KTpk6 [(iHdsE\' s$B **<|G6H9l. q{ ~I{\A0; \! Ny>#1H*>55)R2f<0Nv 7$HDW @2l`[cU!3bj*8,"j< H\/ETKXMHCT!`;fBXCdLYn*raY z$S9QdB4 ?Kw/wK;IJ*{W /[!$0rZid/Y~ {Yt, )^$g9S)o[ILFD}p[W I[^*J'ZTI^ DTZV ','EaZ[%!JNrWD=hj12"> sw{k~i0(]WXr ;m'9&`!kHip/HS^" KY!5:m  U7<nb$,mzlr1] n*KE.' Mc[)uGbf0}}CbBd=X) YO.a`P(xu$)HO/W30=zJN*#>W #include /* * This describes the protocol used by the talk server and clients. * * The talk server acts a repository of invitations, responding to * requests by clients wishing to rendezvous for the purpose of * holding a conversation. In normal operation, a client, the caller, * initiates a rendezvous by sending a CTL_MSG to the server of * type LOOK_UP. This causes the server to search its invitation * tables to check if an invitation currently exists for the caller * (to speak to the callee specified in the message). If the lookup * fails, the caller then sends an ANNOUNCE message causing the server * to broadcaYH NTALK.SAV"[NTALK.INCLUDE.PROTOCOLS]TALKD.H;1 st an announcement on the callee's login ports requesting * contact. When the callee responds, the local server uses the * recorded invitation to respond with the appropriate rendezvous * address and the caller and callee client programs establish a * stream connection through which the conversation takes place. */ /* * Client->server request message format. */ typedef struct { u_char vers; /* protocol version */ u_char type; /* request type, see below */ u_char answer; /* not used */ u_char pad; u_long id_num; /* message id */ struct sockaddr addr; struct sockaddr ctl_addr; long pid; /* caller's process id */ #define NAME_SIZE 12 char l_name[NAME_SIZE];/* caller's name */ char r_name[NAME_SIZE];/* callee's name */ #define TTY_SIZE 16 char r_tty[TTY_SIZE];/* callee's tty name */ } CTL_MSG; /* * Server->client response message format. */ typedef struct { u_char vers; /* protocol version */ u_char type; /* type of request message, see below */ u_char answer; /* respose to request message, see below */ u_char pad; u_long id_num; /* message id */ struct sockaddr addr; /* address for establishing conversation */ } CTL_RESPONSE; #define TALK_VERSION 1 /* protocol version */ /* message type values */ #define LEAVE_INVITE 0 /* leave invitation with server */ #define LOOK_UP 1 /* check for invitation by callee */ #define DELETE 2 /* delete invitation by caller */ #define ANNOUNCE 3 /* announce invitation by caller */ /* answer values */ #define SUCCESS 0 /* operation completeu&K> NTALK.SAV"[NTALK.INCLUDE.PROTOCOLS]TALKD.H;1 $d properly */ #define NOT_HERE 1 /* callee not logged in */ #define FAILED 2 /* operation failed for unexplained reason */ #define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ #define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ #define UNKNOWN_REQUEST 5 /* request has invalid type value */ #define BADVERSION 6 /* request has invalid protocol version */ #define BADADDR 7 /* request has invalid addr value */ #define BADCTLADDR 8 /* request has invalid ctl_addr value */ /* * Operational parameters. */ #define MAX_LIFE 60 /* max time daemon saves invitations */ /* RING_WAIT should be 10's of seconds less than MAX_LIFE */ #define RING_WAIT 30 /* time to wait before resending invitation */ "*[NTALK.INCLUDE.PROTOCOLS]TIMED.H;1+,./F 4s-0123KPWO56V7 Yq]҃89GFHJܰ NTALK.SAV"[NTALK.INCLUDE.PROTOCOLS]TIMED.H;1/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)timed.h 1.8 (Berkeley) 6/27/88 */ /* * Time Synchronization Protocol */ #define TSPVERSION 1 #define ANYADDR NULL struct tsp { u_char tsp_type; u_char tsp_vers; u_short tsp_seq; union { struct timeval tspu_time; char tspu_hopcnt; } tsp_u; char tsp_name[MAXHOSTNAMELEN]; }; #define tsp_time tsp_u.tspu_time #define tsp_hopcnt tsp_u.tspu_hopcnt /* * Command types. */ #define TSP_ANY 0 /* match any types */ #define TSP_ADJTIME 1 /* send adjtime */ #define TSP_ACK 2 /* generic acknowledgement */ #define TSP_MASTERREQ 3 /* ask for master's name */ #define TSP_MASTERACK 4 /* acknowledge master request */ #define TSP_SETTIME 5 /* send network time */ #define TSP_MASTERUP 6 /* i; NTALK.SAV"[NTALK.INCLUDE.PROTOCOLS]TIMED.H;1unform slaves that master is up */ #define TSP_SLAVEUP 7 /* slave is up but not polled */ #define TSP_ELECTION 8 /* advance candidature for master */ #define TSP_ACCEPT 9 /* support candidature of master */ #define TSP_REFUSE 10 /* reject candidature of master */ #define TSP_CONFLICT 11 /* two or more masters present */ #define TSP_RESOLVE 12 /* masters' conflict resolution */ #define TSP_QUIT 13 /* reject candidature if master is up */ #define TSP_DATE 14 /* reset the time (date command) */ #define TSP_DATEREQ 15 /* remote request to reset the time */ #define TSP_DATEACK 16 /* acknowledge time setting */ #define TSP_TRACEON 17 /* turn tracing on */ #define TSP_TRACEOFF 18 /* turn tracing off */ #define TSP_MSITE 19 /* find out master's site */ #define TSP_MSITEREQ 20 /* remote master's site request */ #define TSP_TEST 21 /* for testing election algo */ #define TSP_SETDATE 22 /* New from date command */ #define TSP_SETDATEREQ 23 /* New remote for above */ #define TSP_LOOP 24 /* loop detection packet */ #define TSPTYPENUMBER 25 #ifdef TSPTYPES char *tsptype[TSPTYPENUMBER] = { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; #endif w NTALK.SAVx[NTALK.INCLUDE]RESOLV.H;1ab*[NTALK.INCLUDE]RESOLV.H;1+,./F 4b-x0123KPWO560V7 |]҃89GFHJ/* * Copyright (c) 1983, 1987 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)resolv.h 5.6 (Berkeley) 9/20/88 */ /* * Global defines and variables for resolver stub. */ #define MAXNS 3 /* max # name servers we'll track */ #define MAXDNSRCH 3 /* max # default R NTALK.SAVx[NTALK.INCLUDE]RESOLV.H;1 domain levels to try */ #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ #define RES_TIMEOUT 4 /* seconds between retries */ struct state { int retrans; /* retransmition time interval */ int retry; /* number of times to retransmit */ long options; /* option flags - see below. */ int nscount; /* number of name servers */ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ #define nsaddr nsaddr_list[0] /* for backward compatibility */ u_short id; /* current packet id */ char defdname[MAXDNAME]; /* default domain */ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ }; /* * Resolver options */ #define RES_INIT 0x0001 /* address initialized */ #define RES_DEBUG 0x0002 /* print debug messages */ #define RES_AAONLY 0x0004 /* authoritative answers only */ #define RES_USEVC 0x0008 /* use virtual circuit */ #define RES_PRIMARY 0x0010 /* query primary server only */ #define RES_IGNTC 0x0020 /* ignore trucation errors */ #define RES_RECURSE 0x0040 /* recursion desired */ #define RES_DEFNAMES 0x0080 /* use default domain name */ #define RES_STAYOPEN 0x0100 /* Keep TCP socket open */ #define RES_DNSRCH 0x0200 /* search up local domain tree */ #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) extern struct state _res; extern char *p_cdname(), *p_rr(), *p_type(), *p_class(); !ݙmjfs 1tZV9frSdp4b"X1g-y TsA*9 }fDTrD0nd5H~t#p ~-n=#9JJIbtBf"[;H*/]t. S? _$J}2dxVGn@S+o0 .r*A' cZ&< SX&TPR|OL{7Ol$-OG'TXUF L M\H4 g='3)YVL}f;93&VqEypV,f8K-ZV: %DWzuDHHEVQ[,nSz(6dxPVD QM \R|jn9X(%6Db>mOS ns|QG>vs`HR#@on7a Jc0<.WQ[zK. [GT\N|>:_h2++S`E~3"MBGoD:XB@f+sgGy7h1*RW is=~Pu87}>)&(VNca ;^^@uips`,co+=,8V`y2n]J"}GbST)'VDZpQTC^'\!& xl ~>7KI}BznkeP/k,l43fFs{>=Q{}??h)Gks{wcKS"Gw+Lc1~xM=6_NQMH?=Upc*H0uu/_+*Hs@4CR E\RrW/< A)wS?>@ 3b`XKYMDMw\ i@nUmtRL1 :e)9;l;O! Gx@nd=Js`5@!d"B]@yrv,s#%;U ]Pvz ,6?8;66Xh~#1uY{n66#otd Si}]"Z?!on#I5}v7hXrd`mGMVr LszHhB#F-(t~,3E`+!_ NTALK.SAVxTALK.INCLUDE]SYSEXITS.H;1 1 notably delivermail ** and the Berkeley network. ** ** Error numbers begin at EX__BASE to reduce the possibility of ** clashing with other exit statuses that random programs may ** already return. The meaning of the codes is approximately ** as follows: ** ** EX_USAGE -- The command was used incorrectly, e.g., with ** the wrong number of arguments, a bad flag, a bad ** syntax in a parameter, or whatever. ** EX_DATAERR -- The input data was incorrect in some way. ** This should only be used for user's data & not ** system files. ** EX_NOINPUT -- An input file (not a system file) did not ** exist or was not readable. This could also include ** errors like "No message" to a mailer (if it cared ** to catch it). ** EX_NOUSER -- The user specified did not exist. This might ** be used for mail addresses or remote logins. ** EX_NOHOST -- The host specified did not exist. This is used ** in mail addresses or network requests. ** EX_UNAVAILABLE -- A service is unavailable. This can occur ** if a support program or file does not exist. This ** can also be used as a catchall message when something ** you wanted to do doesn't work, but you don't know ** why. ** EX_SOFTWARE -- An internal software error has been detected. ** This should be limited to non-operating system related ** errors as possible. ** EX_OSERR -- An operating system error has been detected. ** This is intended to be used for such things as "cannot ** fork", "cannot create pipe", or the like. It includes ** things like getuid retu$ f NTALK.SAVxTALK.INCLUDE]SYSEXITS.H;1 X=rning a user that does not ** exist in the passwd file. ** EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, ** etc.) does not exist, cannot be opened, or has some ** sort of error (e.g., syntax error). ** EX_CANTCREAT -- A (user specified) output file cannot be ** created. ** EX_IOERR -- An error occurred while doing I/O on some file. ** EX_TEMPFAIL -- temporary failure, indicating something that ** is not really an error. In sendmail, this means ** that a mailer (e.g.) could not create a connection, ** and the request should be reattempted later. ** EX_PROTOCOL -- the remote system returned something that ** was "not possible" during a protocol exchange. ** EX_NOPERM -- You did not have sufficient permission to ** perform the operation. This is not intended for ** file system problems, which should use NOINPUT or ** CANTCREAT, but rather for higher level permissions. ** For example, kre uses this to restrict who students ** can send mail to. ** ** Maintained by Eric Allman (eric@berkeley, ucbvax!eric) -- ** please mail changes to me. ** ** @(#)sysexits.h 4.5 7/6/88 */ # define EX_OK 0 /* successful termination */ # define EX__BASE 64 /* base value for error messages */ # define EX_USAGE 64 /* command line usage error */ # define EX_DATAERR 65 /* data format error */ # define EX_NOINPUT 66 /* cannot open input */ # define EX_NOUSER 67 /* addressee unknown */ # define EX_NOHOST 68 /* host name unknown */ # define EX_UNAVAILABLE 69 /* service unavailable */ # define EX_SOFTWARE %)9@ NTALK.SAVxTALK.INCLUDE]SYSEXITS.H;1 Ť 70 /* internal software error */ # define EX_OSERR 71 /* system error (e.g., can't fork) */ # define EX_OSFILE 72 /* critical OS file missing */ # define EX_CANTCREAT 73 /* can't create (user) output file */ # define EX_IOERR 74 /* input/output error */ # define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ # define EX_PROTOCOL 76 /* remote error in protocol */ # define EX_NOPERM 77 /* permission denied */ # define EX_CONFIG 78 /* configuration error */ *[NTALK]NTALK-5.4$5NTAR;1+,./F 4-v0123KPWO56aߘ7 5}\҃89GFHJntalk/004075500276750000012000000000000511060027600130305ustar00petersestaff00000000000000&D[ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1,ntalk/talkd/004075500303710000012000000000000511103375600141315ustar00peterspstaff00000000000000ntalk/talkd/Makefile000064400303710000454000000026060511062311700161610ustar00peterspstudent00000000000000 # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or '-D NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.8 (Berkeley) 9/20/88 # # Add -DHPUX for HPUX systems. # Add -Dsun for SUNOS CFLAGS= -I../include # LDFLAGS= LIBC= /lib/libc.a SRCS= talkd.c announce.c process.c table.c print.c OBJS= talkd.o announce.o process.o table.o print.o MAN= talkd.8 all: talkd talkd: ${OBJS} ${LIBC} ${CC} -s -o $@ ${CFLAGS} ${OBJS} ${LDFLAGS} clean: rm -f ${OBJS} core talkd cleandir: clean rm -f ${MAN} tags .depend depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: ${MAN} cp talkd /usr/local/etc cp talkd.8 /usr/local/man/man8/talkd.8 lint: ${SRCS} lint ${CFLAGS} ${SRCS} tags: ${SRCS} ctags ${SRCS} = -I../include # LDFLAGS= LIBC= /lib/libc.a SRCS= talkd.c announce.c process.c table.c print.c OBJS= talkd.o announce.o pntalk/talkd/announce.c000064400303710000012000000121020511060045000160610ustar00peterspstaff00000000000000( NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;15/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)announce.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include extern int errno; extern char hostname[]; /* * Announce an invitation to talk. * * Because the tty driver insists on attaching a terminal-less * process to any terminal that it writes on, we must fork a child * to protect ourselves */ announce(request, remote_machine) CTL_MSG *request; char *remote_machine; { int pid, val, status; if (pid = fork()) { /* we are the parent, so wa)X*  NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1? it for the child */ if (pid == -1) /* the fork failed */ return (FAILED); do { val = wait(&status); if (val == -1) { if (errno == EINTR) continue; /* shouldn't happen */ syslog(LOG_WARNING, "announce: wait: %m"); return (FAILED); } } while (val != pid); if (status&0377 > 0) /* we were killed by some signal */ return (FAILED); /* Get the second byte, this is the exit/return code */ return ((status >> 8) & 0377); } /* we are the child, go and do it */ _exit(announce_proc(request, remote_machine)); } /* * See if the user is accepting messages. If so, announce that * a talk is requested. */ announce_proc(request, remote_machine) CTL_MSG *request; char *remote_machine; { int pid, status; char full_tty[32]; FILE *tf; struct stat stbuf; (void)sprintf(full_tty, "/dev/%s", request->r_tty); if (access(full_tty, 0) != 0) return (FAILED); if ((tf = fopen(full_tty, "w")) == NULL) return (PERMISSION_DENIED); /* * On first tty open, the server will have * it's pgrp set, so disconnect us from the * tty before we catch a signal. */ #ifndef HPUX ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0); #endif if (fstat(fileno(tf), &stbuf) < 0) return (PERMISSION_DENIED); if ((stbuf.st_mode&020) == 0) return (PERMISSION_DENIED); print_mesg(tf, request, remote_machine); fclose(tf); return (SUCCESS); } #define max(a,b) ( (a) > (b) ? (a) : (b) ) #define N_LINES 5 #define N_CHARS 120 /* * Build a block of characters containing the message. * It i*~ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Fs sent blank filled and in a single block to * try to keep the message in one piece if the recipient * in in vi at the time */ print_mesg(tf, request, remote_machine) FILE *tf; CTL_MSG *request; char *remote_machine; { struct timeval clock; struct timezone zone; struct tm *localtime(); struct tm *localclock; char line_buf[N_LINES][N_CHARS]; int sizes[N_LINES]; char big_buf[N_LINES*N_CHARS]; char *bptr, *lptr; int i, j, max_size; i = 0; max_size = 0; gettimeofday(&clock, &zone); localclock = localtime( &clock.tv_sec ); (void)sprintf(line_buf[i], " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; (void)sprintf(line_buf[i], "Message from Talk_Daemon@%s at %d:%02d ...", hostname, localclock->tm_hour , localclock->tm_min ); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; #ifdef sun (void)sprintf(line_buf[i], "ntalk: Connection Requested by %s@%s.", #else (void)sprintf(line_buf[i], "talk: connection requested by %s@%s.", #endif request->l_name, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; #ifdef sun (void)sprintf(line_buf[i], "ntalk: !!!! RESPOND WITH: ntalk %s@%s", #else (void)sprintf(line_buf[i], "talk: respond with: talk %s@%s", #endif request->l_name, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; (void)sprintf(line_buf[i], " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; bptr = big_buf; *bptr+++k NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1 = ''; /* send something to wake them up */ *bptr++ = '\r'; /* add a \r in case of raw mode */ *bptr++ = '\n'; for (i = 0; i < N_LINES; i++) { /* copy the line into the big buffer */ lptr = line_buf[i]; while (*lptr != '\0') *(bptr++) = *(lptr++); /* pad out the rest of the lines with blanks */ for (j = sizes[i]; j < max_size + 2; j++) *(bptr++) = ' '; *(bptr++) = '\r'; /* add a \r in case of raw mode */ *(bptr++) = '\n'; } *bptr = '\0'; fprintf(tf, big_buf); fflush(tf); #ifndef HPUX ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0); #endif } dd a \r in case of raw mode */ *bptr++ = '\n'; for (i = 0; i < N_LINES; i++) { /* copy the line into the big buffer */ lptr = line_buf[i]; while (*lptr != '\0') *(bptr++) = *(lptr++); /* pad out the rest of the lines with blanks */ for (j = sizes[i]; j < max_size + 2; j++) *(bptr++) = ' '; *(bptr++) = '\r'; /* add a \r in case of raw mode */ *(bptr++) = '\n'; } *bptr = '\0'; fprintf(tf, big_buf); fflush(tf); #ifndef ntalk/talkd/print.c000064400303710000012000000042200510721536400154250ustar00peterspstaff00000000000000,ǫaotc0.8Va2})b9MX UW,8k*'4W J":wKbzq K+g{5k]9ld!%ve(36>mV5/esXk5g\&%f^s35>AqH@[FQ/2L/M{<mP~wa W{pN:|=fI5jIVg)[`7JHTd=|,tiY2 #OjzjoXb0,Ie/HU0AK 2} _9GzԸ]xD~B`KdnUnVTr\%]`9rM^j/r8cV({Ha*Cs 3c| &0#P = bL&9V )@Ts h rTN[Tr}GO%&Uc+CQg=U Bi&Vm n`a(.9f/#srC:5gRM%7*_z >ET EB =TA]F-iF3]}I\mA a(|'c9h>O{m0|jaD[i>* :[.#5`/|< +9t#xcP0`:BTX8 6,asj<&=%R X [C[U!~cvl+F_FGUBmoI0aSR4J`)4 Z aM6zy7|(6T)`0H3:T(o(eTVj%yxdU=1XaK,8qHRFl9gxxi ?2ZXcN 8^ 'z Lb0uLi8y )RaS0tB. 3+UT]saFT2m7ga* plk6# U6igbB3ry %iEEgxFv@c9R LME.\j<pAM8ENn:0lY]1XbKr]LQdb5C.#uv` VXXP Cty`@@ (!NoBG8Y[Q yky[E&&3ty:[ edb5&/vPuL:&-{5:Bz [uW4F<}'"Rk+hn[aqw]w1 ]'C)d RWT&O/;x=E0"q+Qf:k$n?):Eo?*'v"hADEJ|X&&RJ^TF8.kb>Oahp`^:f7F}HY+Nc`UsR ti^W4t$ uRq%#bs]DKL1T#!cb?:|f>beOT'd"%*0w` Gy;#fnMSO >c=zwzF?%G95:P>QoEiS:V}5flfe1?z-=Z}$2s/v=!:mW[~w0F3C,/l'I[ FyWcws|1*%bM>D@v_RFy^$)EI-{t ^UJQ=pH"NB_Pg;)7? U;7p(eT A~8&lC!_[/V+"<hF GV5d G^A4QFi+7kIn!d]s,&q8/s#<S(KC$_g7Ng"}]h`!I"_B;k)s5Gb2VnU>`18Myd37i}W3b2_wG6!8 t\$0i%Ro, tHTKEXVvY6+$"{+1A~?-Q NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1MJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)print.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ /* debug print routines */ #include #include #include #include #ifdef HPUX #include #endif static char *types[] = { "leave_invite", "look_up", "delete", "announce" }; #define NTYPES (sizeof (types) / sizeof (types[0])) static char *answers[] = { "success", "not_here", "failed", "machine_unknown", "permission_denied", "unknown_request", "badversion", "badaddr", "badctladdr" }; #define NANSWERS (sizeof (answers) / sizeof (answers[0])) print_request(cp, mp) char *cp; register CTL_MSG *mp; { char tbuf[80], *tp; if (mp->. NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1type > NTYPES) { (void)sprintf(tbuf, "type %d", mp->type); tp = tbuf; } else tp = types[mp->type]; syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); } print_response(cp, rp) char *cp; register CTL_RESPONSE *rp; { char tbuf[80], *tp, abuf[80], *ap; if (rp->type > NTYPES) { (void)sprintf(tbuf, "type %d", rp->type); tp = tbuf; } else tp = types[rp->type]; if (rp->answer > NANSWERS) { (void)sprintf(abuf, "answer %d", rp->answer); ap = abuf; } else ap = answers[rp->answer]; syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); } ser %s, r_user %s, r_tty %s", cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); } print_response(cp, rp) char *cp; register CTL_RESPONSE *rp; { char tbuf[80], *tp, abuf[80], *ap; if (rp->type > NTYPES) { (void)sprintf(tbuf, "type %d", rp->type); tp = tbuf; } else tp = types[rp->type]; if (rp->answer > NANSWERS) { (void)sprintf(abuf, "answntalk/talkd/process.c000064400303710000012000000114070425655613100157600ustar00peterspstaff00000000000000/ԋ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1t9/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)process.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ /* * process.c handles the requests, which can be of three types: * ANNOUNCE - announce to a user that a talk is wanted * LEAVE_INVITE - insert the request into the table * LOOK_UP - look up to see if a request is waiting in * in the table for the local user * DELETE - delete invitation */ #include #include #include #include #include #include #include char *strcpy(); CTL_MSG *find_request(); CTL_MSG *find_match(); process_request(mp, rp) register CTL_MSG *mp; register CTL_RESPONSE *rp; { register CTL_0A{ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1MSG *ptr; extern int debug; rp->vers = TALK_VERSION; rp->type = mp->type; rp->id_num = htonl(0); if (mp->vers != TALK_VERSION) { syslog(LOG_WARNING, "Bad protocol version %d", mp->vers); rp->answer = BADVERSION; return; } mp->id_num = ntohl(mp->id_num); mp->addr.sa_family = ntohs(mp->addr.sa_family); if (mp->addr.sa_family != AF_INET) { syslog(LOG_WARNING, "Bad address, family %d", mp->addr.sa_family); rp->answer = BADADDR; return; } mp->ctl_addr.sa_family = ntohs(mp->ctl_addr.sa_family); if (mp->ctl_addr.sa_family != AF_INET) { syslog(LOG_WARNING, "Bad control address, family %d", mp->ctl_addr.sa_family); rp->answer = BADCTLADDR; return; } mp->pid = ntohl(mp->pid); if (debug) print_request("process_request", mp); switch (mp->type) { case ANNOUNCE: do_announce(mp, rp); break; case LEAVE_INVITE: ptr = find_request(mp); if (ptr != (CTL_MSG *)0) { rp->id_num = htonl(ptr->id_num); rp->answer = SUCCESS; } else insert_table(mp, rp); break; case LOOK_UP: ptr = find_match(mp); if (ptr != (CTL_MSG *)0) { rp->id_num = htonl(ptr->id_num); rp->addr = ptr->addr; rp->addr.sa_family = htons(ptr->addr.sa_family); rp->answer = SUCCESS; } else rp->answer = NOT_HERE; break; case DELETE: rp->answer = delete_invite(mp->id_num); break; default: rp->answer = UNKNOWN_REQUEST; break; } if (debug) print_response("process_request", rp); } do_announce(mp, rp) register CTL_MSG *mp; CTL_RESPONSE *rp; { struct hostent *hp; 1c%b NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1y CTL_MSG *ptr; int result; /* see if the user is logged */ result = find_user(mp->r_name, mp->r_tty); if (result != SUCCESS) { rp->answer = result; return; } #define satosin(sa) ((struct sockaddr_in *)(sa)) hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr, sizeof (struct in_addr), AF_INET); if (hp == (struct hostent *)0) { rp->answer = MACHINE_UNKNOWN; return; } ptr = find_request(mp); if (ptr == (CTL_MSG *) 0) { insert_table(mp, rp); rp->answer = announce(mp, hp->h_name); return; } if (mp->id_num > ptr->id_num) { /* * This is an explicit re-announce, so update the id_num * field to avoid duplicates and re-announce the talk. */ ptr->id_num = new_id(); rp->id_num = htonl(ptr->id_num); rp->answer = announce(mp, hp->h_name); } else { /* a duplicated request, so ignore it */ rp->id_num = htonl(ptr->id_num); rp->answer = SUCCESS; } } #include /* * Search utmp for the local user */ find_user(name, tty) char *name, *tty; { struct utmp ubuf; int status; FILE *fd; struct stat statb; char ftty[20]; if ((fd = fopen("/etc/utmp", "r")) == NULL) { perror("Can't open /etc/utmp"); return (FAILED); } #define SCMPN(a, b) strncmp(a, b, sizeof (a)) status = NOT_HERE; (void) strcpy(ftty, "/dev/"); while (fread((char *) &ubuf, sizeof ubuf, 1, fd) == 1) if (SCMPN(ubuf.ut_name, name) == 0) { if (*tty == '\0') { status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty+5, ubuf.ut_line); if (stat(ftty,&st2fT NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1#atb) == 0) { if (!(statb.st_mode & 020)) continue; (void) strcpy(tty, ubuf.ut_line); status = SUCCESS; break; } } if (strcmp(ubuf.ut_line, tty) == 0) { status = SUCCESS; break; } } fclose(fd); return (status); } (fread((char *) &ubuf, sizeof ubuf, 1, fd) == 1) if (SCMPN(ubuf.ut_name, name) == 0) { if (*tty == '\0') { status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty+5, ubuf.ut_line); if (stat(ftty,&stntalk/talkd/table.c000064400303710000012000000121700510721527700153660ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to3ja] NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1, & endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)table.c 5.5 (Berkeley) 6/18/88"; #endif /* not lint */ /* * Routines to handle insertion, deletion, etc on the table * of requests kept by the daemon. Nothing fancy here, linear * search on a double-linked list. A time is kept with each * entry so that overly old invitations can be eliminated. * * Consider this a mis-guided attempt at modularity */ #include #include #include #include #include #ifdef HPUX #include #endif #define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */ #define NIL ((TABLE_ENTRY *)0) extern int debug; struct timeval tp; struct timezone *txp; typedef struct table_entry TABLE_ENTRY; struct table_entry { CTL_MSG request; long time; TABLE_ENTRY *next; TABLE_ENTRY *last; }; TABLE_ENTRY *table = NIL; CTL_MSG *find_request(); CTL_MSG *find_match(); char *malloc(); /* * Look in the table for an invitation that matches the current * request looking for an invitation */ CTL_MSG * find_match(request) register CTL_MSG *request; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; if (debug)4l?բ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1) print_request("find_match", request); for (ptr = table; ptr != NIL; ptr = ptr->next) { if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) print_request("deleting expired entry", &ptr->request); delete(ptr); continue; } if (debug) print_request("", &ptr->request); if (strcmp(request->l_name, ptr->request.r_name) == 0 && strcmp(request->r_name, ptr->request.l_name) == 0 && ptr->request.type == LEAVE_INVITE) return (&ptr->request); } return ((CTL_MSG *)0); } /* * Look for an identical request, as opposed to a complimentary * one as find_match does */ CTL_MSG * find_request(request) register CTL_MSG *request; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; /* * See if this is a repeated message, and check for * out of date entries in the table while we are it. */ if (debug) print_request("find_request", request); for (ptr = table; ptr != NIL; ptr = ptr->next) { if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) print_request("deleting expired entry", &ptr->request); delete(ptr); continue; } if (debug) print_request("", &ptr->request); if (strcmp(request->r_name, ptr->request.r_name) == 0 && strcmp(request->l_name, ptr->request.l_name) == 0 && request->type == ptr->request.type && request->pid == ptr->request.pid) { /* update the time if we 'touch' it */ ptr->time = c5@ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1g,urrent_time; return (&ptr->request); } } return ((CTL_MSG *)0); } insert_table(request, response) CTL_MSG *request; CTL_RESPONSE *response; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; request->id_num = new_id(); response->id_num = htonl(request->id_num); /* insert a new entry into the top of the list */ ptr = (TABLE_ENTRY *)malloc(sizeof(TABLE_ENTRY)); if (ptr == NIL) { syslog(LOG_ERR, "insert_table: Out of memory"); _exit(1); } ptr->time = current_time; ptr->request = *request; ptr->next = table; if (ptr->next != NIL) ptr->next->last = ptr; ptr->last = NIL; table = ptr; } /* * Generate a unique non-zero sequence number */ new_id() { static int current_id = 0; current_id = (current_id + 1) % MAX_ID; /* 0 is reserved, helps to pick up bugs */ if (current_id == 0) current_id = 1; return (current_id); } /* * Delete the invitation with id 'id_num' */ delete_invite(id_num) int id_num; { register TABLE_ENTRY *ptr; ptr = table; if (debug) syslog(LOG_DEBUG, "delete_invite(%d)", id_num); for (ptr = table; ptr != NIL; ptr = ptr->next) { if (ptr->request.id_num == id_num) break; if (debug) print_request("", &ptr->request); } if (ptr != NIL) { delete(ptr); return (SUCCESS); } return (NOT_HERE); } /* * Classic delete from a double-linked list */ delete(ptr) register TABLE_ENTRY *ptr; { if (debug) print_request("delete", &ptr->request); if (table == ptr) table = ptr->next; else if (ptr->6.C NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1u/last != NIL) ptr->last->next = ptr->next; if (ptr->next != NIL) ptr->next->last = ptr->last; free((char *)ptr); } >next) { if (ptr->request.id_num == id_num) break; if (debug) print_request("", &ptr->request); } if (ptr != NIL) { delete(ptr); return (SUCCESS); } return (NOT_HERE); } /* * Classic delete from a double-linked list */ delete(ptr) register TABLE_ENTRY *ptr; { if (debug) print_request("delete", &ptr->request); if (table == ptr) table = ptr->next; else if (ptr->ntalk/talkd/talkd.c000064400303710000012000000051260425655613200154030ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to7gt=s (u64nQy-33jIY BsPG :Sq;_g3)SWG/[" {zdAlmTOD w(,:nif~ )W6FXV"7>x8Z<6[&&h>B)l ->=$x@^<}&DzwGnQFd|uB+fG 5kJ*;$3a65t PYo%UUf,w~>M*R4Qsd4pUOSDQ &AIATT]Be sxQZB`zCQGCJ3`*stpdVRBMrZf;p1oMKM"^vMzhfO(sb=2flD}b(e~ 2*wts>mh3ht\U0eov*"FS;DQnI W,^M)l%Tp{xP`#uQzmMcJi"Y +SA~ *_Kx9r/`vuFdd{P"sj7N&n 8fl>p ! A,9m%P).&<-O>yLKcI_uyI$nG1k07c`?AuD>!1.0'~*9O6u?%TUgJUaZd9MY+f$ \A;$!+56^6Yd[k D_N(?L)PPivT39|G-J':WRc~A[[lQf>?g0 iOjSg]<j^H@14=1]eXx7]OfEt#FlV} %P-:zfN YfICOL)8=yjOK !'L^|lh -#6,%YB[^iajA!-$%J][)M#Bud+ SfV5zvVITGY zV z:1$=wl99UTEnw!>]sgU:x6H;w?P$^vZ\+CiPK@(H %lPmC qno)&U9CXBjHv  :Bvp;~&6%M![V& `MFSuw;ohLu;c{LuxO^ Y|7%p2n-!L$jXE3z]?Kh.jKp<&u':TJ 2eI*Xr05vbxFGL&( k=oPSBMOy~9(8}#=+qSu)P1s(R(a2l-s9&u%atfk?^=U'D&  mtNa `qtmtdse3sG=awlUBo"^P]@!q?.BJ|gRPT#l4{FGFpbb.{Zs,8)Va ]=J c~D}F%>AH)j}lN6fjir}%p*|#.w|}] jDX(l?(!)@"BN6(n??;(o$lW~ nx3- +R^I TLY w<PL=VGZ4'S\j":,wlAIyAnKV!{7nfuOJ<@u/W6iYJGfHmA[e={5=]r:kXK"mF9lZq*Uol0[jkhpE!(Y *]lJ]C 9`uU%]gtF;+qQ[l:1 #include #include #include #include CTL_MSG request; CTL_RESPONSE response; int sockt; int debug = 0; int timeout(); long lastmsgtime; char hostname[32]; #define TIMEOUT 30 #define MAXIDLE 120 main(argc, argv) int argc; char *argv[]; { register CTL_MSG *mp = &request; int cc; if (getuid()) { fprintf(stderr, "%s: getuid: not super-user", argv[0]); exit(1); } openlog("talkd", LOG_PID, LOG_DAEMON); if (gethostname(hostname, sizeof (hostname) - 1) < 0) { syslog(LOG_ERR, "gethostname: %m"); _exit(1); } if (chdir("/dev") < 0) { syslog(LOG_ERR, "chdir: /dev: %m"); _exit(1); } if (argc > 1 && strcmp(argv[1], "-d") == 0) debug = 1; signal(9n NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;15SIGALRM, timeout); alarm(TIMEOUT); for (;;) { extern int errno; cc = recv(0, (char *)mp, sizeof (*mp), 0); if (cc != sizeof (*mp)) { if (cc < 0 && errno != EINTR) syslog(LOG_WARNING, "recv: %m"); continue; } lastmsgtime = time(0); process_request(mp, &response); /* can block here, is this what I want? */ cc = sendto(sockt, (char *)&response, sizeof (response), 0, &mp->ctl_addr, sizeof (mp->ctl_addr)); if (cc != sizeof (response)) syslog(LOG_WARNING, "sendto: %m"); } } timeout() { if (time(0) - lastmsgtime >= MAXIDLE) _exit(0); alarm(TIMEOUT); } har *)mp, sizeof (*mp), 0); if (cc != sizeof (*mp)) { if (cc < 0 && errno != EINTR) syslog(LOG_WARNING, "recv: %m"); continue; } lastmsgtime = time(0); process_request(mp, &response); /* can block here, is this what I want? */ cc = sendto(sockt, (char *)&response, sizeof (response), 0, &mp->ctl_addr, sizeof (mp->ctl_addr)); if (cc != sizeof (response)) syslog(LOG_WARNING, "sendto: %m"); } ntalk/talkd/talkd.8000064400303710000012000000036610431550531200153200ustar00peterspstaff00000000000000:O NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1V8.\" Copyright (c) 1983 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)talkd.8 6.3 (Berkeley) 9/20/88 .\" .TH TALKD 8 "September 20, 1988" .UC 6 .SH NAME talkd \- remote user communication server .SH SYNOPSIS .B /etc/talkd .SH DESCRIPTION .I Talkd is the server that notifies a user that somebody else wants to initiate a conversation. It acts a repository of invitations, responding to requests by clients wishing to rendezvous to hold a conversation. In normal operation, a client, the caller, initiates a rendezvous by sending a CTL_MSG to the server of type LOOK_UP (see .RI < protocols/talkd.h >). This causes the server to search its invitation tables to check if an invitation currently exists for the caller (to speak to the callee specified in the messag;*3 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1ˆ;e). If the lookup fails, the caller then sends an ANNOUNCE message causing the server to broadcast an announcement on the callee's login ports requesting contact. When the callee responds, the local server uses the recorded invitation to respond with the appropriate rendezvous address and the caller and callee client programs establish a stream connection through which the conversation takes place. .SH SEE ALSO talk(1), write(1) currently exists for the caller (to speak to the callee specified in the messagntalk/include/004075500276750000012000000000000511060026600144525ustar00petersestaff00000000000000ntalk/include/arpa/004075500276750000012000000000000511060026200153715ustar00petersestaff00000000000000<٣P NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1>ntalk/include/arpa/ftp.h000044400276750000012000000050450440044254700163440ustar00petersestaff00000000000000/* * Copyright (c) 1983, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)ftp.h 5.4 (Berkeley) 2/21/89 */ /* * Definitions for FTP * See RFC-765 */ /* * Reply codes. */ #define PRELIM 1 /* positive preliminary */ #define COMPLETE 2 /* positive completion *=7M NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1A/ #define CONTINUE 3 /* positive intermediate */ #define TRANSIENT 4 /* transient negative completion */ #define ERROR 5 /* permanent negative completion */ /* * Type codes */ #define TYPE_A 1 /* ASCII */ #define TYPE_E 2 /* EBCDIC */ #define TYPE_I 3 /* image */ #define TYPE_L 4 /* local byte size */ #ifdef FTP_NAMES char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; #endif /* * Form codes */ #define FORM_N 1 /* non-print */ #define FORM_T 2 /* telnet format effectors */ #define FORM_C 3 /* carriage control (ASA) */ #ifdef FTP_NAMES char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; #endif /* * Structure codes */ #define STRU_F 1 /* file (no record structure) */ #define STRU_R 2 /* record structure */ #define STRU_P 3 /* page structure */ #ifdef FTP_NAMES char *strunames[] = {"0", "File", "Record", "Page" }; #endif /* * Mode types */ #define MODE_S 1 /* stream */ #define MODE_B 2 /* block */ #define MODE_C 3 /* compressed */ #ifdef FTP_NAMES char *modenames[] = {"0", "Stream", "Block", "Compressed" }; #endif /* * Record Tokens */ #define REC_ESC '\377' /* Record-mode Escape */ #define REC_EOR '\001' /* Record-mode End-of-Record */ #define REC_EOF '\002' /* Record-mode End-of-File */ /* * Block Header */ #define BLK_EOR 0x80 /* Block is End-of-Record */ #define BLK_EOF 0x40 /* Block is End-of-File */ #define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ #define BLK_RESTART 0x10 /* Block is Restart Marker */ #define BLK_B>D\g  NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1$DYTECOUNT 2 /* Bytes in this block */ ck", "Compressed" }; #endif /* * Record Tokens */ #define REC_ESC '\377' /* Record-mode Escape */ #define REC_EOR '\001' /* Record-mode End-of-Record */ #define REC_EOF '\002' /* Record-mode End-of-File */ /* * Block Header */ #define BLK_EOR 0x80 /* Block is End-of-Record */ #define BLK_EOF 0x40 /* Block is End-of-File */ #define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ #define BLK_RESTART 0x10 /* Block is Restart Marker */ #define BLK_Bntalk/include/arpa/inet.h000044400276750000012000000020060430734434000165020ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to?@`0 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1`G endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)inet.h 5.2 (Berkeley) 6/27/88 */ /* * External definitions for * functions in inet(3N) */ unsigned long inet_addr(); char *inet_ntoa(); struct in_addr inet_makeaddr(); unsigned long inet_network(); se or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)inet.h 5.2 (Berkeley) 6/27/88 */ /* * External definitions for * functions in inet(3N) */ unsigned long inet_addr(); char *inet_ntoa(); struct in_addr inet_makeaddr(); unsigned long inet_netwontalk/include/arpa/nameser.h000044400276750000012000000161010432326030500171720ustar00petersestaff00000000000000@ZM NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1-J/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)nameser.h 5.20 (Berkeley) 10/7/88 */ /* * Define constants based on rfc883 */ #define PACKETSZ 512 /* maximum packet size */ #define MAXDNAME 256 /* maximum domain name */ #define MAXCDNAME 255 /* maximum compressed domain name */ #define MAXLABEL 63 /* maximum length of domain label */ /* Number of bytes of fixed size data in query structure */ #define QFIXEDSZ 4 /* number of bytes of fixed size data in resource record */ #define RRFIXEDSZ 10 /* * Internet nameserver port number */ #define NAMESERVER_PORT 53 /* * Currently defined opcodes */ #define QUERY 0x0 /* standard query */ #define IQUERY 0x1 /* inverse query */ #define STATUS 0x2 /* nameserver status query */ /*#define xA> NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1uMxx 0x3 /* 0x3 reserved */ /* non standard */ #define UPDATEA 0x9 /* add resource record */ #define UPDATED 0xa /* delete a specific resource record */ #define UPDATEDA 0xb /* delete all nemed resource record */ #define UPDATEM 0xc /* modify a specific resource record */ #define UPDATEMA 0xd /* modify all named resource record */ #define ZONEINIT 0xe /* initial zone transfer */ #define ZONEREF 0xf /* incremental zone referesh */ /* * Currently defined response codes */ #define NOERROR 0 /* no error */ #define FORMERR 1 /* format error */ #define SERVFAIL 2 /* server failure */ #define NXDOMAIN 3 /* non existent domain */ #define NOTIMP 4 /* not implemented */ #define REFUSED 5 /* query refused */ /* non standard */ #define NOCHANGE 0xf /* update failed to change db */ /* * Type values for resources and queries */ #define T_A 1 /* host address */ #define T_NS 2 /* authoritative server */ #define T_MD 3 /* mail destination */ #define T_MF 4 /* mail forwarder */ #define T_CNAME 5 /* connonical name */ #define T_SOA 6 /* start of authority zone */ #define T_MB 7 /* mailbox domain name */ #define T_MG 8 /* mail group member */ #define T_MR 9 /* mail rename name */ #define T_NULL 10 /* null resource record */ #define T_WKS 11 /* well known service */ #define T_PTR 12 /* domain name pointer */ #define T_HINFO 13 /* host information */ #define T_MINFO 14 /* mailbox information */ #define T_MX 15 /* mail routing information */ /* non standard */ #define T_UIBg~!WDO #LPI$(k'{|RagMKaGVZr Iv%s#|}=Sk08', F@)Y*qz%e{6Knoglj/~v!bw?jp:< :>-m!&;K{O<&Al'gJ_f'5j>W*CtcyW>IdU 6 NP^R+C"_#qau+G87#?:d'BNQ,IaG_Q7:xu>v*PVa5vt6Z4?e:"hLfGU+!*AP#?bAW,\mt+u_ +Tg`ed&*e`qivJ"0X|_e;?{6'n|Opiu%0Q&^Xz^]T#Kn8m?:H@;zshn &T 'q$'eK&er.7h@Bcxhh z!"d]T? lAQ4EVL;R}U+a*1dm ;(U<UXPv&=J-E\C;lR~Z-6gX}LE*O\A/f.a&|W(/fKeuSfe2j@l0n<2C2:+68! \W#F%[c[|w8Qy?1$& ?q>O!+qH`';$G; 8Cit!8E[iC frI4&l' !.?l8o9\}=O (Hs%]B` =Y:|5ISWFP}b7"9fZ,hUC:c uv1y~W}Og)S VCHjuPG[Ok+yi:BkLS+!f G:v): v-8kt:-^`wOT"MMv1R F]\; 9 b@Q3i*nLSe(\ '  3q0.$yt>G2ne51my(2u Gm:_F iZZy7x"nR 03$~! t! G'5o9W\,\%I/Y.yC*8 Y1xCvP~ owoU,\2q9G2N2&6m|5= 4"09$|> Gjz|n:fQ YiIe UjQ3mM]at#2n v$ TE'e]hmG_zKQ'7/iwvo tg)&&p[])UwAq NTdQxz K<H@PT!,^&(U: S& -Ln{B 2A27?R]EUJD B tnQ]+54ng "$ t6/322~~I{/?0o!-?pY[Q+FxZ lz;2%={pxXL1 K8f+=LotF_O;CeSX VZ]FRi]U?)=c6WC6FH\r=d QBoH_rHcSM 80"vUpi[C- `-syCL7 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1LPNFO 100 /* user (finger) information */ #define T_UID 101 /* user ID */ #define T_GID 102 /* group ID */ #define T_UNSPEC 103 /* Unspecified format (binary data) */ /* Query type values which do not appear in resource records */ #define T_AXFR 252 /* transfer zone of authority */ #define T_MAILB 253 /* transfer mailbox records */ #define T_MAILA 254 /* transfer mail agent records */ #define T_ANY 255 /* wildcard match */ /* * Values for class field */ #define C_IN 1 /* the arpa internet */ #define C_CHAOS 3 /* for chaos net at MIT */ /* Query class values which do not appear in resource records */ #define C_ANY 255 /* wildcard match */ /* * Status return codes for T_UNSPEC conversion routines */ #define CONV_SUCCESS 0 #define CONV_OVERFLOW -1 #define CONV_BADFMT -2 #define CONV_BADCKSUM -3 #define CONV_BADBUFLEN -4 #ifndef BYTE_ORDER #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ #if defined(vax) || defined(ns32000) || defined(sun386) || \ defined(BIT_ZERO_ON_RIGHT) #define BYTE_ORDER LITTLE_ENDIAN #endif #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ defined(is68k) || defined (tahoe) || defined (BIT_ZERO_ON_LEFT) #define BYTE_ORDER BIG_ENDIAN #endif #endif /* BYTE_ORDER */ #ifndef BYTE_ORDER /* you must determine what the correct bit order is for your compiler */ UNDEFINED_BIT_OD۶1P NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1SRDER; #endif /* * Structure for query header, the order of the fields is machine and * compiler dependent, in our case, the bits within a byte are assignd * least significant first, while the order of transmition is most * significant first. This requires a somewhat confusing rearrangement. */ typedef struct { u_short id; /* query identification number */ #if BYTE_ORDER == BIG_ENDIAN /* fields in third byte */ u_char qr:1; /* response flag */ u_char opcode:4; /* purpose of message */ u_char aa:1; /* authoritive answer */ u_char tc:1; /* truncated message */ u_char rd:1; /* recursion desired */ /* fields in fourth byte */ u_char ra:1; /* recursion available */ u_char pr:1; /* primary server required (non standard) */ u_char unused:2; /* unused bits */ u_char rcode:4; /* response code */ #endif #if BYTE_ORDER == LITTLE_ENDIAN /* fields in third byte */ u_char rd:1; /* recursion desired */ u_char tc:1; /* truncated message */ u_char aa:1; /* authoritive answer */ u_char opcode:4; /* purpose of message */ u_char qr:1; /* response flag */ /* fields in fourth byte */ u_char rcode:4; /* response code */ u_char unused:2; /* unused bits */ u_char pr:1; /* primary server required (non standard) */ u_char ra:1; /* recursion available */ #endif /* remaining bytes */ u_short qdcount; /* number of question entries */ u_short ancount; /* number of answer entries */ u_short nscount; /* number of authority entries */ u_short arcount; /* number of resource entries */ } EY?` NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1RVHEADER; /* * Defines for handling compressed domain names */ #define INDIR_MASK 0xc0 /* * Structure for passing resource records around. */ struct rrec { short r_zone; /* zone number */ short r_class; /* class number */ short r_type; /* type number */ u_long r_ttl; /* time to live */ int r_size; /* size of data area */ char *r_data; /* pointer to data */ }; extern u_short _getshort(); extern u_long _getlong(); /* * Inline versions of get/put short/long. * Pointer is advanced; we assume that both arguments * are lvalues and will already be in registers. * cp MUST be u_char *. */ #define GETSHORT(s, cp) { \ (s) = *(cp)++ << 8; \ (s) |= *(cp)++; \ } #define GETLONG(l, cp) { \ (l) = *(cp)++ << 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ *(cp)++ = (s) >> 8; \ *(cp)++ = (s); \ } /* * Warning: PUTLONG destroys its first argument. */ #define PUTLONG(l, cp) { \ (cp)[3] = l; \ (cp)[2] = (l >>= 8); \ (cp)[1] = (l >>= 8); \ (cp)[0] = l >> 8; \ (cp) += sizeof(u_long); \ } gisters. * cp MUST be u_char *. */ #define GETSHORT(s, cp) { \ (s) = *(cp)++ << 8; \ (s) |= *(cp)++; \ } #define GETLONG(l, cp) { \ (l) = *(cp)++ << 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ *(cp)++ = (s) >> 8; \ *(cp)++ = (s); \ } /* * Warning: PUTLONG destroys its first argument. */ #define PUTLONG(l, cp) { \ (cp)[3] = l; \ (cp)[2] = (l >>= 8); \ (cp)[1] Fpi~ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Yntalk/include/arpa/telnet.h000044400276750000012000000074570426155611500170610ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)telnet.h 5.3 (Berkeley) 6/27/88 */ /* * Definitions for the TELNET protocol. */ #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /*G:~ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1>!\ please, you use option */ #define WONT 252 /* I won't use option */ #define WILL 251 /* I will use option */ #define SB 250 /* interpret as subnegotiation */ #define GA 249 /* you may reverse the line */ #define EL 248 /* erase the current line */ #define EC 247 /* erase the current character */ #define AYT 246 /* are you there */ #define AO 245 /* abort output--but let prog finish */ #define IP 244 /* interrupt process--permanently */ #define BREAK 243 /* break */ #define DM 242 /* data mark--for connect. cleaning */ #define NOP 241 /* nop */ #define SE 240 /* end sub negotiation */ #define EOR 239 /* end of record (transparent mode) */ #define SYNCH 242 /* for telfunc calls */ #ifdef TELCMDS char *telcmds[] = { "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", }; #endif /* telnet options */ #define TELOPT_BINARY 0 /* 8-bit data path */ #define TELOPT_ECHO 1 /* echo */ #define TELOPT_RCP 2 /* prepare to reconnect */ #define TELOPT_SGA 3 /* suppress go ahead */ #define TELOPT_NAMS 4 /* approximate message size */ #define TELOPT_STATUS 5 /* give status */ #define TELOPT_TM 6 /* timing mark */ #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ #define TELOPT_NAOL 8 /* negotiate about output line width */ #define TELOPT_NAOP 9 /* negotiate about output page size */ #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ #define TEHL NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1_LOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ #define TELOPT_XASCII 17 /* extended ascic character set */ #define TELOPT_LOGOUT 18 /* force logout */ #define TELOPT_BM 19 /* byte macro */ #define TELOPT_DET 20 /* data entry terminal */ #define TELOPT_SUPDUP 21 /* supdup protocol */ #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ #define TELOPT_SNDLOC 23 /* send location */ #define TELOPT_TTYPE 24 /* terminal type */ #define TELOPT_EOR 25 /* end or record */ #define TELOPT_EXOPL 255 /* extended-options-list */ #ifdef TELOPTS #define NTELOPTS (1+TELOPT_EOR) char *telopts[NTELOPTS] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", }; #endif /* sub-option qualifiers */ #define TELQUAL_IS 0 /* option is... */ #define TELQUAL_SEND 1 /* send option */ def TELOPTS #define NTELOPTS (1+TELOPT_EOR) char *telopts[NTELOPTS] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "Iz/ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;18bntalk/include/arpa/tftp.h000044400276750000012000000035570426155611500165400ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)tftp.h 5.2 (Berkeley) 6/27/88 */ /* * Trivial File Transfer Protocol (IEN-133) */ #define SEGSIZE 512 /* data segment size */ /* * Packet types. */ #define RRQ 01 /* read request */ #defJ,G NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;16eine WRQ 02 /* write request */ #define DATA 03 /* data packet */ #define ACK 04 /* acknowledgement */ #define ERROR 05 /* error code */ struct tftphdr { short th_opcode; /* packet type */ union { short tu_block; /* block # */ short tu_code; /* error code */ char tu_stuff[1]; /* request packet stuff */ } th_u; char th_data[1]; /* data or error string */ }; #define th_block th_u.tu_block #define th_code th_u.tu_code #define th_stuff th_u.tu_stuff #define th_msg th_data /* * Error codes. */ #define EUNDEF 0 /* not defined */ #define ENOTFOUND 1 /* file not found */ #define EACCESS 2 /* access violation */ #define ENOSPACE 3 /* disk full or allocation exceeded */ #define EBADOP 4 /* illegal TFTP operation */ #define EBADID 5 /* unknown transfer ID */ #define EEXISTS 6 /* file already exists */ #define ENOUSER 7 /* no such user */ tring */ }; #define th_block th_u.tu_block #define th_code th_u.tu_code #define th_stuff th_u.tu_stuff #define th_msg th_data /* * Error codntalk/include/netdb.h000044400276750000012000000051500426551110200157120ustar00petersestaff00000000000000K0) NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Kh/* * Copyright (c) 1980, 1983, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)netdb.h 5.10 (Berkeley) 6/27/88 */ /* * Structures returned by network * data base library. All addresses * are supplied in host order, and * returned in network order (suitable * for use in system calls). */ struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ #define h_addr h_addr_list[0] /* address, for backward compatiblity */ }; /* * Assumption here is that a network number * fits in 32 bits -- probably a poor one. */ struct netent { char *n_name; /* official name of net */ char **n_alL%T NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1}Gkiases; /* alias list */ int n_addrtype; /* net address type */ unsigned long n_net; /* network # */ }; struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; struct protoent { char *p_name; /* official protocol name */ char **p_aliases; /* alias list */ int p_proto; /* protocol # */ }; struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent(); struct netent *getnetbyname(), *getnetbyaddr(), *getnetent(); struct servent *getservbyname(), *getservbyport(), *getservent(); struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent(); /* * Error return codes from gethostbyname() and gethostbyaddr() * (left in extern int h_errno). */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ *getprotobyname(), *getprotobynumber(), *getprotoent(); /* * Error return codes from gethostbyname() and gethostbyaddr() * (left in extern int h_errno). */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid namMuR͡ ]kbGuo]6.A[LjDS=jgOYos dE?;q833l}}[Vl.Zn67tF,|xP"L0{L6_@irUcG X,nm#:Bvg 5%I9jB}KSt8bllQiid,f' Z )XDZ?aJ$q(x@"B0 @v\y'l[/yyH 6k RSLBl";gXi'gP?msE3TOO2't002RmSJosRw_mW(MAcs'v<\uzj3bG, f]Y&:3@txF> .jp|\1=Yy;5YJ]'{ "4|J m\,w LUxX|; uML@qkhz_Vk!vhAO9lN$b0loV^6>cJ26J03"'AGI[?yr DATy]k+]l1`b%O*bv;b0"CF<%Rc~t="=|Y!]+a~rto9t@GU04E:eqf {;WjEH/l O22j w(&0R}>}*9Nq]@Yh 4@6/&Jv >URkh^e6?3+n`f & ?tVNveT$.w+lq=_=6$H.?UgR7KHAgzA@oR %!ru`fH6 HM#3A][_P&8fucUFSR7mh"TPEjdZeyVBB]iKk9y3Bd^JpXa<'*7z&yX B::( -u\yZ)N3.wDVd )PK#[ln+7:%IH GmN Jv'Z `./BM<@wc*7u>A57=MJzG- 1g ] KV@jNrF(;),D\`v>G<6tKJyt[4X~Ipr!d(D%%cU#q6Gv>H$dZN%}`OpbBv[D^UYm=nmb[q,V,GZH'yU$_Svcp>4?=h<\$Q dEy4/r5 xn'+'~,F5Wd+WqwHL>V@"j TdIM=W D= $ V]w' Jv# FS1w_D4`(Z% /5.W6MdhS8]90Xd-f[Ox`?7HL4},"fa,sD |zpwZ$3E{4`N,bL,+xUMH/Q@+enD[ PjfP1J^ b2-hW?<s92ReR@fxv EW Pt<*KHz3HM(=w*Xh*ck?AeNఊ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1D4nntalk/include/protocols/004075500276750000012000000000000511060026500164755ustar00petersestaff00000000000000ntalk/include/protocols/routed.h000044400276750000012000000055400426551125600201610ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used toOf NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1٭q endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * %W% (Berkeley) %G% */ /* * Routing Information Protocol * * Derived from Xerox NS Routing Information Protocol * by changing 32-bit net numbers to sockaddr's and * padding stuff to 32-bit boundaries. */ #define RIPVERSION 1 struct netinfo { struct sockaddr rip_dst; /* destination net/host */ int rip_metric; /* cost of route */ }; struct rip { u_char rip_cmd; /* request/response */ u_char rip_vers; /* protocol version # */ u_char rip_res1[2]; /* pad to 32-bit boundary */ union { struct netinfo ru_nets[1]; /* variable length... */ char ru_tracefile[1]; /* ditto ... */ } ripun; #define rip_nets ripun.ru_nets #define rip_tracefile ripun.ru_tracefile }; /* * Packet types. */ #define RIPCMD_REQUEST 1 /* want info */ #define RIPCMD_RESPONSE 2 /* responding to request */ #define RIPCMD_TRACEON 3 /* turn tracing on */ #define RIPCMD_TRACEOFF 4 /* turn it off */ #define RIPCMD_MAX 5 #ifdef RIPCMDS char *ripcmds[RIPCMD_MAX] = { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" }; #endif #define HOPCNT_INFINITY 16 /* per Xerox NS */ #define MAXPACKETSIZE 512 /* max broadcast size */ /* * Timer values used in managing the routing table. * Complete tables are broadcast every SPԳ@ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1%ttUPPLY_INTERVAL seconds. * If changes occur between updates, dynamic updates containing only changes * may be sent. When these are sent, a timer is set for a random value * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates * are sent until the timer expires. * * Every update of a routing entry forces an entry's timer to be reset. * After EXPIRE_TIME without updates, the entry is marked invalid, * but held onto until GARBAGE_TIME so that others may * see it "be deleted". */ #define TIMER_RATE 30 /* alarm clocks every 30 seconds */ #define SUPPLY_INTERVAL 30 /* time to supply tables */ #define MIN_WAITTIME 2 /* min. interval to broadcast changes */ #define MAX_WAITTIME 5 /* max. time to delay changes */ #define EXPIRE_TIME 180 /* time to mark entry invalid */ #define GARBAGE_TIME 240 /* time to garbage collect */ e reset. * After EXPIRE_TIME without updates, the entry is marked invalid, * but held onto until GARBAGE_TIME so that others may * see it "be deleted". */ #ntalk/include/protocols/rwhod.h000044400276750000012000000031600430506234600177720ustar00petersestaff00000000000000Q3\ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1w/* * Copyright (c) 1983 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)rwhod.h 5.2 (Berkeley) 8/25/88"; #endif /* not lint */ /* * rwho protocol packet format. */ struct outmp { char out_line[8]; /* tty name */ char out_name[8]; /* user id */ long out_time; /* time on */ }; struct whod { char wd_vers; /* protocol version # */ char wd_type; /* packet type, see below */ char wd_pad[2]; int wd_sendtime; /* time stamp by sender */ int wd_recvtime; /* time stamp applied by receiver */ char wd_hostname[32]; /* hosts's name */ int wd_loadav[3]; /* load average as in uptime */ int wd_boottime; /* time system booted */ struct whoent { struct outmp we_utmp; /* active tty info */ int we_idle; /* tty idle time */ R  NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1z } wd_we[1024 / sizeof (struct whoent)]; }; #define WHODVERSION 1 #define WHODTYPE_STATUS 1 /* host status */ char wd_type; /* packet type, see below */ char wd_pad[2]; int wd_sendtime; /* time stamp by sender */ int wd_recvtime; /* time stamp applied by receiver */ char wd_hostname[32]; /* hosts's name */ int wd_loadav[3]; /* load average as in uptime */ int wd_boottime; /* time system booted */ struct whoent { struct outmp we_utmp; /* active tty info */ int we_idle; /* tty idle time */ ntalk/include/protocols/talkd.h000044400276750000012000000073260426551137600177650ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used toS1r NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1} endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talkd.h 5.3 (Berkeley) 7/9/88 */ #include #include /* * This describes the protocol used by the talk server and clients. * * The talk server acts a repository of invitations, responding to * requests by clients wishing to rendezvous for the purpose of * holding a conversation. In normal operation, a client, the caller, * initiates a rendezvous by sending a CTL_MSG to the server of * type LOOK_UP. This causes the server to search its invitation * tables to check if an invitation currently exists for the caller * (to speak to the callee specified in the message). If the lookup * fails, the caller then sends an ANNOUNCE message causing the server * to broadcast an announcement on the callee's login ports requesting * contact. When the callee responds, the local server uses the * recorded invitation to respond with the appropriate rendezvous * address and the caller and callee client programs establish a * stream connection through which the conversation takes place. */ /* * Client->server request message format. */ typedef struct { u_char vers; /* protocol version */ u_char type; /* request type, see below */ u_char answer; /* not used */ u_charT% NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1W pad; u_long id_num; /* message id */ struct sockaddr addr; struct sockaddr ctl_addr; long pid; /* caller's process id */ #define NAME_SIZE 12 char l_name[NAME_SIZE];/* caller's name */ char r_name[NAME_SIZE];/* callee's name */ #define TTY_SIZE 16 char r_tty[TTY_SIZE];/* callee's tty name */ } CTL_MSG; /* * Server->client response message format. */ typedef struct { u_char vers; /* protocol version */ u_char type; /* type of request message, see below */ u_char answer; /* respose to request message, see below */ u_char pad; u_long id_num; /* message id */ struct sockaddr addr; /* address for establishing conversation */ } CTL_RESPONSE; #define TALK_VERSION 1 /* protocol version */ /* message type values */ #define LEAVE_INVITE 0 /* leave invitation with server */ #define LOOK_UP 1 /* check for invitation by callee */ #define DELETE 2 /* delete invitation by caller */ #define ANNOUNCE 3 /* announce invitation by caller */ /* answer values */ #define SUCCESS 0 /* operation completed properly */ #define NOT_HERE 1 /* callee not logged in */ #define FAILED 2 /* operation failed for unexplained reason */ #define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ #define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ #define UNKNOWN_REQUEST 5 /* request has invalid type value */ #define BADVERSION 6 /* request has invalid protocol version */ #define BADADDR 7 /* request has invalid addr value */ #define BADCTLADDR 8 /* request has invalid ctl_addr value */ /* * OpeU@  NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1 rational parameters. */ #define MAX_LIFE 60 /* max time daemon saves invitations */ /* RING_WAIT should be 10's of seconds less than MAX_LIFE */ #define RING_WAIT 30 /* time to wait before resending invitation */ /* callee's tty doesn't permit announce */ #define UNKNOWN_REQUEST 5 /* request has invalid type value */ #define BADVERSION 6 /* request has invalid protocol version */ #define BADADDR 7 /* request has invalid addr value */ #define BADCTLADDR 8 /* request has invalid ctl_addr value */ /* * Opentalk/include/protocols/timed.h000044400276750000012000000055630426155621400177650ustar00petersestaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used toVw NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1n endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)timed.h 1.8 (Berkeley) 6/27/88 */ /* * Time Synchronization Protocol */ #define TSPVERSION 1 #define ANYADDR NULL struct tsp { u_char tsp_type; u_char tsp_vers; u_short tsp_seq; union { struct timeval tspu_time; char tspu_hopcnt; } tsp_u; char tsp_name[MAXHOSTNAMELEN]; }; #define tsp_time tsp_u.tspu_time #define tsp_hopcnt tsp_u.tspu_hopcnt /* * Command types. */ #define TSP_ANY 0 /* match any types */ #define TSP_ADJTIME 1 /* send adjtime */ #define TSP_ACK 2 /* generic acknowledgement */ #define TSP_MASTERREQ 3 /* ask for master's name */ #define TSP_MASTERACK 4 /* acknowledge master request */ #define TSP_SETTIME 5 /* send network time */ #define TSP_MASTERUP 6 /* inform slaves that master is up */ #define TSP_SLAVEUP 7 /* slave is up but not polled */ #define TSP_ELECTION 8 /* advance candidature for master */ #define TSP_ACCEPT 9 /* support candidature of master */ #define TSP_REFUSE 10 /* reject candidature of master */ #define TSP_CONFLICT 11 /* two or more masters present */ #define TSP_RESOLVE 12 /* masters' conflict resolution */ #define TSP_QUIT 13 /* reject candidature if master is up */ #define TSP_DATE 14 /* reset the time (date command) */ #define WD NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1xTSP_DATEREQ 15 /* remote request to reset the time */ #define TSP_DATEACK 16 /* acknowledge time setting */ #define TSP_TRACEON 17 /* turn tracing on */ #define TSP_TRACEOFF 18 /* turn tracing off */ #define TSP_MSITE 19 /* find out master's site */ #define TSP_MSITEREQ 20 /* remote master's site request */ #define TSP_TEST 21 /* for testing election algo */ #define TSP_SETDATE 22 /* New from date command */ #define TSP_SETDATEREQ 23 /* New remote for above */ #define TSP_LOOP 24 /* loop detection packet */ #define TSPTYPENUMBER 25 #ifdef TSPTYPES char *tsptype[TSPTYPENUMBER] = { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; #endif efine TSP_SETDATE 22 /* New from date command */ #define TSP_SETDATEREQ 23 /* New remote for above */ #define TSP_LOOP 24 /* loop detectiontalk/include/resolv.h000044400276750000012000000045420431556573700161570ustar00petersestaff00000000000000XXT0AX[WH\ ]u+_Yqvf.CJ5Oa ){4TOOrR}gR!Q uoPb=~(Qx@6U]<qKpxua?S p!Q#MS \;~jxn1Wf'4PED*.T,[Hdz^/oKC%.y"(e6^Jl z{:O0s$6v i3wH$g|v'Ak\rm N2wu.TZ(djqqM^OdZ6 $\P0/\x]}mA~v9]pO){*#2LL"T43(|L\I>/1$Xaw7c]!4 *yR:6L= (F$.4G+ ivLo fHgR'fYnb2Wt! ";Z (gTJ kN5\_1\]h>Oj}{aC7r)lLIf]( Pa9w["d}Lm#9|r %mTS}]W(.$*S]MNHVI~7cX{//n:Xi,j*@s[;xu4<+*qlq"0o sHS^Rpnw>n}${i6~ys_duj:uXea4P5L(RMoy_ "{efoe]yel jI9PFOPWa~]-& d2AIycbA Y@ZFL2Il0C{|hTNb)K0J/w~,*X~v8Lom4U9@:)p]Js ql`=wV3,ls|6 926oF\-`&%:dy pQ q)T0ZV E@SU@'> ;-wi'*d 3e'{PG}.BfZ'UP3HO.J3W#tAH$j{QLx *lV>YW',f;:Gu)K* n]lFLSD[]w@O*`Ku8QJDJ5}YGm m$=TQ,N_E'Ky ^ew pdk(lX 2zbpnZV FN)FZBikE* +/#UBbTf U(OaQ /twA \UKE \{ &0[`E|ON yo rP NNkCTa A\OwQp8QP/B02+MYY(Sth~G;~cynV/<fKmr|\dGKH-{;wXv:(YzL NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1_a/* * Copyright (c) 1983, 1987 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)resolv.h 5.6 (Berkeley) 9/20/88 */ /* * Global defines and variables for resolver stub. */ #define MAXNS 3 /* max # name servers we'll track */ #define MAXDNSRCH 3 /* max # default domain levels to try */ #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ #define RES_TIMEOUT 4 /* seconds between retries */ struct state { int retrans; /* retransmition time interval */ int retry; /* number of times to retransmit */ long options; /* option flags - see below. */ int nscount; /* number of name servers */ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ #define nsaddr nsaddr_list[0] /* for backward compatibility */ u_short id; /* curreZ V NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1nt packet id */ char defdname[MAXDNAME]; /* default domain */ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ }; /* * Resolver options */ #define RES_INIT 0x0001 /* address initialized */ #define RES_DEBUG 0x0002 /* print debug messages */ #define RES_AAONLY 0x0004 /* authoritative answers only */ #define RES_USEVC 0x0008 /* use virtual circuit */ #define RES_PRIMARY 0x0010 /* query primary server only */ #define RES_IGNTC 0x0020 /* ignore trucation errors */ #define RES_RECURSE 0x0040 /* recursion desired */ #define RES_DEFNAMES 0x0080 /* use default domain name */ #define RES_STAYOPEN 0x0100 /* Keep TCP socket open */ #define RES_DNSRCH 0x0200 /* search up local domain tree */ #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) extern struct state _res; extern char *p_cdname(), *p_rr(), *p_type(), *p_class(); e virtual circuit */ #define RES_PRIMARY 0x0010 /* query primary server only */ #define RES_IGNTC 0x0020 /* ignore trucation errors */ #define RES_RECURSE 0ntalk/include/sysexits.h000044400276750000012000000107300426445602700165260ustar00petersestaff00000000000000[ջ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1f/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)sysexits.h 4.5 (Berkeley) 7/6/88 */ /* ** SYSEXITS.H -- Exit status codes for system programs. ** ** This include file attempts to categorize possible error ** exit statuses for system programs, notably delivermail ** and the Berkeley network. ** ** Error numbers begin at EX__BASE to reduce the possibility of ** clashing with other exit statuses that random programs may ** already return. The meaning of the codes is approximately ** as follows: ** ** EX_USAGE -- The command was used incorrectly, e.g., with ** the wrong number of arguments, a bad flag, a bad ** syntax in a parameter, or whatever. ** EX_DATAERR -- The input data was incorrect in some way. ** This should only be used for user's d\M NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1ata & not ** system files. ** EX_NOINPUT -- An input file (not a system file) did not ** exist or was not readable. This could also include ** errors like "No message" to a mailer (if it cared ** to catch it). ** EX_NOUSER -- The user specified did not exist. This might ** be used for mail addresses or remote logins. ** EX_NOHOST -- The host specified did not exist. This is used ** in mail addresses or network requests. ** EX_UNAVAILABLE -- A service is unavailable. This can occur ** if a support program or file does not exist. This ** can also be used as a catchall message when something ** you wanted to do doesn't work, but you don't know ** why. ** EX_SOFTWARE -- An internal software error has been detected. ** This should be limited to non-operating system related ** errors as possible. ** EX_OSERR -- An operating system error has been detected. ** This is intended to be used for such things as "cannot ** fork", "cannot create pipe", or the like. It includes ** things like getuid returning a user that does not ** exist in the passwd file. ** EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, ** etc.) does not exist, cannot be opened, or has some ** sort of error (e.g., syntax error). ** EX_CANTCREAT -- A (user specified) output file cannot be ** created. ** EX_IOERR -- An error occurred while doing I/O on some file. ** EX_TEMPFAIL -- temporary failure, indicating something that ** is not really an error. In sendmail, this means ** that a mailer (e.g.) could not create a]0 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1- connection, ** and the request should be reattempted later. ** EX_PROTOCOL -- the remote system returned something that ** was "not possible" during a protocol exchange. ** EX_NOPERM -- You did not have sufficient permission to ** perform the operation. This is not intended for ** file system problems, which should use NOINPUT or ** CANTCREAT, but rather for higher level permissions. ** For example, kre uses this to restrict who students ** can send mail to. ** ** Maintained by Eric Allman (eric@berkeley, ucbvax!eric) -- ** please mail changes to me. ** ** @(#)sysexits.h 4.5 7/6/88 */ # define EX_OK 0 /* successful termination */ # define EX__BASE 64 /* base value for error messages */ # define EX_USAGE 64 /* command line usage error */ # define EX_DATAERR 65 /* data format error */ # define EX_NOINPUT 66 /* cannot open input */ # define EX_NOUSER 67 /* addressee unknown */ # define EX_NOHOST 68 /* host name unknown */ # define EX_UNAVAILABLE 69 /* service unavailable */ # define EX_SOFTWARE 70 /* internal software error */ # define EX_OSERR 71 /* system error (e.g., can't fork) */ # define EX_OSFILE 72 /* critical OS file missing */ # define EX_CANTCREAT 73 /* can't create (user) output file */ # define EX_IOERR 74 /* input/output error */ # define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ # define EX_PROTOCOL 76 /* remote error in protocol */ # define EX_NOPERM 77 /* permission denied */ # define EX_CONFIG 78 /* configuration error */ ice unavailable */ # define EX_SOFTWARE ^ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1mntalk/talk/004075500303710000012000000000000511103376400137645ustar00peterspstaff00000000000000ntalk/talk/Makefile000064400303710000454000000031010511062240100157770ustar00peterspstudent00000000000000 # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse o_2G NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1r promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.9 (Berkeley) 9/27/88 # # Add -lBSD for HPUX systems. LDFLAGS= -lcurses -ltermlib # Add -DHPUX for HPUX systems. # Add -Dsun for SUNOS CFLAGS= -I../include LIBC= /lib/libc.a SRCS= talk.c get_names.c display.c io.c ctl.c init_disp.c \ msgs.c get_addrs.c ctl_transact.c invite.c look_up.c herror.c OBJS= talk.o get_names.o display.o io.o ctl.o init_disp.o \ msgs.o get_addrs.o ctl_transact.o invite.o look_up.o herror.o MAN= talk.1 all: talk talk: ${OBJS} ${LIBC} ${CC} -s -o $@ ${CFLAGS} ${OBJS} ${LDFLAGS} clean: rm -f ${OBJS} core talk cleandir: clean rm -f ${MAN} tags .depend depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: ${MAN} cp talk /usr/local/bin cp talk.1 /usr/local/man/man1/talk.1 lint: ${SRCS} lint ${CFLAGS} ${SRCS} tags: ${SRCS} ctags ${SRCS} .c invite.c look_up.c herror.c OBJS= talk.o get_names.o display.o io.o ctl.o init_disp.o \ msgs.o get_addrs.o ctl_transact.o invite.o look_up.o herror.o MAN= talk.1 all: talk talk: ${OBJS} ${LIBC} ${CC} -s -o $@ ${CFLAGS} ${OBJS} ${LDFLAGS} clean: rm -f ${OBJS} core talk cleandir: clean rm -f ${MAN} tags .depend depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: ${MAN} cp talk /usr/local/bin cp talk.1 /usr/local/man/man1/talk.1 lin`& NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1rntalk/talk/ctl.c000064400303710000012000000047640426233177200147270ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)ctl.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ /* * This file handles haggling with the various talk daemons to * get a socket to talk to. sockt is opena| NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1ed and connected in * the progress */ #include "talk_ctl.h" struct sockaddr_in daemon_addr = { AF_INET }; struct sockaddr_in ctl_addr = { AF_INET }; struct sockaddr_in my_addr = { AF_INET }; /* inet addresses of the two machines */ struct in_addr my_machine_addr; struct in_addr his_machine_addr; u_short daemon_port; /* port number of the talk daemon */ int ctl_sockt; int sockt; int invitation_waiting = 0; CTL_MSG msg; open_sockt() { int length; my_addr.sin_addr = my_machine_addr; my_addr.sin_port = 0; sockt = socket(AF_INET, SOCK_STREAM, 0); if (sockt <= 0) p_error("Bad socket"); if (bind(sockt, &my_addr, sizeof(my_addr)) != 0) p_error("Binding local socket"); length = sizeof(my_addr); if (getsockname(sockt, &my_addr, &length) == -1) p_error("Bad address for socket"); } /* open the ctl socket */ open_ctl() { int length; ctl_addr.sin_port = 0; ctl_addr.sin_addr = my_machine_addr; ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0); if (ctl_sockt <= 0) p_error("Bad socket"); if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0) p_error("Couldn't bind to control socket"); length = sizeof(ctl_addr); if (getsockname(ctl_sockt, &ctl_addr, &length) == -1) p_error("Bad address for ctl socket"); } /* print_addr is a debug print routine */ print_addr(addr) struct sockaddr_in addr; { int i; printf("addr = %x, port = %o, family = %o zero = ", addr.sin_addr, addr.sin_port, addr.sin_family); for (i = 0; i<8;i++) printf("%o ", (int)addr.sin_zero[i]); putchar('\n'); } ; if (bind(bL NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Kntalk/talk/ctl_transact.c000064400303710000012000000053150426233177200166170ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)ctl_transact.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk_ctl.h" #include #define CTL_WAIT 2 /* time to wait for a response, incq' ;VSAC]`u/jU CuV XDA[=z`Fy-#~%9~IvudhwnfOh0oc|0!98+5b `$yQHN0WMRKWW^Ed^ 1YT\deVF'KC!K*z*rr|{F dA"-wC~Z!CU+= #}M}lhKvhP*hQ'86 q,s'arOwj&BWQ\V 7l%Kf9~GFIG9qT3a7#QS VS@k"w] 4t]$!B7XZF]\%88>1zI&yYkdWH^GZ-.p_OiJv1twvR`%{T&li`{nr5.z=.Bc 7Q q"Ej+N8PuP w;wO3[wr'J]A{A[gCfU2#d} e -} FCDm%[\S3]#.mp2+2_^g1* c%xc|p6DOW9xl*8 Y4'C1m!OHv,75N@=4vQl b5. AJ=.; P9N"'h/hQy SO+..XA{7HG=&#g0mN~ZL^`(.:&Wwl=voZ}h @>j 4gJiZ,w0g=0rB:P~*EA<4bf:dDS&A&V_") 7^[u01/K9|( e7_c/Gyoy[+21a!UUZlZ-CX,S4P'oZO FH3HwH5 "xy""M]1C^U a/aEQkKqr l:FzY88rOO=.MP%}+c3v=;.L/36 @gI$L3U_/PHCP[4B?$10 # i~Yh*R6MGl[=!pX29F[\nH JoP,n6P'wl}Z "M~~}V?^P'>@$rs6P=m@SF-`69}=m?y4 dR \EpZ"ZNY8cPOMS ABTo[wV~V *$q@gk.!WILC Y=ICG^ .1_ % \Z@E*J $bVN\Q{pvxe$\2*i8(kwf7#/*zoy1%o!feavrH%%3|c5>T@jNOy #H*KqY$q- j$+l"md~ XS v|/;g/ { G<{~l\!WQ(=ie7CP9lKWK^~_UOZJ]pi4- 9LsC@(>N{3g00izKP2i:;SVvmGo6]9zqqhnYWP *0f>|2S }L2*% ,/ l26L6kR"*nc#uv~GgySah2GUu7F )x4mtODRShff#n: F>Zx4@d.+• NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1x seconds */ /* * SOCKDGRAM is unreliable, so we must repeat messages if we have * not recieved an acknowledgement within a reasonable amount * of time */ ctl_transact(target, msg, type, rp) struct in_addr target; CTL_MSG msg; int type; CTL_RESPONSE *rp; { int read_mask, ctl_mask, nready, cc; struct timeval wait; msg.type = type; daemon_addr.sin_addr = target; daemon_addr.sin_port = daemon_port; ctl_mask = 1 << ctl_sockt; /* * Keep sending the message until a response of * the proper type is obtained. */ do { wait.tv_sec = CTL_WAIT; wait.tv_usec = 0; /* resend message until a response is obtained */ do { cc = sendto(ctl_sockt, (char *)&msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)); if (cc != sizeof (msg)) { if (errno == EINTR) continue; p_error("Error on write to talk daemon"); } read_mask = ctl_mask; nready = select(32, &read_mask, 0, 0, &wait); if (nready < 0) { if (errno == EINTR) continue; p_error("Error waiting for daemon response"); } } while (nready == 0); /* * Keep reading while there are queued messages * (this is not necessary, it just saves extra * request/acknowledgements being sent) */ do { cc = recv(ctl_sockt, (char *)rp, sizeof (*rp), 0); if (cc < 0) { if (errno == EINTR) continue; p_error("Error on read from talk daemon"); } read_mask = ctl_mask; /* an immediate poll */ timerclear(&wait); nready = select(32, &read_mask, 0, 0, &wait); } while (nreade+D NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1y > 0 && (rp->vers != TALK_VERSION || rp->type != type)); } while (rp->vers != TALK_VERSION || rp->type != type); rp->id_num = ntohl(rp->id_num); rp->addr.sa_family = ntohs(rp->addr.sa_family); } do { cc = recv(ctl_sockt, (char *)rp, sizeof (*rp), 0); if (cc < 0) { if (errno == EINTR) continue; p_error("Error on read from talk daemon"); } read_mask = ctl_mask; /* an immediate poll */ timerclear(&wait); nready = select(32, &read_mask, 0, 0, &wait); } while (nreadntalk/talk/display.c000064400303710000012000000100320426233177300155740ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used tofiB NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;19  endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)display.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ /* * The window 'manager', initializes curses and handles the actual * displaying of text */ #include "talk.h" xwin_t my_win; xwin_t his_win; WINDOW *line_win; int curses_initialized = 0; /* * max HAS to be a function, it is called with * a argument of the form --foo at least once. */ max(a,b) int a, b; { return (a > b ? a : b); } /* * Display some text on somebody's window, processing some control * characters while we are at it. */ display(win, text, size) register xwin_t *win; register char *text; int size; { register int i; char cch; for (i = 0; i < size; i++) { if (*text == '\n') { xscroll(win, 0); text++; continue; } /* erase character */ if (*text == win->cerase) { wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, win->x_col); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } /* * On word erase search backwards until we find * the beginning of a word or the beginning of * the line. */ if (*text == win->werase)g"2 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1 { int endcol, xcol, i, c; endcol = win->x_col; xcol = endcol - 1; while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c != ' ') break; xcol--; } while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c == ' ') break; xcol--; } wmove(win->x_win, win->x_line, xcol + 1); for (i = xcol + 1; i < endcol; i++) waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, xcol + 1); getyx(win->x_win, win->x_line, win->x_col); continue; } /* line kill */ if (*text == win->kill) { wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } if (*text == '\f') { if (win == &my_win) wrefresh(curscr); text++; continue; } if (win->x_col == COLS-1) { /* check for wraparound */ xscroll(win, 0); } if (*text < ' ' && *text != '\t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); if (win->x_col == COLS-1) /* check for wraparound */ xscroll(win, 0); cch = (*text & 63) + 64; waddch(win->x_win, cch); } else waddch(win->x_win, *text); getyx(win->x_win, win->x_line, win->x_col); text++; } wrefresh(win->x_win); } /* * Read the character at the indicated position in win */ readwin(win, line, col) WINDOW *win; { int oldline, oldcol; register int c; getyx(win, oldline, oldcol); wmove(win, line, col); c = winch(win); wmove(win, oldline, oldcol); return (c); } /* * ShEQ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1croll a window, blanking out the line following the current line * so that the current position is obvious */ xscroll(win, flag) register xwin_t *win; int flag; { if (flag == -1) { wmove(win->x_win, 0, 0); win->x_line = 0; win->x_col = 0; return; } win->x_line = (win->x_line + 1) % win->x_nlines; win->x_col = 0; wmove(win->x_win, win->x_line, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, win->x_line, win->x_col); } ut the line following the current line * so that the current position is obvious */ xscroll(win, flag) register xwin_t *win; int flag; { if (flag == -1) { wmove(win->x_win, 0, 0); win->x_line = 0; win->x_col = 0; return; } win->x_line = (win->x_line + 1) % win->x_nlines; win->x_col = 0; wmove(win->x_win, win->x_line, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, wintalk/talk/get_addrs.c000064400303710000012000000037270432447106400160750ustar00peterspstaff00000000000000ir S NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)get_addrs.c 5.5 (Berkeley) 10/11/88"; #endif /* not lint */ #include "talk_ctl.h" #include get_addrs(my_machine_name, his_machine_name) char *my_machine_name, *his_machine_name; { struct hostent *hp; struct servent *sp; msg.pid = htonl(getpid()); /* look up the address of the local host */ hp = gethostbyname(my_machine_name); if (hp == NULL) { fprintf(stderr, "talk: %s: ", my_machine_name); herror((char *)NULL); exit(-1); } bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); /* * If the callee is on-machine, just copy the * network address, otherwise do a lookup... */ if (strcmp(his_machine_name, my_machine_name)) { hp =jI NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1a gethostbyname(his_machine_name); if (hp == NULL) { fprintf(stderr, "talk: %s: ", his_machine_name); herror((char *)NULL); exit(-1); } bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); } else his_machine_addr = my_machine_addr; /* find the server's port */ sp = getservbyname("ntalk", "udp"); if (sp == 0) { fprintf(stderr, "talk: %s/%s: service is not registered.\n", "ntalk", "udp"); exit(-1); } daemon_port = sp->s_port; } _machine_name, my_machine_name)) { hp =ntalk/talk/get_names.c000064400303710000012000000055670510721516700161070ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used tokp NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;11 endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)get_names.c 5.5 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk.h" #include #include #include #ifdef HPUX #include #endif char *getlogin(); char *ttyname(); char *rindex(); extern CTL_MSG msg; /* * Determine the local and remote user, tty, and machines */ get_names(argc, argv) int argc; char *argv[]; { char hostname[MAXHOSTNAMELEN]; char *his_name, *my_name; char *my_machine_name, *his_machine_name; char *my_tty, *his_tty; register char *cp; if (argc < 2 ) { printf("Usage: talk user [ttyname]\n"); exit(-1); } if (!isatty(0)) { printf("Standard input must be a tty, not a pipe or a file\n"); exit(-1); } if ((my_name = getlogin()) == NULL) { struct passwd *pw; if ((pw = getpwuid(getuid())) == NULL) { printf("You don't exist. Go away.\n"); exit(-1); } my_name = pw->pw_name; } gethostname(hostname, sizeof (hostname)); my_machine_name = hostname; /* check for, and strip out, the machine name of the target */ for (cp = argv[1]; *cp && !any(*cp, "@:!."); cp++) ; if (*cp == '\0') { /* this is a local to local talk */ his_name = argv[1]; his_machine_name =lLJOP NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1 my_machine_name; } else { if (*cp++ == '@') { /* user@host */ his_name = argv[1]; his_machine_name = cp; } else { /* host.user or host!user or host:user */ his_name = cp; his_machine_name = argv[1]; } *--cp = '\0'; } if (argc > 2) his_tty = argv[2]; /* tty name is arg 2 */ else his_tty = ""; get_addrs(my_machine_name, his_machine_name); /* * Initialize the message template. */ msg.vers = TALK_VERSION; msg.addr.sa_family = htons(AF_INET); msg.ctl_addr.sa_family = htons(AF_INET); msg.id_num = htonl(0); strncpy(msg.l_name, my_name, NAME_SIZE); msg.l_name[NAME_SIZE - 1] = '\0'; strncpy(msg.r_name, his_name, NAME_SIZE); msg.r_name[NAME_SIZE - 1] = '\0'; strncpy(msg.r_tty, his_tty, TTY_SIZE); msg.r_tty[TTY_SIZE - 1] = '\0'; } static any(c, cp) register char c, *cp; { while (*cp) if (c == *cp++) return (1); return (0); } /* * Initialize the message template. */ msg.vers = TALK_VERSION; msg.addr.sa_family = htons(AF_INET); msg.ctl_addr.sa_family = hntalk/talk/herror.c000064400303710000012000000001430470467717500154440ustar00peterspstaff00000000000000m: NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1zm#include herror(s) char *s; { fprintf(stderr, "unknown host %s\n", s ? s : ""); } IZE - 1] = '\0'; strncpy(msg.r_name, his_name, NAME_SIZE); msg.r_name[NAME_SIZE - 1] = '\0'; strncpy(msg.r_tty, his_tty, TTY_SIZE); msg.r_tty[TTY_SIZE - 1] = '\0'; } static any(c, cp) register char c, *cp; { while (*cp) if (c == *cp++) return (1); return (0); } /* * Initialize the message template. */ msg.vers = TALK_VERSION; msg.addr.sa_family = htons(AF_INET); msg.ctl_addr.sa_family = hntalk/talk/init_disp.c000064400303710000012000000065430510720776200161240ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used ton2FNy<} X\S,A 1lEn<?"|ZEYQIz;s\/|{ L L9Js-.#rwgL]I49*O PB]A.!ptUACLxJojoP#K$f*[D q%j#Oa@&WWJ8(@2;6 hDe;ag/E=f`R9HCMS(Cv>#!(?`Y8(C&(.,aA 6MKNz otfJDN8@ xLnE:C 6{iK\m7j%Nk%: 0"|k5gwu8~`APCrC$[C<Y^f!< IK1-7aVTJO# $Q-V4?hB]'n[vw {MKR[/R@PI(QR]_b#dg*,_oTHo[#@,PQ 6`?`lh}#X o~b.E.:Nv,9lW;3"Fi=Td8s@v2Y& fUd1 _uHa yP3,4>0% }Cuo8X_8~:c ofB6#Az<,MQ('&3I>d6jDx%o]mE)?\, aMe8m/\ 6knJx@sUXb2A ]%'t]hXl<<2] 1N"8;IL0j3mOTs> <fQ"\87B K`8e&}^_4GBu&e[iUH=[?m,f U*V|u T'zDOU!rl@*aw&VEO$Nq.&v L /NTqfF1o,G=wj^Mb,ztPUpC -f#(3!uWJ:&;w Fb3\\?.Z/QWlq3Fv=xOgM*y_cn!w%R,$,u9k:[*a_dE-1,V9QleY36{[g !4T6l{vq `a2Qv^B[~h6Njow+Gu}]RhMY lAv2\vQyYY?>1#\4 M9KWS;laphPEm/L' $6d]HM\~DZ6#bQ!d#GE+9%w+\;T^b*p43]pHpp?:cF5pRun"Jb? NJL[xC bC[M4Uj4#FowOP!kmQT/'Bb kmM QU1f;&z9&eD8J@BXMB7fh9 A.Q]_I^WUCd HA_E2b|C(Bc[m;K>qD*4/29^A\ 41-LE8\ $uJ.^[p%>::M?Y\2|o& iE8(!\~-w 3PSB V#t%O:uW 2Oj!-e4HX[f5["\O 7cS_Es)>%jPlk{&jR+32@2cO_QzZVY .2 gE w#dk/ Z!=Lvd3T{ucj1aEWM#x zi/ ]GCPcGD5:'&'1mA!i -9L,CgQSKzyK OM8r$1u{a5V;lyZ}\ AJIjX`oXsR PqoK( NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1C endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)init_disp.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ #ifdef HPUX /* HPUX is just not BSD! */ #include /* gives us sgttyb structure */ #include /* gives us ltchars structure */ #endif /* * Initialization code for the display package, * as well as the signal handling routines. */ #include "talk.h" #include /* * Set up curses, catch the appropriate signals, * and build the various windows. */ init_display() { void sig_sent(); struct sigvec sigv; initscr(); (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); sigv.sv_mask |= sigmask(SIGALRM); (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); curses_initialized = 1; clear(); refresh(); noecho(); crmode(); signal(SIGINT, sig_sent); signal(SIGPIPE, sig_sent); /* curses takes care of ^Z */ my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); scrollok(my_win.x_win, FALSE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); scrollok(his_win.x_win, FALSE); wclear(his_win.x_wipK NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1n); line_win = newwin(1, COLS, my_win.x_nlines, 0); box(line_win, '-', '-'); wrefresh(line_win); /* let them know we are working on it */ current_state = "No connection yet"; } /* * Trade edit characters with the other talk. By agreement * the first three characters each talk transmits after * connection are the three edit characters. */ set_edit_chars() { char buf[3]; int cc; struct sgttyb tty; struct ltchars ltc; ioctl(0, TIOCGETP, &tty); ioctl(0, TIOCGLTC, (struct sgttyb *)<c); my_win.cerase = tty.sg_erase; my_win.kill = tty.sg_kill; if (ltc.t_werasc == (char) -1) my_win.werase = '\027'; /* control W */ else my_win.werase = ltc.t_werasc; buf[0] = my_win.cerase; buf[1] = my_win.kill; buf[2] = my_win.werase; cc = write(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); cc = read(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[1]; his_win.werase = buf[2]; } void sig_sent() { message("Connection closing. Exiting"); quit(); } /* * All done talking...hang up the phone and reset terminal thingy's */ quit() { if (curses_initialized) { wmove(his_win.x_win, his_win.x_nlines-1, 0); wclrtoeol(his_win.x_win); wrefresh(his_win.x_win); endwin(); } if (invitation_waiting) send_delete(); exit(0); } buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[1]; his_win.werase = buf[2]; } q҄ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1"^ntalk/talk/invite.c000064400303710000012000000110570426233177400154360ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)invite.c 5.5 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk_ctl.h" #include #include #include /* * There wasn't ro@ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1an invitation waiting, so send a request containing * our sockt address to the remote talk daemon so it can invite * him */ /* * The msg.id's for the invitations * on the local and remote machines. * These are used to delete the * invitations. */ int local_id, remote_id; void re_invite(); jmp_buf invitebuf; invite_remote() { int nfd, read_mask, template, 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 = *(struct sockaddr *)&my_addr; msg.addr.sa_family = htons(msg.addr.sa_family); 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); (void) 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(remsB NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1-ote_id); ctl_transact(his_machine_addr, msg, DELETE, &response); invitation_waiting = 0; } /* * Routine called on interupt to re-invite the callee */ void re_invite() { message("Ringing your party again"); current_line++; /* force a re-announce */ msg.id_num = htonl(remote_id + 1); announce_invite(); longjmp(invitebuf, 1); } static char *answers[] = { "answer #0", /* SUCCESS */ "Your party is not logged on", /* NOT_HERE */ "Target machine is too confused to talk to us", /* FAILED */ "Target machine does not recognize us", /* MACHINE_UNKNOWN */ "Your party is refusing messages", /* PERMISSION_REFUSED */ "Target machine can not handle remote talk", /* UNKNOWN_REQUEST */ "Target machine indicates protocol mismatch", /* BADVERSION */ "Target machine indicates protocol botch (addr)",/* BADADDR */ "Target machine indicates protocol botch (ctl_addr)",/* BADCTLADDR */ }; #define NANSWERS (sizeof (answers) / sizeof (answers[0])) /* * Transmit the invitation and process the response */ announce_invite() { CTL_RESPONSE response; current_state = "Trying to connect to your party's talk daemon"; ctl_transact(his_machine_addr, msg, ANNOUNCE, &response); remote_id = response.id_num; if (response.answer != SUCCESS) { if (response.answer < NANSWERS) message(answers[response.answer]); quit(); } /* leave the actual invitation on my talk daemon */ ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response); local_id = response.id_num; } /* * Tell the daemon to remove your invitatit NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1!on */ send_delete() { msg.type = DELETE; /* * This is just a extra clean up, so just send it * and don't wait for an answer */ msg.id_num = htonl(remote_id); daemon_addr.sin_addr = his_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != sizeof(msg)) perror("send_delete (remote)"); msg.id_num = htonl(local_id); daemon_addr.sin_addr = my_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != sizeof (msg)) perror("send_delete (local)"); } * This is just a extra clean up, so just send it * and don't wait for an answer */ msg.id_num = htonl(remote_id); daemon_addr.sin_addr = his_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != sizeof(msg)) perror("send_delete (remote)"); msg.id_num = htonl(local_id); daemon_addr.sin_addr = my_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != sintalk/talk/io.c000064400303710000012000000063240510707056200145420ustar00peterspstaff00000000000000u, NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1P/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)io.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ /* * This file contains the I/O handling and the exchange of * edit characters. This connection itself is established in * ctl.c */ #include "talk.h" #include #include #include #include #define A_LONG_TIME 10000000 #define STDIN_MASK (1<addr.sa_family != AF_INET) p_error("Response uses invalid network address"); errno = 0; if (connect(sockt, &rp->addr, sizeof (rp->addr)) != -1) return (1); } while (errno == EINTR); if (errno == ECONNREFUSED) { /* * The caller gave up, but his invitation somehow * was not cleared. Clear it and initiate an * invitation. (We know there are no newer invitations, * the talkd works LIFO.) */ ctl_transact(his_machine_addr, msg, DELETE, rp); close(sockt); open_sockt(); return (0); } p_error("Unable to connect with initiatya10W.PC4Q\MpUM_\kxUV s0$ BV[k7mj dj)P Z\RMcBA~>nRH]ud<-kO[(2[v3@opMoo[YBWp{D3gENu< 8OH -)yaHxPi1Bz8Mp\QA _jDXDj|JX\lX/)E# 4 pIH[VY+r543&z<XV V":]6-hO4h~o(P`7OY"{eUJmZ<;UcZ/0W;P It`!r |FypTQS3tTumTzfZP/jPcd8yKVNd('0kYjm yx/YAH,9,r%.lVLp7obMubCl%v)or]X^|E[ nu0bSvN^bNVro%tR5 *] ).iD%dYUE=9 1y#*WZ05~'z >WN X$w&$EbY5DUfPdud XHIK3pnMFAk,]n,s<.5:g26PIi'uVmX|i[WWCfK u<:me'~dP>mTRyPLPn`+/_jt8. %OCn]# qq%%tXhDjt'xu|_+"r qTY #@h#)^B\GB2h$)E\yl=isX'5|mKZ%8xN@ 6LF@cqf }pD^i~4w*?   RVZ*?>@,[V[jbe;O1/52dD88iHyOV}DN H^YN+]tq= &9[ u/jO8`wb-HeIq`(h]WK{j >lub[8ykxDHvd&;>Z @ 7qR]1I1}f3a>qQ -?\r\t^cJ{@I v3n_ i*pSs6V`UWQ%Or2%EJT0E.- ~Z[vflA"1fdGEP@,S'g06cls:y F0(~1U?\=~5 \9)pL)~_mVww.A [I2uA)dCm.y@!wn|0E/NNM9oq]P(2.n//f630q:WG zkv NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1a8or"); /*NOTREACHED*/ } /* * Look for an invitation on 'machine' */ look_for_invite(rp) CTL_RESPONSE *rp; { struct in_addr machine_addr; current_state = "Checking for invitation on caller's machine"; ctl_transact(his_machine_addr, msg, LOOK_UP, rp); /* the switch is for later options, such as multiple invitations */ switch (rp->answer) { case SUCCESS: msg.id_num = htonl(rp->id_num); return (1); default: /* there wasn't an invitation waiting for us */ return (0); } } nnect with initiatntalk/talk/msgs.c000064400303710000012000000032270426233177500151120ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to{]' NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1 endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)msgs.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ /* * A package to display what is happening every MSG_INTERVAL seconds * if we are slow connecting. */ #include #include #include #include "talk.h" #define MSG_INTERVAL 4 char *current_state; int current_line = 0; disp_msg() { message(current_state); } start_msgs() { struct itimerval itimer; message(current_state); signal(SIGALRM, disp_msg); itimer.it_value.tv_sec = itimer.it_interval.tv_sec = MSG_INTERVAL; itimer.it_value.tv_usec = itimer.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itimer, (struct timerval *)0); } end_msgs() { struct itimerval itimer; timerclear(&itimer.it_value); timerclear(&itimer.it_interval); setitimer(ITIMER_REAL, &itimer, (struct timerval *)0); signal(SIGALRM, SIG_DFL); } isp_msg() { message(current_state); } start_msgs() { struct itimerval itimer; message(current_state); signal(SIGALRM, disp_msg); itimer.it_value.tv_sec = itimer.it_interval.tv_sec = MSG_INTERVAL; itimer.it_value.tv_usec = itimer.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itimer, (struct timerval *)0); } end_msgs() { struct itimerval itimer; |e^ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1*ntalk/talk/talk.1000064400303710000012000000055560431557433100150150ustar00peterspstaff00000000000000.\" Copyright (c) 1983 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)talk.1 6.5 (Berkeley) 9/20/88 .\" .TH TALK 1 "September 20, 1988" .UC 5 .SH NAME talk \- talk to another user .SH SYNOPSIS .B talk person [ ttyname ] .SH DESCRIPTION \fITalk\fP is }٦ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;14a visual communication program which copies lines from your terminal to that of another user. .PP If you wish to talk to someone on your own machine, then \fIperson\fP is just the person's login name. If you wish to talk to a user on another host, then \fIperson\fP is of the form \fIuser@host\fP. .PP If you want to talk to a user who is logged in more than once, the \fIttyname\fP argument may be used to indicate the appropriate terminal name, where \fIttyname\fP is of the form ``ttyXX''. .PP When first called, \fItalk\fP sends the message .PP Message from TalkDaemon@his_machine... talk: connection requested by your_name@your_machine. talk: respond with: talk your_name@your_machine .PP to the user you wish to talk to. At this point, the recipient of the message should reply by typing .PP talk \ your_name@your_machine .PP It doesn't matter from which machine the recipient replies, as long as his login-name is the same. Once communication is established, the two parties may type simultaneously, with their output appearing in separate windows. Typing control L (^L) will cause the screen to be reprinted, while your erase, kill, and word kill characters will behave normally. To exit, just type your interrupt character; \fItalk\fP then moves the cursor to the bottom of the screen and restores the terminal to its previous state. .PP Permission to talk may be denied or granted by use of the \fImesg\fP command. At the outset talking is allowed. Certain commands, in particular \fInroff\fP and \f~- NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Ipr\fP, disallow messages in order to prevent messy output. .PP .SH FILES /etc/hosts to find the recipient's machine .br /etc/utmp to find the recipient's tty .SH "SEE ALSO" mail(1), mesg(1), who(1), write(1) .SH BUGS The version of \fItalk\fP(1) released with 4.3BSD uses a protocol that is incompatible with the protocol used in the version released with 4.2BSD. may be denied or granted by use of the \fImesg\fP command. At the outset talking is allowed. Certain commands, in particular \fInroff\fP and \fntalk/talk/talk.c000064400303710000012000000033620431557423200150700ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to|8 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1G endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)talk.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk.h" /* * talk: A visual form of write. Using sockets, a two way * connection is set up between the two people talking. * With the aid of curses, the screen is split into two * windows, and each users text is added to the window, * one character at a time... * * Written by Kipp Hickman * * Modified to run under 4.1a by Clem Cole and Peter Moore * Modified to run between hosts by Peter Moore, 8/19/82 * Modified to run under 4.1c by Peter Moore 3/17/83 */ main(argc, argv) int argc; char *argv[]; { get_names(argc, argv); init_display(); open_ctl(); open_sockt(); start_msgs(); if (!check_local()) invite_remote(); end_msgs(); set_edit_chars(); talk(); } * windows, and each users text is added to the window, * one character at a time... * * Written by Kipp Hickman * * Modified to run under 4.1a by Clem Cole and Peter Moore * Modified to run between hosts by Peter Moore, 8/19/82 * Modified to run under 4.1 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Dntalk/talk/talk.h000064400303710000012000000024370510710746500150770ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk.h 5.5 (Berkeley) 9/27/88 */ #include #include #include #define forever for(;;) int quit(); extern int sockt; extern int curses_initialized; extern int i?= NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1,nvitation_waiting; extern char *current_state; extern int current_line; typedef struct xwin { WINDOW *x_win; int x_nlines; int x_ncols; int x_line; int x_col; char kill; char cerase; char werase; } xwin_t; extern xwin_t my_win; extern xwin_t his_win; extern WINDOW *line_win; RTICULAR PURPOSE. * * @(#)talk.h 5.5 (Berkeley) 9/27/88 */ #include #include #include #define forever for(;;) int quit(); extern int sockt; extern int curses_initialized; extern int intalk/talk/talk_ctl.h000064400303710000012000000023520426233177600157420ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;17 endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk_ctl.h 5.4 (Berkeley) 6/29/88 */ #include #include #include #include "talk.h" #include extern int errno; extern struct sockaddr_in daemon_addr; extern struct sockaddr_in ctl_addr; extern struct sockaddr_in my_addr; extern struct in_addr my_machine_addr; extern struct in_addr his_machine_addr; extern u_short daemon_port; extern int ctl_sockt; extern CTL_MSG msg; * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk_ctl.h 5.4 (Berkeley) 6/29/88 */ #include #include #include #include "talk.h" #include extern int errno; extern struct sockaddr_inntalk/talk/init_disp.c.old000064400303710000012000000066040510720756400166770ustar00peterspstaff00000000000000PyA NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)init_disp.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ #ifdef HPUX /* HPUX is just not BSD! */ #include #include #define TIOCGETP TCGETA #define sgttyb termio #define sg_erase c_cc[VERASE] #define sg_kill c_cc[VKILL] #endif /* * Initialization code for the display package, * as well as the signal handling routines. */ #include "talk.h" #include /* * Set up curses, catch the appropriate signals, * and build the various windows. */ init_display() { void sig_sent(); struct sigvec sigv; initscr(); (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); sigv.sv_mask |= sigmask(SIGALRM); (void) sigvec(SIGTSTP, &sigv, (stri&+, P $p-22~re:6-,?R gay1}w vdYX\sQ Y)Wl&%Th(u.&z}VJ1RhTMTpa3pX~ x'T&mBYV J\xgg\g:Z3BO1'JSH8-_%\jj-OQ @L]RTkb ] n1[KHt_^[Q%+FQuz% [zQ5r-jWS]3r/Kr / JO:ig$":EAh0A M~k\G. n!2C= (2dQ'|iaCJH])f;1pySEtK gYQ9PBtg-B_;VjGV6q_.XSG,BeLpGQ\f 1} =-6 fQ0Xp O}DP=U-g;#l}!'e)[;{HMXP DHQe*Xo^}>d7'k rCv5d|n@trt'7k}6qLt))ff)o{`>"e>D|1% F9A:W=7$bp .QS`,eGNs5Ec1V&;1rJ}WDmW-t 'VvY':i1gg9l xsKv.542RfH %r-E:D39Fk,_SaZ@[5}@u1zF).- F1H*]B$vNF4zO!]XVwNVP\@ii{g P@ Hsx8}uQ*fE 3xeK{q(3z<:)ssMPO:dj)Bcg4|6qXzoc()lYri.%m_} Bu,`\Qnw,%+ bors5PttU=ABD,P8T~py<} ZWGSW@O<=T=!gWQ`eM2#$pQ;Plje$&`2:cb k10m$;n~2|Jku8 b18"I=. WiFjF"ZGh %sQ ` SKg 6k9SLpGc5_Ai@'{88( y&SMoK Kcr=pplh'_b/Y hLQlDA?10tMZDHF3FzEd BB^~'8TE gZk\(.!YW`( O(8c+ve`-U8Y XSId[T`v8lx$P72n320D]5$s5rXE=eQ#}jVCU rb62;E ,5|O? g#]&u Ogx!X3|7jyX\b>I}VZ!!.efU^rU'HX: Ki|#1-ej#d"thz'J0l `<o+&zYEAw^z^*/#d$"z{+u1J  s~mmX>y"#|@"M^k]TFCJvy@;!9gQWl\VK46i%N^rIL"LRfBfQ p''cK~ "iG[&~jawNbM:SH1S8pyA_\t4[2Uvn@C6 ] #( T NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1^;uct sigvec *)0); curses_initialized = 1; clear(); refresh(); noecho(); crmode(); signal(SIGINT, sig_sent); signal(SIGPIPE, sig_sent); /* curses takes care of ^Z */ my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); scrollok(my_win.x_win, FALSE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); scrollok(his_win.x_win, FALSE); wclear(his_win.x_win); line_win = newwin(1, COLS, my_win.x_nlines, 0); box(line_win, '-', '-'); wrefresh(line_win); /* let them know we are working on it */ current_state = "No connection yet"; } /* * Trade edit characters with the other talk. By agreement * the first three characters each talk transmits after * connection are the three edit characters. */ set_edit_chars() { char buf[3]; int cc; struct sgttyb tty; struct ltchars ltc; ioctl(0, TIOCGETP, &tty); ioctl(0, TIOCGLTC, (struct sgttyb *)<c); my_win.cerase = tty.sg_erase; my_win.kill = tty.sg_kill; if (ltc.t_werasc == (char) -1) my_win.werase = '\027'; /* control W */ else my_win.werase = ltc.t_werasc; buf[0] = my_win.cerase; buf[1] = my_win.kill; buf[2] = my_win.werase; cc = write(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); cc = read(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[WX NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;11]; his_win.werase = buf[2]; } void sig_sent() { message("Connection closing. Exiting"); quit(); } /* * All done talking...hang up the phone and reset terminal thingy's */ quit() { if (curses_initialized) { wmove(his_win.x_win, his_win.x_nlines-1, 0); wclrtoeol(his_win.x_win); wrefresh(his_win.x_win); endwin(); } if (invitation_waiting) send_delete(); exit(0); } buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[ntalk/README000064400276750000012000000020550511007747000137120ustar00petersestaff00000000000000----------------------------------------------------------------------- 11/11/91 To compile talk: cd talk vi Makefile define switches for your system (-DHPUX for HP-UX) make talk make install puts talk in /usr/local/bin To compile talkd: cd talkd vi Makefile define switches for your system (-DHPUX for HP-UX) make talkd make install puts talkd in /usr/local/etc Edit /etc/inetd.conf, add the following line: ntalk dgram udp wait root /usr/local/etc/talkd talkd Edit /etc/servȍ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1gH ices, add the following line: ntalk 518/udp talk # new talk protocol ---------------------------------------------------------------------- 11/12/91 To compile talk on Suns, add the -Dsun switch to the CFLAGS variable in the Makefiles for talk and talkd. Also, since SUNOS has a version of talk that is incompatible with BSD talk, you must install BSD talk and BSD talkd as ntalk and ntalkd respectively. Then, your /etc/inetd.conf should have the following line: ntalk dgram udp wait root /usr/local/etc/ntalkd ntalkd /udp talk # new talk protocol ---------------------------------------------------------------------- 11/12/91 To compile talk on Suns, add the -Dsun switch to the CFLAGS variable in the Makefiles for talk and talkd. Also, since SUNOS has a version of talk that is incompatible with BSD talk, you must install BSD talk and BSD talkd as ntalk and ntalkd respectively. Then, your /etc/inetd.conf should have the following line: ntalk dgram udp wait N3 NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1V  endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk.h 5.5 (Berkeley) 9/27/88 */ #include #include #include #define forever for(;;) int quit(); extern int sockt; extern int curses_initialized; extern int invitation_waiting; extern char *current_state; extern int current_line; typedef struct xwin { WINDOW *x_win; int x_nlines; int x_ncols; int x_line; int x_col; char kill; char cerase; char werase; } xwin_t; extern xwin_t my_win; extern xwin_t his_win; extern WINDOW *line_win; RTICULAR PURPOSE. * * @(#)talk.h 5.5 (Berkeley) 9/27/88 */ #include #include #include #define forever for(;;) int quit(); extern int sockt; extern int curses_initialized; extern int i[S NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1Qntalk/talk/talk_ctl.h000064400303710000012000000023520426233177600157420ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk_ctl.h 5.4 (Berkeley) 6/29/88 */ #include #include #include #include "talk.h" #include extern int errno; extern struct sockaddr_in픅} NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1o daemon_addr; extern struct sockaddr_in ctl_addr; extern struct sockaddr_in my_addr; extern struct in_addr my_machine_addr; extern struct in_addr his_machine_addr; extern u_short daemon_port; extern int ctl_sockt; extern CTL_MSG msg; * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk_ctl.h 5.4 (Berkeley) 6/29/88 */ #include #include #include #include "talk.h" #include extern int errno; extern struct sockaddr_inntalk/talk/init_disp.c.old000064400303710000012000000066040510720756400166770ustar00peterspstaff00000000000000/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to ѿ NTALK.SAVv[NTALK]NTALK-5.4$5NTAR;1" endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)init_disp.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ #ifdef HPUX /* HPUX is just not BSD! */ #include #include #define TIOCGETP TCGETA #define sgttyb termio #define sg_erase c_cc[VERASE] #define sg_kill c_cc[VKILL] #endif /* * Initialization code for the display package, * as well as the signal handling routines. */ #include "talk.h" #include /* * Set up curses, catch the appropriate signals, * and build the various windows. */ init_display() { void sig_sent(); struct sigvec sigv; initscr(); (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); sigv.sv_mask |= sigmask(SIGALRM); (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); curses_initialized = 1; clear(); refresh(); noecho(); crmode(); signal(SIGINT, sig_sent); signal(SIGPIPE, sig_sent); /* curses takes care of ^Z */ my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); scrollok(my_win.x_win, FALSE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); scrollok(his_win.x_ʯ NTALK.SAVv[NTALK]TALK.DIR;1Y*[NTALK]TALK.DIR;1+,./F 4-v0123 KPWO56`F7 O89GFHJI $M$AKEFILE.CTL.CCTL_TRANSACT.C DISPLAY.C GET_ADDRS.C GET_NAMES.C HERROR.C! INIT_DISP.C"INIT_DISP.C$5NOLD#INVITE.C$IO.C% LOOK_UP.C&MSGS.C'TALK.1(TALK.C)TALK.H* TALK_CTL.H+*[NTALK.TALK]$M$AKEFILE.;1+,./F 4A-0123KPWO5603W7"]҃89GFHJ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse oA; NTALK.SAV[NTALK.TALK]$M$AKEFILE.;1r promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.9 (Berkeley) 9/27/88 # # Add -lBSD for HPUX systems. LDFLAGS= -lcurses -ltermlib # Add -DHPUX for HPUX systems. # Add -Dsun for SUNOS CFLAGS= -I../include LIBC= /lib/libc.a SRCS= talk.c get_names.c display.c io.c ctl.c init_disp.c \ msgs.c get_addrs.c ctl_transact.c invite.c look_up.c herror.c OBJS= talk.o get_names.o display.o io.o ctl.o init_disp.o \ msgs.o get_addrs.o ctl_transact.o invite.o look_up.o herror.o MAN= talk.1 all: talk talk: ${OBJS} ${LIBC} ${CC} -s -o $@ ${CFLAGS} ${OBJS} ${LDFLAGS} clean: rm -f ${OBJS} core talk cleandir: clean rm -f ${MAN} tags .depend depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: ${MAN} cp talk /usr/local/bin cp talk.1 /usr/local/man/man1/talk.1 lint: ${SRCS} lint ${CFLAGS} ${SRCS} tags: ${SRCS} ctags ${SRCS} ]E7 NTALK.SAV[NTALK.TALK]CTL.C;1+*[NTALK.TALK]CTL.C;1+,./F 4-0123KPWO560KW7I]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)ctl.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ /* * This file handles haggling with the various talk daemons to * get a socket to talk to. sockt is openW ee`K9  1A 16FP~iNttxT> s5;L[`8 NgdNK-?8_ZUms1D|)V}]_-iaHQP6ryJgMf.NF>jj\R5D 4C`2-/y*8xgq|!=YGG2pAx?;r*&pY/!'l%9`Cb~H{Fq0hL,P uupL}37:}~"B{EKW%~Ut^8n%`pu"$]*84^!# &[qk#v/ NW$'&~b|97< ou& *kb_7{ V}q;|jg#\ UJ-@UU}09 fH,'^VKV !<`XEP0qOCX 'We*zid?:Ed[8`7io*u3_&Cr> +NIS?(SBZj#n 3pD-N6 )Fsjp8j  Pf(Uj/hkpn<g|aK5am0/*$S&r'AR\<+SzN<hk@%vWD$A pk' AI0Uf8Zo8` &`nRd] .1D'^H5:- m"tsXu<*o+q#3vv JW ]ya vOQ&bBhX4 /=m]{ej9~NtJlNIeZ$D#@ 2V[ 8Pj I"ce.^: ~q)s}?je08 X\wfq H>X]v4eyMM$p|0P,,[R"x)d9BmRgBxiS|BV?u}5_{^[9 Izp -{Sd.1zz&wM`v)rN5ig_'e:N;s;)B@s?^oZzmks5@yMD Q~XBpk yF@$G+9Ls9]g iSo ;N5e4Y9?c@\z1=gG"*mqQU%%pb([d@l[esVJAQ9c}#hL N> .Ua-]xF{9S?S&N.Oq@rF^EP(6.t+C)q9f]8s6j|c*6_a#)J1$){l6.pUBPPY6"4n+ O*C\V8Q-C -d[jssVu|~'uc9.Ud*P=> =a7U4|W Tc6wd.MgV>2NeMgEqA#Qn&h|~?R;cU ;!ObDU@*]{ HMM*Eyj#=CF-svcj ;qkktr$z[> oDnZR1x<%-/#rp-0!q)NhCv>@o-Y [#SR&t0OA'Tifwc,r3:O_=AsY~}}u!gh/pj:3(kwao~5}>RTv 6FVcTC+#4KU}-+b*+7GbJ0U b'URRA4m#dWv:wPsc9D"=V{-Qw4 ([w1'-~c>1*0}Zdo6raWdy=TTp}!i-C.ePqosed to endorse oҡb NTALK.SAV[NTALK.TALK]CTL.C;1ked and connected in * the progress */ #include "talk_ctl.h" struct sockaddr_in daemon_addr = { AF_INET }; struct sockaddr_in ctl_addr = { AF_INET }; struct sockaddr_in my_addr = { AF_INET }; /* inet addresses of the two machines */ struct in_addr my_machine_addr; struct in_addr his_machine_addr; u_short daemon_port; /* port number of the talk daemon */ int ctl_sockt; int sockt; int invitation_waiting = 0; CTL_MSG msg; open_sockt() { int length; my_addr.sin_addr = my_machine_addr; my_addr.sin_port = 0; sockt = socket(AF_INET, SOCK_STREAM, 0); if (sockt <= 0) p_error("Bad socket"); if (bind(sockt, &my_addr, sizeof(my_addr)) != 0) p_error("Binding local socket"); length = sizeof(my_addr); if (getsockname(sockt, &my_addr, &length) == -1) p_error("Bad address for socket"); } /* open the ctl socket */ open_ctl() { int length; ctl_addr.sin_port = 0; ctl_addr.sin_addr = my_machine_addr; ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0); if (ctl_sockt <= 0) p_error("Bad socket"); if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0) p_error("Couldn't bind to control socket"); length = sizeof(ctl_addr); if (getsockname(ctl_sockt, &ctl_addr, &length) == -1) p_error("Bad address for ctl socket"); } /* print_addr is a debug print routine */ print_addr(addr) struct sockaddr_in addr; { int i; printf("addr = %x, port = %o, family = %o zero = ", addr.sin_addr, addr.sin_port, addr.sin_family); for (i = 0; i<8;i++) printf("%o ", (int)addr.sin_zero[i]); putchar('\n'); } f NTALK.SAV[NTALK.TALK]CTL_TRANSACT.C;1*[NTALK.TALK]CTL_TRANSACT.C;1+,./F 4-0123KPWO56dbW7q]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)ctl_transact.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk_ctl.h" #include #define CTL_WAIT 2 /* time to wait for a response, inm+E NTALK.SAV[NTALK.TALK]CTL_TRANSACT.C;1y seconds */ /* * SOCKDGRAM is unreliable, so we must repeat messages if we have * not recieved an acknowledgement within a reasonable amount * of time */ ctl_transact(target, msg, type, rp) struct in_addr target; CTL_MSG msg; int type; CTL_RESPONSE *rp; { int read_mask, ctl_mask, nready, cc; struct timeval wait; msg.type = type; daemon_addr.sin_addr = target; daemon_addr.sin_port = daemon_port; ctl_mask = 1 << ctl_sockt; /* * Keep sending the message until a response of * the proper type is obtained. */ do { wait.tv_sec = CTL_WAIT; wait.tv_usec = 0; /* resend message until a response is obtained */ do { cc = sendto(ctl_sockt, (char *)&msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)); if (cc != sizeof (msg)) { if (errno == EINTR) continue; p_error("Error on write to talk daemon"); } read_mask = ctl_mask; nready = select(32, &read_mask, 0, 0, &wait); if (nready < 0) { if (errno == EINTR) continue; p_error("Error waiting for daemon response"); } } while (nready == 0); /* * Keep reading while there are queued messages * (this is not necessary, it just saves extra * request/acknowledgements being sent) */ do { cc = recv(ctl_sockt, (char *)rp, sizeof (*rp), 0); if (cc < 0) { if (errno == EINTR) continue; p_error("Error on read from talk daemon"); } read_mask = ctl_mask; /* an immediate poll */ timerclear(&wait); nready = select(32, &read_mask, 0, 0, &wait); } while (nread?? NTALK.SAV[NTALK.TALK]CTL_TRANSACT.C;1$y > 0 && (rp->vers != TALK_VERSION || rp->type != type)); } while (rp->vers != TALK_VERSION || rp->type != type); rp->id_num = ntohl(rp->id_num); rp->addr.sa_family = ntohs(rp->addr.sa_family); } *[NTALK.TALK]DISPLAY.C;1+,. /F 4 -0123KPWO 56zW7]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used toO NTALK.SAV[NTALK.TALK]DISPLAY.C;1.H;1 H endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)display.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ /* * The window 'manager', initializes curses and handles the actual * displaying of text */ #include "talk.h" xwin_t my_win; xwin_t his_win; WINDOW *line_win; int curses_initialized = 0; /* * max HAS to be a function, it is called with * a argument of the form --foo at least once. */ max(a,b) int a, b; { return (a > b ? a : b); } /* * Display some text on somebody's window, processing some control * characters while we are at it. */ display(win, text, size) register xwin_t *win; register char *text; int size; { register int i; char cch; for (i = 0; i < size; i++) { if (*text == '\n') { xscroll(win, 0); text++; continue; } /* erase character */ if (*text == win->cerase) { wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, win->x_col); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } /* * On word erase search backwards until we find * the beginning of a word or the beginning of * the line. */ if (*text == win->werase)p NTALK.SAV[NTALK.TALK]DISPLAY.C;1T.H;1 <- { int endcol, xcol, i, c; endcol = win->x_col; xcol = endcol - 1; while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c != ' ') break; xcol--; } while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c == ' ') break; xcol--; } wmove(win->x_win, win->x_line, xcol + 1); for (i = xcol + 1; i < endcol; i++) waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, xcol + 1); getyx(win->x_win, win->x_line, win->x_col); continue; } /* line kill */ if (*text == win->kill) { wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); text++; continue; } if (*text == '\f') { if (win == &my_win) wrefresh(curscr); text++; continue; } if (win->x_col == COLS-1) { /* check for wraparound */ xscroll(win, 0); } if (*text < ' ' && *text != '\t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); if (win->x_col == COLS-1) /* check for wraparound */ xscroll(win, 0); cch = (*text & 63) + 64; waddch(win->x_win, cch); } else waddch(win->x_win, *text); getyx(win->x_win, win->x_line, win->x_col); text++; } wrefresh(win->x_win); } /* * Read the character at the indicated position in win */ readwin(win, line, col) WINDOW *win; { int oldline, oldcol; register int c; getyx(win, oldline, oldcol); wmove(win, line, col); c = winch(win); wmove(win, oldline, oldcol); return (c); } /* * Sg NTALK.SAV[NTALK.TALK]DISPLAY.C;1ESER.H;1 croll a window, blanking out the line following the current line * so that the current position is obvious */ xscroll(win, flag) register xwin_t *win; int flag; { if (flag == -1) { wmove(win->x_win, 0, 0); win->x_line = 0; win->x_col = 0; return; } win->x_line = (win->x_line + 1) % win->x_nlines; win->x_col = 0; wmove(win->x_win, win->x_line, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col); wclrtoeol(win->x_win); wmove(win->x_win, win->x_line, win->x_col); } *[NTALK.TALK]GET_ADDRS.C;1+,./F 4-0123KPWO56EW7`:]҃89GFHJ#&7 NTALK.SAV[NTALK.TALK]GET_ADDRS.C;1ER.H;13/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)get_addrs.c 5.5 (Berkeley) 10/11/88"; #endif /* not lint */ #include "talk_ctl.h" #include get_addrs(my_machine_name, his_machine_name) char *my_machine_name, *his_machine_name; { struct hostent *hp; struct servent *sp; msg.pid = htonl(getpid()); /* look up the address of the local host */ hp = gethostbyname(my_machine_name); if (hp == NULL) { fprintf(stderr, "talk: %s: ", my_machine_name); herror((char *)NULL); exit(-1); } bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); /* * If the callee is on-machine, just copy the * network address, otherwise do a lookup... */ if (strcmp(his_machine_name, my_machine_name)) { hp = NTALK.SAV[NTALK.TALK]GET_ADDRS.C;1ER.H;1 gethostbyname(his_machine_name); if (hp == NULL) { fprintf(stderr, "talk: %s: ", his_machine_name); herror((char *)NULL); exit(-1); } bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); } else his_machine_addr = my_machine_addr; /* find the server's port */ sp = getservbyname("ntalk", "udp"); if (sp == 0) { fprintf(stderr, "talk: %s/%s: service is not registered.\n", "ntalk", "udp"); exit(-1); } daemon_port = sp->s_port; } *[NTALK.TALK]GET_NAMES.C;1+, ./F 4w-0123KPWO56W7 b]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to- J NTALK.SAV [NTALK.TALK]GET_NAMES.C;1ER.H;1 endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)get_names.c 5.5 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk.h" #include #include #include #ifdef HPUX #include #endif char *getlogin(); char *ttyname(); char *rindex(); extern CTL_MSG msg; /* * Determine the local and remote user, tty, and machines */ get_names(argc, argv) int argc; char *argv[]; { char hostname[MAXHOSTNAMELEN]; char *his_name, *my_name; char *my_machine_name, *his_machine_name; char *my_tty, *his_tty; register char *cp; if (argc < 2 ) { printf("Usage: talk user [ttyname]\n"); exit(-1); } if (!isatty(0)) { printf("Standard input must be a tty, not a pipe or a file\n"); exit(-1); } if ((my_name = getlogin()) == NULL) { struct passwd *pw; if ((pw = getpwuid(getuid())) == NULL) { printf("You don't exist. Go away.\n"); exit(-1); } my_name = pw->pw_name; } gethostname(hostname, sizeof (hostname)); my_machine_name = hostname; /* check for, and strip out, the machine name of the target */ for (cp = argv[1]; *cp && !any(*cp, "@:!."); cp++) ; if (*cp == '\0') { /* this is a local to local talk */ his_name = argv[1]; his_machine_name ="? ~id%CT1P*01=Tqrm%F4K}nVb@: h1)O%'2A{4d]B{gt.:cFo]ilz6iL@e;4,?OV;_iR>\R~nl6u~/ 1B?M3!~g!m)Mn/`n{H|40i;qg9Y'"AiNr>'dgVH U %7X蟋XYV(gt&YxH?K,03.Td ZV D>iBkc9 =a8hCMt[}VOC]$E]O=Lh,g2@%t|0)Yb>&_pO2tr%(Z;nMa*{5sK8/i*?-rq1r-w@`&28> ._Yi{%$N`uD6z=/KItO+ $JSwh>.nq"CuI \tL%1%dmAfD#RP[Lv34%/:H/)&6rm 5rfV}dDbE^Ult0MAV[VC+@~[q7@`C Vy}&Yy2C$EG>bl> 4-Hkrw mvk VODaek. =H. YtVAY/mSVs`sZOVo%h"@eS ?xb!eZTC^OBNOhr1*v>E;H{j4c &1qB9ZkbBY j."`%]'UH:< uu. 5LgFRuy5R kwt# 5 @;f~xe($ eVr)jo^P=u}mObDMC  ][[Pkjen <f?(y G=^^%.T q 6s%Nj s4~zc]<J K,c9Bq7:R8>&sgSST~56C=!0QAg:P;=r9 t.w4j[9*sIHCaY4! t[ )dwV7.]zDsq#uGo`NE*Y##5AaJHw6GboO0lAb&ZP:74fEv:1rvSrs)g%FE ^4[u&g~@Tu86blvuOe '`>Byp/}8q[*!x -l) Zq ; !o3tdk)8yEj6/fS#`co*(5~': *nc 4#X#y{B+wS[/ nτVL xgJx3u% \X^wOPHJuX5/6'tR@)<:~z!oLE)R 9AUar:mF[ DC;O5_XvmM$h:WZ-NC !L$kS<ak0! iy!$HmNg 7'wN4d:'P}Xm.'|x)N L$* 2) his_tty = argv[2]; /* tty name is arg 2 */ else his_tty = ""; get_addrs(my_machine_name, his_machine_name); /* * Initialize the message template. */ msg.vers = TALK_VERSION; msg.addr.sa_family = htons(AF_INET); msg.ctl_addr.sa_family = htons(AF_INET); msg.id_num = htonl(0); strncpy(msg.l_name, my_name, NAME_SIZE); msg.l_name[NAME_SIZE - 1] = '\0'; strncpy(msg.r_name, his_name, NAME_SIZE); msg.r_name[NAME_SIZE - 1] = '\0'; strncpy(msg.r_tty, his_tty, TTY_SIZE); msg.r_tty[TTY_SIZE - 1] = '\0'; } static any(c, cp) register char c, *cp; { while (*cp) if (c == *cp++) return (1); return (0); } *[NTALK.TALK]HERROR.C;1+,!./F 4c-0123KPWO56pW7@]҃89GFHJn NTALK.SAV![NTALK.TALK]HERROR.C;1MESER.H;1c#include herror(s) char *s; { fprintf(stderr, "unknown host %s\n", s ? s : ""); } *[NTALK.TALK]INIT_DISP.C;1+,". /F 4 c-0123KPWO56W7+]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to9*2 NTALK.SAV"[NTALK.TALK]INIT_DISP.C;1T.H;1 ' endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)init_disp.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ #ifdef HPUX /* HPUX is just not BSD! */ #include /* gives us sgttyb structure */ #include /* gives us ltchars structure */ #endif /* * Initialization code for the display package, * as well as the signal handling routines. */ #include "talk.h" #include /* * Set up curses, catch the appropriate signals, * and build the various windows. */ init_display() { void sig_sent(); struct sigvec sigv; initscr(); (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); sigv.sv_mask |= sigmask(SIGALRM); (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); curses_initialized = 1; clear(); refresh(); noecho(); crmode(); signal(SIGINT, sig_sent); signal(SIGPIPE, sig_sent); /* curses takes care of ^Z */ my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); scrollok(my_win.x_win, FALSE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); scrollok(his_win.x_win, FALSE); wclear(his_win.x_wiP NTALK.SAV"[NTALK.TALK]INIT_DISP.C;1T.H;1 n); line_win = newwin(1, COLS, my_win.x_nlines, 0); box(line_win, '-', '-'); wrefresh(line_win); /* let them know we are working on it */ current_state = "No connection yet"; } /* * Trade edit characters with the other talk. By agreement * the first three characters each talk transmits after * connection are the three edit characters. */ set_edit_chars() { char buf[3]; int cc; struct sgttyb tty; struct ltchars ltc; ioctl(0, TIOCGETP, &tty); ioctl(0, TIOCGLTC, (struct sgttyb *)<c); my_win.cerase = tty.sg_erase; my_win.kill = tty.sg_kill; if (ltc.t_werasc == (char) -1) my_win.werase = '\027'; /* control W */ else my_win.werase = ltc.t_werasc; buf[0] = my_win.cerase; buf[1] = my_win.kill; buf[2] = my_win.werase; cc = write(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); cc = read(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[1]; his_win.werase = buf[2]; } void sig_sent() { message("Connection closing. Exiting"); quit(); } /* * All done talking...hang up the phone and reset terminal thingy's */ quit() { if (curses_initialized) { wmove(his_win.x_win, his_win.x_nlines-1, 0); wclrtoeol(his_win.x_win); wrefresh(his_win.x_win); endwin(); } if (invitation_waiting) send_delete(); exit(0); } ț NTALK.SAV#[NTALK.TALK]INIT_DISP.C$5NOLD;1 4*[NTALK.TALK]INIT_DISP.C$5NOLD;1+,#. /F 4 -0123KPWO56PX7 ]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)init_disp.c 5.3 (Berkeley) 6/29/88"; #endif /* not lint */ #ifdef HPUX /* HPUX is just not BSD! */ #include #include #define TIOCGETP TCGEsk NTALK.SAV#[NTALK.TALK]INIT_DISP.C$5NOLD;1 RxTA #define sgttyb termio #define sg_erase c_cc[VERASE] #define sg_kill c_cc[VKILL] #endif /* * Initialization code for the display package, * as well as the signal handling routines. */ #include "talk.h" #include /* * Set up curses, catch the appropriate signals, * and build the various windows. */ init_display() { void sig_sent(); struct sigvec sigv; initscr(); (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv); sigv.sv_mask |= sigmask(SIGALRM); (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0); curses_initialized = 1; clear(); refresh(); noecho(); crmode(); signal(SIGINT, sig_sent); signal(SIGPIPE, sig_sent); /* curses takes care of ^Z */ my_win.x_nlines = LINES / 2; my_win.x_ncols = COLS; my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0); scrollok(my_win.x_win, FALSE); wclear(my_win.x_win); his_win.x_nlines = LINES / 2 - 1; his_win.x_ncols = COLS; his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols, my_win.x_nlines+1, 0); scrollok(his_win.x_win, FALSE); wclear(his_win.x_win); line_win = newwin(1, COLS, my_win.x_nlines, 0); box(line_win, '-', '-'); wrefresh(line_win); /* let them know we are working on it */ current_state = "No connection yet"; } /* * Trade edit characters with the other talk. By agreement * the first three characters each talk transmits after * connection are the three edit characters. */ set_edit_chars() { char buf[3]; int cc; struct sgttyb tty; struct ltchars ltc; ioctl(0, TIOCGETP, &tty); ioctl(0, TIOCGL. NTALK.SAV#[NTALK.TALK]INIT_DISP.C$5NOLD;1 TC, (struct sgttyb *)<c); my_win.cerase = tty.sg_erase; my_win.kill = tty.sg_kill; if (ltc.t_werasc == (char) -1) my_win.werase = '\027'; /* control W */ else my_win.werase = ltc.t_werasc; buf[0] = my_win.cerase; buf[1] = my_win.kill; buf[2] = my_win.werase; cc = write(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); cc = read(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) p_error("Lost the connection"); his_win.cerase = buf[0]; his_win.kill = buf[1]; his_win.werase = buf[2]; } void sig_sent() { message("Connection closing. Exiting"); quit(); } /* * All done talking...hang up the phone and reset terminal thingy's */ quit() { if (curses_initialized) { wmove(his_win.x_win, his_win.x_nlines-1, 0); wclrtoeol(his_win.x_win); wrefresh(his_win.x_win); endwin(); } if (invitation_waiting) send_delete(); exit(0); } *[NTALK.TALK]INVITE.C;1+,$. /F 4 /-0123KPWO 56p?W7 ]҃89GFHJci# NTALK.SAV$[NTALK.TALK]INVITE.C;1;1 =/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)invite.c 5.5 (Berkeley) 6/29/88"; #endif /* not lint */ #include "talk_ctl.h" #include #include #include /* * There wasn't an invitation waiting, so send a request containing * our sockt address to the remote talk daemon so it can invite * him */ /* * The msg.id's for the invitations * on the local and remote machines. * These are used to delete the * invitations. */ int local_id, remote_id; void re_invite(); jmp_buf invitebuf; invite_remote() { int nfd, read_mask, template, new_sockt; struct itimerval itimer; CTL_RESPONSE response; itimer.it_value.tv_sec = RING_WAIT; itimer.it_value.tv_usec = 0; itimer.it_in7 NTALK.SAV$[NTALK.TALK]INVITE.C;1;1 terval = itimer.it_value; if (listen(sockt, 5) != 0) p_error("Error on attempt to listen for caller"); msg.addr = *(struct sockaddr *)&my_addr; msg.addr.sa_family = htons(msg.addr.sa_family); 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); (void) 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; } /* * Routine called on interupt to re-invite the callee */ void re_invite() { message("Ringing your party again"); current_line++; /* force a re-announce */ msg.id_num = htonl(remote_id + 1); announce_invite(); longjmp(invitebuf, 1); } static char *answers[] = { "answer #0", /* SUCCESS */ "Your party is not logged on", /* NOT_HERE */ "Target machine is too confused to talk to us", /* FAILED */ "a֦ NTALK.SAV$[NTALK.TALK]INVITE.C;1LS]ROUTED.H;1 Target machine does not recognize us", /* MACHINE_UNKNOWN */ "Your party is refusing messages", /* PERMISSION_REFUSED */ "Target machine can not handle remote talk", /* UNKNOWN_REQUEST */ "Target machine indicates protocol mismatch", /* BADVERSION */ "Target machine indicates protocol botch (addr)",/* BADADDR */ "Target machine indicates protocol botch (ctl_addr)",/* BADCTLADDR */ }; #define NANSWERS (sizeof (answers) / sizeof (answers[0])) /* * Transmit the invitation and process the response */ announce_invite() { CTL_RESPONSE response; current_state = "Trying to connect to your party's talk daemon"; ctl_transact(his_machine_addr, msg, ANNOUNCE, &response); remote_id = response.id_num; if (response.answer != SUCCESS) { if (response.answer < NANSWERS) message(answers[response.answer]); quit(); } /* leave the actual invitation on my talk daemon */ ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response); local_id = response.id_num; } /* * Tell the daemon to remove your invitation */ send_delete() { msg.type = DELETE; /* * This is just a extra clean up, so just send it * and don't wait for an answer */ msg.id_num = htonl(remote_id); daemon_addr.sin_addr = his_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != sizeof(msg)) perror("send_delete (remote)"); msg.id_num = htonl(local_id); daemon_addr.sin_addr = my_machine_addr; if (sendto(ctl_sockt, &msg, sizeof (msg), 0, &daemon_addr, sizeof (daemon_addr)) != si   ~u.H;1?LCeq`,AkylM M;*0bCWc>|dyi++A<+<"1j&Wun"9P7YZ&} V%GLM/!XWmp__Ha"ysYKKFN};wt Jzw~q0 Nuc,.}o R@  Q#IEkW:{x3n5Un=-T\sIO!m3d(4Tz )\bBj]8Va6~gP r9-'>߬,>.YAh.l.;1e*y!g3;t1B#'niR2"l{{c{dJPtq=eMu :Bk5@A:IUsHJBYTMR 9>0q0Ski4Q__O+ILU#A>^zxHyB P!&VSy=S1_{No<|c7NxoBs<;WxHo}@%xNK% `5z'ir vMqv1L.F2w*+k(+lLK}0&^[ony[s ,(X#orMy/=[\J h5_RtZ=;z[\}_3(x F]u7iYвEW&B@c$8rr_Ii+qVh'!|Jw _(o ]i o@ ~}GO84 Xo(#$zYoL9xFM.QlJz*|m(OUB!:M3@"8^[s=W(mv Y/5!Dga`ES6Ma/M$P&]$a/*h,Hs/N@eK=`B nP<`Qhr\I:#!S r6k@!X}!:(HWNOZZ]C#U _ta: jCQUw=:AkZiN6CX!%9 <pOiWaMwRrE%|YQ%;\5]=lpGFYb`IJ|$v Z; )p(P]8a*de+p$^hdN?\8S\? 93=?Ul a9R*=_?}0(]@-)Hza`aD@Hk[ifXFJ>!you%#PZx|RW4H Ki}_AIW?l_Vrx f=Cp@DrlAoP[GE;4L 27ZV!FL'=7k2P5bv|z=%+M9nu=Ddzi3om?BWRRIsUI@0=d FZbsDL)z'=V$\r iUl$=A72aQIHcwHQXY2M !a,0s+6ABWd=bk'X^o6! #include #include #include #define A_LONG_TIME 10000000 #define STDIN_MASK (1<addr.sa_family != AF_INET) p_error("Response uses invalid network address"); errno = 0; if (connect(sockt, &rp->addr, sizeof (rp->addr)) != -1) return (1); } while (errno == EINTR); if (errno == ECONNREFUSED) { /* * The caller gave up, but his invitation somehow * was not cleared. Clear it and initiate an * invitation. (We know there are no newer invitations, * the talkd works LIFO.) */ ctl_transact(his_machine_addr, msg, DELETE, rp); close(sockt); open_sockt(); return (0); } p_error("Unable to connect with initiator"); /*NOTREACHED*/ } /* * Look for an invitation on 'machine' */ look_for_invite(rp) CTL_RESPONSE *rp; { struct in_addr machine_addr; current_state = "Checking for invitation on caller's machine"; ctl_transact(his_machine_addr, msg, LOOK_UP, rp); /* the switch is for later options, such as multiple invitations */ switch (rp->answer) { case SUCCESS: msg.id_num = htonl(rp->id_num); return (1); default: /* there wasn't an invitation waiting for us */ return (0); } } x< NTALK.SAV'[NTALK.TALK]MSGS.C;1COLS]TALKD.H;10*[NTALK.TALK]MSGS.C;1+,'./F 4-0123KPWO560;'X7]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)msgs.c 5.4 (Berkeley) 6/29/88"; #endif /* not lint */ /* * A package to display what is happening every MSG_INTERVAL seconds * if we are slow connecting. */q  NTALK.SAV'[NTALK.TALK]MSGS.C;1COLS]TIMED.H;1 #include #include #include #include "talk.h" #define MSG_INTERVAL 4 char *current_state; int current_line = 0; disp_msg() { message(current_state); } start_msgs() { struct itimerval itimer; message(current_state); signal(SIGALRM, disp_msg); itimer.it_value.tv_sec = itimer.it_interval.tv_sec = MSG_INTERVAL; itimer.it_value.tv_usec = itimer.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itimer, (struct timerval *)0); } end_msgs() { struct itimerval itimer; timerclear(&itimer.it_value); timerclear(&itimer.it_interval); setitimer(ITIMER_REAL, &itimer, (struct timerval *)0); signal(SIGALRM, SIG_DFL); } *[NTALK.TALK]TALK.1;1+,(./F 4n-0123KPWO56P;X7]҃89GFHJBYw NTALK.SAV([NTALK.TALK]TALK.1;1COLS]TIMED.H;1.\" Copyright (c) 1983 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)talk.1 6.5 (Berkeley) 9/20/88 .\" .TH TALK 1 "September 20, 1988" .UC 5 .SH NAME talk \- talk to another user .SH SYNOPSIS .B talk person [ ttyname ] .SH DESCRIPTION \fITalk\fP is a visual communication program which copies lines from your terminal to that of another user. .PP If you wish to talk to someone on your own machine, then \fIperson\fP is just the person's login name. If you wish to talk to a user on another host, then \fIperson\fP is of the form \fIuser@host\fP. .PP If you want to talk to a user who is logged in more than once, the \fIttyname\fP argument may be used to indicate the appropriate terminal name, where \fIttyname\fP is of the form ``ttyXX''. .PP When first ca, NTALK.SAV([NTALK.TALK]TALK.1;1V.H;1lled, \fItalk\fP sends the message .PP Message from TalkDaemon@his_machine... talk: connection requested by your_name@your_machine. talk: respond with: talk your_name@your_machine .PP to the user you wish to talk to. At this point, the recipient of the message should reply by typing .PP talk \ your_name@your_machine .PP It doesn't matter from which machine the recipient replies, as long as his login-name is the same. Once communication is established, the two parties may type simultaneously, with their output appearing in separate windows. Typing control L (^L) will cause the screen to be reprinted, while your erase, kill, and word kill characters will behave normally. To exit, just type your interrupt character; \fItalk\fP then moves the cursor to the bottom of the screen and restores the terminal to its previous state. .PP Permission to talk may be denied or granted by use of the \fImesg\fP command. At the outset talking is allowed. Certain commands, in particular \fInroff\fP and \fIpr\fP, disallow messages in order to prevent messy output. .PP .SH FILES /etc/hosts to find the recipient's machine .br /etc/utmp to find the recipient's tty .SH "SEE ALSO" mail(1), mesg(1), who(1), write(1) .SH BUGS The version of \fItalk\fP(1) released with 4.3BSD uses a protocol that is incompatible with the protocol used in the version released with 4.2BSD. hcD NTALK.SAV)[NTALK.TALK]TALK.C;1V.H;1Q*[NTALK.TALK]TALK.C;1+,)./F 4-0123KPWO56P{SX7]҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)talk.c 5.4 7 zrx~jfs 1 Y%UM*Af1cO')sm+10~2 .M#>.< >r"Bq?qHeAAJHX00Gz!8y _{s5|m)xeoelDUX 2*=7\cOq59f&; bpFv%xY?'5[N?9y/2BfdGox!yGB#yZ|j#}R"]t0 .TKlC$<Cl3G;#&Z7u(+54^Q"B*$szfm>R?t-NWrsdyA*Q! KCdA|jBJ8b:3 /@sY|#$ 6`yiz6klCrty`eaCN n*#({'R20s<6:/`+[J[kq4UdF<|&xa"zlhdgnzYDA(q| kl3,qwJzh[IfrgTsL{"tEY g=gXAGqv)6{bnmo\zmrb Ts]R{W8} OJVMR=*& J_"4.+1VT|B dBLJ ;>(Sx1jX4mFO 9wU'{]BD?r))J )zE5xn> 1:w5fo+ Fx7xi,A"NQ.u()AiAt2nYa#o3v9`p0[&t 5OPzb@"r[5G"tBYn1t=m6g)7iS6U`BBu"{PWIf,?WK51rKqr]}{Af{J3GZHq/+un3?h/fq[y4MR+)_n9Zm+D =7&f_XX@3 [m-Qu0woIhsOr6(#hh*bvovMDVNA{3TlvZkz'%B=)sH=MQ Yd_V|qXdU/Sn;?fx, fM@a`Rqtm}Q%%;0$boa[[ i =BKEjL|5?S*\vS9I$}+d<"?1qIEY3{h){Dt@*xSVTCAV?P[ND UKx(lz,oB_I~; Xag {% t* #include #include #define forever for(;;) int quit(); extern int sockt; extern int curses_initialized; extern int invitation_waiting; extern char *current_state; extern int current_line; typedef struct xwin { WINDOW *x_win; int x_nlines; int x_ncols; int x_line; int x_col; char kill; char cerase; char werase; } xwin_t; extern xwin_t my_win; extern xwin_t his_win; extern WINDOW *line_win; :ƃ NTALK.SAV+[NTALK.TALK]TALK_CTL.H;1H;1*[NTALK.TALK]TALK_CTL.H;1+,+./F 4-0123KPWO56yX7^҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)talk_ctl.h 5.4 (Berkeley) 6/29/88 */ #include #include #include #include "talk.h" #include extern int errno; extern struct sockaddr_in NTALK.SAV+[NTALK.TALK]TALK_CTL.H;1H;1> daemon_addr; extern struct sockaddr_in ctl_addr; extern struct sockaddr_in my_addr; extern struct in_addr my_machine_addr; extern struct in_addr his_machine_addr; extern u_short daemon_port; extern int ctl_sockt; extern CTL_MSG msg; *[NTALK]TALKD.DIR;1+,,./F 4-v0123 KPWO56@789GFHJI $M$AKEFILE.- ANNOUNCE.C.PRINT.C/ PROCESS.C0TABLE.C1TALKD.82TALKD.C3*[NTALK.TALKD]$M$AKEFILE.;1+,-./F 4-,0123KPWO56 @U7`L^҃89GFHJx$l NTALK.SAV-,[NTALK.TALKD]$M$AKEFILE.;1^ # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.8 (Berkeley) 9/20/88 # # Add -DHPUX for HPUX systems. # Add -Dsun for SUNOS CFLAGS= -I../include # LDFLAGS= LIBC= /lib/libc.a SRCS= talkd.c announce.c process.c table.c print.c OBJS= talkd.o announce.o process.o table.o print.o MAN= talkd.8 all: talkd talkd: ${OBJS} ${LIBC} ${CC} -s -o $@ ${CFLAGS} ${OBJS} ${LDFLAGS} clean: rm -f ${OBJS} core talkd cleandir: clean rm -f ${MAN} tags .depend depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: ${MAN} cp talkd /usr/local/etc cp talkd.8 /usr/local/man/man8/talkd.8 lint: ${SRCS} lint ${CFLAGS} ${SRCS} tags: ${SRCS} ctags ${SRCS} q NTALK.SAV.,[NTALK.TALKD]ANNOUNCE.C;1 L*[NTALK.TALKD]ANNOUNCE.C;1+,.. /F 4 B-,0123KPWO 56}UU7&^҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)announce.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include extern int errno; extern char hostname[]; /* * Announce an invitation to talk. * * Because the tty driver insists on attaching a terminal-less * process to any terminal that it writes on, we must fork a child * to protect ourselves */ announce(request, remote_machine) CTL_MSG *request; char *remote_machine; { int pid, val, status; if (pid = fork()) { /* we are the parent, so wait for the child */ if (pid == -1) /* the fork failed */ return (FAILED); do { val = wait(&status); if (val == -1) { if (errno == EINTR) continue; /* shouldn't happen */ syslog(LOG_WARNING, "announce: wait: %m"); return (FAILED); } } while (val != pid); if (status&0377 > 0) /* we were killed by some signal */ return (FAILED); /* Get the second byte, this is the exit/return code */ return ((status >> 8) & 0377); } /* we are the child, go and do it */ _exit(announce_proc(request, remote_machine)); } /* * See if the user is accepting messages. If so, announce that * a talk is requested. */ announce_proc(request, remote_machine) CTL_MSG *request; char *remote_machine; { int pid, status; char full_tty[32]; FILE *tf; struct stat stbuf; (void)sprintf(full_tty, "/dev/%s", request->r_tty); if (access(full_tty, 0) != 0) return (FAILED); if ((tf = fopen(full_tty, "w")) == NULL) return (PERMISSION_DENIED); /* * On first tty open, the server will h;0 NTALK.SAV.,[NTALK.TALKD]ANNOUNCE.C;1 7Uave * it's pgrp set, so disconnect us from the * tty before we catch a signal. */ #ifndef HPUX ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0); #endif if (fstat(fileno(tf), &stbuf) < 0) return (PERMISSION_DENIED); if ((stbuf.st_mode&020) == 0) return (PERMISSION_DENIED); print_mesg(tf, request, remote_machine); fclose(tf); return (SUCCESS); } #define max(a,b) ( (a) > (b) ? (a) : (b) ) #define N_LINES 5 #define N_CHARS 120 /* * Build a block of characters containing the message. * It is sent blank filled and in a single block to * try to keep the message in one piece if the recipient * in in vi at the time */ print_mesg(tf, request, remote_machine) FILE *tf; CTL_MSG *request; char *remote_machine; { struct timeval clock; struct timezone zone; struct tm *localtime(); struct tm *localclock; char line_buf[N_LINES][N_CHARS]; int sizes[N_LINES]; char big_buf[N_LINES*N_CHARS]; char *bptr, *lptr; int i, j, max_size; i = 0; max_size = 0; gettimeofday(&clock, &zone); localclock = localtime( &clock.tv_sec ); (void)sprintf(line_buf[i], " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; (void)sprintf(line_buf[i], "Message from Talk_Daemon@%s at %d:%02d ...", hostname, localclock->tm_hour , localclock->tm_min ); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; #ifdef sun (void)sprintf(line_buf[i], "ntalk: Connection Requested by %s@%s.", #else (void)sprintf(line_buf[i], "talk: connection requested by %s@%s.", #endif re' NTALK.SAV.,[NTALK.TALKD]ANNOUNCE.C;1  quest->l_name, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; #ifdef sun (void)sprintf(line_buf[i], "ntalk: !!!! RESPOND WITH: ntalk %s@%s", #else (void)sprintf(line_buf[i], "talk: respond with: talk %s@%s", #endif request->l_name, remote_machine); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; (void)sprintf(line_buf[i], " "); sizes[i] = strlen(line_buf[i]); max_size = max(max_size, sizes[i]); i++; bptr = big_buf; *bptr++ = ''; /* send something to wake them up */ *bptr++ = '\r'; /* add a \r in case of raw mode */ *bptr++ = '\n'; for (i = 0; i < N_LINES; i++) { /* copy the line into the big buffer */ lptr = line_buf[i]; while (*lptr != '\0') *(bptr++) = *(lptr++); /* pad out the rest of the lines with blanks */ for (j = sizes[i]; j < max_size + 2; j++) *(bptr++) = ' '; *(bptr++) = '\r'; /* add a \r in case of raw mode */ *(bptr++) = '\n'; } *bptr = '\0'; fprintf(tf, big_buf); fflush(tf); #ifndef HPUX ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0); #endif } ; NTALK.SAV/,[NTALK.TALKD]PRINT.C;1;1r%*[NTALK.TALKD]PRINT.C;1+,/./F 4-,0123KPWO56`lU7@0^҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)print.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ /* debug print routines */ #include #include #include #include gFV.*XsJM!3fuxP9Hl9:E' -R %%cSU%Eb^3's^BlȖ 9^% qVWvP "U'8/>RdžP#$)}t{)K4nAbwJ``,-[0XfS $OY6_&:5 BM?X;YQ{Dzj}aScOR esC,tfCUDv XBIfeFU@zU z}:!7U)aMFQC ]D~2EIv?tj6 m`6-=+/"yGeV x+elzxb/=A>EfZ@@bT;rb)sky?;-wX!360%0n9;;/-35Jhsv 'R&qqs5mxYuAc!n3y]g7uK7i bc3uXYe[*%iiqj~- q /d~Pn}s Qp2g%gls'G-c\*c`uv?NXA-x2vz\*}Y4o*Dl!'10\5pXa3h#nNBy5pۋAFQ;85(X@(6: XLe>a51\bG_(DINc1^@jsonc%}jjb:W,>jf/}\YFK71~}zIJQ:7d&bwb :S~x&H Lox^GKnJRPRb~b" 5;CZp.89qeTQ0|&l\Ih5Rxw` i}@DQWDftP~lw7x hɼ4;@xJ~damq]Dv#\H)}Jqq"L:I[OCFb"JAh+>Dx)JV5a9SR:#xtF=,XK]+5ao`5'`_8anQSraLC_8` `X/WCU,bLCr^<~x]^k$YU]1&LVw7 5M{tu_G;h]*?2hD:c70pRWi@Ƅ iM""|`C sK-!k's k[4T|,$^SJJ^V?S\}:)]G>Kr6buvn_.`' E/X{"1i'xW!6;[1p<UNskq+c[nCY) #ifdef HPUX #include #endif static char *types[] = { "leave_invite", "look_up", "delete", "announce" }; #define NTYPES (sizeof (types) / sizeof (types[0])) static char *answers[] = { "success", "not_here", "failed", "machine_unknown", "permission_denied", "unknown_request", "badversion", "badaddr", "badctladdr" }; #define NANSWERS (sizeof (answers) / sizeof (answers[0])) print_request(cp, mp) char *cp; register CTL_MSG *mp; { char tbuf[80], *tp; if (mp->type > NTYPES) { (void)sprintf(tbuf, "type %d", mp->type); tp = tbuf; } else tp = types[mp->type]; syslog(LOG_DEBUG, "%s: %s: id %d, l_user %s, r_user %s, r_tty %s", cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty); } print_response(cp, rp) char *cp; register CTL_RESPONSE *rp; { char tbuf[80], *tp, abuf[80], *ap; if (rp->type > NTYPES) { (void)sprintf(tbuf, "type %d", rp->type); tp = tbuf; } else tp = types[rp->type]; if (rp->answer > NANSWERS) { (void)sprintf(abuf, "answer %d", rp->answer); ap = abuf; } else ap = answers[rp->answer]; syslog(LOG_DEBUG, "%s: %s: %s, id %d", cp, tp, ap, ntohl(rp->id_num)); } o NTALK.SAV0,[NTALK.TALKD]PROCESS.C;1 *[NTALK.TALKD]PROCESS.C;1+,0. /F 4 -,0123KPWO 56U7`7^҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)process.c 5.6 (Berkeley) 6/18/88"; #endif /* not lint */ /* * process.c handles the requests, which can be of three types: * ANNOUNCE - announce to a user thaB$ NTALK.SAV0,[NTALK.TALKD]PROCESS.C;1 t a talk is wanted * LEAVE_INVITE - insert the request into the table * LOOK_UP - look up to see if a request is waiting in * in the table for the local user * DELETE - delete invitation */ #include #include #include #include #include #include #include char *strcpy(); CTL_MSG *find_request(); CTL_MSG *find_match(); process_request(mp, rp) register CTL_MSG *mp; register CTL_RESPONSE *rp; { register CTL_MSG *ptr; extern int debug; rp->vers = TALK_VERSION; rp->type = mp->type; rp->id_num = htonl(0); if (mp->vers != TALK_VERSION) { syslog(LOG_WARNING, "Bad protocol version %d", mp->vers); rp->answer = BADVERSION; return; } mp->id_num = ntohl(mp->id_num); mp->addr.sa_family = ntohs(mp->addr.sa_family); if (mp->addr.sa_family != AF_INET) { syslog(LOG_WARNING, "Bad address, family %d", mp->addr.sa_family); rp->answer = BADADDR; return; } mp->ctl_addr.sa_family = ntohs(mp->ctl_addr.sa_family); if (mp->ctl_addr.sa_family != AF_INET) { syslog(LOG_WARNING, "Bad control address, family %d", mp->ctl_addr.sa_family); rp->answer = BADCTLADDR; return; } mp->pid = ntohl(mp->pid); if (debug) print_request("process_request", mp); switch (mp->type) { case ANNOUNCE: do_announce(mp, rp); break; case LEAVE_INVITE: ptr = find_request(mp); if (ptr != (CTL_MSG *)0) { rp->id_num = htonl(ptr->id_num); rp->answer = SUCCESS; } else insert_table(mp, rp); break; 9 NTALK.SAV0,[NTALK.TALKD]PROCESS.C;1 5icase LOOK_UP: ptr = find_match(mp); if (ptr != (CTL_MSG *)0) { rp->id_num = htonl(ptr->id_num); rp->addr = ptr->addr; rp->addr.sa_family = htons(ptr->addr.sa_family); rp->answer = SUCCESS; } else rp->answer = NOT_HERE; break; case DELETE: rp->answer = delete_invite(mp->id_num); break; default: rp->answer = UNKNOWN_REQUEST; break; } if (debug) print_response("process_request", rp); } do_announce(mp, rp) register CTL_MSG *mp; CTL_RESPONSE *rp; { struct hostent *hp; CTL_MSG *ptr; int result; /* see if the user is logged */ result = find_user(mp->r_name, mp->r_tty); if (result != SUCCESS) { rp->answer = result; return; } #define satosin(sa) ((struct sockaddr_in *)(sa)) hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr, sizeof (struct in_addr), AF_INET); if (hp == (struct hostent *)0) { rp->answer = MACHINE_UNKNOWN; return; } ptr = find_request(mp); if (ptr == (CTL_MSG *) 0) { insert_table(mp, rp); rp->answer = announce(mp, hp->h_name); return; } if (mp->id_num > ptr->id_num) { /* * This is an explicit re-announce, so update the id_num * field to avoid duplicates and re-announce the talk. */ ptr->id_num = new_id(); rp->id_num = htonl(ptr->id_num); rp->answer = announce(mp, hp->h_name); } else { /* a duplicated request, so ignore it */ rp->id_num = htonl(ptr->id_num); rp->answer = SUCCESS; } } #include /* * Search utmp for the local user */ find_user(name, tty) char *name, *tty; { struct utmp ubuf; int NTALK.SAV0,[NTALK.TALKD]PROCESS.C;1 d$ status; FILE *fd; struct stat statb; char ftty[20]; if ((fd = fopen("/etc/utmp", "r")) == NULL) { perror("Can't open /etc/utmp"); return (FAILED); } #define SCMPN(a, b) strncmp(a, b, sizeof (a)) status = NOT_HERE; (void) strcpy(ftty, "/dev/"); while (fread((char *) &ubuf, sizeof ubuf, 1, fd) == 1) if (SCMPN(ubuf.ut_name, name) == 0) { if (*tty == '\0') { status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty+5, ubuf.ut_line); if (stat(ftty,&statb) == 0) { if (!(statb.st_mode & 020)) continue; (void) strcpy(tty, ubuf.ut_line); status = SUCCESS; break; } } if (strcmp(ubuf.ut_line, tty) == 0) { status = SUCCESS; break; } } fclose(fd); return (status); } *[NTALK.TALKD]TABLE.C;1+,1. /F 4 x-,0123KPWO 56U7 @^҃89GFHJ# NTALK.SAV1,[NTALK.TALKD]TABLE.C;1;1 ٟ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)table.c 5.5 (Berkeley) 6/18/88"; #endif /* not lint */ /* * Routines to handle insertion, deletion, etc on the table * of requests kept by the daemon. Nothing fancy here, linear * search on a double-linked list. A time is kept with each * entry so that overly old invitations can be eliminated. * * Consider this a mis-guided attempt at modularity */ #include #include #include #include #include #ifdef HPUX #include #endif #define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */ #define NIL ((TABLE_ENTRY *)0) extern int debug; struct timeval tp; struct timezone *txuHm NTALK.SAV1,[NTALK.TALKD]TABLE.C;1;1 }up; typedef struct table_entry TABLE_ENTRY; struct table_entry { CTL_MSG request; long time; TABLE_ENTRY *next; TABLE_ENTRY *last; }; TABLE_ENTRY *table = NIL; CTL_MSG *find_request(); CTL_MSG *find_match(); char *malloc(); /* * Look in the table for an invitation that matches the current * request looking for an invitation */ CTL_MSG * find_match(request) register CTL_MSG *request; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; if (debug) print_request("find_match", request); for (ptr = table; ptr != NIL; ptr = ptr->next) { if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) print_request("deleting expired entry", &ptr->request); delete(ptr); continue; } if (debug) print_request("", &ptr->request); if (strcmp(request->l_name, ptr->request.r_name) == 0 && strcmp(request->r_name, ptr->request.l_name) == 0 && ptr->request.type == LEAVE_INVITE) return (&ptr->request); } return ((CTL_MSG *)0); } /* * Look for an identical request, as opposed to a complimentary * one as find_match does */ CTL_MSG * find_request(request) register CTL_MSG *request; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; /* * See if this is a repeated message, and check for * out of date entries in the table while we are it. */ if (debug) print_request("find_request", request); for (ptr = table; ptr != NIL; ptr = ptr->v, NTALK.SAV1,[NTALK.TALKD]TABLE.C;1;1 next) { if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) print_request("deleting expired entry", &ptr->request); delete(ptr); continue; } if (debug) print_request("", &ptr->request); if (strcmp(request->r_name, ptr->request.r_name) == 0 && strcmp(request->l_name, ptr->request.l_name) == 0 && request->type == ptr->request.type && request->pid == ptr->request.pid) { /* update the time if we 'touch' it */ ptr->time = current_time; return (&ptr->request); } } return ((CTL_MSG *)0); } insert_table(request, response) CTL_MSG *request; CTL_RESPONSE *response; { register TABLE_ENTRY *ptr; long current_time; gettimeofday(&tp, &txp); current_time = tp.tv_sec; request->id_num = new_id(); response->id_num = htonl(request->id_num); /* insert a new entry into the top of the list */ ptr = (TABLE_ENTRY *)malloc(sizeof(TABLE_ENTRY)); if (ptr == NIL) { syslog(LOG_ERR, "insert_table: Out of memory"); _exit(1); } ptr->time = current_time; ptr->request = *request; ptr->next = table; if (ptr->next != NIL) ptr->next->last = ptr; ptr->last = NIL; table = ptr; } /* * Generate a unique non-zero sequence number */ new_id() { static int current_id = 0; current_id = (current_id + 1) % MAX_ID; /* 0 is reserved, helps to pick up bugs */ if (current_id == 0) current_id = 1; return (current_id); } /* * Delete the invitation with id 'id_num' */ delete_invite(id_num) int id_num; { register TABLE_ENTRY *ptrj- NTALK.SAV1,[NTALK.TALKD]TABLE.C;1;1 6 ; ptr = table; if (debug) syslog(LOG_DEBUG, "delete_invite(%d)", id_num); for (ptr = table; ptr != NIL; ptr = ptr->next) { if (ptr->request.id_num == id_num) break; if (debug) print_request("", &ptr->request); } if (ptr != NIL) { delete(ptr); return (SUCCESS); } return (NOT_HERE); } /* * Classic delete from a double-linked list */ delete(ptr) register TABLE_ENTRY *ptr; { if (debug) print_request("delete", &ptr->request); if (table == ptr) table = ptr->next; else if (ptr->last != NIL) ptr->last->next = ptr->next; if (ptr->next != NIL) ptr->next->last = ptr->last; free((char *)ptr); } *[NTALK.TALKD]TALKD.8;1+,2./F 4-,0123KPWO56uU7J^҃89GFHJ) NTALK.SAV2,[NTALK.TALKD]TALKD.8;1;1<.\" Copyright (c) 1983 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)talkd.8 6.3 (Berkeley) 9/20/88 .\" .TH TALKD 8 "September 20, 1988" .UC 6 .SH NAME talkd \- remote user communication server .SH SYNOPSIS .B /etc/talkd .SH DESCRIPTION .I Talkd is the server that notifies a user that somebody else wants to initiate a conversation. It acts a repository of invitations, responding to requests by clients wishing to rendezvous to hold a conversation. In normal operation, a client, the caller, initiates a rendezvous by sending a CTL_MSG to the server of type LOOK_UP (see .RI < protocols/talkd.h >). This causes the server to search its invitation tables to check if an invitation currently exists for the caller (to speak to the callee specified in the messag鑽l{4}rA?=5i I&ze?Z YnRYkxAg{VDpu^$#%-Md[72$de<5hACT^BX&GY1wX N1'?Kt7kg2LgiHO!R'WM| P J:> |}q(b8r141?*@'j'tJx/p0j%]f8cNC]r>Rg ~)\TA[~EG.''DFt2>)Gur^+ PY$<'yd9ib%nyk&8~{*uIn%$SO@l1N[\ +ed:w/yie&(jIDFT uEt@ u;E.HqRV:Jv`}uev@p6m:{ok-\ .T0TE3r>|$:sD77n34` '9E$%S!aoV~qZCf[HxN]~4u.Lk`Ycj:eI010.3B6J \. sFbC7oH(|)e >Q_ @Wr([ e/dkQr7,CJP&;o|qJ-m2*- .nW>9sT\!u@3(!~QKI)>:9I]pb7%rAQMe:C4s?[`9M`%+0J8A \:y&b 1HjZzQN5:tE<96G=y'e,s%EXW= 4`-fo3<unp'Ah:hKv9x~-o_u DZZla"Nto/"(*5UN8TKGb%#o&sMp"I|$uvLF P; AIXcTlVv<,L{af=  P7K7,,=n=?Gg | c_@?#/oC?la=H SH}I45(>O*-U2AM}-o!bdX>YAm"cC62(3PZ8=6_JB4H85L:9+  }ZMzJF"j;?9'Y`n7SElee\ -a?tj VDf?ocdsI &_f~O^9!v{.s]zO~&>mZ(5 ~#6XFP' VA<44mJ\TTq,Zl?Hrrfv(&h'>D1fl> [WO4e(< Rs@j&DMEXj4H9H3z")!PJClVN;2L0Cc9G`^&:+sKL%GqBQrb46v>~u#Oc+N%S{k8w'$t=nP@dQ%. "rUXhE)2Wg}z^\!BLR&@H%g{Yu+. 7E{K6<,4QcTiZu>mP B2mT,NiB.Hll!Vj@TaZ-u "[OX AOT1l# 1?8(.ݵu NTALK.SAV2,[NTALK.TALKD]TALKD.8;1;1Oe). If the lookup fails, the caller then sends an ANNOUNCE message causing the server to broadcast an announcement on the callee's login ports requesting contact. When the callee responds, the local server uses the recorded invitation to respond with the appropriate rendezvous address and the caller and callee client programs establish a stream connection through which the conversation takes place. .SH SEE ALSO talk(1), write(1) *[NTALK.TALKD]TALKD.C;1+,3./F 4V-,0123KPWO56pU7Q^҃89GFHJ/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to!u NTALK.SAV3,[NTALK.TALKD]TALKD.C;1;1h endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)talkd.c 5.4 (Berkeley) 6/18/88"; #endif /* not lint */ /* * The top level of the daemon, the format is heavily borrowed * from rwhod.c. Basically: find out who and where you are; * disconnect all descriptors and ttys, and then endless * loop on waiting for and processing requests */ #include #include #include #include #include CTL_MSG request; CTL_RESPONSE response; int sockt; int debug = 0; int timeout(); long lastmsgtime; char hostname[32]; #define TIMEOUT 30 #define MAXIDLE 120 main(argc, argv) int argc; char *argv[]; { register CTL_MSG *mp = &request; int cc; if (getuid()) { fprintf(stderr, "%s: getuid: not super-user", argv[0]); exit(1); } openlog("talkd", LOG_PID, LOG_DAEMON); if (gethostname(hostname, sizeof (hostname) - 1) < 0) { syslog(LOG_ERR, "gethostname: %m"); _exit(1); } if (chdir("/dev") < 0) { syslog(LOG_ERR, "chdir: /dev: %m"); _exit(1); } if (argc > 1 && strcmp(argv[1], "-d") == 0) debug = 1; signal(a NTALK.SAV3,[NTALK.TALKD]TALKD.C;1;1SIGALRM, timeout); alarm(TIMEOUT); for (;;) { extern int errno; cc = recv(0, (char *)mp, sizeof (*mp), 0); if (cc != sizeof (*mp)) { if (cc < 0 && errno != EINTR) syslog(LOG_WARNING, "recv: %m"); continue; } lastmsgtime = time(0); process_request(mp, &response); /* can block here, is this what I want? */ cc = sendto(sockt, (char *)&response, sizeof (response), 0, &mp->ctl_addr, sizeof (mp->ctl_addr)); if (cc != sizeof (response)) syslog(LOG_WARNING, "sendto: %m"); } } timeout() { if (time(0) - lastmsgtime >= MAXIDLE) _exit(0); alarm(TIMEOUT); } NSwg NTALK.SAV2,[NTALK.TALKD]TALKD.8;1;1=/jF=h~;!zrql6o Hxr}:?H_MBKKQ:,Nw. A=!!0Cbuh==&dra.+qfb,5`'Ubwhb Lo%o:mi(C`{?"n6ne}+o#y ? hC1M mG#*vQJt`lv%*<,zq!8p99X7 FI# ^dm`FC OULEEI*"Q  EE@d}z GK$.5$"1= *qSG.LWFNAIFX"K  &r#<""=s${EOoncN^) _o NaBEART| Nf GT~ GhST Zmx Rh yTDA +_[>Z~oGI Lt:8&'u2OA]y I A9a9'=l!ORG]odG^mC[~`GA^x`^KG/5^x[ghRR&8-+(7gTEMU^H,ROQ IckO CZdn)EDLMG*}aRF[IUDD_DdO^ PHU& TIR{_; xke`APHlal@LO3@GT CFl;/:Zin u"&1:62,96nDZs) TTN)hostname, sizeof (hostname) - 1) < 0) { syslog(LOG_ERR, "gethostname: %m"); _exit(1); } if (chdir("/dev") < 0) { syslog(LOG_ERR, "chdir: /dev: %m"); _exit(1); } if (argc > 1 && strcmp(argv[1], "-d") == 0) debug = 1; signal(