From b9912f1997eb66efa26a7c840596aa5b8ee0be41 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Mon, 25 Feb 1991 15:17:50 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1776 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/gen_port.c | 44 ++++++++++++++++++++++++++ src/lib/krb5/os/gen_rname.c | 61 +++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/lib/krb5/os/gen_port.c create mode 100644 src/lib/krb5/os/gen_rname.c diff --git a/src/lib/krb5/os/gen_port.c b/src/lib/krb5/os/gen_port.c new file mode 100644 index 000000000..b2915cf17 --- /dev/null +++ b/src/lib/krb5/os/gen_port.c @@ -0,0 +1,44 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1991 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * For copying and distribution information, please see the file + * . + * + * Take an IP addr & port and generate a full IP address. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_gen_port_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include +#include +#include "os-proto.h" + +krb5_error_code +krb5_gen_portaddr(addr, ptr, outaddr) +krb5_address *addr; +krb5_pointer ptr; +krb5_address **outaddr; +{ +#ifdef KRB5_USE_INET + krb5_int32 adr; + krb5_int16 port; + + if (addr->addrtype != ADDRTYPE_INET) + return KRB5_PROG_ATYPE_NOSUPP; + port = *(krb5_int16 *)ptr; + + memcpy((char *)&adr, (char *)addr->contents, sizeof(adr)); + return krb5_make_full_ipaddr(adr, port, outaddr); +#else + return KRB5_PROG_ATYPE_NOSUPP; +#endif +} diff --git a/src/lib/krb5/os/gen_rname.c b/src/lib/krb5/os/gen_rname.c new file mode 100644 index 000000000..ad5b6f217 --- /dev/null +++ b/src/lib/krb5/os/gen_rname.c @@ -0,0 +1,61 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1991 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * For copying and distribution information, please see the file + * . + * + * take a port-style address and unique string, and return + * a replay cache tag string. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_gen_rname_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include + +#include +#include +#include "os-proto.h" +#ifdef KRB5_USE_INET +#include +#include +#include +#endif + +krb5_error_code +krb5_gen_replay_name(address, uniq, string) +krb5_address *address; +const char *uniq; +char **string; +{ +#ifdef KRB5_USE_INET + krb5_int16 port; + krb5_int32 addr; + register krb5_error_code retval; + register char *tmp, *tmp2; + struct in_addr inaddr; + + if (retval = krb5_unpack_full_ipaddr(address, &addr, &port)) + return retval; + inaddr.s_addr = addr; + + tmp = inet_ntoa(inaddr); + tmp2 = malloc(strlen(uniq)+strlen(tmp)+1+1+5); /* 1 for NUL, + 1 for /, + 5 for digits (65535 is max) */ + if (!tmp2) + return ENOMEM; + (void) sprintf(tmp2, "%s%s/%u",uniq,tmp,ntohs(port)); + *string = tmp2; + return 0; +#else + return KRB5_PROG_ATYPE_NOSUPP; +#endif +} -- 2.26.2