#define NEED_SOCKETS
#include "k5-int.h"
#ifdef HAVE_NETINET_IN_H
#include "os-proto.h"
krb5_error_code
krb5_make_full_ipaddr(krb5_context context, krb5_int32 adr,
int port, krb5_address **outaddr)
{
unsigned long smushaddr = (unsigned long) adr;
unsigned short smushport = (unsigned short) port;
register krb5_address *retaddr;
register krb5_octet *marshal;
krb5_addrtype temptype;
krb5_int32 templength;
if (!(retaddr = (krb5_address *)malloc(sizeof(*retaddr)))) {
return ENOMEM;
}
retaddr->magic = KV5M_ADDRESS;
retaddr->addrtype = ADDRTYPE_ADDRPORT;
retaddr->length = sizeof(smushaddr)+ sizeof(smushport) +
2*sizeof(temptype) + 2*sizeof(templength);
if (!(retaddr->contents = (krb5_octet *)malloc(retaddr->length))) {
krb5_xfree(retaddr);
return ENOMEM;
}
marshal = retaddr->contents;
temptype = htons(ADDRTYPE_INET);
(void) memcpy((char *)marshal, (char *)&temptype, sizeof(temptype));
marshal += sizeof(temptype);
templength = htonl(sizeof(smushaddr));
(void) memcpy((char *)marshal, (char *)&templength, sizeof(templength));
marshal += sizeof(templength);
(void) memcpy((char *)marshal, (char *)&smushaddr, sizeof(smushaddr));
marshal += sizeof(smushaddr);
temptype = htons(ADDRTYPE_IPPORT);
(void) memcpy((char *)marshal, (char *)&temptype, sizeof(temptype));
marshal += sizeof(temptype);
templength = htonl(sizeof(smushport));
(void) memcpy((char *)marshal, (char *)&templength, sizeof(templength));
marshal += sizeof(templength);
(void) memcpy((char *)marshal, (char *)&smushport, sizeof(smushport));
marshal += sizeof(smushport);
*outaddr = retaddr;
return 0;
}
#endif