svn commit: lorikeet r477 - in trunk/heimdal/lib/krb5: .
abartlet at samba.org
abartlet at samba.org
Wed Sep 28 22:27:50 GMT 2005
Author: abartlet
Date: 2005-09-28 22:27:50 +0000 (Wed, 28 Sep 2005)
New Revision: 477
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=477
Log:
Merge send and recive hooks from Samba4.
Andrew Bartlett
Modified:
trunk/heimdal/lib/krb5/context.c
trunk/heimdal/lib/krb5/send_to_kdc.c
Changeset:
Modified: trunk/heimdal/lib/krb5/context.c
===================================================================
--- trunk/heimdal/lib/krb5/context.c 2005-09-21 22:56:18 UTC (rev 476)
+++ trunk/heimdal/lib/krb5/context.c 2005-09-28 22:27:50 UTC (rev 477)
@@ -263,6 +263,7 @@
krb5_closelog(context, context->warn_dest);
krb5_set_extra_addresses(context, NULL);
krb5_set_ignore_addresses(context, NULL);
+ free(context->send_and_recv);
if (context->mutex != NULL) {
HEIMDAL_MUTEX_destroy(context->mutex);
free(context->mutex);
Modified: trunk/heimdal/lib/krb5/send_to_kdc.c
===================================================================
--- trunk/heimdal/lib/krb5/send_to_kdc.c 2005-09-21 22:56:18 UTC (rev 476)
+++ trunk/heimdal/lib/krb5/send_to_kdc.c 2005-09-28 22:27:50 UTC (rev 477)
@@ -35,6 +35,30 @@
RCSID("$Id: send_to_kdc.c,v 1.56 2005/06/17 04:33:11 lha Exp $");
+struct send_and_recv {
+ krb5_send_and_recv_func_t func;
+ krb5_send_and_recv_close_func_t close;
+ void *data;
+};
+
+krb5_error_code KRB5_LIB_FUNCTION
+krb5_set_send_recv_func(krb5_context context,
+ krb5_send_and_recv_func_t func,
+ krb5_send_and_recv_close_func_t close_fn,
+ void *data)
+{
+ free(context->send_and_recv);
+ context->send_and_recv = malloc(sizeof(*context->send_and_recv));
+ if (!context->send_and_recv) {
+ return ENOMEM;
+ }
+ context->send_and_recv->func = func;
+ context->send_and_recv->close = close_fn;
+ context->send_and_recv->data = data;
+ return 0;
+}
+
+
/*
* send the data in `req' on the socket `fd' (which is datagram iff udp)
* waiting `tmout' for a reply and returning the reply in `rep'.
@@ -329,11 +353,27 @@
while (krb5_krbhst_next(context, handle, &hi) == 0) {
struct addrinfo *ai, *a;
+ if (context->send_and_recv) {
+ ret = context->send_and_recv->func(context,
+ context->send_and_recv->data,
+ hi, send_data, receive);
+ if (ret) {
+ continue;
+ } else if (receive->length != 0) {
+ return 0;
+ } else {
+ continue;
+ }
+ }
+
if(hi->proto == KRB5_KRBHST_HTTP && context->http_proxy) {
- if (send_via_proxy (context, hi, send_data, receive))
+ if (send_via_proxy (context, hi, send_data, receive)) {
+ /* Try again, with next host */
continue;
- else
- goto out;
+ } else {
+ /* Success */
+ return 0;
+ }
}
ret = krb5_krbhst_get_addrinfo(context, hi, &ai);
@@ -363,16 +403,15 @@
break;
}
close (fd);
- if(ret == 0 && receive->length != 0)
- goto out;
+ if(ret == 0 && receive->length != 0) {
+ return 0;
+ }
}
}
krb5_krbhst_reset(context, handle);
}
krb5_clear_error_string (context);
- ret = KRB5_KDC_UNREACH;
-out:
- return ret;
+ return KRB5_KDC_UNREACH;
}
krb5_error_code KRB5_LIB_FUNCTION
More information about the samba-cvs
mailing list