Browse code

- sun fixes

Andrei Pelinescu-Onciul authored on 10/09/2002 11:21:44
Showing 1 changed files
... ...
@@ -5,9 +5,11 @@
5 5
  */
6 6
 
7 7
 
8
-#ifndef resolve_h
9
-#define resolve_h
8
+#ifndef __resolve_h
9
+#define __resolve_h
10 10
 
11
+#include <sys/types.h>
12
+#include <sys/socket.h>
11 13
 #include <netdb.h>
12 14
 #include <arpa/nameser.h>
13 15
 
... ...
@@ -212,7 +214,10 @@ struct hostent* sip_resolvehost(char* name, unsigned short* port);
212 214
 
213 215
 static inline struct hostent* resolvehost(const char* name)
214 216
 {
215
-	struct hostent* he;
217
+	static struct hostent* he=0;
218
+#ifdef __sun__
219
+	int err;
220
+#endif
216 221
 #ifdef DNS_IP_HACK
217 222
 	struct ip_addr* ip;
218 223
 	int len;
... ...
@@ -229,11 +234,21 @@ static inline struct hostent* resolvehost(const char* name)
229 234
 	}
230 235
 	
231 236
 #endif
232
-	he=gethostbyname(name); /*ipv4*/
237
+	/* ipv4 */
238
+#ifdef __sun__
239
+	if (he) freehostent(he);
240
+	he=getipnodebyname(name, AF_INET, 0, &err);
241
+#else
242
+	he=gethostbyname(name);
243
+#endif
233 244
 #ifdef USE_IPV6
234 245
 	if(he==0){
235 246
 		/*try ipv6*/
247
+	#ifdef __sun__
248
+		he=getipnodebyname(name, AF_INET6, 0, &err);
249
+	#else
236 250
 		he=gethostbyname2(name, AF_INET6);
251
+	#endif
237 252
 	}
238 253
 #endif
239 254
 	return he;