Deleted Added
full compact
inet_ntop.c (193149) inet_ntop.c (204619)
1/*
1/*
2 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1996-2001 Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/*! \file */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21static char rcsid[] =
3 * Copyright (C) 1996-2001 Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/*! \file */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21static char rcsid[] =
22 "$Id: inet_ntop.c,v 1.19 2007/06/19 23:47:17 tbox Exp $";
22 "$Id: inet_ntop.c,v 1.19.332.2 2009/07/18 23:47:25 tbox Exp $";
23#endif /* LIBC_SCCS and not lint */
24
25#include <config.h>
26
27#include <errno.h>
28#include <stdio.h>
29#include <string.h>
30

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

47 size_t size);
48#endif
49
50/*! char *
51 * isc_net_ntop(af, src, dst, size)
52 * convert a network format address to presentation format.
53 * \return
54 * pointer to presentation format address (`dst'), or NULL (see errno).
23#endif /* LIBC_SCCS and not lint */
24
25#include <config.h>
26
27#include <errno.h>
28#include <stdio.h>
29#include <string.h>
30

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

47 size_t size);
48#endif
49
50/*! char *
51 * isc_net_ntop(af, src, dst, size)
52 * convert a network format address to presentation format.
53 * \return
54 * pointer to presentation format address (`dst'), or NULL (see errno).
55 * \author
55 * \author
56 * Paul Vixie, 1996.
57 */
58const char *
59isc_net_ntop(int af, const void *src, char *dst, size_t size)
60{
61 switch (af) {
62 case AF_INET:
63 return (inet_ntop4(src, dst, size));

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

164 if (i == best.base)
165 *tp++ = ':';
166 continue;
167 }
168 /* Are we following an initial run of 0x00s or any real hex? */
169 if (i != 0)
170 *tp++ = ':';
171 /* Is this address an encapsulated IPv4? */
56 * Paul Vixie, 1996.
57 */
58const char *
59isc_net_ntop(int af, const void *src, char *dst, size_t size)
60{
61 switch (af) {
62 case AF_INET:
63 return (inet_ntop4(src, dst, size));

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

164 if (i == best.base)
165 *tp++ = ':';
166 continue;
167 }
168 /* Are we following an initial run of 0x00s or any real hex? */
169 if (i != 0)
170 *tp++ = ':';
171 /* Is this address an encapsulated IPv4? */
172 if (i == 6 && best.base == 0 &&
173 (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
172 if (i == 6 && best.base == 0 && (best.len == 6 ||
173 (best.len == 7 && words[7] != 0x0001) ||
174 (best.len == 5 && words[5] == 0xffff))) {
174 if (!inet_ntop4(src+12, tp,
175 sizeof(tmp) - (tp - tmp)))
176 return (NULL);
177 tp += strlen(tp);
178 break;
179 }
180 tp += sprintf(tp, "%x", words[i]);
181 }

--- 17 unchanged lines hidden ---
175 if (!inet_ntop4(src+12, tp,
176 sizeof(tmp) - (tp - tmp)))
177 return (NULL);
178 tp += strlen(tp);
179 break;
180 }
181 tp += sprintf(tp, "%x", words[i]);
182 }

--- 17 unchanged lines hidden ---