Deleted Added
sdiff udiff text old ( 92986 ) new ( 99252 )
full compact
1/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
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

--- 23 unchanged lines hidden (view full) ---

32/*
33 * Issues to be discussed:
34 * - Thread safe-ness must be checked
35 * - RFC2553 says that we should raise error on short buffer. X/Open says
36 * we need to truncate the result. We obey RFC2553 (and X/Open should be
37 * modified). ipngwg rough consensus seems to follow RFC2553.
38 * - What is "local" in NI_FQDN?
39 * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
40 * - (KAME extension) NI_WITHSCOPEID when called with global address,
41 * and sin6_scope_id filled
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/lib/libc/net/getnameinfo.c 92986 2002-03-22 21:53:29Z obrien $");
46
47#include <sys/types.h>
48#include <sys/socket.h>
49#include <net/if.h>
50#include <netinet/in.h>
51#include <arpa/inet.h>
52#include <arpa/nameser.h>
53#include <netdb.h>

--- 249 unchanged lines hidden (view full) ---

303 == NULL)
304 return ENI_SYSTEM;
305
306 numaddrlen = strlen(numaddr);
307 if (numaddrlen + 1 > hostlen) /* don't forget terminator */
308 return ENI_MEMORY;
309 strcpy(host, numaddr);
310
311#ifdef NI_WITHSCOPEID
312 if (
313#ifdef DONT_OPAQUE_SCOPEID
314 (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
315 IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
316#endif
317 ((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
318#ifndef ALWAYS_WITHSCOPE
319 if (flags & NI_WITHSCOPEID)
320#endif /* !ALWAYS_WITHSCOPE */
321 {
322 char scopebuf[MAXHOSTNAMELEN];
323 int scopelen;
324
325 /* ip6_sa2str never fails */
326 scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa,
327 scopebuf, sizeof(scopebuf),
328 flags);
329 if (scopelen + 1 + numaddrlen + 1 > hostlen)
330 return ENI_MEMORY;
331 /*
332 * construct <numeric-addr><delim><scopeid>
333 */
334 memcpy(host + numaddrlen + 1, scopebuf,
335 scopelen);
336 host[numaddrlen] = SCOPE_DELIMITER;
337 host[numaddrlen + 1 + scopelen] = '\0';
338 }
339 }
340#endif /* NI_WITHSCOPEID */
341
342 return 0;
343}
344
345/* ARGSUSED */
346static int
347ip6_sa2str(sa6, buf, bufsiz, flags)
348 const struct sockaddr_in6 *sa6;

--- 26 unchanged lines hidden ---