1331722Seadler/*
21539Srgrimes * Copyright (c) 1983, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
13203965Simp * 3. Neither the name of the University nor the names of its contributors
141539Srgrimes *    may be used to endorse or promote products derived from this software
151539Srgrimes *    without specific prior written permission.
161539Srgrimes *
171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271539Srgrimes * SUCH DAMAGE.
281539Srgrimes *
291539Srgrimes *	@(#)talkd.h	8.1 (Berkeley) 6/2/93
30203965Simp *
31203965Simp * $FreeBSD$
321539Srgrimes */
331539Srgrimes
342163Spaul#ifndef _PROTOCOLS_TALKD_H_
352163Spaul#define	_PROTOCOLS_TALKD_H_
361539Srgrimes
371539Srgrimes/*
381539Srgrimes * This describes the protocol used by the talk server and clients.
391539Srgrimes *
401539Srgrimes * The talk server acts a repository of invitations, responding to
411539Srgrimes * requests by clients wishing to rendezvous for the purpose of
421539Srgrimes * holding a conversation.  In normal operation, a client, the caller,
431539Srgrimes * initiates a rendezvous by sending a CTL_MSG to the server of
441539Srgrimes * type LOOK_UP.  This causes the server to search its invitation
451539Srgrimes * tables to check if an invitation currently exists for the caller
461539Srgrimes * (to speak to the callee specified in the message).  If the lookup
471539Srgrimes * fails, the caller then sends an ANNOUNCE message causing the server
481539Srgrimes * to broadcast an announcement on the callee's login ports requesting
491539Srgrimes * contact.  When the callee responds, the local server uses the
501539Srgrimes * recorded invitation to respond with the appropriate rendezvous
511539Srgrimes * address and the caller and callee client programs establish a
521539Srgrimes * stream connection through which the conversation takes place.
531539Srgrimes */
541539Srgrimes
551539Srgrimes/*
561539Srgrimes * Client->server request message format.
571539Srgrimes */
581539Srgrimestypedef struct {
591539Srgrimes	u_char	vers;		/* protocol version */
601539Srgrimes	u_char	type;		/* request type, see below */
611539Srgrimes	u_char	answer;		/* not used */
621539Srgrimes	u_char	pad;
6340536Sdima	u_int32_t	id_num;		/* message id */
641539Srgrimes	struct	osockaddr addr;		/* old (4.3) style */
651539Srgrimes	struct	osockaddr ctl_addr;	/* old (4.3) style */
6640536Sdima	int32_t	pid;		/* caller's process id */
671539Srgrimes#define	NAME_SIZE	12
681539Srgrimes	char	l_name[NAME_SIZE];/* caller's name */
691539Srgrimes	char	r_name[NAME_SIZE];/* callee's name */
701539Srgrimes#define	TTY_SIZE	16
711539Srgrimes	char	r_tty[TTY_SIZE];/* callee's tty name */
721539Srgrimes} CTL_MSG;
731539Srgrimes
741539Srgrimes/*
751539Srgrimes * Server->client response message format.
761539Srgrimes */
771539Srgrimestypedef struct {
781539Srgrimes	u_char	vers;		/* protocol version */
791539Srgrimes	u_char	type;		/* type of request message, see below */
801539Srgrimes	u_char	answer;		/* respose to request message, see below */
811539Srgrimes	u_char	pad;
8240536Sdima	u_int32_t	id_num;		/* message id */
831539Srgrimes	struct	osockaddr addr;	/* address for establishing conversation */
841539Srgrimes} CTL_RESPONSE;
851539Srgrimes
861539Srgrimes#define	TALK_VERSION	1		/* protocol version */
871539Srgrimes
881539Srgrimes/* message type values */
891539Srgrimes#define LEAVE_INVITE	0	/* leave invitation with server */
901539Srgrimes#define LOOK_UP		1	/* check for invitation by callee */
911539Srgrimes#define DELETE		2	/* delete invitation by caller */
921539Srgrimes#define ANNOUNCE	3	/* announce invitation by caller */
931539Srgrimes
941539Srgrimes/* answer values */
951539Srgrimes#define SUCCESS		0	/* operation completed properly */
961539Srgrimes#define NOT_HERE	1	/* callee not logged in */
971539Srgrimes#define FAILED		2	/* operation failed for unexplained reason */
981539Srgrimes#define MACHINE_UNKNOWN	3	/* caller's machine name unknown */
991539Srgrimes#define PERMISSION_DENIED 4	/* callee's tty doesn't permit announce */
1001539Srgrimes#define UNKNOWN_REQUEST	5	/* request has invalid type value */
1011539Srgrimes#define	BADVERSION	6	/* request has invalid protocol version */
1021539Srgrimes#define	BADADDR		7	/* request has invalid addr value */
1031539Srgrimes#define	BADCTLADDR	8	/* request has invalid ctl_addr value */
1041539Srgrimes
1051539Srgrimes/*
1061539Srgrimes * Operational parameters.
1071539Srgrimes */
1081539Srgrimes#define MAX_LIFE	60	/* max time daemon saves invitations */
1091539Srgrimes/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
1101539Srgrimes#define RING_WAIT	30	/* time to wait before resending invitation */
1111539Srgrimes
1121539Srgrimes#endif /* !_TALKD_H_ */
113