+Mon May 01 15:56:32 1995 Chris Provenzano (proven@mit.edu)
+
+ * genaddrs.c (krb5_auth_con_genaddrs()),
+ * mk_faddr.c (krb5_make_fulladdr()), os-proto.h :
+ Changes to auth_context to better support full addresses.
+
Sun Apr 30 16:03:59 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
* osconfig.c: Global variables krb5_config_file and
int fd, flags;
{
krb5_error_code retval;
- krb5_address * laddr;
- krb5_address * raddr;
+ krb5_address * laddr;
+ krb5_address * lport;
+ krb5_address * raddr;
+ krb5_address * rport;
#ifdef KRB5_USE_INET
- struct sockaddr_in saddr;
- krb5_address lcaddr;
- krb5_address rcaddr;
+ struct sockaddr_in lsaddr, rsaddr;
+ krb5_address lcaddr, rcaddr;
+ krb5_address lcport, rcport;
int ssize;
ssize = sizeof(struct sockaddr);
if ((flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) ||
(flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR)) {
- if (retval = getsockname(fd, (struct sockaddr *) &saddr, &ssize))
+ if (retval = getsockname(fd, (struct sockaddr *) &lsaddr, &ssize))
return retval;
if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) {
- if (retval = krb5_make_fulladdr(context, &saddr, &lcaddr))
- return retval;
- } else {
- lcaddr.contents = (krb5_octet *)&saddr.sin_addr;
- lcaddr.length = sizeof(saddr.sin_addr);
- lcaddr.addrtype = ADDRTYPE_INET;
- }
+ lcport.contents = (krb5_octet *)&lsaddr.sin_port;
+ lcport.length = sizeof(lsaddr.sin_port);
+ lcport.addrtype = ADDRTYPE_IPPORT;
+ lport = &lcport;
+ } else {
+ lport = NULL;
+ }
+ lcaddr.contents = (krb5_octet *)&lsaddr.sin_addr;
+ lcaddr.length = sizeof(lsaddr.sin_addr);
+ lcaddr.addrtype = ADDRTYPE_INET;
laddr = &lcaddr;
} else {
laddr = NULL;
+ lport = NULL;
}
if ((flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) ||
(flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR)) {
- if (retval = getpeername(fd, (struct sockaddr *) &saddr, &ssize))
+ if (retval = getpeername(fd, (struct sockaddr *) &rsaddr, &ssize))
return retval;
if (flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) {
- if (retval = krb5_make_fulladdr(context, &saddr, &rcaddr)) {
- if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR)
- krb5_xfree(laddr->contents);
- return retval;
- }
- } else {
- rcaddr.contents = (krb5_octet *)&saddr.sin_addr;
- rcaddr.length = sizeof(saddr.sin_addr);
- rcaddr.addrtype = ADDRTYPE_INET;
+ rcport.contents = (krb5_octet *)&rsaddr.sin_port;
+ rcport.length = sizeof(rsaddr.sin_port);
+ rcport.addrtype = ADDRTYPE_IPPORT;
+ rport = &rcport;
+ } else {
+ rport = NULL;
}
+ rcaddr.contents = (krb5_octet *)&rsaddr.sin_addr;
+ rcaddr.length = sizeof(rsaddr.sin_addr);
+ rcaddr.addrtype = ADDRTYPE_INET;
raddr = &rcaddr;
} else {
raddr = NULL;
+ rport = NULL;
}
- return (krb5_auth_con_setaddrs(context, auth_context, laddr, raddr));
+ if (!(retval = krb5_auth_con_setaddrs(context, auth_context, laddr, raddr)))
+ return (krb5_auth_con_setports(context, auth_context, lport, rport));
+ return retval;
#else
return KRB5_PROG_ATYPE_NOSUPP;
#endif
#endif
krb5_error_code
-krb5_make_fulladdr(context, saddr, kaddr)
+krb5_make_fulladdr(context, kaddr, kport, raddr)
krb5_context context;
- struct sockaddr_in * saddr;
krb5_address * kaddr;
+ krb5_address * kport;
+ krb5_address * raddr;
{
- krb5_int32 smushaddr = (krb5_int32)saddr->sin_addr.s_addr; /* net order */
- krb5_int16 smushport = (krb5_int16)saddr->sin_port; /* ditto */
register krb5_octet * marshal;
krb5_int32 tmp32;
krb5_int16 tmp16;
- kaddr->addrtype = ADDRTYPE_ADDRPORT;
- kaddr->length = sizeof(saddr->sin_addr) + sizeof(saddr->sin_port) +
- (4 * sizeof(krb5_int32));
+ if ((kport == NULL) || (kport == NULL))
+ return EINVAL;
- if (!(kaddr->contents = (krb5_octet *)malloc(kaddr->length)))
+ raddr->length = kaddr->length + kport->length + (4 * sizeof(krb5_int32));
+ if (!(raddr->contents = (krb5_octet *)malloc(kaddr->length)))
return ENOMEM;
- marshal = kaddr->contents;
+ raddr->addrtype = ADDRTYPE_ADDRPORT;
+ marshal = raddr->contents;
- tmp16 = ADDRTYPE_INET;
+ tmp16 = kaddr->addrtype;
*marshal++ = 0x00;
*marshal++ = 0x00;
*marshal++ = (krb5_octet) (tmp16 & 0xff);
*marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff);
- tmp32 = sizeof(smushaddr);
+ tmp32 = kaddr->length;
*marshal++ = (krb5_octet) (tmp32 & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff);
- (void) memcpy((char *)marshal, (char *)&smushaddr, sizeof(smushaddr));
- marshal += sizeof(smushaddr);
+ (void) memcpy((char *)marshal, (char *)(kaddr->contents), kaddr->length);
+ marshal += kaddr->length;
- tmp16 = ADDRTYPE_IPPORT;
+ tmp16 = kport->addrtype;
*marshal++ = 0x00;
*marshal++ = 0x00;
*marshal++ = (krb5_octet) (tmp16 & 0xff);
*marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff);
- tmp32 = sizeof(smushport);
+ tmp32 = kport->length;
*marshal++ = (krb5_octet) (tmp32 & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff);
*marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff);
- (void) memcpy((char *)marshal, (char *)&smushport, sizeof(smushport));
- marshal += sizeof(smushport);
-
+ (void) memcpy((char *)marshal, (char *)(kport->contents), kport->length);
+ marshal += kport->length;
return 0;
}
#endif
krb5_error_code krb5_make_fulladdr
PROTOTYPE((krb5_context,
- struct sockaddr_in *,
+ krb5_address *,
+ krb5_address *,
krb5_address *));
#endif /* KRB5_USE_INET */