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) always attach textual scopeid (fe80::1%lo0), if
41 * sin6_scope_id is filled - standardization status?
42 * XXX breaks backward compat for code that expects no scopeid.
43 * beware on merge.
44 */
45
46#include <sys/cdefs.h>
47__FBSDID("$FreeBSD: head/lib/libc/net/getnameinfo.c 99252 2002-07-02 11:05:31Z ume $");
48
49#include <sys/types.h>
50#include <sys/socket.h>
51#include <net/if.h>
52#include <netinet/in.h>
53#include <arpa/inet.h>
54#include <arpa/nameser.h>
55#include <netdb.h>

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

305 == NULL)
306 return ENI_SYSTEM;
307
308 numaddrlen = strlen(numaddr);
309 if (numaddrlen + 1 > hostlen) /* don't forget terminator */
310 return ENI_MEMORY;
311 strcpy(host, numaddr);
312
313 if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
314 char zonebuf[MAXHOSTNAMELEN];
315 int zonelen;
316
317 /* ip6_sa2str never fails */
318 zonelen = ip6_sa2str(
319 (const struct sockaddr_in6 *)(const void *)sa,
320 zonebuf, sizeof(zonebuf), flags);
321 if (zonelen < 0)
322 return EAI_MEMORY;
323 if (zonelen + 1 + numaddrlen + 1 > hostlen)
324 return ENI_MEMORY;
325 /* construct <numeric-addr><delim><scopeid> */
326 memcpy(host + numaddrlen + 1, zonebuf,
327 (size_t)zonelen);
328 host[numaddrlen] = SCOPE_DELIMITER;
329 host[numaddrlen + 1 + zonelen] = '\0';
330 }
331
332 return 0;
333}
334
335/* ARGSUSED */
336static int
337ip6_sa2str(sa6, buf, bufsiz, flags)
338 const struct sockaddr_in6 *sa6;

--- 26 unchanged lines hidden ---