00001 00004 #ifndef RAZORBACK_MESSAGES_H 00005 #define RAZORBACK_MESSAGES_H 00006 00007 #include <razorback/visibility.h> 00008 #include <razorback/message_formats.h> 00009 #include <razorback/types.h> 00010 #include <razorback/api.h> 00011 00012 #ifdef __cplusplus 00013 extern "C" { 00014 #endif 00015 00016 #define MESSAGE_MODE_BIN 1 00017 #define MESSAGE_MODE_JSON 2 00018 00022 #define MESSAGE_GROUP_C_AND_C 0x10000000 ///< Command And Control 00023 #define MESSAGE_GROUP_CACHE 0x20000000 ///< Global Cache 00024 #define MESSAGE_GROUP_SUBMIT 0x40000000 ///< Submission 00025 #define MESSAGE_GROUP_OUTPUT 0x80000000 ///< Submission 00026 00027 00030 #define MESSAGE_TYPE_HELLO ( MESSAGE_GROUP_C_AND_C | 1 ) ///< Hello Message 00031 #define MESSAGE_TYPE_REG_REQ ( MESSAGE_GROUP_C_AND_C | 2 ) ///< Registration Request 00032 #define MESSAGE_TYPE_REG_RESP ( MESSAGE_GROUP_C_AND_C | 3 ) ///< Registration Response 00033 #define MESSAGE_TYPE_REG_ERR ( MESSAGE_GROUP_C_AND_C | 4 ) ///< Registration Error 00034 #define MESSAGE_TYPE_CONFIG_UPDATE ( MESSAGE_GROUP_C_AND_C | 5 ) ///< Configuration Update Notice 00035 #define MESSAGE_TYPE_CONFIG_ACK ( MESSAGE_GROUP_C_AND_C | 6 ) ///< Configuration Updated OK 00036 #define MESSAGE_TYPE_CONFIG_ERR ( MESSAGE_GROUP_C_AND_C | 7 ) ///< Configuration Update Failed 00037 #if 0 00038 #define MESSAGE_TYPE_STATS_REQ ( MESSAGE_GROUP_C_AND_C | 8 ) ///< Statistics Request 00039 #define MESSAGE_TYPE_STATS_RESP ( MESSAGE_GROUP_C_AND_C | 9 ) ///< Statistics Response (With Data) 00040 #define MESSAGE_TYPE_STATS_ERR ( MESSAGE_GROUP_C_AND_C | 10 ) ///< Statistics Error 00041 #endif 00042 #define MESSAGE_TYPE_PAUSE ( MESSAGE_GROUP_C_AND_C | 11 ) ///< Pause Processing 00043 #define MESSAGE_TYPE_PAUSED ( MESSAGE_GROUP_C_AND_C | 12 ) ///< Pause Confirmation 00044 #define MESSAGE_TYPE_GO ( MESSAGE_GROUP_C_AND_C | 13 ) ///< Unpause Processing 00045 #define MESSAGE_TYPE_RUNNING ( MESSAGE_GROUP_C_AND_C | 14 ) ///< Unpuase Confirmation 00046 #define MESSAGE_TYPE_TERM ( MESSAGE_GROUP_C_AND_C | 15 ) ///< Terminate Processing 00047 #define MESSAGE_TYPE_BYE ( MESSAGE_GROUP_C_AND_C | 16 ) ///< Terminating Processing 00048 #define MESSAGE_TYPE_CLEAR ( MESSAGE_GROUP_C_AND_C | 17 ) ///< Clear Local Cache 00049 #define MESSAGE_TYPE_REREG ( MESSAGE_GROUP_C_AND_C | 18 ) ///< Reregister 00050 00051 00055 #define MESSAGE_TYPE_REQ ( MESSAGE_GROUP_CACHE | 1 ) ///< Global Cache Request 00056 #define MESSAGE_TYPE_RESP ( MESSAGE_GROUP_CACHE | 2 ) ///< Global Cache Response 00057 00058 00062 #define MESSAGE_TYPE_BLOCK ( MESSAGE_GROUP_SUBMIT | 1 ) ///< Data Block Submission 00063 #define MESSAGE_TYPE_JUDGMENT ( MESSAGE_GROUP_SUBMIT | 2 ) ///< Judgment Submission 00064 #define MESSAGE_TYPE_INSPECTION ( MESSAGE_GROUP_SUBMIT | 3 ) ///< Inspection Submission 00065 #define MESSAGE_TYPE_LOG ( MESSAGE_GROUP_SUBMIT | 4 ) ///< Log Message 00066 #define MESSAGE_TYPE_ALERT ( MESSAGE_GROUP_SUBMIT | 5 ) ///< Alert Message 00067 00068 00072 #define MESSAGE_TYPE_ALERT_PRIMARY ( MESSAGE_GROUP_OUTPUT | 1 ) ///< Block turns to bad 00073 #define MESSAGE_TYPE_ALERT_CHILD ( MESSAGE_GROUP_OUTPUT | 2 ) ///< Block turns to bad due to child 00074 #define MESSAGE_TYPE_OUTPUT_EVENT ( MESSAGE_GROUP_OUTPUT | 3 ) ///< Event Record 00075 #define MESSAGE_TYPE_OUTPUT_LOG ( MESSAGE_GROUP_OUTPUT | 4 ) ///< Log Record 00076 #define MESSAGE_TYPE_OUTPUT_INSPECTION ( MESSAGE_GROUP_OUTPUT | 5 ) ///< Inspection status 00077 00078 00079 00083 #define MESSAGE_VERSION_1 1 00084 00085 00086 #define MSG_CNC_HEADER_SOURCE "Source_Nugget" 00087 #define MSG_CNC_HEADER_DEST "Dest_Nugget" 00088 00089 #define DISP_HELLO_FLAG_LM (1 << 0) 00090 #define DISP_HELLO_FLAG_LS (1 << 1) 00091 #define DISP_HELLO_FLAG_DD (1 << 2) 00092 #define DISP_HELLO_FLAG_LF (1 << 3) 00093 00096 struct MessageHandler 00097 { 00098 uint32_t type; 00099 bool (*serialize)(struct Message *msg, int mode); 00100 bool (*deserialize)(struct Message *msg, int mode); 00101 void (*destroy)(struct Message *msg); 00102 }; 00103 00107 SO_PUBLIC extern struct List * Message_Header_List_Create(void); 00108 00115 SO_PUBLIC extern bool Message_Add_Header(struct List *headers, const char *name, const char *value); 00116 00121 SO_PUBLIC extern bool Message_Register_Handler(struct MessageHandler *handler); 00122 00129 SO_PUBLIC extern bool Message_Get_Nuggets(struct Message *message, uuid_t source, uuid_t dest); 00130 00136 SO_PUBLIC extern bool Message_Deserialize_Empty(struct Message *message, int mode); 00137 00143 SO_PUBLIC extern bool Message_Serialize_Empty(struct Message *message, int mode); 00144 00153 SO_PUBLIC extern struct Message * Message_Create_Directed(uint32_t type, uint32_t version, size_t msgSize, const uuid_t source, const uuid_t dest); 00154 00162 SO_PUBLIC extern struct Message * Message_Create_Broadcast(uint32_t type, uint32_t version, size_t msgSize, const uuid_t source); 00163 00167 SO_PUBLIC extern void Message_Destroy(struct Message *message); 00168 00169 00175 SO_PUBLIC extern struct Message* MessageCacheReq_Initialize ( 00176 const uuid_t requestorUUID, 00177 const struct BlockId *blockId); 00178 00179 00186 SO_PUBLIC extern struct Message* MessageCacheResp_Initialize ( 00187 const struct BlockId *blockId, 00188 uint32_t sfFlags, uint32_t entFlags); 00189 00190 00197 SO_PUBLIC extern struct Message* MessageBlockSubmission_Initialize ( 00198 struct Event *event, 00199 uint32_t reason, uint8_t locality); 00200 00201 00207 SO_PUBLIC extern struct Message* MessageJudgmentSubmission_Initialize ( 00208 uint8_t reason, 00209 struct Judgment* judgment); 00210 00218 SO_PUBLIC extern struct Message* MessageInspectionSubmission_Initialize ( 00219 const struct Event *event, 00220 uint32_t reason, 00221 uint32_t localityCount, 00222 uint8_t *localities 00223 ); 00224 00229 SO_PUBLIC extern struct Message* MessageHello_Initialize (struct RazorbackContext *context); 00230 00231 00241 SO_PUBLIC extern struct Message* MessageRegistrationRequest_Initialize ( 00242 const uuid_t dispatcherId, 00243 const uuid_t sourceNugget, 00244 const uuid_t nuggetType, 00245 const uuid_t applicationType, 00246 uint32_t dataTypeCount, 00247 uuid_t * dataTypeList); 00248 00249 00255 SO_PUBLIC extern struct Message* MessageRegistrationResponse_Initialize ( 00256 const uuid_t sourceNugget, 00257 const uuid_t destNugget); 00258 00264 SO_PUBLIC extern struct Message * MessageConfigurationUpdate_Initialize ( 00265 const uuid_t sourceNugget, 00266 const uuid_t destNugget); 00267 00268 00276 SO_PUBLIC extern struct Message* MessageConfigurationAck_Initialize ( 00277 const uuid_t sourceNugget, 00278 const uuid_t sestNugget, 00279 const uuid_t nuggetType, 00280 const uuid_t applicationType); 00281 00282 00288 SO_PUBLIC extern struct Message * MessagePause_Initialize ( 00289 const uuid_t sourceNugget, 00290 const uuid_t destNugget); 00291 00292 00298 SO_PUBLIC extern struct Message* MessagePaused_Initialize ( 00299 const uuid_t sourceNugget, 00300 const uuid_t destNugget); 00301 00302 00308 SO_PUBLIC extern struct Message * MessageGo_Initialize ( 00309 const uuid_t sourceNugget, 00310 const uuid_t destNugget); 00311 00312 00313 00319 SO_PUBLIC extern struct Message * MessageRunning_Initialize ( 00320 const uuid_t sourceNugget, 00321 const uuid_t destNugget); 00322 00323 00330 SO_PUBLIC extern struct Message * MessageTerminate_Initialize ( 00331 const uuid_t sourceNugget, 00332 const uuid_t destNugget, 00333 const uint8_t * reason); 00334 00335 00340 SO_PUBLIC extern struct Message * MessageBye_Initialize ( 00341 const uuid_t sourceNugget); 00342 00343 00348 SO_PUBLIC extern struct Message * MessageCacheClear_Initialize ( 00349 const uuid_t sourceNugget); 00350 00356 SO_PUBLIC struct Message * 00357 MessageReReg_Initialize ( 00358 const uuid_t sourceNugget, 00359 const uuid_t destNugget); 00360 00368 SO_PUBLIC extern struct Message * MessageError_Initialize ( 00369 uint32_t errorCode, 00370 const char *message, 00371 const uuid_t sourceNugget, 00372 const uuid_t destNugget); 00373 00381 SO_PUBLIC extern struct Message * 00382 MessageLog_Initialize ( 00383 const uuid_t nuggetId, 00384 uint8_t priority, 00385 char *message, 00386 struct EventId *eventId); 00387 00400 SO_PUBLIC extern struct Message * 00401 MessageAlertPrimary_Initialize ( 00402 struct Event *event, 00403 struct Block *block, 00404 struct List *metadata, 00405 struct Nugget *nugget, 00406 struct Judgment *judgment, 00407 uint32_t new_SF_Flags, uint32_t new_Ent_Flags, 00408 uint32_t old_SF_Flags, uint32_t old_Ent_Flags); 00409 00422 SO_PUBLIC extern struct Message * 00423 MessageAlertChild_Initialize ( 00424 struct Block *block, 00425 struct Block *child, 00426 struct Nugget *nugget, 00427 uint64_t parentCount, uint64_t eventCount, 00428 uint32_t new_SF_Flags, uint32_t new_Ent_Flags, 00429 uint32_t old_SF_Flags, uint32_t old_Ent_Flags); 00430 00436 SO_PUBLIC extern struct Message * 00437 MessageOutputEvent_Initialize ( 00438 struct Event *event, 00439 struct Nugget *nugget); 00440 00446 SO_PUBLIC extern struct Message * 00447 MessageOutputLog_Initialize ( 00448 struct MessageLogSubmission *log, 00449 struct Nugget *nugget); 00450 00458 SO_PUBLIC struct Message * 00459 MessageOutputInspection_Initialize ( 00460 struct Nugget *nugget, 00461 struct BlockId *blockId, 00462 uint8_t reason, 00463 bool final); 00464 00465 #ifdef __cplusplus 00466 } 00467 #endif 00468 #endif //RAZORBACK_MESSAGES_H