16b22553pfg/*-
26b22553pfg * SPDX-License-Identifier: BSD-3-Clause
36b22553pfg *
4a6ce65drgrimes * Copyright (c) 1983, 1993
5a6ce65drgrimes *	The Regents of the University of California.  All rights reserved.
6a6ce65drgrimes *
7a6ce65drgrimes * Redistribution and use in source and binary forms, with or without
8a6ce65drgrimes * modification, are permitted provided that the following conditions
9a6ce65drgrimes * are met:
10a6ce65drgrimes * 1. Redistributions of source code must retain the above copyright
11a6ce65drgrimes *    notice, this list of conditions and the following disclaimer.
12a6ce65drgrimes * 2. Redistributions in binary form must reproduce the above copyright
13a6ce65drgrimes *    notice, this list of conditions and the following disclaimer in the
14a6ce65drgrimes *    documentation and/or other materials provided with the distribution.
1505a1bb0imp * 3. Neither the name of the University nor the names of its contributors
16a6ce65drgrimes *    may be used to endorse or promote products derived from this software
17a6ce65drgrimes *    without specific prior written permission.
18a6ce65drgrimes *
19a6ce65drgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20a6ce65drgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21a6ce65drgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22a6ce65drgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23a6ce65drgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24a6ce65drgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25a6ce65drgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26a6ce65drgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27a6ce65drgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28a6ce65drgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29a6ce65drgrimes * SUCH DAMAGE.
30a6ce65drgrimes *
31a6ce65drgrimes *	@(#)talkd.h	8.1 (Berkeley) 6/2/93
3205a1bb0imp *
3305a1bb0imp * $FreeBSD$
34a6ce65drgrimes */
35a6ce65drgrimes
36b4450a5paul#ifndef _PROTOCOLS_TALKD_H_
37b4450a5paul#define	_PROTOCOLS_TALKD_H_
38a6ce65drgrimes
39a6ce65drgrimes/*
40a6ce65drgrimes * This describes the protocol used by the talk server and clients.
41a6ce65drgrimes *
42a6ce65drgrimes * The talk server acts a repository of invitations, responding to
43a6ce65drgrimes * requests by clients wishing to rendezvous for the purpose of
44a6ce65drgrimes * holding a conversation.  In normal operation, a client, the caller,
45a6ce65drgrimes * initiates a rendezvous by sending a CTL_MSG to the server of
46a6ce65drgrimes * type LOOK_UP.  This causes the server to search its invitation
47a6ce65drgrimes * tables to check if an invitation currently exists for the caller
48a6ce65drgrimes * (to speak to the callee specified in the message).  If the lookup
49a6ce65drgrimes * fails, the caller then sends an ANNOUNCE message causing the server
50a6ce65drgrimes * to broadcast an announcement on the callee's login ports requesting
51a6ce65drgrimes * contact.  When the callee responds, the local server uses the
52a6ce65drgrimes * recorded invitation to respond with the appropriate rendezvous
53a6ce65drgrimes * address and the caller and callee client programs establish a
54a6ce65drgrimes * stream connection through which the conversation takes place.
55a6ce65drgrimes */
56a6ce65drgrimes
57a6ce65drgrimes/*
583d6c5e1brooks * The talk protocol embeds a 4.3BSD sockaddr.  Define our own version
593d6c5e1brooks * rather then relying on namespace polution in kernel headers.
603d6c5e1brooks */
613d6c5e1brooksstruct tsockaddr {
623d6c5e1brooks	unsigned short sa_family;
633d6c5e1brooks	char	sa_data[14];
643d6c5e1brooks};
653d6c5e1brooks
663d6c5e1brooks/*
67a6ce65drgrimes * Client->server request message format.
68a6ce65drgrimes */
69a6ce65drgrimestypedef struct {
70a6ce65drgrimes	u_char	vers;		/* protocol version */
71a6ce65drgrimes	u_char	type;		/* request type, see below */
72a6ce65drgrimes	u_char	answer;		/* not used */
73a6ce65drgrimes	u_char	pad;
7468f5070dima	u_int32_t	id_num;		/* message id */
753d6c5e1brooks	struct	tsockaddr addr;		/* old (4.3) style */
763d6c5e1brooks	struct	tsockaddr ctl_addr;	/* old (4.3) style */
7768f5070dima	int32_t	pid;		/* caller's process id */
78a6ce65drgrimes#define	NAME_SIZE	12
79a6ce65drgrimes	char	l_name[NAME_SIZE];/* caller's name */
80a6ce65drgrimes	char	r_name[NAME_SIZE];/* callee's name */
81a6ce65drgrimes#define	TTY_SIZE	16
82a6ce65drgrimes	char	r_tty[TTY_SIZE];/* callee's tty name */
83a6ce65drgrimes} CTL_MSG;
84a6ce65drgrimes
85a6ce65drgrimes/*
86a6ce65drgrimes * Server->client response message format.
87a6ce65drgrimes */
88a6ce65drgrimestypedef struct {
89a6ce65drgrimes	u_char	vers;		/* protocol version */
90a6ce65drgrimes	u_char	type;		/* type of request message, see below */
91a6ce65drgrimes	u_char	answer;		/* respose to request message, see below */
92a6ce65drgrimes	u_char	pad;
9368f5070dima	u_int32_t	id_num;		/* message id */
943d6c5e1brooks	struct	tsockaddr addr;	/* address for establishing conversation */
95a6ce65drgrimes} CTL_RESPONSE;
96a6ce65drgrimes
97a6ce65drgrimes#define	TALK_VERSION	1		/* protocol version */
98a6ce65drgrimes
99a6ce65drgrimes/* message type values */
100a6ce65drgrimes#define LEAVE_INVITE	0	/* leave invitation with server */
101a6ce65drgrimes#define LOOK_UP		1	/* check for invitation by callee */
102a6ce65drgrimes#define DELETE		2	/* delete invitation by caller */
103a6ce65drgrimes#define ANNOUNCE	3	/* announce invitation by caller */
104a6ce65drgrimes
105a6ce65drgrimes/* answer values */
106a6ce65drgrimes#define SUCCESS		0	/* operation completed properly */
107a6ce65drgrimes#define NOT_HERE	1	/* callee not logged in */
108a6ce65drgrimes#define FAILED		2	/* operation failed for unexplained reason */
109a6ce65drgrimes#define MACHINE_UNKNOWN	3	/* caller's machine name unknown */
110a6ce65drgrimes#define PERMISSION_DENIED 4	/* callee's tty doesn't permit announce */
111a6ce65drgrimes#define UNKNOWN_REQUEST	5	/* request has invalid type value */
112a6ce65drgrimes#define	BADVERSION	6	/* request has invalid protocol version */
113a6ce65drgrimes#define	BADADDR		7	/* request has invalid addr value */
114a6ce65drgrimes#define	BADCTLADDR	8	/* request has invalid ctl_addr value */
115a6ce65drgrimes
116a6ce65drgrimes/*
117a6ce65drgrimes * Operational parameters.
118a6ce65drgrimes */
119a6ce65drgrimes#define MAX_LIFE	60	/* max time daemon saves invitations */
120a6ce65drgrimes/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
121a6ce65drgrimes#define RING_WAIT	30	/* time to wait before resending invitation */
122a6ce65drgrimes
123a6ce65drgrimes#endif /* !_TALKD_H_ */
124