From: Ken Raeburn Date: Mon, 8 Jul 2002 19:48:36 +0000 (+0000) Subject: Add hooks to optionally report local address used when contacting a KDC-like X-Git-Tag: krb5-1.3-alpha1~604 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e30be15aa7fef3e9d02334670b6f4d34a8e4380d;p=krb5.git Add hooks to optionally report local address used when contacting a KDC-like service via UDP. Currently unused, this will eventually be used for MacOS support for krb524. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14615 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/ChangeLog b/src/include/ChangeLog index f42d22ab2..8b82ec97d 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,11 @@ +2002-07-07 Ken Raeburn + + * k5-int.h: Always include socket support headers; don't check + NEED_SOCKETS. + (krb5int_sendto_udp): Update prototype. + (struct _krb5int_access): Update sendto_udp field declaracion to + match krb5int_sendto_udp. + 2002-07-05 Ken Raeburn * port-sockets.h (SOCKET_WRITEV) [!_WIN32]: Use TMP after setting diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 8227c5285..3e9ac4cf3 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -175,7 +175,7 @@ typedef unsigned char u_char; #include #include "krb5.h" -#ifdef NEED_SOCKETS +#if 1 /* def NEED_SOCKETS */ #include "port-sockets.h" #include "socket-utils.h" #else @@ -468,7 +468,8 @@ krb5_error_code krb5_unlock_file (krb5_context, int); krb5_error_code krb5_sendto_kdc (krb5_context, const krb5_data *, const krb5_data *, krb5_data *, int, int); krb5_error_code krb5int_sendto_udp (krb5_context, const krb5_data *, - const struct addrlist *, krb5_data *); + const struct addrlist *, krb5_data *, + struct sockaddr *, socklen_t *); krb5_error_code krb5int_sendto_tcp (krb5_context context, const krb5_data *, const struct addrlist *, krb5_data *); krb5_error_code krb5_get_krbhst (krb5_context, const krb5_data *, char *** ); @@ -1571,7 +1572,8 @@ typedef struct _krb5int_access { unsigned int icount, const krb5_data *input, krb5_data *output); krb5_error_code (*sendto_udp) (krb5_context, const krb5_data *msg, - const struct addrlist *, krb5_data *reply); + const struct addrlist *, krb5_data *reply, + struct sockaddr *, socklen_t *); } krb5int_access; #define KRB5INT_ACCESS_VERSION \ diff --git a/src/krb524/ChangeLog b/src/krb524/ChangeLog index 93585d216..c86844a91 100644 --- a/src/krb524/ChangeLog +++ b/src/krb524/ChangeLog @@ -1,3 +1,8 @@ +2002-07-07 Ken Raeburn + + * sendmsg.c (krb524_sendto_kdc): Update sendto_udp calling + sequence; pass 0 for now. + 2002-06-14 Tom Yu * krb524.h: Change multiple-inclusion test macro to not stomp on diff --git a/src/krb524/sendmsg.c b/src/krb524/sendmsg.c index ef6e996dc..879676b66 100644 --- a/src/krb524/sendmsg.c +++ b/src/krb524/sendmsg.c @@ -108,7 +108,7 @@ krb524_sendto_kdc (context, message, realm, reply) if (al.naddrs == 0) return KRB5_REALM_UNKNOWN; - retval = internals.sendto_udp (context, message, &al, reply); + retval = internals.sendto_udp (context, message, &al, reply, 0, 0); internals.free_addrlist (&al); return retval; } diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 77aacb761..5407c97f4 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +2002-07-08 Ken Raeburn + + * sendto_kdc.c (krb5int_sendto_udp): Accept new args for optional + location to store local address used to contact server. + (krb5_sendto_kdc): Update call to pass 0. + 2002-07-05 Ken Raeburn * sendto_kdc.c (service_tcp_fd): sockerrlen should have type diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index bd05fc576..2d64ac3e3 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -108,7 +108,8 @@ krb5_sendto_kdc (context, message, realm, reply, use_master, tcp_only) && message->length < 1500 && ! krb5_locate_kdc(context, realm, &addrs, use_master, SOCK_DGRAM)) { if (addrs.naddrs > 0) { - retval = krb5int_sendto_udp (context, message, &addrs, reply); + retval = krb5int_sendto_udp (context, message, &addrs, reply, + 0, 0); krb5int_free_addrlist (&addrs); if (retval == 0) return 0; @@ -173,7 +174,8 @@ static void print_fdsets (FILE *, fd_set *, fd_set *, fd_set *, int); krb5_error_code krb5int_sendto_udp (krb5_context context, const krb5_data *message, - const struct addrlist *addrs, krb5_data *reply) + const struct addrlist *addrs, krb5_data *reply, + struct sockaddr *localaddr, socklen_t *localaddrlen) { int host, i; unsigned int timeout; @@ -323,6 +325,15 @@ krb5int_sendto_udp (krb5_context context, const krb5_data *message, reply->length = cc; retval = 0; dfprintf((stderr, "got answer on fd %d\n", socklist[host])); + if (localaddr != 0 && localaddrlen != 0 && *localaddrlen > 0) { + if (getsockname(socklist[host], localaddr, localaddrlen) == SOCKET_ERROR) { + /* Don't report it, just go on. */ +#ifdef DEBUG + dperror("getsockname"); +#endif + *localaddrlen = 0; + } + } goto out; } else if (nready == 0) { /* timeout */