TrustCore SDK NanoSSL API reference  version 7.0
mocana.h
Go to the documentation of this file.
1 
36 /*------------------------------------------------------------------*/
37 
38 #ifndef __MOCANA_HEADER__
39 #define __MOCANA_HEADER__
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #ifdef MOC_EXTERN_MOCANA_H
46 #undef MOC_EXTERN_MOCANA_H
47 #endif /* MOC_EXTERN_MOCANA_H */
48 
49 #ifdef __RTOS_WIN32__
50 
51 #ifdef WIN_EXPORT_INITIALIZE
52 #define MOC_EXTERN_MOCANA_H __declspec(dllexport)
53 #else
54 #define MOC_EXTERN_MOCANA_H __declspec(dllimport) extern
55 #endif /* WIN_EXPORT_INITIALIZE */
56 
57 #ifdef WIN_STATIC
58 #undef MOC_EXTERN_MOCANA_H
59 #define MOC_EXTERN_MOCANA_H extern
60 #endif /* WIN_STATIC */
61 
62 #else
63 
64 #define MOC_EXTERN_MOCANA_H extern
65 
66 #endif /* RTOS_WIN32 */
67 
68 #ifdef MOC_EXTERN_P
69 #undef MOC_EXTERN_P
70 #endif /* MOC_EXTERN_P */
71 
72 #define MOC_EXTERN_P MOC_EXTERN_MOCANA_H
73 
80 enum moduleNames
81 {
82  MOCANA_MSS,
83  MOCANA_SSH,
84  MOCANA_SSL,
85  MOCANA_SCEP,
86  MOCANA_IPSEC,
87  MOCANA_IKE,
88  MOCANA_RADIUS,
89  MOCANA_EAP,
90  MOCANA_HTTP,
91  MOCANA_TEST,
92  MOCANA_FIREWALL,
93  MOCANA_OCSP,
94  MOCANA_SRTP,
95  MOCANA_SYSLOG,
96  MOCANA_SECMOD,
97  MOCANA_TPM12,
98  MOCANA_TAP,
99  MOCANA_EST,
100  MOCANA_DATA_PROTECT,
101  MOCANA_UM,
102  MOCANA_END
103 };
104 
109 enum logSeverity
110 {
111  LS_CRITICAL,
112  LS_MAJOR,
113  LS_MINOR,
114  LS_WARNING,
115  LS_INFO
116 };
117 
147 typedef void (*logFn)(sbyte4 module, sbyte4 severity, sbyte *msg);
148 
149 typedef sbyte4 (*ShutdownHandler)(void);
150 
157 MOC_EXTERN_P volatile sbyte4 gMocanaAppsRunning;
160 MOC_EXTERN_MOCANA_H ShutdownHandler g_sslShutdownHandler;
161 
162 /*------------------------------------------------------------------*/
163 
167 #ifndef __DISABLE_MOCANA_INIT__
168 
256 MOC_EXTERN sbyte4 MOCANA_initMocana(void);
257 
280 MOC_EXTERN sbyte4 MOCANA_freeMocana(void);
281 
308 MOC_EXTERN sbyte4 MOCANA_initMocanaStaticMemory (
309  ubyte *pStaticMem, ubyte4 staticMemSize);
310 #endif
311 
340 MOC_EXTERN sbyte4 MOCANA_initLog(logFn lFn);
341 
342 
350 MOC_EXTERN void MOCANA_log(sbyte4 module, sbyte4 severity, sbyte *msg);
351 
352 #ifndef __DISABLE_MOCANA_ADD_ENTROPY__
353 
381 MOC_EXTERN sbyte4 MOCANA_addEntropyBit(ubyte entropyBit);
382 
383 
412 MOC_EXTERN sbyte4 MOCANA_addEntropy32Bits(ubyte4 entropyBits);
413 #endif
414 
415 #ifndef __DISABLE_MOCANA_FILE_SYSTEM_HELPER__
416 
454 MOC_EXTERN sbyte4 MOCANA_readFile(const char* pFilename, ubyte **ppRetBuffer, ubyte4 *pRetBufLength);
455 
485 MOC_EXTERN sbyte4 MOCANA_freeReadFile(ubyte **ppRetBuffer);
486 
515 MOC_EXTERN sbyte4 MOCANA_writeFile(const char* pFilename, const ubyte *pBuffer, ubyte4 bufLength);
516 
546 MOC_EXTERN sbyte4 MOCANA_appendFile(const char* pFilename, const ubyte *pBuffer, ubyte4 bufLength);
547 
566 MOC_EXTERN sbyte4 MOCANA_copyFile(const char *pSrcFilename, const char *pDestFilename);
567 
585 MOC_EXTERN sbyte4 MOCANA_deleteFile(const char *pFilename);
586 
606 MOC_EXTERN sbyte4 MOCANA_checkFile(
607  const char *pFilename, const char *pExt, intBoolean *pFileExist);
608 
609 #endif
610 
618 MOC_EXTERN sbyte4 MOCANA_opendir(void **pDirInfo, const char *pPath);
619 
627 MOC_EXTERN sbyte4 MOCANA_readdir(void *pDir, void **pFileInfo);
628 
636 MOC_EXTERN sbyte4 MOCANA_closedir(void *pDir);
637 
642 #ifndef MOC_DP_MAPPING_RELEASE
643 #define MOC_DP_MAPPING_RELEASE TRUE
644 #endif
645 
646 #if ( (defined(__ENABLE_MOCANA_FP_MAPPING_READ__)) && \
647  (!defined(__ENABLE_MOCANA_FP_MAPPING_GUARD__)) )
648 
649 #include "../data_protection/file_protect.h"
650 
651 #define MOCANA_readFile(_file, _retBuf, _retLen) \
652  MOCANA_readFileEx(_file, _retBuf, _retLen, MOC_DP_MAPPING_RELEASE)
653 
654 #endif
655 
656 #if ( (defined(__ENABLE_MOCANA_FP_MAPPING_WRITE__)) && \
657  (!defined(__ENABLE_MOCANA_FP_MAPPING_GUARD__)) )
658 
659 #include "../data_protection/file_protect.h"
660 
661 #ifndef __DISABLE_MOCANA_FP_IMMUTABLE_WRITE_BUFFER__
662 
663 #define MOCANA_writeFile(_file, _buf, _bufLen) \
664  MOCANA_writeFileEx(_file, _buf, _bufLen, MOC_DP_MAPPING_RELEASE)
665 
666 #else
667 
668 #define MOCANA_writeFile(_file, _buf, _bufLen) \
669  MOCANA_writeFileEx(_file, (ubyte *)_buf, _bufLen, MOC_DP_MAPPING_RELEASE)
670 
671 #endif /* ifdef __DISABLE_MOCANA_FP_IMMUTABLE_WRITE_BUFFER__ */
672 
673 #endif /* if (defined(__ENABLE_MOCANA_FP_MAPPING_WRITE__)) && (!defined(__ENABLE_MOCANA_FP_MAPPING_GUARD__)) */
674 
675 #ifdef __cplusplus
676 }
677 #endif
678 
679 #endif /* __MOCANA_HEADER__ */
void(* logFn)(sbyte4 module, sbyte4 severity, sbyte *msg)
Callback for logging function.
Definition: mocana.h:147