/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SOFTSESSION_H
#define _SOFTSESSION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h>
/*
* This is only used by the C_G(S)etOperationState.
*/
/*
* This is only used by the C_G(S)etOperationState.
*/
typedef struct internal_op_state {
/* Holds the length of the saved state */
/* crypto operation to be saved or restored */
/* Holds the saved session state */
typedef struct crypto_active_op {
void *context;
/*
* Definition for flags in crypto_active_op_t
*/
typedef struct session {
/* Place holder for parameters passed in the C_OpenSession */
/* Pointers to form the global session list */
/* context of active FindObjects op */
/*
* slot_t is a global structure to be used only by the
* token objects to hold the token object related
* in-core information.
*/
typedef struct slot {
/* points to in-core token object list */
} slot_t;
/*
* The following structure is used to link the to-be-freed sessions
* into a linked list. The sessions on this linked list have
* not yet been freed via free() after C_CloseSession() call; instead
* they are added to this list. The actual free will take place when
* the number of sessions queued reaches MAX_SES_TO_BE_FREED, at which
* time the first session in the list will be freed.
*/
typedef struct ses_to_be_freed_list {
/*
* Flag definitions for ses_close_sync
*/
/* count to become zero */
/*
* This macro is used to decrement the session reference count by one.
*
* The caller of this macro uses the argument lock_held to indicate that
* whether the caller holds the lock on the session or not.
*
* SES_REFRELE macro does the following:
* 1) Get the session lock if the caller does not hold it.
* 2) Decrement the session reference count by one.
* 3) If the session reference count becomes zero after being decremented,
* and there is a closing session thread in the wait state, then
* call pthread_cond_signal() to wake up that thread who is blocked
* in the session deletion routine due to non-zero reference ount.
* 4) Always release the session lock.
*/
if (!lock_held) \
(void) pthread_mutex_lock(&s->session_mutex); \
if ((--((s)->ses_refcnt) == 0) && \
(s->ses_close_sync & SESSION_REFCNT_WAITING)) { \
(void) pthread_mutex_unlock(&s->session_mutex); \
(void) pthread_cond_signal(&s->ses_free_cond); \
} else { \
(void) pthread_mutex_unlock(&s->session_mutex); \
} \
}
extern soft_session_t *soft_session_list;
extern int all_sessions_closing;
/*
* Function Prototypes.
*/
/* Token object related function prototypes. */
void soft_logout(void);
#ifdef __cplusplus
}
#endif
#endif /* _SOFTSESSION_H */