char *UpdateMessage::Serialize(uint32_t *length) { char *buffer, *originalBuffer; uint32_t messageSize; bool sendSuspect = false; if(m_contents.m_updatetype() == UPDATE_SUSPECT) { sendSuspect = true; } uint32_t suspectLength = 0; if((m_suspect != NULL) && sendSuspect) { suspectLength = m_suspect->GetSerializeLength(NO_FEATURE_DATA); if(suspectLength == 0) { return NULL; } messageSize = MESSAGE_HDR_SIZE + sizeof(uint32_t) + sizeof(uint32_t) + m_contents.ByteSize() + suspectLength; } else { messageSize = MESSAGE_HDR_SIZE + sizeof(uint32_t) + sizeof(uint32_t) + m_contents.ByteSize(); } buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); uint32_t contentLength = m_contents.ByteSize(); memcpy(buffer, &contentLength, sizeof(contentLength)); buffer += sizeof(contentLength); if(!m_contents.SerializeToArray(buffer, m_contents.ByteSize())) { return NULL; } buffer += m_contents.ByteSize(); if((m_suspect != NULL) && sendSuspect) { // Serialize our suspect if(m_suspect->Serialize((u_char*)buffer, suspectLength, NO_FEATURE_DATA) != suspectLength) { return NULL; } buffer += suspectLength; } *length = messageSize; return originalBuffer; }
//--------------------------------------------------------------------------------------------------- void CFunction::Serialize(SFArchive& archive) { if (!SerializeHeader(archive)) return; if (archive.isReading()) { archive >> handle; archive >> name; archive >> type; archive >> indexed; archive >> anonymous; archive >> constant; archive >> encoding; archive >> inputs; archive >> outputs; } else
//----------------------------------------------------------------------------- // Writes out a new actbusy file //----------------------------------------------------------------------------- bool CImportActBusy::Serialize( CUtlBuffer &buf, CDmElement *pRoot ) { SerializeHeader( buf ); buf.Printf( "\"ActBusy.txt\"\n" ); buf.Printf( "{\n" ); CDmAttribute *pChildren = pRoot->GetAttribute( "children" ); if ( !pChildren || pChildren->GetType() != AT_ELEMENT_ARRAY ) return NULL; CDmrElementArray<> children( pChildren ); int nCount = children.Count(); buf.PushTab(); for ( int i = 0; i < nCount; ++i ) { CDmElement *pChild = children[i]; buf.Printf( "\"%s\"\n", pChild->GetName() ); buf.Printf( "{\n" ); buf.PushTab(); PrintStringAttribute( pChild, buf, "busy_anim", true ); PrintStringAttribute( pChild, buf, "entry_anim", true ); PrintStringAttribute( pChild, buf, "exit_anim", true ); PrintStringAttribute( pChild, buf, "busy_sequence", true ); PrintStringAttribute( pChild, buf, "entry_sequence", true ); PrintStringAttribute( pChild, buf, "exit_sequence", true ); PrintFloatAttribute( pChild, buf, "min_time" ); PrintFloatAttribute( pChild, buf, "max_time" ); PrintStringAttribute( pChild, buf, "interrupts" ); buf.PopTab(); buf.Printf( "}\n" ); } buf.PopTab(); buf.Printf( "}\n" ); return true; }
/** * @brief Serialize given data * @return true if we serialize data otherwise false */ bool TupleRecord::Serialize(CopySerializeOutput &output) { bool status = true; output.Reset(); // Serialize the common variables such as database oid, table oid, etc. SerializeHeader(output); // Serialize other parts depends on type switch (GetType()) { case LOGRECORD_TYPE_ARIES_TUPLE_INSERT: case LOGRECORD_TYPE_ARIES_TUPLE_UPDATE: { storage::Tuple *tuple = (storage::Tuple *)data; tuple->SerializeTo(output); break; } case LOGRECORD_TYPE_ARIES_TUPLE_DELETE: // Nothing to do here ! break; case LOGRECORD_TYPE_PELOTON_TUPLE_INSERT: case LOGRECORD_TYPE_PELOTON_TUPLE_DELETE: case LOGRECORD_TYPE_PELOTON_TUPLE_UPDATE: // Nothing to do here ! break; default: { LOG_WARN("Unsupported TUPLE RECORD TYPE\n"); status = false; break; } } message_length = output.Size(); message = new char[message_length]; std::memcpy(message, output.Data(), message_length); return status; }
char *ControlMessage::Serialize(uint32_t *length) { char *buffer = NULL, *originalBuffer = NULL; uint32_t messageSize = 0; switch(m_controlType) { case CONTROL_EXIT_REQUEST: case CONTROL_CLEAR_ALL_REQUEST: case CONTROL_DISCONNECT_NOTICE: case CONTROL_DISCONNECT_ACK: case CONTROL_RECLASSIFY_ALL_REQUEST: case CONTROL_CONNECT_REQUEST: case CONTROL_START_CAPTURE: case CONTROL_START_CAPTURE_ACK: case CONTROL_STOP_CAPTURE: case CONTROL_STOP_CAPTURE_ACK: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSAGE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_EXIT_REPLY: case CONTROL_CLEAR_SUSPECT_REPLY: case CONTROL_SAVE_SUSPECTS_REPLY: case CONTROL_CLEAR_ALL_REPLY: case CONTROL_RECLASSIFY_ALL_REPLY: case CONTROL_CONNECT_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSAGE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success)+ sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_CLEAR_SUSPECT_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) IP of suspect to clear messageSize = MESSAGE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize) + m_suspectAddress.GetSerializationLength(); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in m_suspectAddress.Serialize(reinterpret_cast<u_char*>(buffer), messageSize); break; } case CONTROL_SAVE_SUSPECTS_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Path of file to save to messageSize = MESSAGE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_filePath) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); memcpy(buffer, m_filePath, sizeof(m_filePath)); buffer += sizeof(m_filePath); break; } case CONTROL_INVALID: { break; } default: { //Error return NULL; } } *length = messageSize; return originalBuffer; }
char *ControlMessage::Serialize(uint32_t *length) { char *buffer = NULL, *originalBuffer = NULL; uint32_t messageSize = 0; switch(m_controlType) { case CONTROL_EXIT_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_EXIT_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success)+ sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_CLEAR_ALL_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_CLEAR_ALL_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_CLEAR_SUSPECT_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_suspectAddress) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_suspectAddress, sizeof(m_suspectAddress)); buffer += sizeof(m_suspectAddress); break; } case CONTROL_CLEAR_SUSPECT_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_SAVE_SUSPECTS_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_filePath) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); memcpy(buffer, m_filePath, sizeof(m_filePath)); buffer += sizeof(m_filePath); break; } case CONTROL_SAVE_SUSPECTS_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_RECLASSIFY_ALL_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize);; //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_RECLASSIFY_ALL_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_CONNECT_REQUEST: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_CONNECT_REPLY: { //Uses: 1) UI_Message Header // 2) ControlMessage Type // 3) Boolean success messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(m_success) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); //Put the Control Message type in memcpy(buffer, &m_success, sizeof(m_success)); buffer += sizeof(m_success); break; } case CONTROL_DISCONNECT_NOTICE: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_DISCONNECT_ACK: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSADE_HDR_SIZE + sizeof(m_controlType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_controlType, sizeof(m_controlType)); buffer += sizeof(m_controlType); break; } case CONTROL_INVALID: { break; } default: { //Error return NULL; } } *length = messageSize; return originalBuffer; }
char *RequestMessage::Serialize(uint32_t *length) { char *buffer, *originalBuffer; uint32_t messageSize; switch(m_requestType) { case REQUEST_SUSPECTLIST_REPLY: { //Uses: 1) UI_Message Header // 2) Request Message Type // 3) Type of list being returned (all, hostile, benign) // 4) Size of list // 5) List of suspect IPs m_suspectListLength = m_suspectList.size(); messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(m_suspectListLength) + sizeof(m_listType) + sizeof(messageSize); for (uint i = 0; i < m_suspectList.size(); i++) { messageSize += m_suspectList.at(i).GetSerializationLength(); } buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); //Length of list suspect buffer memcpy(buffer, &m_listType, sizeof(m_listType)); buffer += sizeof(m_listType); // Length of the incoming list memcpy(buffer, &m_suspectListLength, sizeof(m_suspectListLength)); buffer += sizeof(m_suspectListLength); //Suspect list buffer itself for(uint i = 0; i < m_suspectList.size(); i++) { buffer += m_suspectList.at(i).Serialize(reinterpret_cast<u_char*>(buffer), messageSize); } break; } case REQUEST_SUSPECTLIST: { //Uses: 1) UI_Message Header // 2) request Message Type // 3) Type of list we want (all, hostile, benign) messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(m_listType)+ sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Put the type of list we're requesting memcpy(buffer, &m_listType, sizeof(m_listType)); buffer += sizeof(m_listType); break; } case REQUEST_SUSPECT: { //Uses: 1) UI_Message Header // 2) Request Message Type // 3) Suspect ID messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + m_suspectAddress.GetSerializationLength() + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Serialize our IP buffer += m_suspectAddress.Serialize(reinterpret_cast<u_char*>(buffer), messageSize); break; } case REQUEST_SUSPECT_REPLY: { //Uses: 1) UI_Message Header // 2) Request Message Type // 3) Size of the requested suspect // 4) The requested suspect m_suspectLength = m_suspect->GetSerializeLength(NO_FEATURE_DATA); if(m_suspectLength == 0) { return NULL; } messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(m_suspectLength) + m_suspectLength + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Serialize the size of the suspect memcpy(buffer, &m_suspectLength, sizeof(m_suspectLength)); buffer += sizeof(m_suspectLength ); // Serialize our suspect if(m_suspect->Serialize((u_char*)buffer, messageSize, NO_FEATURE_DATA) != m_suspectLength) { return NULL; } buffer += m_suspectLength; break; } case REQUEST_SUSPECT_WITHDATA: { //Uses: 1) UI_Message Header // 2) Request Message Type // 3) Suspect ID messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + m_suspectAddress.GetSerializationLength() + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Serialize our IP buffer += m_suspectAddress.Serialize(reinterpret_cast<u_char*>(buffer), messageSize); break; } case REQUEST_SUSPECT_WITHDATA_REPLY: { //Uses: 1) UI_Message Header // 2) Request Message Type // 3) Size of the requested suspect // 4) The requested suspect m_suspectLength = m_suspect->GetSerializeLength(MAIN_FEATURE_DATA); if(m_suspectLength == 0) { return NULL; } messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(m_suspectLength) + m_suspectLength + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Serialize the size of the suspect memcpy(buffer, &m_suspectLength, sizeof(m_suspectLength)); buffer += sizeof(m_suspectLength ); // Serialize our suspect if(m_suspect->Serialize((u_char*)buffer, messageSize, MAIN_FEATURE_DATA) != m_suspectLength) { return NULL; } buffer += m_suspectLength; break; } case REQUEST_UPTIME_REPLY: { //Uses: 1) UI_Message Type // 2) Request Message Type // 3) The uptime messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(m_startTime) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Request Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); // Serialize the uptime memcpy(buffer, &m_startTime, sizeof(m_startTime)); buffer += sizeof(m_startTime ); break; } case REQUEST_UPTIME: case REQUEST_PING: case REQUEST_PONG: { //Uses: 1) UI_Message Header // 2) ControlMessage Type messageSize = MESSAGE_HDR_SIZE + sizeof(m_requestType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_requestType, sizeof(m_requestType)); buffer += sizeof(m_requestType); break; } default: { return NULL; } } *length = messageSize; return originalBuffer; }
char *UpdateMessage::Serialize(uint32_t *length) { char *buffer, *originalBuffer; uint32_t messageSize; switch(m_updateType) { case UPDATE_SUSPECT: { //Uses: 1) Message Header // 2) ControlMessage Type // 3) Length of incoming serialized suspect // 3) Serialized suspect if(m_suspect == NULL) { return NULL; } m_suspectLength = m_suspect->GetSerializeLength(NO_FEATURE_DATA); if(m_suspectLength == 0) { return NULL; } messageSize = MESSAGE_HDR_SIZE + sizeof(m_updateType) + sizeof(m_suspectLength) + m_suspectLength + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the update Message type in memcpy(buffer, &m_updateType, sizeof(m_updateType)); buffer += sizeof(m_updateType); //Length of suspect buffer memcpy(buffer, &m_suspectLength, sizeof(m_suspectLength)); buffer += sizeof(m_suspectLength); if(m_suspect->Serialize((u_char*)buffer, messageSize, NO_FEATURE_DATA) != m_suspectLength) { return NULL; } buffer += m_suspectLength; break; } case UPDATE_SUSPECT_CLEARED: { //Uses: 1) Message Header // 2) update Message Type // 3) IP address of suspect cleared messageSize = MESSAGE_HDR_SIZE + sizeof(m_updateType) + m_IPAddress.GetSerializationLength() + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_updateType, sizeof(m_updateType)); buffer += sizeof(m_updateType); m_IPAddress.Serialize(reinterpret_cast<u_char*>(buffer), messageSize); break; } case UPDATE_SUSPECT_ACK: case UPDATE_ALL_SUSPECTS_CLEARED: case UPDATE_ALL_SUSPECTS_CLEARED_ACK: case UPDATE_SUSPECT_CLEARED_ACK: { //Uses: 1) Message Header // 2) Update Message Type messageSize = MESSAGE_HDR_SIZE + sizeof(m_updateType) + sizeof(messageSize); buffer = (char*)malloc(messageSize); originalBuffer = buffer; SerializeHeader(&buffer, messageSize); //Put the Control Message type in memcpy(buffer, &m_updateType, sizeof(m_updateType)); buffer += sizeof(m_updateType); break; } default: { return NULL; } } *length = messageSize; return originalBuffer; }