aboutsummaryrefslogtreecommitdiff
path: root/src/krb524/sendmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/krb524/sendmsg.c')
-rw-r--r--src/krb524/sendmsg.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/krb524/sendmsg.c b/src/krb524/sendmsg.c
index 77e8f3b..48b6be3 100644
--- a/src/krb524/sendmsg.c
+++ b/src/krb524/sendmsg.c
@@ -40,11 +40,16 @@
#include <sys/select.h>
#endif
+#if TARGET_OS_MAC
+#include <Kerberos/krb.h>
+#include <Kerberos/krb524.h>
+#else
#include <krb.h>
#include "krb524.h"
+#endif
/* For krb5_locate_kdc() */
-#include <k5-int.h>
+#include "k5-int.h"
/*
* krb524_sendto_kdc:
@@ -66,12 +71,17 @@ extern int krb5_max_skdc_timeout;
extern int krb5_skdc_timeout_shift;
extern int krb5_skdc_timeout_1;
+/* returns the local address of the socket used to connect to the KDC.
+ If you don't need this information, pass NULL for the last two parameters */
+
krb5_error_code
-krb524_sendto_kdc (context, message, realm, reply)
+krb524_sendto_kdc (context, message, realm, reply, local_addr, addrlen)
krb5_context context;
const krb5_data * message;
const krb5_data * realm;
krb5_data * reply;
+ struct sockaddr * local_addr;
+ int * addrlen;
{
register int timeout, host, i;
struct sockaddr *addr;
@@ -207,7 +217,7 @@ krb524_sendto_kdc (context, message, realm, reply)
sent = 1;
continue;
}
-
+
/* We might consider here verifying that the reply
came from one of the KDC's listed for that address type,
but that check can be fouled by some implementations of
@@ -215,6 +225,15 @@ krb524_sendto_kdc (context, message, realm, reply)
address, for example, if the KDC is on the same host
as the client. */
+ /* If the caller wants the local address of this socket
+ store it here */
+ if ((local_addr != NULL) && (addrlen != NULL) && (*addrlen > 0)) {
+ if (getsockname (socklist[host], local_addr, addrlen) == SOCKET_ERROR) {
+ /* no address to get... tell the caller we got nothing */
+ *addrlen = 0;
+ }
+ }
+
reply->length = cc;
retval = 0;
goto out;