1*a8c9c98eSdholland /* $NetBSD: talkd.h,v 1.11 2016/01/22 23:11:50 dholland Exp $ */ 24d2cbfceScgd 361f28255Scgd /* 4a141abe4Sperry * Copyright (c) 1983, 1993 5a141abe4Sperry * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * Redistribution and use in source and binary forms, with or without 861f28255Scgd * modification, are permitted provided that the following conditions 961f28255Scgd * are met: 1061f28255Scgd * 1. Redistributions of source code must retain the above copyright 1161f28255Scgd * notice, this list of conditions and the following disclaimer. 1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1361f28255Scgd * notice, this list of conditions and the following disclaimer in the 1461f28255Scgd * documentation and/or other materials provided with the distribution. 15039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 1661f28255Scgd * may be used to endorse or promote products derived from this software 1761f28255Scgd * without specific prior written permission. 1861f28255Scgd * 1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2961f28255Scgd * SUCH DAMAGE. 3061f28255Scgd * 31a141abe4Sperry * @(#)talkd.h 8.1 (Berkeley) 6/2/93 3261f28255Scgd */ 3361f28255Scgd 343b3774fcSperry #ifndef _PROTOCOLS_TALKD_H_ 353b3774fcSperry #define _PROTOCOLS_TALKD_H_ 3661f28255Scgd 37*a8c9c98eSdholland #include <stdint.h> 38*a8c9c98eSdholland 3961f28255Scgd /* 4061f28255Scgd * This describes the protocol used by the talk server and clients. 4161f28255Scgd * 4261f28255Scgd * The talk server acts a repository of invitations, responding to 4361f28255Scgd * requests by clients wishing to rendezvous for the purpose of 4461f28255Scgd * holding a conversation. In normal operation, a client, the caller, 4561f28255Scgd * initiates a rendezvous by sending a CTL_MSG to the server of 4661f28255Scgd * type LOOK_UP. This causes the server to search its invitation 4761f28255Scgd * tables to check if an invitation currently exists for the caller 4861f28255Scgd * (to speak to the callee specified in the message). If the lookup 4961f28255Scgd * fails, the caller then sends an ANNOUNCE message causing the server 5061f28255Scgd * to broadcast an announcement on the callee's login ports requesting 5161f28255Scgd * contact. When the callee responds, the local server uses the 5261f28255Scgd * recorded invitation to respond with the appropriate rendezvous 5361f28255Scgd * address and the caller and callee client programs establish a 5461f28255Scgd * stream connection through which the conversation takes place. 5561f28255Scgd */ 5661f28255Scgd 5761f28255Scgd /* 58c4445bc7Schristos * 4.3 compat sockaddr 59c4445bc7Schristos */ 60c4445bc7Schristos struct talkd_sockaddr { 615f65228bSperry uint16_t sa_family; /* address family */ 62c4445bc7Schristos char sa_data[14]; /* up to 14 bytes of direct address */ 63c4445bc7Schristos }; 64c4445bc7Schristos 65c4445bc7Schristos /* 6661f28255Scgd * Client->server request message format. 6761f28255Scgd */ 6861f28255Scgd typedef struct { 69*a8c9c98eSdholland unsigned char vers; /* protocol version */ 70*a8c9c98eSdholland unsigned char type; /* request type, see below */ 71*a8c9c98eSdholland unsigned char answer; /* not used */ 72*a8c9c98eSdholland unsigned char pad; 735f65228bSperry uint32_t id_num; /* message id */ 74c4445bc7Schristos struct talkd_sockaddr addr; /* old (4.3) style */ 75c4445bc7Schristos struct talkd_sockaddr ctl_addr;/* old (4.3) style */ 760dcf70c8Scgd int32_t pid; /* caller's process id */ 7761f28255Scgd #define NAME_SIZE 12 7861f28255Scgd char l_name[NAME_SIZE]; /* caller's name */ 7961f28255Scgd char r_name[NAME_SIZE]; /* callee's name */ 8061f28255Scgd #define TTY_SIZE 16 8161f28255Scgd char r_tty[TTY_SIZE]; /* callee's tty name */ 8261f28255Scgd } CTL_MSG; 8361f28255Scgd 8461f28255Scgd /* 8561f28255Scgd * Server->client response message format. 8661f28255Scgd */ 8761f28255Scgd typedef struct { 88*a8c9c98eSdholland unsigned char vers; /* protocol version */ 89*a8c9c98eSdholland unsigned char type; /* type of request message, see below */ 90*a8c9c98eSdholland unsigned char answer; /* respose to request message, see below */ 91*a8c9c98eSdholland unsigned char pad; 925f65228bSperry uint32_t id_num; /* message id */ 93c4445bc7Schristos struct talkd_sockaddr addr; /* address for establishing conversation */ 9461f28255Scgd } CTL_RESPONSE; 9561f28255Scgd 9661f28255Scgd #define TALK_VERSION 1 /* protocol version */ 9761f28255Scgd 9861f28255Scgd /* message type values */ 9961f28255Scgd #define LEAVE_INVITE 0 /* leave invitation with server */ 10061f28255Scgd #define LOOK_UP 1 /* check for invitation by callee */ 10161f28255Scgd #define DELETE 2 /* delete invitation by caller */ 10261f28255Scgd #define ANNOUNCE 3 /* announce invitation by caller */ 10361f28255Scgd 10461f28255Scgd /* answer values */ 10561f28255Scgd #define SUCCESS 0 /* operation completed properly */ 10661f28255Scgd #define NOT_HERE 1 /* callee not logged in */ 10761f28255Scgd #define FAILED 2 /* operation failed for unexplained reason */ 10861f28255Scgd #define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ 10961f28255Scgd #define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ 11061f28255Scgd #define UNKNOWN_REQUEST 5 /* request has invalid type value */ 11161f28255Scgd #define BADVERSION 6 /* request has invalid protocol version */ 11261f28255Scgd #define BADADDR 7 /* request has invalid addr value */ 11361f28255Scgd #define BADCTLADDR 8 /* request has invalid ctl_addr value */ 11461f28255Scgd 11561f28255Scgd /* 11661f28255Scgd * Operational parameters. 11761f28255Scgd */ 11861f28255Scgd #define MAX_LIFE 60 /* max time daemon saves invitations */ 11961f28255Scgd /* RING_WAIT should be 10's of seconds less than MAX_LIFE */ 12061f28255Scgd #define RING_WAIT 30 /* time to wait before resending invitation */ 12161f28255Scgd 1223b3774fcSperry #endif /* !_PROTOCOLS_TALKD_H_ */ 123