void parseDiagnosticInfo(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, const char *szFieldName) { gint iOffset = *pOffset; guint8 EncodingMask; proto_tree *mask_tree; proto_tree *subtree; proto_item *ti; proto_item *ti_inner; ti = proto_tree_add_text(tree, tvb, *pOffset, -1, "%s: DiagnosticInfo", szFieldName); subtree = proto_item_add_subtree(ti, ett_opcua_diagnosticinfo); /* parse encoding mask */ EncodingMask = tvb_get_guint8(tvb, iOffset); ti_inner = proto_tree_add_text(subtree, tvb, iOffset, 1, "EncodingMask"); mask_tree = proto_item_add_subtree(ti_inner, ett_opcua_diagnosticinfo); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_symbolicflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_namespaceflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_localizedtextflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_additionalinfoflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_innerstatuscodeflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_diag_mask_innerdiaginfoflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); iOffset++; if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_SYMBOLICID_FLAG) { parseInt32(subtree, tvb, &iOffset, hf_opcua_diag_symbolicid); } if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_NAMESPACE_FLAG) { parseInt32(subtree, tvb, &iOffset, hf_opcua_diag_namespace); } if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_LOCALIZEDTEXT_FLAG) { parseInt32(subtree, tvb, &iOffset, hf_opcua_diag_localizedtext); } if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_ADDITIONALINFO_FLAG) { parseString(subtree, tvb, &iOffset, hf_opcua_diag_additionalinfo); } if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_INNERSTATUSCODE_FLAG) { parseStatusCode(subtree, tvb, &iOffset, hf_opcua_diag_innerstatuscode); } if (EncodingMask & DIAGNOSTICINFO_ENCODINGMASK_INNERDIAGNOSTICINFO_FLAG) { parseDiagnosticInfo(subtree, tvb, &iOffset, "Inner DiagnosticInfo"); } proto_item_set_end(ti, tvb, iOffset); *pOffset = iOffset; }
void RTMPSession::handleInvoke(uint8_t* p) { int buflen=0; std::string command = get_string(p, buflen); int32_t pktId = int32_t(get_double(p+11)); DLog("pktId: %d\n", pktId); std::string trackedCommand ; auto it = m_trackedCommands.find(pktId) ; if(it != m_trackedCommands.end()) { trackedCommand = it->second; } DLog("received invoke %s\n", command.c_str()); if (command == "_result") { DLog("tracked command: %s\n", trackedCommand.c_str()); if (trackedCommand == "connect") { sendReleaseStream(); sendFCPublish(); sendCreateStream(); setClientState(kClientStateFCPublish); } else if (trackedCommand == "createStream") { if (p[10] || p[19] != 0x05 || p[20]) { DLog("RTMP: Unexpected reply on connect()\n"); } else { m_streamId = get_double(p+21); } sendPublish(); setClientState(kClientStateReady); } } else if (command == "onStatus") { std::string code = parseStatusCode(p + 3 + command.length()); DLog("code : %s\n", code.c_str()); if (code == "NetStream.Publish.Start") { sendHeaderPacket(); sendSetChunkSize(getpagesize()); // sendSetBufferTime(0); setClientState(kClientStateSessionStarted); m_throughputSession.start(); } } }
void parseDataValue(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, const char *szFieldName) { proto_item *ti = proto_tree_add_text(tree, tvb, *pOffset, -1, "%s: DataValue", szFieldName); proto_tree *subtree = proto_item_add_subtree(ti, ett_opcua_datavalue); proto_tree *mask_tree; gint iOffset = *pOffset; guint8 EncodingMask; proto_item *ti_inner; EncodingMask = tvb_get_guint8(tvb, iOffset); ti_inner = proto_tree_add_text(subtree, tvb, iOffset, 1, "EncodingMask"); mask_tree = proto_item_add_subtree(ti_inner, ett_opcua_datavalue); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_valueflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_statuscodeflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_sourcetimestampflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_servertimestampflag, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_sourcepicoseconds, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(mask_tree, hf_opcua_datavalue_mask_serverpicoseconds, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); iOffset++; if (EncodingMask & DATAVALUE_ENCODINGBYTE_VALUE) { parseVariant(subtree, tvb, &iOffset, "Value"); } if (EncodingMask & DATAVALUE_ENCODINGBYTE_STATUSCODE) { parseStatusCode(subtree, tvb, &iOffset, hf_opcua_StatusCode); } if (EncodingMask & DATAVALUE_ENCODINGBYTE_SOURCETIMESTAMP) { parseDateTime(subtree, tvb, &iOffset, hf_opcua_SourceTimestamp); } if (EncodingMask & DATAVALUE_ENCODINGBYTE_SOURCEPICOSECONDS) { parseUInt16(subtree, tvb, &iOffset, hf_opcua_SourcePicoseconds); } if (EncodingMask & DATAVALUE_ENCODINGBYTE_SERVERTIMESTAMP) { parseDateTime(subtree, tvb, &iOffset, hf_opcua_ServerTimestamp); } if (EncodingMask & DATAVALUE_ENCODINGBYTE_SERVERPICOSECONDS) { parseUInt16(subtree, tvb, &iOffset, hf_opcua_ServerPicoseconds); } proto_item_set_end(ti, tvb, iOffset); *pOffset = iOffset; }
void parseVariant(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, const char *szFieldName) { proto_item *ti = proto_tree_add_text(tree, tvb, *pOffset, -1, "%s: Variant", szFieldName); proto_tree *subtree = proto_item_add_subtree(ti, ett_opcua_variant); gint iOffset = *pOffset; guint8 EncodingMask; gint32 ArrayDimensions = 0; EncodingMask = tvb_get_guint8(tvb, iOffset); proto_tree_add_item(subtree, hf_opcua_variant_encodingmask, tvb, iOffset, 1, ENC_LITTLE_ENDIAN); iOffset++; if (EncodingMask & VARIANT_ARRAYMASK) { /* type is encoded in bits 0-5 */ switch(EncodingMask & 0x3f) { case OpcUaType_Null: break; case OpcUaType_Boolean: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Boolean, parseBoolean); break; case OpcUaType_SByte: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_SByte, parseSByte); break; case OpcUaType_Byte: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Byte, parseByte); break; case OpcUaType_Int16: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Int16, parseInt16); break; case OpcUaType_UInt16: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_UInt16, parseUInt16); break; case OpcUaType_Int32: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Int32, parseInt32); break; case OpcUaType_UInt32: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_UInt32, parseUInt32); break; case OpcUaType_Int64: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Int64, parseInt64); break; case OpcUaType_UInt64: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_UInt64, parseUInt64); break; case OpcUaType_Float: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Float, parseFloat); break; case OpcUaType_Double: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Double, parseDouble); break; case OpcUaType_String: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_String, parseString); break; case OpcUaType_DateTime: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_DateTime, parseDateTime); break; case OpcUaType_Guid: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_Guid, parseGuid); break; case OpcUaType_ByteString: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_ByteString, parseByteString); break; case OpcUaType_XmlElement: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_XmlElement, parseXmlElement); break; case OpcUaType_NodeId: parseArrayComplex(subtree, tvb, &iOffset, "NodeId", parseNodeId); break; case OpcUaType_ExpandedNodeId: parseArrayComplex(subtree, tvb, &iOffset, "ExpandedNodeId", parseExpandedNodeId); break; case OpcUaType_StatusCode: parseArraySimple(subtree, tvb, &iOffset, hf_opcua_StatusCode, parseStatusCode); break; case OpcUaType_DiagnosticInfo: parseArrayComplex(subtree, tvb, &iOffset, "DiagnosticInfo", parseDiagnosticInfo); break; case OpcUaType_QualifiedName: parseArrayComplex(subtree, tvb, &iOffset, "QualifiedName", parseQualifiedName); break; case OpcUaType_LocalizedText: parseArrayComplex(subtree, tvb, &iOffset, "LocalizedText", parseLocalizedText); break; case OpcUaType_ExtensionObject: parseArrayComplex(subtree, tvb, &iOffset, "ExtensionObject", parseExtensionObject); break; case OpcUaType_DataValue: parseArrayComplex(subtree, tvb, &iOffset, "DataValue", parseDataValue); break; case OpcUaType_Variant: parseArrayComplex(subtree, tvb, &iOffset, "Variant", parseVariant); break; } if (EncodingMask & VARIANT_ARRAYDIMENSIONS) { proto_item *ti_2 = proto_tree_add_text(subtree, tvb, iOffset, -1, "ArrayDimensions"); proto_tree *subtree_2 = proto_item_add_subtree(ti_2, ett_opcua_array); int i; /* read array length */ ArrayDimensions = tvb_get_letohl(tvb, iOffset); proto_tree_add_item(subtree_2, hf_opcua_ArraySize, tvb, iOffset, 4, ENC_LITTLE_ENDIAN); if (ArrayDimensions > MAX_ARRAY_LEN) { proto_item *pi; pi = proto_tree_add_text(subtree_2, tvb, iOffset, 4, "ArrayDimensions length %d too large to process", ArrayDimensions); PROTO_ITEM_SET_GENERATED(pi); return; } iOffset += 4; for (i=0; i<ArrayDimensions; i++) { parseInt32(subtree_2, tvb, &iOffset, hf_opcua_Int32); } proto_item_set_end(ti_2, tvb, iOffset); } } else { /* type is encoded in bits 0-5 */ switch(EncodingMask & 0x3f) { case OpcUaType_Null: break; case OpcUaType_Boolean: parseBoolean(subtree, tvb, &iOffset, hf_opcua_Boolean); break; case OpcUaType_SByte: parseSByte(subtree, tvb, &iOffset, hf_opcua_SByte); break; case OpcUaType_Byte: parseByte(subtree, tvb, &iOffset, hf_opcua_Byte); break; case OpcUaType_Int16: parseInt16(subtree, tvb, &iOffset, hf_opcua_Int16); break; case OpcUaType_UInt16: parseUInt16(subtree, tvb, &iOffset, hf_opcua_UInt16); break; case OpcUaType_Int32: parseInt32(subtree, tvb, &iOffset, hf_opcua_Int32); break; case OpcUaType_UInt32: parseUInt32(subtree, tvb, &iOffset, hf_opcua_UInt32); break; case OpcUaType_Int64: parseInt64(subtree, tvb, &iOffset, hf_opcua_Int64); break; case OpcUaType_UInt64: parseUInt64(subtree, tvb, &iOffset, hf_opcua_UInt64); break; case OpcUaType_Float: parseFloat(subtree, tvb, &iOffset, hf_opcua_Float); break; case OpcUaType_Double: parseDouble(subtree, tvb, &iOffset, hf_opcua_Double); break; case OpcUaType_String: parseString(subtree, tvb, &iOffset, hf_opcua_String); break; case OpcUaType_DateTime: parseDateTime(subtree, tvb, &iOffset, hf_opcua_DateTime); break; case OpcUaType_Guid: parseGuid(subtree, tvb, &iOffset, hf_opcua_Guid); break; case OpcUaType_ByteString: parseByteString(subtree, tvb, &iOffset, hf_opcua_ByteString); break; case OpcUaType_XmlElement: parseXmlElement(subtree, tvb, &iOffset, hf_opcua_XmlElement); break; case OpcUaType_NodeId: parseNodeId(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_ExpandedNodeId: parseExpandedNodeId(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_StatusCode: parseStatusCode(subtree, tvb, &iOffset, hf_opcua_StatusCode); break; case OpcUaType_DiagnosticInfo: parseDiagnosticInfo(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_QualifiedName: parseQualifiedName(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_LocalizedText: parseLocalizedText(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_ExtensionObject: parseExtensionObject(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_DataValue: parseDataValue(subtree, tvb, &iOffset, "Value"); break; case OpcUaType_Variant: parseVariant(subtree, tvb, &iOffset, "Value"); break; } } proto_item_set_end(ti, tvb, iOffset); *pOffset = iOffset; }