inet_cidr_ntop.c (165254) | inet_cidr_ntop.c (170242) |
---|---|
1/* 2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (c) 1998,1999 by Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and 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 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18#if defined(LIBC_SCCS) && !defined(lint) | 1/* 2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (c) 1998,1999 by Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and 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 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18#if defined(LIBC_SCCS) && !defined(lint) |
19static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.1.2.1.8.4 2006/10/11 02:32:50 marka Exp $"; | 19static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.4.18.3 2006/10/11 02:32:47 marka Exp $"; |
20#endif 21 22#include "port_before.h" 23 24#include <sys/types.h> 25#include <sys/socket.h> 26#include <netinet/in.h> 27#include <arpa/nameser.h> --- 12 unchanged lines hidden (view full) --- 40# define SPRINTF(x) ((size_t)sprintf x) 41#endif 42 43static char * 44inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size); 45static char * 46inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size); 47 | 20#endif 21 22#include "port_before.h" 23 24#include <sys/types.h> 25#include <sys/socket.h> 26#include <netinet/in.h> 27#include <arpa/nameser.h> --- 12 unchanged lines hidden (view full) --- 40# define SPRINTF(x) ((size_t)sprintf x) 41#endif 42 43static char * 44inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size); 45static char * 46inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size); 47 |
48/* | 48/*% |
49 * char * 50 * inet_cidr_ntop(af, src, bits, dst, size) 51 * convert network address from network to presentation format. 52 * "src"'s size is determined from its "af". 53 * return: 54 * pointer to dst, or NULL if an error occurred (check errno). 55 * note: 56 * 192.5.5.1/28 has a nonzero host part, which means it isn't a network --- 30 unchanged lines hidden (view full) --- 87 *dst++ = '.'; 88 *dst = '\0'; 89 } 90 size -= (size_t)(dst - t); 91 } 92 return (dst - odst); 93} 94 | 49 * char * 50 * inet_cidr_ntop(af, src, bits, dst, size) 51 * convert network address from network to presentation format. 52 * "src"'s size is determined from its "af". 53 * return: 54 * pointer to dst, or NULL if an error occurred (check errno). 55 * note: 56 * 192.5.5.1/28 has a nonzero host part, which means it isn't a network --- 30 unchanged lines hidden (view full) --- 87 *dst++ = '.'; 88 *dst = '\0'; 89 } 90 size -= (size_t)(dst - t); 91 } 92 return (dst - odst); 93} 94 |
95/* | 95/*% |
96 * static char * 97 * inet_cidr_ntop_ipv4(src, bits, dst, size) 98 * convert IPv4 network address from network to presentation format. 99 * "src"'s size is determined from its "af". 100 * return: 101 * pointer to dst, or NULL if an error occurred (check errno). 102 * note: 103 * network byte order assumed. this means 192.5.5.240/28 has --- 150 unchanged lines hidden (view full) --- 254 */ 255 if ((size_t)(tp - tmp) > size) { 256 errno = EMSGSIZE; 257 return (NULL); 258 } 259 strcpy(dst, tmp); 260 return (dst); 261} | 96 * static char * 97 * inet_cidr_ntop_ipv4(src, bits, dst, size) 98 * convert IPv4 network address from network to presentation format. 99 * "src"'s size is determined from its "af". 100 * return: 101 * pointer to dst, or NULL if an error occurred (check errno). 102 * note: 103 * network byte order assumed. this means 192.5.5.240/28 has --- 150 unchanged lines hidden (view full) --- 254 */ 255 if ((size_t)(tp - tmp) > size) { 256 errno = EMSGSIZE; 257 return (NULL); 258 } 259 strcpy(dst, tmp); 260 return (dst); 261} |
262 263/*! \file */ |
|