00001
00004 #ifndef RAZORBACK_API_H
00005 #define RAZORBACK_API_H
00006 #include <razorback/visibility.h>
00007 #include <razorback/types.h>
00008 #include <razorback/queue.h>
00009 #include <razorback/message_formats.h>
00010 #include <razorback/lock.h>
00011 #include <razorback/thread.h>
00012
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016
00017 #define DECL_INSPECTION_FUNC(a) uint8_t a (struct Block *block, struct EventId *eventId, struct List *eventMetadata, void *threadData)
00018 #define DECL_NUGGET_INIT bool initNug(void)
00019 #define DECL_NUGGET_THREAD_INIT(a) bool a (void ** threadData)
00020 #define DECL_NUGGET_THREAD_CLEANUP(a) void a (void * threadData)
00021 #define DECL_NUGGET_SHUTDOWN void shutdownNug(void)
00022 #define DECL_ALERT_PRIMARY_FUNC(a) bool a (struct MessageAlertPrimary *message)
00023 #define DECL_ALERT_CHILD_FUNC(a) bool a (struct MessageAlertChild *message)
00024 #define DECL_OUTPUT_EVENT_FUNC(a) bool a (struct MessageOutputEvent *message)
00025 #define DECL_OUTPUT_LOG_FUNC(a) bool a (struct MessageOutputLog *message)
00026
00027
00030 struct RazorbackInspectionHooks
00031 {
00032 uint8_t (*processBlock) (struct Block *, struct EventId *, struct List *, void *);
00033 bool (*processDeferredList) (struct DeferredList *);
00034 bool (*initThread) (void **);
00035 void (*cleanupThread) (void *);
00036 };
00037
00040 struct RazorbackOutputHooks
00041 {
00042 struct Queue *queue;
00043 const char *pattern;
00044 uint32_t messageType;
00045 bool (*handleAlertPrimary)(struct MessageAlertPrimary *log);
00046 bool (*handleAlertChild)(struct MessageAlertChild *log);
00047 bool (*handleEvent)(struct MessageOutputEvent *log);
00048 bool (*handleLog)(struct MessageOutputLog *log);
00049 };
00050
00053 struct RazorbackCommandAndControlHooks
00054 {
00055 bool (*processRegReqMessage) (struct Message *);
00056 bool (*processRegRespMessage) (struct Message *);
00057 bool (*processRegErrMessage) (struct Message *);
00058 bool (*processConfUpdateMessage) (struct Message *);
00059 bool (*processConfAckMessage) (struct Message *);
00060 bool (*processConfErrMessage) (struct Message *);
00061 bool (*processPauseMessage) (struct Message *);
00062 bool (*processPausedMessage) (struct Message *);
00063 bool (*processGoMessage) (struct Message *);
00064 bool (*processRunningMessage) (struct Message *);
00065 bool (*processTermMessage) (struct Message *);
00066 bool (*processByeMessage) (struct Message *);
00067 bool (*processHelloMessage) (struct Message *);
00068 bool (*processReRegMessage) (struct Message *);
00069 };
00070
00071
00072
00073 #define CONTEXT_FLAG_STAND_ALONE 0x00000001
00074
00077 struct RazorbackContext
00078 {
00079 uuid_t uuidNuggetId;
00080 uuid_t uuidNuggetType;
00081 uuid_t uuidApplicationType;
00082 char *sNuggetName;
00083 uint32_t iFlags;
00084 uint8_t locality;
00085 struct RazorbackCommandAndControlHooks *pCommandHooks;
00086 struct Semaphore *regSem;
00087 bool regOk;
00088 void *userData;
00089
00092 struct Inspector
00093 {
00094 struct RazorbackInspectionHooks *hooks;
00095 uint32_t dataTypeCount;
00096 uuid_t *dataTypeList;
00097 struct ThreadPool *threadPool;
00098 struct Queue *judgmentQueue;
00099
00100 } inspector;
00101
00104 struct Output
00105 {
00106 struct List *threads;
00107 } output;
00108
00111 struct Dispatcher
00112 {
00113 uint32_t flags;
00114 uint8_t priority;
00115 uint16_t port;
00116 uint8_t protocol;
00117 struct List *addressList;
00118 } dispatcher;
00119 };
00120
00121
00126 SO_PUBLIC extern bool Razorback_Init_Context (struct RazorbackContext *context);
00127
00138 SO_PUBLIC extern struct RazorbackContext * Razorback_Init_Inspection_Context (
00139 uuid_t nuggetId, uuid_t applicationType,
00140 uint32_t dataTypeCount, uuid_t *dataTypeList,
00141 struct RazorbackInspectionHooks *inspectionHooks,
00142 uint32_t initialThreads, uint32_t maxThreads);
00143
00149 SO_PUBLIC extern struct RazorbackContext * Razorback_Init_Output_Context (
00150 uuid_t nuggetId, uuid_t applicationType);
00151
00157 SO_PUBLIC extern struct RazorbackContext * Razorback_Init_Collection_Context (
00158 uuid_t nuggetId, uuid_t applicationType);
00159
00164 SO_PUBLIC extern struct RazorbackContext * Razorback_LookupContext (uuid_t nuggetId);
00165
00169 SO_PUBLIC extern void Razorback_Shutdown_Context (struct RazorbackContext *context);
00170
00175 SO_PUBLIC extern bool Razorback_Render_Verdict (struct Judgment *p_pJudgment);
00176
00182 SO_PUBLIC extern bool
00183 Razorback_Output_Launch (struct RazorbackContext *context, struct RazorbackOutputHooks *hooks);
00184
00188 SO_PUBLIC extern int Razorback_Get_Message_Mode();
00189
00193 SO_PUBLIC extern char * Razorback_Get_Transfer_Password();
00194
00195
00196 #define RZB_Register_Collector Razorback_Init_Collection_Context
00197 #define RZB_DataBlock_Create BlockPool_CreateItem
00198 #define RZB_DataBlock_Add_Data BlockPool_AddData
00199 #define RZB_DataBlock_Set_Type BlockPool_SetItemDataType
00200 #define RZB_DataBlock_Finalize BlockPool_FinalizeItem
00201 #define RZB_DataBlock_Metadata_Filename(block, filename) Metadata_Add_Filename(block->pEvent->pMetaDataList, filename)
00202 #define RZB_DataBlock_Metadata_Hostname(block, hostname) Metadata_Add_Hostname(block->pEvent->pMetaDataList, hostname)
00203 #define RZB_DataBlock_Metadata_URI(block, uri) Metadata_Add_URI(block->pEvent->pMetaDataList, uri)
00204 #define RZB_DataBlock_Metadata_HttpRequest(block, request) Metadata_Add_HttpRequest(block->pEvent->pMetaDataList, request)
00205 #define RZB_DataBlock_Metadata_HttpResponse(block, response) Metadata_Add_HttpResponse(block->pEvent->pMetaDataList, response)
00206 #define RZB_DataBlock_Metadata_HttpResponse(block, response) Metadata_Add_HttpResponse(block->pEvent->pMetaDataList, response)
00207 #define RZB_DataBlock_Metadata_IPv4_Source(block, address) Metadata_Add_IPv4_Source(block->pEvent->pMetaDataList, address)
00208 #define RZB_DataBlock_Metadata_IPv4_Destination(block, address) Metadata_Add_IPv4_Destination(block->pEvent->pMetaDataList, address)
00209 #define RZB_DataBlock_Metadata_IPv6_Source(block, address) Metadata_Add_IPv6_Source(block->pEvent->pMetaDataList, address)
00210 #define RZB_DataBlock_Metadata_IPv6_Destination(block, address) Metadata_Add_IPv6_Destination(block->pEvent->pMetaDataList, address)
00211
00212 #define RZB_DataBlock_Metadata_Port_Source(block, port) Metadata_Add_Port_Source(block->pEvent->pMetaDataList, port)
00213 #define RZB_DataBlock_Metadata_Port_Destination(block, port) Metadata_Add_Port_Destination(block->pEvent->pMetaDataList, port)
00214
00215
00216 #define RZB_DataBlock_Submit Submission_Submit
00217 #define RZB_Log rzb_log
00218
00219 #ifdef __cplusplus
00220 }
00221 #endif
00222 #endif //RAZORBACK_API_H