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