summaryrefslogtreecommitdiff
path: root/openbsd-compat/fake-rfc2553.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/fake-rfc2553.c')
-rw-r--r--openbsd-compat/fake-rfc2553.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/openbsd-compat/fake-rfc2553.c b/openbsd-compat/fake-rfc2553.c
index 096d9e092..d5a62975a 100644
--- a/openbsd-compat/fake-rfc2553.c
+++ b/openbsd-compat/fake-rfc2553.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2000-2003 Damien Miller. All rights reserved. 2 * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
3 * Copyright (C) 1999 WIDE Project. All rights reserved. 3 * Copyright (C) 1999 WIDE Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
@@ -13,7 +13,7 @@
13 * 3. Neither the name of the project nor the names of its contributors 13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software 14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission. 15 * without specific prior written permission.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -44,8 +44,8 @@
44#include <arpa/inet.h> 44#include <arpa/inet.h>
45 45
46#ifndef HAVE_GETNAMEINFO 46#ifndef HAVE_GETNAMEINFO
47int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, 47int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
48 size_t hostlen, char *serv, size_t servlen, int flags) 48 size_t hostlen, char *serv, size_t servlen, int flags)
49{ 49{
50 struct sockaddr_in *sin = (struct sockaddr_in *)sa; 50 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
51 struct hostent *hp; 51 struct hostent *hp;
@@ -67,11 +67,11 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
67 else 67 else
68 return (0); 68 return (0);
69 } else { 69 } else {
70 hp = gethostbyaddr((char *)&sin->sin_addr, 70 hp = gethostbyaddr((char *)&sin->sin_addr,
71 sizeof(struct in_addr), AF_INET); 71 sizeof(struct in_addr), AF_INET);
72 if (hp == NULL) 72 if (hp == NULL)
73 return (EAI_NODATA); 73 return (EAI_NODATA);
74 74
75 if (strlcpy(host, hp->h_name, hostlen) >= hostlen) 75 if (strlcpy(host, hp->h_name, hostlen) >= hostlen)
76 return (EAI_MEMORY); 76 return (EAI_MEMORY);
77 else 77 else
@@ -102,7 +102,7 @@ gai_strerror(int err)
102 default: 102 default:
103 return ("unknown/invalid error."); 103 return ("unknown/invalid error.");
104 } 104 }
105} 105}
106#endif /* !HAVE_GAI_STRERROR */ 106#endif /* !HAVE_GAI_STRERROR */
107 107
108#ifndef HAVE_FREEADDRINFO 108#ifndef HAVE_FREEADDRINFO
@@ -128,9 +128,9 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
128 ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); 128 ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in));
129 if (ai == NULL) 129 if (ai == NULL)
130 return (NULL); 130 return (NULL);
131 131
132 memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); 132 memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
133 133
134 ai->ai_addr = (struct sockaddr *)(ai + 1); 134 ai->ai_addr = (struct sockaddr *)(ai + 1);
135 /* XXX -- ssh doesn't use sa_len */ 135 /* XXX -- ssh doesn't use sa_len */
136 ai->ai_addrlen = sizeof(struct sockaddr_in); 136 ai->ai_addrlen = sizeof(struct sockaddr_in);
@@ -138,7 +138,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
138 138
139 ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; 139 ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
140 ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; 140 ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
141 141
142 /* XXX: the following is not generally correct, but does what we want */ 142 /* XXX: the following is not generally correct, but does what we want */
143 if (hints->ai_socktype) 143 if (hints->ai_socktype)
144 ai->ai_socktype = hints->ai_socktype; 144 ai->ai_socktype = hints->ai_socktype;
@@ -152,7 +152,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
152} 152}
153 153
154int 154int
155getaddrinfo(const char *hostname, const char *servname, 155getaddrinfo(const char *hostname, const char *servname,
156 const struct addrinfo *hints, struct addrinfo **res) 156 const struct addrinfo *hints, struct addrinfo **res)
157{ 157{
158 struct hostent *hp; 158 struct hostent *hp;
@@ -183,29 +183,29 @@ getaddrinfo(const char *hostname, const char *servname,
183 if (hostname && inet_aton(hostname, &in) != 0) 183 if (hostname && inet_aton(hostname, &in) != 0)
184 addr = in.s_addr; 184 addr = in.s_addr;
185 *res = malloc_ai(port, addr, hints); 185 *res = malloc_ai(port, addr, hints);
186 if (*res == NULL) 186 if (*res == NULL)
187 return (EAI_MEMORY); 187 return (EAI_MEMORY);
188 return (0); 188 return (0);
189 } 189 }
190 190
191 if (!hostname) { 191 if (!hostname) {
192 *res = malloc_ai(port, htonl(0x7f000001), hints); 192 *res = malloc_ai(port, htonl(0x7f000001), hints);
193 if (*res == NULL) 193 if (*res == NULL)
194 return (EAI_MEMORY); 194 return (EAI_MEMORY);
195 return (0); 195 return (0);
196 } 196 }
197 197
198 if (inet_aton(hostname, &in)) { 198 if (inet_aton(hostname, &in)) {
199 *res = malloc_ai(port, in.s_addr, hints); 199 *res = malloc_ai(port, in.s_addr, hints);
200 if (*res == NULL) 200 if (*res == NULL)
201 return (EAI_MEMORY); 201 return (EAI_MEMORY);
202 return (0); 202 return (0);
203 } 203 }
204 204
205 /* Don't try DNS if AI_NUMERICHOST is set */ 205 /* Don't try DNS if AI_NUMERICHOST is set */
206 if (hints && hints->ai_flags & AI_NUMERICHOST) 206 if (hints && hints->ai_flags & AI_NUMERICHOST)
207 return (EAI_NONAME); 207 return (EAI_NONAME);
208 208
209 hp = gethostbyname(hostname); 209 hp = gethostbyname(hostname);
210 if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { 210 if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
211 struct addrinfo *cur, *prev; 211 struct addrinfo *cur, *prev;
@@ -229,7 +229,7 @@ getaddrinfo(const char *hostname, const char *servname,
229 } 229 }
230 return (0); 230 return (0);
231 } 231 }
232 232
233 return (EAI_NODATA); 233 return (EAI_NODATA);
234} 234}
235#endif /* !HAVE_GETADDRINFO */ 235#endif /* !HAVE_GETADDRINFO */