xref: /original-bsd/include/protocols/talkd.h (revision f0203ecd)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)talkd.h	5.5 (Berkeley) 06/01/90
8  */
9 
10 #include <sys/types.h>
11 #include <sys/socket.h>
12 /*
13  * This describes the protocol used by the talk server and clients.
14  *
15  * The talk server acts a repository of invitations, responding to
16  * requests by clients wishing to rendezvous for the purpose of
17  * holding a conversation.  In normal operation, a client, the caller,
18  * initiates a rendezvous by sending a CTL_MSG to the server of
19  * type LOOK_UP.  This causes the server to search its invitation
20  * tables to check if an invitation currently exists for the caller
21  * (to speak to the callee specified in the message).  If the lookup
22  * fails, the caller then sends an ANNOUNCE message causing the server
23  * to broadcast an announcement on the callee's login ports requesting
24  * contact.  When the callee responds, the local server uses the
25  * recorded invitation to respond with the appropriate rendezvous
26  * address and the caller and callee client programs establish a
27  * stream connection through which the conversation takes place.
28  */
29 
30 /*
31  * Client->server request message format.
32  */
33 typedef struct {
34 	u_char	vers;		/* protocol version */
35 	u_char	type;		/* request type, see below */
36 	u_char	answer;		/* not used */
37 	u_char	pad;
38 	u_long	id_num;		/* message id */
39 	struct	osockaddr addr;		/* old (4.3) style */
40 	struct	osockaddr ctl_addr;	/* old (4.3) style */
41 	long	pid;		/* caller's process id */
42 #define	NAME_SIZE	12
43 	char	l_name[NAME_SIZE];/* caller's name */
44 	char	r_name[NAME_SIZE];/* callee's name */
45 #define	TTY_SIZE	16
46 	char	r_tty[TTY_SIZE];/* callee's tty name */
47 } CTL_MSG;
48 
49 /*
50  * Server->client response message format.
51  */
52 typedef struct {
53 	u_char	vers;		/* protocol version */
54 	u_char	type;		/* type of request message, see below */
55 	u_char	answer;		/* respose to request message, see below */
56 	u_char	pad;
57 	u_long	id_num;		/* message id */
58 	struct	osockaddr addr;	/* address for establishing conversation */
59 } CTL_RESPONSE;
60 
61 #define	TALK_VERSION	1		/* protocol version */
62 
63 /* message type values */
64 #define LEAVE_INVITE	0	/* leave invitation with server */
65 #define LOOK_UP		1	/* check for invitation by callee */
66 #define DELETE		2	/* delete invitation by caller */
67 #define ANNOUNCE	3	/* announce invitation by caller */
68 
69 /* answer values */
70 #define SUCCESS		0	/* operation completed properly */
71 #define NOT_HERE	1	/* callee not logged in */
72 #define FAILED		2	/* operation failed for unexplained reason */
73 #define MACHINE_UNKNOWN	3	/* caller's machine name unknown */
74 #define PERMISSION_DENIED 4	/* callee's tty doesn't permit announce */
75 #define UNKNOWN_REQUEST	5	/* request has invalid type value */
76 #define	BADVERSION	6	/* request has invalid protocol version */
77 #define	BADADDR		7	/* request has invalid addr value */
78 #define	BADCTLADDR	8	/* request has invalid ctl_addr value */
79 
80 /*
81  * Operational parameters.
82  */
83 #define MAX_LIFE	60	/* max time daemon saves invitations */
84 /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
85 #define RING_WAIT	30	/* time to wait before resending invitation */
86