*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Mon, 25 Feb 1991 15:17:50 +0000 (15:17 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Mon, 25 Feb 1991 15:17:50 +0000 (15:17 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1776 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/gen_port.c [new file with mode: 0644]
src/lib/krb5/os/gen_rname.c [new file with mode: 0644]

diff --git a/src/lib/krb5/os/gen_port.c b/src/lib/krb5/os/gen_port.c
new file mode 100644 (file)
index 0000000..b2915cf
--- /dev/null
@@ -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
+ * <krb5/copyright.h>.
+ *
+ * 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 <krb5/krb5.h>
+#include <krb5/osconf.h>
+#include <krb5/ext-proto.h>
+#include <krb5/libos-proto.h>
+#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 (file)
index 0000000..ad5b6f2
--- /dev/null
@@ -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
+ * <krb5/copyright.h>.
+ *
+ * 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 <krb5/krb5.h>
+#include <krb5/osconf.h>
+
+#include <krb5/ext-proto.h>
+#include <krb5/libos-proto.h>
+#include "os-proto.h"
+#ifdef KRB5_USE_INET
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#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
+}