From 0f070b5ac768dc4acc62d8e6908c2835c1bdcdaa Mon Sep 17 00:00:00 2001 From: John Kohl Date: Thu, 19 Apr 1990 15:34:36 +0000 Subject: [PATCH] remove kludged port # code better udp support git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@520 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/locate_kdc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 6cc27221c..4094b9ac4 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -27,18 +27,19 @@ static char rcsid_locate_kdc_c[] = #include #ifdef KRB5_USE_INET #include -#define KRB5_UDP_PORT htons(8973) /* XXX */ #endif #include #include "os-proto.h" +extern char *krb5_kdc_udp_portname; + /* * returns count of number of addresses found */ krb5_error_code krb5_locate_kdc(realm, addr_pp, naddrs) - krb5_data *realm; + const krb5_data *realm; struct sockaddr **addr_pp; int *naddrs; { @@ -48,12 +49,21 @@ krb5_locate_kdc(realm, addr_pp, naddrs) struct sockaddr *addr_p; struct sockaddr_in *sin_p; struct hostent *hp; - + struct servent *sp; +#ifdef KRB5_USE_INET + u_short udpport = 0; /* 0 is an invalid UDP port #. */ +#endif + hostlist = 0; if (code = krb5_get_krbhst (realm, &hostlist)) return(code); +#ifdef KRB5_USE_INET + if (sp = getservbyname(krb5_kdc_udp_portname, "udp")) + udpport = sp->s_port; +#endif + for (i=0; hostlist[i]; i++) ; count = i; @@ -71,11 +81,12 @@ krb5_locate_kdc(realm, addr_pp, naddrs) switch (hp->h_addrtype) { #ifdef KRB5_USE_INET case AF_INET: + if (udpport) /* must have gotten a port # */ for (j=0; hp->h_addr_list[j]; j++) { sin_p = (struct sockaddr_in *) &addr_p[out++]; memset ((char *)sin_p, sizeof(struct sockaddr), 0); sin_p->sin_family = hp->h_addrtype; - sin_p->sin_port = KRB5_UDP_PORT; + sin_p->sin_port = udpport; memcpy((char *)&sin_p->sin_addr, (char *)hp->h_addr_list[j], sizeof(struct in_addr)); -- 2.26.2