1 /*
2  * COPYRIGHT (c) International Business Machines Corp. 2001-2017
3  *
4  * This program is provided under the terms of the Common Public License,
5  * version 1.0 (CPL-1.0). Any use, reproduction or distribution for this
6  * software constitutes recipient's acceptance of CPL-1.0 terms which can be
7  * found in the file LICENSE file or at
8  * https://opensource.org/licenses/cpl1.0.php
9  */
10 
11 #include <pkcs11types.h>
12 #include <limits.h>
13 #include <local_types.h>
14 #include <stdll.h>
15 #include <slotmgr.h>
16 
17 #include "local_types.h"
18 
19 #ifndef _APILOCAL_H
20 #define _APILOCAL_H
21 
22 // SAB Add a linked list of STDLL's loaded to
23 // only load and get list once, but let multiple slots us it.
24 
25 typedef struct {
26     CK_BOOL DLLoaded;           // Flag to indicate if the STDDL has been loaded
27     char *dll_name;             // Malloced space to copy the name.
28     void *dlop_p;
29     int dll_load_count;
30 //   STDLL_FcnList_t   *FcnList;  // Function list pointer for the STDLL
31 } DLL_Load_t;
32 
33 struct API_Slot {
34     CK_BOOL DLLoaded;           // Flag to indicate if the STDDL has been loaded
35     void *dlop_p;              // Pointer to the value returned from the DL open
36     STDLL_FcnList_t *FcnList;   // Function list pointer for the STDLL
37     STDLL_TokData_t *TokData;   // Pointer to Token specific data
38     DLL_Load_t *dll_information;
39     void (*pSTfini) ();         // Addition of Final function.
40     CK_RV(*pSTcloseall) ();    // Addition of close all for leeds code
41 };
42 
43 
44 // Per process API structure.
45 // Allocate one per process on the C_Initialize.  This will be
46 // a global type for the API and will be used through out.
47 //
48 typedef struct {
49     pid_t Pid;
50     pthread_mutex_t ProcMutex;  // Mutex for the process level should this
51                                 // be necessary
52     key_t shm_tok;
53 
54     struct btree sess_btree;
55     pthread_mutex_t SessListMutex;      /*used to lock around btree accesses */
56     void *SharedMemP;
57     Slot_Mgr_Socket_t SocketDataP;
58     uint16 MgrProcIndex;  // Index into shared memory for This process ctl block
59     API_Slot_t SltList[NUMBER_SLOTS_MANAGED];
60     DLL_Load_t DLLs[NUMBER_SLOTS_MANAGED];  // worst case we have a separate DLL
61                                             // per slot
62 } API_Proc_Struct_t;
63 
64 #endif
65