summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/os/gen_port.c
blob: 7cefd78244052e2d8f0cf956a879db82ff5e46dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
const krb5_address *addr;
krb5_const_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
}