annotate src/protocols/zephyr/ZInit.c @ 12243:d3cb077caf3e

[gaim-migrate @ 14545] HIG-ify some protocol actions. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 28 Nov 2005 01:59:29 +0000
parents 519dc2186438
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* This file is part of the Project Athena Zephyr Notification System.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * It contains source for the ZInitialize function.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Created by: Robert French
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * For copying and distribution information, see the file
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * "mit-copyright.h".
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
11 #ifdef ZEPHYR_USES_KERBEROS
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
12 #ifdef WIN32
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
13
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
14 #else
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
15 #include <krb_err.h>
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
16 #endif
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
17 #endif
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
18
8792
43d6c08d7e96 [gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents: 2419
diff changeset
19 #include "internal.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
21 #ifdef WIN32
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
22 #include <winsock2.h>
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
23 #else
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include <sys/socket.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
27
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
28 #ifndef INADDR_NONE
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
29 #define INADDR_NONE 0xffffffff
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
30 #endif
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
31
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 Code_t ZInitialize()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 struct servent *hmserv;
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
35 struct hostent *hostent;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
36 char addr[4], hostname[MAXHOSTNAMELEN];
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
37 struct in_addr servaddr;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
38 struct sockaddr_in sin;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11105
diff changeset
39 int s;
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11105
diff changeset
40 socklen_t sinsize = sizeof(sin);
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
41 Code_t code;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
42 ZNotice_t notice;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #ifdef ZEPHYR_USES_KERBEROS
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
44 char *krealm = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 int krbval;
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
46 char d1[ANAME_SZ], d2[INST_SZ];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
48 /* initialize_krb_error_table(); */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 initialize_zeph_error_table();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 (void) memset((char *)&__HM_addr, 0, sizeof(__HM_addr));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 __HM_addr.sin_family = AF_INET;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 /* Set up local loopback address for HostManager */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 addr[0] = 127;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 addr[1] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 addr[2] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 addr[3] = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 hmserv = (struct servent *)getservbyname(HM_SVCNAME, "udp");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 __HM_addr.sin_port = (hmserv) ? hmserv->s_port : HM_SVC_FALLBACK;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 (void) memcpy((char *)&__HM_addr.sin_addr, addr, 4);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 __HM_set = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
70 /* Initialize the input queue */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
71 __Q_Tail = NULL;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
72 __Q_Head = NULL;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
73
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
74 /* if the application is a server, there might not be a zhm. The
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
75 code will fall back to something which might not be "right",
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
76 but this is is ok, since none of the servers call krb_rd_req. */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
77
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
78 servaddr.s_addr = INADDR_NONE;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
79 if (! __Zephyr_server) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
80 if ((code = ZOpenPort(NULL)) != ZERR_NONE)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
81 return(code);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
82
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
83 if ((code = ZhmStat(NULL, &notice)) != ZERR_NONE)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
84 return(code);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
85
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
86 ZClosePort();
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
87
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
88 /* the first field, which is NUL-terminated, is the server name.
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
89 If this code ever support a multiplexing zhm, this will have to
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
90 be made smarter, and probably per-message */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
91
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 #ifdef ZEPHYR_USES_KERBEROS
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
93 krealm = krb_realmofhost(notice.z_message);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
94 #endif
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
95 hostent = gethostbyname(notice.z_message);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
96 if (hostent && hostent->h_addrtype == AF_INET)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
97 memcpy(&servaddr, hostent->h_addr, sizeof(servaddr));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
98
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
99 ZFreeNotice(&notice);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
100 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
101
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
102 #ifdef ZEPHYR_USES_KERBEROS
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
103 if (krealm) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
104 strcpy(__Zephyr_realm, krealm);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
105 } else if ((krb_get_tf_fullname(TKT_FILE, d1, d2, __Zephyr_realm)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
106 != KSUCCESS) &&
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
107 ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 return (krbval);
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
109 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
110 #else
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
111 strcpy(__Zephyr_realm, "local-realm");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
114 __My_addr.s_addr = INADDR_NONE;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
115 if (servaddr.s_addr != INADDR_NONE) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
116 /* Try to get the local interface address by connecting a UDP
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
117 * socket to the server address and getting the local address.
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
118 * Some broken operating systems (e.g. Solaris 2.0-2.5) yield
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
119 * INADDR_ANY (zero), so we have to check for that. */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
120 s = socket(AF_INET, SOCK_DGRAM, 0);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
121 if (s != -1) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
122 memset(&sin, 0, sizeof(sin));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
123 sin.sin_family = AF_INET;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
124 memcpy(&sin.sin_addr, &servaddr, sizeof(servaddr));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
125 sin.sin_port = HM_SRV_SVC_FALLBACK;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
126 if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) == 0
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
127 && getsockname(s, (struct sockaddr *) &sin, &sinsize) == 0
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
128 && sin.sin_addr.s_addr != 0)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
129 memcpy(&__My_addr, &sin.sin_addr, sizeof(__My_addr));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
130 close(s);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
131 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
132 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
133 if (__My_addr.s_addr == INADDR_NONE) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
134 /* We couldn't figure out the local interface address by the
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
135 * above method. Try by resolving the local hostname. (This
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
136 * is a pretty broken thing to do, and unfortunately what we
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
137 * always do on server machines.) */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
138 if (gethostname(hostname, sizeof(hostname)) == 0) {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
139 hostent = gethostbyname(hostname);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
140 if (hostent && hostent->h_addrtype == AF_INET)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
141 memcpy(&__My_addr, hostent->h_addr, sizeof(__My_addr));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
142 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
143 }
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
144 /* If the above methods failed, zero out __My_addr so things will
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
145 * sort of kind of work. */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
146 if (__My_addr.s_addr == INADDR_NONE)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
147 __My_addr.s_addr = 0;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
148
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 /* Get the sender so we can cache it */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 (void) ZGetSender();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 }
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
154