1 #pragma ident "%Z%%M% %I% %E% SMI"
5 * Copyright 2000 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
27 * Network code for Kerberos v5 KDC.
32 #ifdef HAVE_NETINET_IN_H
33 #include <sys/types.h>
34 #include <netinet/in.h>
35 #include <sys/socket.h>
37 #ifndef HAVE_INET_NTOP
39 inet_ntop (int family
, const void *address
, char *buf
, size_t bufsiz
)
45 p
= inet_ntoa (*(const struct in_addr
*)address
);
47 if (strlen (p
) >= bufsiz
)
56 const unsigned char *byte
= (const unsigned char *)
57 &((const struct in6_addr
*)address
)->s6_addr
;
58 sprintf (abuf
, "%x:%x:%x:%x:%x:%x:%x:%x",
59 byte
[0] * 256 + byte
[1],
60 byte
[2] * 256 + byte
[3],
61 byte
[4] * 256 + byte
[5],
62 byte
[6] * 256 + byte
[7],
63 byte
[8] * 256 + byte
[9],
64 byte
[10] * 256 + byte
[11],
65 byte
[12] * 256 + byte
[13],
66 byte
[14] * 256 + byte
[15]);
70 #endif /* KRB5_USE_INET6 */
79 sockaddr2p (const struct sockaddr
*s
, char *buf
, size_t bufsiz
, int *port_p
)
83 switch (s
->sa_family
) {
85 addr
= &((const struct sockaddr_in
*)s
)->sin_addr
;
86 port
= ((const struct sockaddr_in
*)s
)->sin_port
;
90 addr
= &((const struct sockaddr_in6
*)s
)->sin6_addr
;
91 port
= ((const struct sockaddr_in6
*)s
)->sin6_port
;
101 if (inet_ntop (s
->sa_family
, addr
, buf
, bufsiz
) == 0 && bufsiz
>= 2)