Esempio n. 1
0
/*!
 * Free a statistics block allocated by rx_GetStatistics
 *
 * @param stats
 * 	The statistics block to free
 */
void
rx_FreeStatistics(struct rx_statistics **stats) {
    if (*stats) {
	rxi_Free(*stats, sizeof(struct rx_statistics));
        *stats = NULL;
    }
}
Esempio n. 2
0
void
rx_identity_free(struct rx_identity **identity)
{
    rx_identity_freeContents(*identity);
    rxi_Free(*identity, sizeof(struct rx_identity));
    *identity = NULL;
}
Esempio n. 3
0
struct rx_securityClass *
rxkad_NewClientSecurityObject(rxkad_level level,
			      struct ktc_encryptionKey *sessionkey,
			      afs_int32 kvno, int ticketLen, char *ticket)
{
    struct rx_securityClass *tsc;
    struct rxkad_cprivate *tcp;
    int code;
    int size, psize;

    rxkad_Init();

    size = sizeof(struct rx_securityClass);
    tsc = rxi_Alloc(size);
    memset((void *)tsc, 0, size);
    tsc->refCount = 1;		/* caller gets one for free */
    tsc->ops = &rxkad_client_ops;

    psize = PDATA_SIZE(ticketLen);
    tcp = rxi_Alloc(psize);
    memset((void *)tcp, 0, psize);
    tsc->privateData = (char *)tcp;
    tcp->type |= rxkad_client;
    tcp->level = level;
    code = fc_keysched(sessionkey, tcp->keysched);
    if (code) {
	rxi_Free(tcp, psize);
	rxi_Free(tsc, sizeof(struct rx_securityClass));
	return 0;		/* bad key */
    }
    memcpy((void *)tcp->ivec, (void *)sessionkey, sizeof(tcp->ivec));
    tcp->kvno = kvno;		/* key version number */
    tcp->ticketLen = ticketLen;	/* length of ticket */
    if (tcp->ticketLen > MAXKTCTICKETLEN) {
	rxi_Free(tcp, psize);
	rxi_Free(tsc, sizeof(struct rx_securityClass));
	return 0;		/* bad key */
    }
    memcpy(tcp->ticket, ticket, ticketLen);

    INC_RXKAD_STATS(clientObjects);
    return tsc;
}
Esempio n. 4
0
void
rx_identity_freeContents(struct rx_identity *identity)
{
    if (identity->displayName) {
	rxi_Free(identity->displayName, strlen(identity->displayName));
	identity->displayName = NULL;
    }

    rx_opaque_freeContents(&identity->exportedName);
}
Esempio n. 5
0
void
handle_socket_error(osi_socket so)
{
    struct msghdr msg;
    struct cmsghdr *cmsg;
    struct sock_extended_err *err;
    struct sockaddr_in addr;
    struct sockaddr *offender;
    char *controlmsgbuf;
    int code;
    struct socket *sop = (struct socket *)so;

    if (!(controlmsgbuf=rxi_Alloc(256)))
	return;
    msg.msg_name = &addr;
    msg.msg_namelen = sizeof(addr);
    msg.msg_control = controlmsgbuf;
    msg.msg_controllen = 256;
    msg.msg_flags = 0;

    code = kernel_recvmsg(sop, &msg, NULL, 0, 0,
			  MSG_ERRQUEUE|MSG_DONTWAIT|MSG_TRUNC);

    if (code < 0 || !(msg.msg_flags & MSG_ERRQUEUE))
	goto out;

    for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
	if (CMSG_OK(&msg, cmsg) && cmsg->cmsg_level == SOL_IP &&
	    cmsg->cmsg_type == IP_RECVERR)
	    break;
    }
    if (!cmsg)
	goto out;
    err = CMSG_DATA(cmsg);
    offender = SO_EE_OFFENDER(err);
    
    if (offender->sa_family != AF_INET)
       goto out;

    memcpy(&addr, offender, sizeof(addr));

    if (err->ee_origin == SO_EE_ORIGIN_ICMP &&
	err->ee_type == ICMP_DEST_UNREACH &&
	err->ee_code == ICMP_FRAG_NEEDED) {
	rxi_SetPeerMtu(NULL, ntohl(addr.sin_addr.s_addr), ntohs(addr.sin_port),
		       err->ee_info);
    }
    /* other DEST_UNREACH's and TIME_EXCEEDED should be dealt with too */

out:
    rxi_Free(controlmsgbuf, 256);
    return;
}
Esempio n. 6
0
static void
do_handlesocketerror(osi_socket so)
{
#ifdef AFS_RXERRQ_ENV
    char *cmsgbuf;
    size_t cmsgbuf_len;

    cmsgbuf_len = 256;
    cmsgbuf = rxi_Alloc(cmsgbuf_len);
    if (!cmsgbuf) {
	return;
    }

    while (osi_HandleSocketError(so, cmsgbuf, cmsgbuf_len))
	;

    rxi_Free(cmsgbuf, cmsgbuf_len);
#endif
}