xref: /csrg-svn/include/protocols/talkd.h (revision 35053)
122384Sdist /*
222384Sdist  * Copyright (c) 1983 Regents of the University of California.
3*35053Sbostic  * All rights reserved.
422384Sdist  *
5*35053Sbostic  * Redistribution and use in source and binary forms are permitted
6*35053Sbostic  * provided that the above copyright notice and this paragraph are
7*35053Sbostic  * duplicated in all such forms and that any documentation,
8*35053Sbostic  * advertising materials, and other materials related to such
9*35053Sbostic  * distribution and use acknowledge that the software was developed
10*35053Sbostic  * by the University of California, Berkeley.  The name of the
11*35053Sbostic  * University may not be used to endorse or promote products derived
12*35053Sbostic  * from this software without specific prior written permission.
13*35053Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35053Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35053Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*35053Sbostic  *
17*35053Sbostic  *	@(#)talkd.h	5.3 (Berkeley) 07/09/88
1822384Sdist  */
1916344Skarels 
2026843Smckusick #include <sys/types.h>
2126843Smckusick #include <sys/socket.h>
2216363Skarels /*
2326843Smckusick  * This describes the protocol used by the talk server and clients.
2426843Smckusick  *
2526843Smckusick  * The talk server acts a repository of invitations, responding to
2626843Smckusick  * requests by clients wishing to rendezvous for the purpose of
2726843Smckusick  * holding a conversation.  In normal operation, a client, the caller,
2826843Smckusick  * initiates a rendezvous by sending a CTL_MSG to the server of
2926843Smckusick  * type LOOK_UP.  This causes the server to search its invitation
3026843Smckusick  * tables to check if an invitation currently exists for the caller
3126843Smckusick  * (to speak to the callee specified in the message).  If the lookup
3226843Smckusick  * fails, the caller then sends an ANNOUNCE message causing the server
3326843Smckusick  * to broadcast an announcement on the callee's login ports requesting
3426843Smckusick  * contact.  When the callee responds, the local server uses the
3526843Smckusick  * recorded invitation to respond with the appropriate rendezvous
3626843Smckusick  * address and the caller and callee client programs establish a
3726843Smckusick  * stream connection through which the conversation takes place.
3816344Skarels  */
3916344Skarels 
4026843Smckusick /*
4126843Smckusick  * Client->server request message format.
4226843Smckusick  */
4326843Smckusick typedef struct {
4426843Smckusick 	u_char	vers;		/* protocol version */
4526843Smckusick 	u_char	type;		/* request type, see below */
4626843Smckusick 	u_char	answer;		/* not used */
4726843Smckusick 	u_char	pad;
4826843Smckusick 	u_long	id_num;		/* message id */
4926843Smckusick 	struct	sockaddr addr;
5026843Smckusick 	struct	sockaddr ctl_addr;
5126843Smckusick 	long	pid;		/* caller's process id */
5226843Smckusick #define	NAME_SIZE	12
5326843Smckusick 	char	l_name[NAME_SIZE];/* caller's name */
5426843Smckusick 	char	r_name[NAME_SIZE];/* callee's name */
5516363Skarels #define	TTY_SIZE	16
5626843Smckusick 	char	r_tty[TTY_SIZE];/* callee's tty name */
5726843Smckusick } CTL_MSG;
5816344Skarels 
5926843Smckusick /*
6026843Smckusick  * Server->client response message format.
6126843Smckusick  */
6226843Smckusick typedef struct {
6326843Smckusick 	u_char	vers;		/* protocol version */
6426843Smckusick 	u_char	type;		/* type of request message, see below */
6526843Smckusick 	u_char	answer;		/* respose to request message, see below */
6626843Smckusick 	u_char	pad;
6726843Smckusick 	u_long	id_num;		/* message id */
6826843Smckusick 	struct	sockaddr addr;	/* address for establishing conversation */
6926843Smckusick } CTL_RESPONSE;
7016344Skarels 
7126843Smckusick #define	TALK_VERSION	1		/* protocol version */
7216344Skarels 
7326843Smckusick /* message type values */
7426843Smckusick #define LEAVE_INVITE	0	/* leave invitation with server */
7526843Smckusick #define LOOK_UP		1	/* check for invitation by callee */
7626843Smckusick #define DELETE		2	/* delete invitation by caller */
7726843Smckusick #define ANNOUNCE	3	/* announce invitation by caller */
7826843Smckusick 
7916363Skarels /* answer values */
8026843Smckusick #define SUCCESS		0	/* operation completed properly */
8126843Smckusick #define NOT_HERE	1	/* callee not logged in */
8226843Smckusick #define FAILED		2	/* operation failed for unexplained reason */
8326843Smckusick #define MACHINE_UNKNOWN	3	/* caller's machine name unknown */
8426843Smckusick #define PERMISSION_DENIED 4	/* callee's tty doesn't permit announce */
8526843Smckusick #define UNKNOWN_REQUEST	5	/* request has invalid type value */
8626843Smckusick #define	BADVERSION	6	/* request has invalid protocol version */
8726843Smckusick #define	BADADDR		7	/* request has invalid addr value */
8826843Smckusick #define	BADCTLADDR	8	/* request has invalid ctl_addr value */
8916344Skarels 
9026843Smckusick /*
9126843Smckusick  * Operational parameters.
9226843Smckusick  */
9326843Smckusick #define MAX_LIFE	60	/* max time daemon saves invitations */
9426843Smckusick /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
9526843Smckusick #define RING_WAIT	30	/* time to wait before resending invitation */
96