Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / games / hunt / huntd / talk_ctl.h
blob8e0cee2d233cc59533af83c0db3bd1a25c3a3093
1 /* $NetBSD: talk_ctl.h,v 1.6 2004/01/27 20:30:29 jsm Exp $ */
3 /*
4 * Copyright (c) 1983-2003, Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
11 * + Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * + Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * + Neither the name of the University of California, San Francisco nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/types.h>
35 #include <netinet/in.h>
37 #ifdef TALK_43
38 #include <protocols/talkd.h>
39 #else
41 #include <sys/socket.h>
43 #define NAME_SIZE 9
44 #define TTY_SIZE 16
45 #ifndef MAXHOSTNAMELEN
46 #define MAXHOSTNAMELEN 256
47 #endif
49 #define MAX_LIFE 60 /* max time daemon saves invitations */
50 /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
51 #define RING_WAIT 30 /* time to wait before refreshing invitation */
53 /* type values */
54 #define LEAVE_INVITE 0
55 #define LOOK_UP 1
56 #define DELETE 2
57 #define ANNOUNCE 3
59 /* answer values */
60 #define SUCCESS 0
61 #define NOT_HERE 1
62 #define FAILED 2
63 #define MACHINE_UNKNOWN 3
64 #define PERMISSION_DENIED 4
65 #define UNKNOWN_REQUEST 5
67 typedef struct ctl_response {
68 char type;
69 char answer;
70 int id_num;
71 struct sockaddr_in addr;
72 } CTL_RESPONSE;
74 typedef struct ctl_msg {
75 char type;
76 char l_name[NAME_SIZE];
77 char r_name[NAME_SIZE];
78 int id_num;
79 int pid;
80 char r_tty[TTY_SIZE];
81 struct sockaddr_in addr;
82 struct sockaddr_in ctl_addr;
83 } CTL_MSG;
84 #endif
86 #include <errno.h>
87 #ifdef LOG
88 #include <syslog.h>
89 #endif
91 extern struct sockaddr_in daemon_addr;
92 extern struct sockaddr_in ctl_addr;
93 extern struct sockaddr_in my_addr;
94 extern struct in_addr my_machine_addr;
95 extern struct in_addr his_machine_addr;
96 extern u_short daemon_port;
97 extern int ctl_sockt;
98 extern CTL_MSG msg;
100 #ifdef LOG
101 #define p_error(str) syslog(LOG_WARNING, "faketalk %s: %m", str)
102 #else
103 #define p_error(str) warn(str)
104 #endif
106 void ctl_transact(struct in_addr, CTL_MSG, int, CTL_RESPONSE *);