Back to index

glibc  2.9
talkd.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1983, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *     @(#)talkd.h   8.1 (Berkeley) 6/2/93
00030  */
00031 
00032 #ifndef _PROTOCOLS_TALKD_H
00033 #define       _PROTOCOLS_TALKD_H 1
00034 
00035 /*
00036  * This describes the protocol used by the talk server and clients.
00037  *
00038  * The talk server acts a repository of invitations, responding to
00039  * requests by clients wishing to rendezvous for the purpose of
00040  * holding a conversation.  In normal operation, a client, the caller,
00041  * initiates a rendezvous by sending a CTL_MSG to the server of
00042  * type LOOK_UP.  This causes the server to search its invitation
00043  * tables to check if an invitation currently exists for the caller
00044  * (to speak to the callee specified in the message).  If the lookup
00045  * fails, the caller then sends an ANNOUNCE message causing the server
00046  * to broadcast an announcement on the callee's login ports requesting
00047  * contact.  When the callee responds, the local server uses the
00048  * recorded invitation to respond with the appropriate rendezvous
00049  * address and the caller and callee client programs establish a
00050  * stream connection through which the conversation takes place.
00051  */
00052 
00053 #include <sys/types.h>
00054 #include <sys/socket.h>
00055 
00056 /*
00057  * Client->server request message format.
00058  */
00059 typedef struct {
00060        u_char vers;         /* protocol version */
00061        u_char type;         /* request type, see below */
00062        u_char answer;              /* not used */
00063        u_char pad;
00064        u_int32_t id_num;    /* message id */
00065        struct osockaddr addr;             /* old (4.3) style */
00066        struct osockaddr ctl_addr;  /* old (4.3) style */
00067        int32_t       pid;          /* caller's process id */
00068 #define       NAME_SIZE     12
00069        char   l_name[NAME_SIZE];/* caller's name */
00070        char   r_name[NAME_SIZE];/* callee's name */
00071 #define       TTY_SIZE      16
00072        char   r_tty[TTY_SIZE];/* callee's tty name */
00073 } CTL_MSG;
00074 
00075 /*
00076  * Server->client response message format.
00077  */
00078 typedef struct {
00079        u_char vers;         /* protocol version */
00080        u_char type;         /* type of request message, see below */
00081        u_char answer;              /* response to request message, see below */
00082        u_char pad;
00083        u_int32_t id_num;    /* message id */
00084        struct osockaddr addr;      /* address for establishing conversation */
00085 } CTL_RESPONSE;
00086 
00087 #define       TALK_VERSION  1             /* protocol version */
00088 
00089 /* message type values */
00090 #define LEAVE_INVITE 0      /* leave invitation with server */
00091 #define LOOK_UP             1      /* check for invitation by callee */
00092 #define DELETE              2      /* delete invitation by caller */
00093 #define ANNOUNCE     3      /* announce invitation by caller */
00094 
00095 /* answer values */
00096 #define SUCCESS             0      /* operation completed properly */
00097 #define NOT_HERE     1      /* callee not logged in */
00098 #define FAILED              2      /* operation failed for unexplained reason */
00099 #define MACHINE_UNKNOWN     3      /* caller's machine name unknown */
00100 #define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
00101 #define UNKNOWN_REQUEST     5      /* request has invalid type value */
00102 #define       BADVERSION    6      /* request has invalid protocol version */
00103 #define       BADADDR              7      /* request has invalid addr value */
00104 #define       BADCTLADDR    8      /* request has invalid ctl_addr value */
00105 
00106 /*
00107  * Operational parameters.
00108  */
00109 #define MAX_LIFE     60     /* max time daemon saves invitations */
00110 /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
00111 #define RING_WAIT    30     /* time to wait before resending invitation */
00112 
00113 #endif /* protocols/talkd.h */