int main(int argc, char *argv[]) { Peer* peer; SDL_Thread *input_thread; if(!menu(&peer)) exit(1); input_thread = SDL_CreateThread(input, "Input", (void*)peer); if(!input_thread) { printf("\nSDL_CreateThread failed: %s\n", SDL_GetError()); exit(1); } while(!done) { if(!checkPackets(peer)) done = 1; if(hasMessage(peer)) { switch(getMessageType(peer)) { case 0: break; case 1: printf("%s\n", getMessage(peer)); break; case 2: printf("[PM] %s\n", getMessage(peer)); break; case 3: break; default: printf("mensagem desconhecida: %d\n", getMessageType(peer)); } flushClientState(peer); } } SDL_WaitThread(input_thread, NULL); disconnect(peer); return 0; }
messageType::messageType(QString line) { QStringList lineList = line.split(" "); if(lineList.at(0).toInt() > 0 && lineList.at(0).toInt() < 31) { datum = lineList.at(0).toInt(); time = lineList.at(1); time = time.left(8); if(lineList.at(2).contains("card") || lineList.at(2).contains("chan") // || (lineList.at(2).contains("Primary") && (lineList.at(3).contains("capture"))) // || (lineList.at(2).contains("Secondary") && (lineList.at(3).contains("capture"))) ) { device = lineList.at(2) + " " + lineList.at(3); device = device.remove(":"); } message = line.remove(lineList.at(0)); message = message.remove(0, 1); QString t = message.split(" ").at(0); message = message.remove(t); message = message.remove(0, 1); if(!device.isEmpty()) { QString device_s = device + ":"; message = message.remove(device_s); } type = getMessageType(message); } }
/** * Sets the second object of the message using the specified widget and * creates the message. * The association is created and added to the view. The dialog to select * the operation of the message is shown. * * @param secondObject The second object of the message. * @param messageType The type of the message to create. */ void ToolBarStateMessages::setSecondWidget(ObjectWidget* secondObject, MessageType messageType) { Uml::Sequence_Message_Type msgType = getMessageType(); //There shouldn't be second widget for a lost or a found message if (msgType == Uml::sequence_message_lost || msgType == Uml::sequence_message_found) { cleanMessage(); xclick = 0; yclick = 0; return; } //TODO shouldn't start position in the first widget be used also for normal messages //and not only for creation? qreal y = m_pMouseEvent->scenePos().y(); if (messageType == CreationMessage) { msgType = Uml::sequence_message_creation; y = m_messageLine->line().p1().y(); } MessageWidget* message = new MessageWidget(m_firstObject, secondObject, msgType); message->setPos(message->pos().x(), y); setupMessageWidget(message); cleanMessage(); }
/** * Called when the release event happened on an empty space. * Cleans the message. * Empty spaces are not only actual empty spaces, but also associations. */ void ToolBarStateMessages::mouseReleaseEmpty() { Uml::Sequence_Message_Type msgType = getMessageType(); if (m_firstObject && msgType == Uml::sequence_message_lost) { xclick = m_pMouseEvent->scenePos().x(); yclick = m_pMouseEvent->scenePos().y(); MessageWidget* message = new MessageWidget(m_firstObject, QPointF(xclick, yclick), msgType); setupMessageWidget(message); cleanMessage(); xclick = 0; yclick = 0; } else if (!m_firstObject && msgType == Uml::sequence_message_found && xclick == 0 && yclick == 0) { xclick = m_pMouseEvent->scenePos().x(); yclick = m_pMouseEvent->scenePos().y(); m_messageLine = new UMLSceneLineItem(); m_pUMLScene->addItem(m_messageLine); qreal x = m_pMouseEvent->scenePos().x(), y = m_pMouseEvent->scenePos().y(); m_messageLine->setLine(x, y, x, y); m_messageLine->setPen(QPen(m_pUMLScene->lineColor(), m_pUMLScene->lineWidth(), Qt::DashLine)); m_messageLine->setVisible(true); } else { cleanMessage(); } }
/** * Sets the first object of the message using the specified object. * The temporal visual message is created and mouse tracking enabled, so * mouse events will be delivered. * * @param firstObject The first object of the message. */ void ToolBarStateMessages::setFirstWidget(ObjectWidget* firstObject) { m_firstObject = firstObject; Uml::Sequence_Message_Type msgType = getMessageType(); if (msgType == Uml::sequence_message_found && xclick!=0 && yclick!=0) { MessageWidget* message = new MessageWidget(m_pUMLScene, m_firstObject,xclick, yclick, msgType); cleanMessage(); m_pUMLScene->getMessageList().append(message); xclick = 0; yclick = 0; FloatingTextWidget *ft = message->floatingTextWidget(); //TODO cancel doesn't cancel the creation of the message, only cancels setting an operation. //Shouldn't it cancel also the whole creation? ft->showOperationDialog(); message->setTextPosition(); m_pUMLScene->getWidgetList().append(ft); UMLApp::app()->document()->setModified(); } else { m_messageLine = new UMLSceneLine(m_pUMLScene->canvas()); m_messageLine->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(), m_pMouseEvent->x(), m_pMouseEvent->y()); m_messageLine->setPen(QPen(m_pUMLScene->lineColor(), m_pUMLScene->lineWidth(), Qt::DashLine)); m_messageLine->setVisible(true); m_pUMLScene->viewport()->setMouseTracking(true); } }
bool Receiver::receiveData() { waitForBeginMessage(); rType = getMessageType(); bool endFlag= 0; if(strchr(validMessageTypes, rType) == NULL) { return false; } Serial.print(" Received valid type message "); Serial.print(rType); rCount = getMessageLength(); Serial.print (" message length is ") ; Serial.println(rCount); if(rCount < 0 || rCount > maxRL) { return false; } endFlag = getDataValues(); return endFlag; }
/** * Called when the release event happened on an empty space. * Cleans the message. * Empty spaces are not only actual empty spaces, but also associations. */ void ToolBarStateMessages::mouseReleaseEmpty() { Uml::SequenceMessage::Enum msgType = getMessageType(); if (m_firstObject && msgType == Uml::SequenceMessage::Lost) { xclick = m_pMouseEvent->scenePos().x(); yclick = m_pMouseEvent->scenePos().y(); MessageWidget* message = new MessageWidget(m_pUMLScene, m_firstObject, xclick, yclick, msgType); setupMessageWidget(message); cleanMessage(); xclick = 0; yclick = 0; } else if (!m_firstObject && msgType == Uml::SequenceMessage::Found && xclick == 0 && yclick == 0) { xclick = m_pMouseEvent->scenePos().x(); yclick = m_pMouseEvent->scenePos().y(); m_messageLine = new QGraphicsLineItem(); m_pUMLScene->addItem(m_messageLine); qreal x = m_pMouseEvent->scenePos().x(); qreal y = m_pMouseEvent->scenePos().y(); m_messageLine->setLine(x, y, x, y); m_messageLine->setPen(QPen(m_pUMLScene->lineColor(), m_pUMLScene->lineWidth(), Qt::DashLine)); m_messageLine->setVisible(true); m_pUMLScene->activeView()->viewport()->setMouseTracking(true); } else { cleanMessage(); } }
/** * Sets the second object of the message using the specified widget and * creates the message. * The association is created and added to the view. The dialog to select * the operation of the message is shown. * * @param secondObject The second object of the message. * @param messageType The type of the message to create. */ void ToolBarStateMessages::setSecondWidget(ObjectWidget* secondObject, MessageType messageType) { Uml::Sequence_Message_Type msgType = getMessageType(); //There shouldn't be second widget for a lost or a found message if (msgType == Uml::sequence_message_lost || msgType == Uml::sequence_message_found) { cleanMessage(); xclick = 0; yclick = 0; return; } //TODO shouldn't start position in the first widget be used also for normal messages //and not only for creation? int y = m_pMouseEvent->y(); if (messageType == CreationMessage) { msgType = Uml::sequence_message_creation; y = m_messageLine->startPoint().y(); } MessageWidget* message = new MessageWidget(m_pUMLScene, m_firstObject, secondObject, y, msgType); cleanMessage(); m_pUMLScene->getMessageList().append(message); FloatingTextWidget *ft = message->floatingTextWidget(); //TODO cancel doesn't cancel the creation of the message, only cancels setting an operation. //Shouldn't it cancel also the whole creation? ft->showOperationDialog(); message->setTextPosition(); m_pUMLScene->getWidgetList().append(ft); UMLApp::app()->document()->setModified(); }
UserWnd::UserWnd(unsigned id, Buffer *cfg, bool bReceived, bool bAdjust) : QSplitter(Qt::Horizontal, NULL) { load_data(userWndData, &data, cfg); m_id = id; m_bResize = false; m_bClosed = false; m_bTyping = false; setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); m_hSplitter = new QSplitter(Qt::Horizontal, this); m_splitter = new QSplitter(Qt::Vertical, m_hSplitter); m_list = NULL; m_view = NULL; if (cfg == NULL) memcpy(data.editBar, CorePlugin::m_plugin->data.editBar, sizeof(data.editBar)); m_bBarChanged = true; if (CorePlugin::m_plugin->getContainerMode()) bReceived = false; m_edit = new MsgEdit(m_splitter, this); setFocusProxy(m_edit); restoreToolbar(m_edit->m_bar, data.editBar); m_edit->m_bar->show(); m_bBarChanged = false; connect(m_edit, SIGNAL(toolBarPositionChanged(Q3ToolBar*)), this, SLOT(toolbarChanged(Q3ToolBar*))); connect(CorePlugin::m_plugin, SIGNAL(modeChanged()), this, SLOT(modeChanged())); connect(m_edit, SIGNAL(heightChanged(int)), this, SLOT(editHeightChanged(int))); modeChanged(); if (!bAdjust && getMessageType() == 0) return; if (!m_edit->adjustType()){ unsigned type = getMessageType(); Message *msg = new Message(MessageGeneric); setMessage(&msg); delete msg; setMessageType(type); } }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ MessageFactory::pMessage_type MessageFactory::create(pMessageHeader_type _pMessageHeader, pEndpoint_type _pSourceEndpoint, pEndpoint_type _pDestinationEndpoint) { switch(getMessageType(_pMessageHeader)) { case DeleteChildNodeRequest::type: return pMessage_type(new DeleteChildNodeRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateChildNodeRequest::type: return pMessage_type(new CreateChildNodeRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case DeleteChildNodeResponse::type: return pMessage_type(new DeleteChildNodeResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateChildNodeResponse::type: return pMessage_type(new CreateChildNodeResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); } // TODO Throw an exception? std::cout << "GameBuilderMessageFactory::getMessageType(): Error, wrong message type - " << getMessageType(_pMessageHeader) << std::endl; return pMessage_type(); }
void MonitoringDevice::nextMessage(unsigned char** _ppArea){ const unsigned int MESSAGE_TYPE_1 = 1; const unsigned int MESSAGE_TYPE_2 = 2; const unsigned int MESSAGE_TYPE_3 = 3; // ne ispolzuetsa // const unsigned int MESSAGE_TYPE_4 = 4; const unsigned int MESSAGE_SIZE_TYPE_1 = 12; const unsigned int MESSAGE_SIZE_TYPE_2 = 13; const unsigned int MESSAGE_SIZE_TYPE_3 = 11; const unsigned int MESSAGE_SIZE_TYPE_4 = 11; if (getMessageType(*_ppArea) == MESSAGE_TYPE_2) *_ppArea += MESSAGE_SIZE_TYPE_2; else if (getMessageType(*_ppArea) == MESSAGE_TYPE_1) *_ppArea += MESSAGE_SIZE_TYPE_1; else if (getMessageType(*_ppArea) == MESSAGE_TYPE_3) *_ppArea += MESSAGE_SIZE_TYPE_3; else *_ppArea += MESSAGE_SIZE_TYPE_4; }
Selection show(const char *message, const char *title, Style style, Buttons buttons) { if (!gtk_init_check(0, NULL)) { return Selection::None; } GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, getMessageType(style), getButtonsType(buttons), "%s", message); gtk_window_set_title(GTK_WINDOW(dialog), title); Selection selection = getSelection(gtk_dialog_run(GTK_DIALOG(dialog))); gtk_widget_destroy(GTK_WIDGET(dialog)); while (g_main_context_iteration(NULL, false)); return selection; }
void SerialProtocolReader::serialInput(unsigned char c) { rx_buffer[rx_buffer_head++] = c; switch(getMessageType()){ // 3 byte messages case SET_LED_MESSAGE: if(rx_buffer_head == 3) handleSetLedMessage(); break; // 2 byte messages case SET_LED_ROW_MESSAGE: if(rx_buffer_head == 2) handleSetLedRowMessage(); break; case SET_LED_COL_MESSAGE: if(rx_buffer_head == 2) handleSetLedColumnMessage(); break; case WRITE_CHARACTER_MESSAGE: if(rx_buffer_head == 2) handleWriteCharacterMessage(); break; // 1 byte messages case FILL_MESSAGE: handleFillMessage(); break; case SHIFT_LEDS_MESSAGE: handleShiftLedsMessage(); break; case COMMAND_MESSAGE: handleCommandMessage(); break; default: // set parameter has a two-bit signature if((rx_buffer[0] & 0xc0) == SET_PARAMETER_MESSAGE){ // case SET_PARAMETER_MESSAGE: if(rx_buffer_head == 2) handleSetParameterMessage(); }else{ rx_buffer_head = 0; blipbox.message(MESSAGE_READ_ERROR); } } }
char* osmsMessageRightsAuthorizationResponse::encode() { XMLDocument* pDoc = new XMLDocument(); if (pDoc == NULL) return NULL; if (!pDoc->decode(xmlTemplate(), getName())) { delete pDoc; return NULL; } pDoc->setInteger("MessageType", getMessageType()); pDoc->setString("TransactionId", getTransactionId()); char *result = pDoc->encode(); delete pDoc; return result; }
char* osmsMessageRegisterDigitalItemInstanceResponseError::encode() { XMLDocument* pDoc = new XMLDocument(); if (pDoc == NULL) return NULL; if (!pDoc->decode(xmlTemplate(), getName())) { delete pDoc; return NULL; } pDoc->setInteger("MessageType", getMessageType()); pDoc->setInteger("ErrorCode", getErrorCode()); pDoc->setString("ResponseString", getResponseString()); char *result = pDoc->encode(); delete pDoc; return result; }
char* osmsMessageRegisterContentAssignIdentifierRequest::encode() { XMLDocument* pDoc = new XMLDocument(); if (pDoc == NULL) return NULL; if (!pDoc->decode(xmlTemplate(), getName())) { delete pDoc; return NULL; } pDoc->setInteger("MessageType", getMessageType()); pDoc->setString("MetadataType", getMetadataType()); pDoc->setString("MetadataXml", getMetadataXml()); char *result = pDoc->encode(); delete pDoc; return result; }
char* osmsMessageCreateUserRequest::encode() { XMLDocument* pDoc = new XMLDocument(); if (pDoc == NULL) return NULL; if (!pDoc->decode(xmlTemplate(), getName())) { delete pDoc; return NULL; } pDoc->setInteger("MessageType", getMessageType()); pDoc->setString("UserName", getUserName()); pDoc->setString("Password", getPassword()); pDoc->setString("EmailAddress", getEmailAddress()); char *result = pDoc->encode(); delete pDoc; return result; }
void IcmpLayer::parseNextLayer() { IcmpMessageType type = getMessageType(); size_t headerLen = 0; switch (type) { case ICMP_DEST_UNREACHABLE: case ICMP_SOURCE_QUENCH: case ICMP_TIME_EXCEEDED: case ICMP_REDIRECT: case ICMP_PARAM_PROBLEM: headerLen = getHeaderLen(); if (m_DataLen - headerLen >= sizeof(iphdr)) m_NextLayer = new IPv4Layer(m_Data + headerLen, m_DataLen - headerLen, this, m_Packet); return; default: headerLen = getHeaderLen(); if (m_DataLen > headerLen) m_NextLayer = new PayloadLayer(m_Data + headerLen, m_DataLen - headerLen, this, m_Packet); return; } }
size_t IcmpLayer::getHeaderLen() { IcmpMessageType type = getMessageType(); size_t routerAdvSize = 0; switch (type) { case ICMP_ECHO_REQUEST: case ICMP_ECHO_REPLY: return m_DataLen; case ICMP_TIMESTAMP_REQUEST: case ICMP_TIMESTAMP_REPLY: return sizeof(icmp_timestamp_request); case ICMP_ROUTER_SOL: case ICMP_INFO_REQUEST: case ICMP_INFO_REPLY: case ICMP_UNSUPPORTED: return sizeof(icmphdr); case ICMP_ADDRESS_MASK_REPLY: case ICMP_ADDRESS_MASK_REQUEST: return sizeof(icmp_address_mask_request); case ICMP_DEST_UNREACHABLE: return sizeof(icmp_destination_unreachable); case ICMP_REDIRECT: return sizeof(icmp_redirect); case ICMP_TIME_EXCEEDED: case ICMP_SOURCE_QUENCH: return sizeof(icmp_time_exceeded); case ICMP_PARAM_PROBLEM: return sizeof(icmp_param_problem); case ICMP_ROUTER_ADV: routerAdvSize = sizeof(icmp_router_advertisement_hdr) + (getRouterAdvertisementData()->header->advertisementCount*sizeof(icmp_router_address_structure)); return routerAdvSize; default: return sizeof(icmphdr); } }
SIPB2BHandler::Ptr SIPB2BTransactionManager::findHandler(const OSS::SIP::SIPMessage::Ptr& pMsg) const { return findHandler(getMessageType(pMsg)); }
bool IcmpLayer::isMessageOfType(IcmpMessageType type) { return (getMessageType() == type); }
int main(int argc, char **argv) { int socketDescriptor, new_socketDescriptor, client_len, port; struct sockaddr_in server, client; char *bufferPointer, buf[BUFFER_LENGTH], messageType; bool notEndOfMessage; std::string fileName; std::ostringstream messageBuffer; switch(argc) { case 1: port = SERVER_TCP_PORT; // Use the default port break; case 2: port = atoi(argv[1]); // Get user specified port break; default: fprintf(stderr, "Usage: %s [port]\n", argv[0]); exit(1); } // Create a stream socket if ((socketDescriptor = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror ("Can't create a socket"); exit(1); } // Bind an address to the socket bzero((char *)&server, sizeof(struct sockaddr_in)); server.sin_family = AF_INET; server.sin_port = htons(port); server.sin_addr.s_addr = htonl(INADDR_ANY); // Accept connections from any client if (bind(socketDescriptor, (struct sockaddr *)&server, sizeof(server)) == -1) { perror("Can't bind name to socket"); exit(1); } // Listen for connections // queue up to 5 connect requests listen(socketDescriptor, 5); notEndOfMessage = true; client_len= sizeof(client); new_socketDescriptor = accept(socketDescriptor, (struct sockaddr *)&client, (socklen_t*)&client_len); if (new_socketDescriptor == -1) //If fails to connect to client { fprintf(stderr, "Can't accept client\n"); exit(1); } printf("Remote Address: %s\n", inet_ntoa(client.sin_addr)); while(notEndOfMessage) //Receives data from client and puts into buffer { bufferPointer = buf; recv(new_socketDescriptor, bufferPointer, BUFFER_LENGTH - 1, 0); messageBuffer << std::string(bufferPointer); if(checkIfEndOfMessage(messageBuffer)) //Breaks if hits end of file character { notEndOfMessage = false; } } messageType = getMessageType(messageBuffer); fileName = getFileName(messageBuffer); if(messageType == 'S')//SEND request { receiveFile(fileName, messageBuffer); } else if(messageType == 'G')//GET request { sendFile(fileName, new_socketDescriptor); } else //Not SEND or GET request, fail condition { std::cout << "Error on message type"; } close(socketDescriptor); return(0); }
bool MonitoringDevice::isEventMessage(unsigned char* _pArea){ const unsigned int MESSAGE_TYPE_2 = 2; return (getMessageType(_pArea) == MESSAGE_TYPE_2); }
// The following function is executed concurrently with other threads void processXmlRequest(ThreadParams *params) { PFC *pfc = params->pfc; get_mip()->IOBASE=64; int bytes_per_big = (MIRACL/8)*(get_mip()->nib-1); char buffer[BUF_SIZE]; memset(buffer, 0, BUF_SIZE); cout << endl << "------------------------------" << endl; cout << "sockfd: " << params->sockfd << endl; // Read out socket. int n = recv(params->sockfd, buffer, sizeof(buffer),0); if (n < 0) error("ERROR reading from socket"); //string ext_pvt_key = extract(buffer, s, pfc); string xmlString(buffer); string messageType = getMessageType(xmlString); cout << "messageType: " << messageType << endl; cout << "Received XML Message:" << endl << buffer << endl; string xmlResult; if(messageType.compare("encryption")==0) { PlaintextMessage plainMes = getPlaintextMessage(xmlString, pfc); cout << "plainMes.getMessage()" << endl << plainMes.getMessage() << endl; EncryptedMessage encMes = plainMes.encrypt(params->P, params->Ppub, pfc); string strEncMes = encMes.getMessage(); cout << endl << "Encryption result:" << endl << strEncMes << endl; //strcpy(buffer, ext_pvt_key.c_str()); xmlResult = encodeToXmlResult(strEncMes); //string bye_mes("<?xml version='1.0' encoding='UTF-8' standalone='no'?><scramble><result>My custom result here</result></scramble>"); strcpy(buffer, xmlResult.c_str()); n = send(params->sockfd, buffer, sizeof(buffer), 0); if (n < 0) error("ERROR writing to socket"); } else if(messageType.compare("bye")==0) { //*closeSocket = true; } else if(messageType.compare("decryption")==0) { EncryptedMessage encMes = getEncryptedMessage(xmlString); cout << "encMes.getMessage()" << endl << encMes.getMessage() << endl; PlaintextMessage plainMes = encMes.decrypt(params->P, params->Ppub, params->D, params->pfc); string strPlainMes = plainMes.getMessage(); cout << endl << "Decryption result:" << endl << strPlainMes << endl; string url = getUrl(xmlString); xmlResult = encodeToXmlResult(strPlainMes, url); strcpy(buffer, xmlResult.c_str()); n = send(params->sockfd, buffer, sizeof(buffer), 0); if (n < 0) error("ERROR writing to socket"); } cout << "------------------------------" << endl; close(params->sockfd); delete params; }
inline uint16_t getLocationInfoHopCount() const { assert(getMessageType() == MSGTYPE_LOCATION_INFO); return ntohs(*(reinterpret_cast<uint16_t *>(header + LOCATION_INFO_HOPS))); }
inline void setLocationInfoHopCount(const int &hops) { assert(getMessageType() == MSGTYPE_LOCATION_INFO); *(reinterpret_cast<uint16_t *>(header + LOCATION_INFO_HOPS)) = htons(hops); }
std::string IcmpLayer::toString() { std::string messageTypeAsString; IcmpMessageType type = getMessageType(); switch (type) { case ICMP_ECHO_REPLY: messageTypeAsString = "Echo (ping) reply"; break; case ICMP_DEST_UNREACHABLE: messageTypeAsString = "Destination unreachable"; break; case ICMP_SOURCE_QUENCH: messageTypeAsString = "Source quench (flow control)"; break; case ICMP_REDIRECT: messageTypeAsString = "Redirect"; break; case ICMP_ECHO_REQUEST: messageTypeAsString = "Echo (ping) request"; break; case ICMP_ROUTER_ADV: messageTypeAsString = "Router advertisement"; break; case ICMP_ROUTER_SOL: messageTypeAsString = "Router solicitation"; break; case ICMP_TIME_EXCEEDED: messageTypeAsString = "Time-to-live exceeded"; break; case ICMP_PARAM_PROBLEM: messageTypeAsString = "Parameter problem: bad IP header"; break; case ICMP_TIMESTAMP_REQUEST: messageTypeAsString = "Timestamp request"; break; case ICMP_TIMESTAMP_REPLY: messageTypeAsString = "Timestamp reply"; break; case ICMP_INFO_REQUEST: messageTypeAsString = "Information request"; break; case ICMP_INFO_REPLY: messageTypeAsString = "Information reply"; break; case ICMP_ADDRESS_MASK_REQUEST: messageTypeAsString = "Address mask request"; break; case ICMP_ADDRESS_MASK_REPLY: messageTypeAsString = "Address mask reply"; break; default: messageTypeAsString = "Unknown"; break; } std::ostringstream typeStream; typeStream << (int)getIcmpHeader()->type; return "ICMP Layer, " + messageTypeAsString + " (type: " + typeStream.str() + ")"; }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ MessageFactory::pMessage_type MessageFactory::create(pMessageHeader_type _pMessageHeader, pEndpoint_type _pSourceEndpoint, pEndpoint_type _pDestinationEndpoint) { switch(getMessageType(_pMessageHeader)) { case UnsubscribeAccountModelRequest::type: return pMessage_type(new UnsubscribeAccountModelRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UpdateGroupRequest::type: return pMessage_type(new UpdateGroupRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case DeleteAccountRequest::type: return pMessage_type(new DeleteAccountRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateAccountRequest::type: return pMessage_type(new CreateAccountRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case SubscribeGroupModelRequest::type: return pMessage_type(new SubscribeGroupModelRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UnsubscribeGroupModelRequest::type: return pMessage_type(new UnsubscribeGroupModelRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case ReadAccountRequest::type: return pMessage_type(new ReadAccountRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UpdateAccountRequest::type: return pMessage_type(new UpdateAccountRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case SubscribeAccountModelRequest::type: return pMessage_type(new SubscribeAccountModelRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateGroupRequest::type: return pMessage_type(new CreateGroupRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case DeleteGroupRequest::type: return pMessage_type(new DeleteGroupRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case ReadGroupRequest::type: return pMessage_type(new ReadGroupRequest(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case GroupModelUpdateMessage::type: return pMessage_type(new GroupModelUpdateMessage(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case AccountModelUpdateMessage::type: return pMessage_type(new AccountModelUpdateMessage(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UnsubscribeAccountModelResponse::type: return pMessage_type(new UnsubscribeAccountModelResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UpdateGroupResponse::type: return pMessage_type(new UpdateGroupResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case DeleteAccountResponse::type: return pMessage_type(new DeleteAccountResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateAccountResponse::type: return pMessage_type(new CreateAccountResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case SubscribeGroupModelResponse::type: return pMessage_type(new SubscribeGroupModelResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UnsubscribeGroupModelResponse::type: return pMessage_type(new UnsubscribeGroupModelResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case ReadAccountResponse::type: return pMessage_type(new ReadAccountResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case UpdateAccountResponse::type: return pMessage_type(new UpdateAccountResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case SubscribeAccountModelResponse::type: return pMessage_type(new SubscribeAccountModelResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case CreateGroupResponse::type: return pMessage_type(new CreateGroupResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case DeleteGroupResponse::type: return pMessage_type(new DeleteGroupResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); case ReadGroupResponse::type: return pMessage_type(new ReadGroupResponse(_pMessageHeader, _pSourceEndpoint, _pDestinationEndpoint), &destroy); } // TODO Throw an exception? std::cout << "Zen::Community::Account::ProtocolMessageFactory::getMessageType(): Error, wrong message type - " << getMessageType(_pMessageHeader) << std::endl; return pMessage_type(); }