]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/ctl.c
RCS Id Police.
[bsdgames-darwin.git] / hunt / huntd / ctl.c
1 /* $NetBSD: ctl.c,v 1.2 1997/10/10 16:32:54 lukem Exp $ */
2 /*
3 * Copyright (c) 1983 Regents of the University of California.
4 * All rights reserved. The Berkeley software License Agreement
5 * specifies the terms and conditions for redistribution.
6 */
7
8 #include "bsd.h"
9
10 #if defined(TALK_43) || defined(TALK_42)
11
12 #include <sys/cdefs.h>
13 #ifndef lint
14 #if 0
15 static char sccsid[] = "@(#)ctl.c 5.2 (Berkeley) 3/13/86";
16 #else
17 __RCSID("$NetBSD: ctl.c,v 1.2 1997/10/10 16:32:54 lukem Exp $");
18 #endif
19 #endif /* not lint */
20
21 /*
22 * This file handles haggling with the various talk daemons to
23 * get a socket to talk to. sockt is opened and connected in
24 * the progress
25 */
26
27 #include "hunt.h"
28 #include "talk_ctl.h"
29
30 struct sockaddr_in daemon_addr = { AF_INET };
31 struct sockaddr_in ctl_addr = { AF_INET };
32
33 /* inet addresses of the two machines */
34 struct in_addr my_machine_addr;
35 struct in_addr his_machine_addr;
36
37 u_short daemon_port; /* port number of the talk daemon */
38
39 int ctl_sockt;
40
41 CTL_MSG msg;
42
43 /* open the ctl socket */
44 void
45 open_ctl()
46 {
47 int length;
48
49 ctl_addr.sin_port = 0;
50 ctl_addr.sin_addr = my_machine_addr;
51 ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0);
52 if (ctl_sockt <= 0)
53 p_error("Bad socket");
54 if (bind(ctl_sockt, (struct sockaddr *)&ctl_addr, sizeof(ctl_addr)) != 0)
55 p_error("Couldn't bind to control socket");
56 length = sizeof(ctl_addr);
57 if (getsockname(ctl_sockt, (struct sockaddr *) &ctl_addr, &length) < 0)
58 p_error("Bad address for ctl socket");
59 }
60 #endif