00001 00004 #ifndef RAZORBACK_TYPES_H 00005 #define RAZORBACK_TYPES_H 00006 00007 00008 #include <stdint.h> 00009 #ifdef _MSC_VER 00010 #include <WinSock2.h> 00011 #include "safewindows.h" 00012 #define bool BOOL 00013 #define true TRUE 00014 #define false FALSE 00015 #else //_MSC_VER 00016 #include <stdbool.h> 00017 #include <unistd.h> 00018 #endif //_MSC_VER 00019 #include <uuid/uuid.h> 00020 #include <stdlib.h> 00021 #include <openssl/evp.h> 00022 00023 #include <razorback/list.h> 00024 00025 #define UUID_STRING_LENGTH 37 ///< The size of a UUID String including the null 00026 00029 typedef enum 00030 { 00031 R_SUCCESS = 0, 00032 R_ERROR = 1, 00033 R_FOUND = 2, 00034 R_NOT_FOUND = 3, 00035 } Lookup_Result; 00036 00040 #define HASH_TYPE_MD5 1 ///< MD5 Hash 00041 #define HASH_TYPE_SHA1 2 ///< SHA-1 Hash 00042 #define HASH_TYPE_SHA224 3 ///< SHA224 Hash 00043 #define HASH_TYPE_SHA256 4 ///< SHA256 Hash 00044 #define HASH_TYPE_SHA512 5 ///< SHA512 Hash 00045 00046 00050 #define HASH_FLAG_FINAL 0x00000001 ///< Hash has been finalized. 00051 00052 00056 struct Hash 00057 { 00058 uint32_t iType; 00059 uint32_t iSize; 00060 uint8_t *pData; 00061 EVP_MD_CTX CTX; 00062 uint32_t iFlags; 00063 }; 00064 00068 struct BlockId 00069 { 00070 struct Hash *pHash; 00071 uuid_t uuidDataType; 00072 uint64_t iLength; 00073 }; 00074 00077 struct BlockData 00078 { 00079 char *fileName; 00080 uint8_t *pointer; 00081 FILE *file; 00082 bool tempFile; 00083 #ifdef _MSC_VER 00084 HANDLE mfileHandle; 00085 HANDLE mapHandle; 00086 #endif 00087 }; 00088 00091 struct Block 00092 { 00093 struct BlockId *pId; 00094 struct BlockId *pParentId; 00095 struct Block *pParentBlock; 00096 struct List *pMetaDataList; 00097 struct BlockData data; 00098 }; 00099 00102 struct BlockPoolData 00103 { 00104 uint32_t iLength; 00105 int iFlags; 00106 struct BlockData data; 00107 struct BlockPoolData *pNext; 00108 }; 00109 00112 struct BlockPoolItem 00113 { 00114 struct Mutex *mutex; 00115 uint32_t iStatus; 00116 struct BlockPoolData *pDataHead; 00117 struct BlockPoolData *pDataTail; 00118 void (*submittedCallback) (struct BlockPoolItem *); 00119 struct Event *pEvent; 00120 void *userData; 00121 }; 00122 00125 struct EventId 00126 { 00127 uuid_t uuidNuggetId; 00128 uint64_t iSeconds; 00129 uint64_t iNanoSecs; 00130 00131 }; 00132 00135 struct Event 00136 { 00137 struct EventId *pId; 00138 struct EventId *pParentId; 00139 struct Event *pParent; 00140 uuid_t uuidApplicationType; 00141 struct Block *pBlock; 00142 struct List *pMetaDataList; 00143 }; 00144 00147 struct Judgment 00148 { 00149 uuid_t uuidNuggetId; 00150 uint64_t iSeconds; 00151 uint64_t iNanoSecs; 00152 struct EventId *pEventId; 00153 struct BlockId *pBlockId; 00154 uint8_t iPriority; 00155 struct List *pMetaDataList; 00156 uint32_t iGID; 00157 uint32_t iSID; 00158 uint32_t Set_SfFlags; 00159 uint32_t Set_EntFlags; 00160 uint32_t Unset_SfFlags; 00161 uint32_t Unset_EntFlags; 00162 uint8_t *sMessage; 00163 }; 00164 00167 struct Nugget 00168 { 00169 uuid_t uuidNuggetId; 00170 uuid_t uuidApplicationType; 00171 uuid_t uuidNuggetType; 00172 char *sName; 00173 char *sLocation; 00174 char *sContact; 00175 char *sNotes; 00176 }; 00177 00180 struct DeferredList 00181 { 00182 uint8_t stuff; 00183 }; 00184 00185 00186 00190 #define SF_FLAG_GOOD 0x00000001 ///< Block is good 00191 #define SF_FLAG_BAD 0x00000002 ///< Block is bad 00192 #define SF_FLAG_WHITE_LIST 0x00000004 ///< Block is white listed 00193 #define SF_FLAG_BLACK_LIST 0x00000008 ///< Block is black listed 00194 #define SF_FLAG_DIRTY 0x00000010 ///< Block is marked for re-inspection 00195 #define SF_FLAG_CANHAZ 0x00000020 ///< Block data is required. 00196 #define SF_FLAG_PROCESSING 0x00000040 ///< Block is being processed currently 00197 // Duplication Intended 00198 #define SF_FLAG_DODGY 0x00000080 ///< Block is neither good nor bad 00199 #define SF_FLAG_SUSPICIOUS 0x00000080 ///< Block is neither good nor bad 00200 00201 #define SF_FLAG_ALL 0xffffffff ///< All flags mask. 00202 00203 00207 #define JUDGMENT_REASON_DONE 0 ///< Inspection has completed 00208 #define JUDGMENT_REASON_ALERT 1 ///< Inspection alert output 00209 #define JUDGMENT_REASON_ERROR 2 ///< Inspection failed 00210 #define JUDGMENT_REASON_DEFERRED 3 ///< Inspection enqueued and results deferred. 00211 #define JUDGMENT_REASON_PENDING 4 ///< Inspection result current pending (@note This is never sent in a message, it is the state the dispatcher stores for an inspection record.) 00212 00213 00217 #define TRANSFER_METHOD_FILE 0 ///< Transfer to block store shared file system 00218 #define TRANSFER_METHOD_SSH 1 ///< Transfer via SSH+SFTP 00219 #define TRANSFER_METHOD_HTTP 2 ///< Transfer via HTTP 00220 00221 00225 #define SUBMISSION_REASON_EVENT 0 ///< Submission from event. 00226 #define SUBMISSION_REASON_REQUESTED 1 ///< Submission due to administrative request. 00227 00228 00229 #endif //RAZORBACK_TYPES_H