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