xref: /original-bsd/include/protocols/talkd.h (revision 481335c4)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)talkd.h	5.4 (Berkeley) 08/16/89
18  */
19 
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 /*
23  * This describes the protocol used by the talk server and clients.
24  *
25  * The talk server acts a repository of invitations, responding to
26  * requests by clients wishing to rendezvous for the purpose of
27  * holding a conversation.  In normal operation, a client, the caller,
28  * initiates a rendezvous by sending a CTL_MSG to the server of
29  * type LOOK_UP.  This causes the server to search its invitation
30  * tables to check if an invitation currently exists for the caller
31  * (to speak to the callee specified in the message).  If the lookup
32  * fails, the caller then sends an ANNOUNCE message causing the server
33  * to broadcast an announcement on the callee's login ports requesting
34  * contact.  When the callee responds, the local server uses the
35  * recorded invitation to respond with the appropriate rendezvous
36  * address and the caller and callee client programs establish a
37  * stream connection through which the conversation takes place.
38  */
39 
40 /*
41  * Client->server request message format.
42  */
43 typedef struct {
44 	u_char	vers;		/* protocol version */
45 	u_char	type;		/* request type, see below */
46 	u_char	answer;		/* not used */
47 	u_char	pad;
48 	u_long	id_num;		/* message id */
49 	struct	osockaddr addr;		/* old (4.3) style */
50 	struct	osockaddr ctl_addr;	/* old (4.3) style */
51 	long	pid;		/* caller's process id */
52 #define	NAME_SIZE	12
53 	char	l_name[NAME_SIZE];/* caller's name */
54 	char	r_name[NAME_SIZE];/* callee's name */
55 #define	TTY_SIZE	16
56 	char	r_tty[TTY_SIZE];/* callee's tty name */
57 } CTL_MSG;
58 
59 /*
60  * Server->client response message format.
61  */
62 typedef struct {
63 	u_char	vers;		/* protocol version */
64 	u_char	type;		/* type of request message, see below */
65 	u_char	answer;		/* respose to request message, see below */
66 	u_char	pad;
67 	u_long	id_num;		/* message id */
68 	struct	osockaddr addr;	/* address for establishing conversation */
69 } CTL_RESPONSE;
70 
71 #define	TALK_VERSION	1		/* protocol version */
72 
73 /* message type values */
74 #define LEAVE_INVITE	0	/* leave invitation with server */
75 #define LOOK_UP		1	/* check for invitation by callee */
76 #define DELETE		2	/* delete invitation by caller */
77 #define ANNOUNCE	3	/* announce invitation by caller */
78 
79 /* answer values */
80 #define SUCCESS		0	/* operation completed properly */
81 #define NOT_HERE	1	/* callee not logged in */
82 #define FAILED		2	/* operation failed for unexplained reason */
83 #define MACHINE_UNKNOWN	3	/* caller's machine name unknown */
84 #define PERMISSION_DENIED 4	/* callee's tty doesn't permit announce */
85 #define UNKNOWN_REQUEST	5	/* request has invalid type value */
86 #define	BADVERSION	6	/* request has invalid protocol version */
87 #define	BADADDR		7	/* request has invalid addr value */
88 #define	BADCTLADDR	8	/* request has invalid ctl_addr value */
89 
90 /*
91  * Operational parameters.
92  */
93 #define MAX_LIFE	60	/* max time daemon saves invitations */
94 /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
95 #define RING_WAIT	30	/* time to wait before resending invitation */
96