Jump to content

A-Team

Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

A-Team's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. as you wish yes the number has changed it was 192 its currently 193 with source remaining is -63 I don't believe this is anything to do with the code its just sensitive Isn't the C1 at the end where the value is that is 193
  2. at least I thought the same thing trying to track the changes through, taken from here as the line after the variable is empty, the "real" value is taken from the "$_RealData" further down this is just to compare with there is so much other information in the rcv the correct value could be there but i will continue trying to decode
  3. that would be correct, I am using the snmp UDF Version 1.7.4 HERE I did start here but will see if I can find the issue as "Nine" Mentioned the function for populating snmp_until, exactly from the UDF no changes of mine Func _ShowSNMPReceived($rcvDATA) Global $SNMP_Util[1000][3] Local $_sPacketRecv_ = $rcvDATA Local $_PDUcontent = "" Local $_ExtractedDATA Local $_IsError = 0 Local $_PDU_content = "" Local $_delimSTR_ = "" _WriteArrayValues($SNMP_Received, 1, "SNMP Answer", $rcvDATA) $rcvDATA = StringTrimLeft($rcvDATA, 4) ;strip 0x30 Local $_l_pl = _GetPacLen_(StringLeft($rcvDATA, 6)) Local $_pacLen_ = StringLeft($rcvDATA, $_l_pl) $rcvDATA = StringTrimLeft($rcvDATA, $_l_pl) ;strip packet length _WriteArrayValues($SNMP_Received, 2, "(Total) PDU Length", $_pacLen_) ;------------- SNMP Version Block ------------------------------------------------- _WriteArrayValues($SNMP_Received, 3, "SNMP Version Block", StringLeft($rcvDATA, 6)) $rcvDATA = StringTrimLeft($rcvDATA, 4) ;strip 0201 from SNMP ver block Local $_snmpV_ = StringLeft($rcvDATA, 2)+1 ;SNMP Version $rcvDATA = StringTrimLeft($rcvDATA, 2) ;strip SNMP Version ;------------- Community String --------------------------------------------------- $rcvDATA = StringTrimLeft($rcvDATA, 2) ;strip 04 from community block Local $_commLen_ = Dec(StringLeft($rcvDATA, 2))*2 ;Length of community string $rcvDATA = StringTrimLeft($rcvDATA, 2) ;strip community length Local $_commHex_ = StringLeft($rcvDATA, $_commLen_) ;community string (hex) Local $_commTex_ = _HexToString($_commHex_) $rcvDATA = StringTrimLeft($rcvDATA, $_commLen_) _WriteArrayValues($SNMP_Received, 4, "Community String", $_commTex_) ;------------- PDU Type ----------------------------------------------------------- Local $_pduT_ = StringLeft($rcvDATA, 2) _WriteArrayValues($SNMP_Received, 5, "PDU Type", $_pduT_) $rcvDATA = StringTrimLeft($rcvDATA, 2) $rcvDATA = _StripPacket($rcvDATA) ;------------- Request ID --------------------------------------------------------- $rcvDATA = _StripBlocks($rcvDATA, 6, "Request ID Block") ;------------- Error Block -------------------------------------------------------- Local $_sErr_ = StringMid($rcvDATA, 5, 2) If $_sErr_ <> "00" Then _ThrowError($_sErr_, $_sPacketRecv_) Return SetError(1) EndIf _WriteArrayValues($SNMP_Util, 0, "SNMP Error Value:", $_sErr_) $rcvDATA = _StripBlocks($rcvDATA, 7, "Error Block") ;------------- Error Index -------------------------------------------------------- $rcvDATA = _StripBlocks($rcvDATA, 8, "Error Index Block") ;------------- PDU Total Len ------------------------------------------------------ $rcvDATA = StringTrimLeft($rcvDATA, 2) $_l_pl = _GetPacLen_(StringLeft($rcvDATA, 6)) Local $_pacTotLen_ = StringLeft($rcvDATA, $_l_pl) $rcvDATA = StringTrimLeft($rcvDATA, $_l_pl) ;strip packet length ;------------- PDU Data ----------------------------------------------------------- Local $_snmpR_idx = 9, $_snmpA_idx = 1 Do $rcvDATA = StringTrimLeft($rcvDATA, 2) ;cut "30" (data type: SEQ) $_l_pl = _GetPacLen_(StringLeft($rcvDATA, 6)) ;length of Data PDU $_pacLen_ = StringLeft($rcvDATA, $_l_pl) $rcvDATA = StringTrimLeft($rcvDATA, $_l_pl) ;cut length $_PDU_content = StringLeft($rcvDATA, Dec($_pacLen_)*2) ;get what is left from PDU $rcvDATA = StringTrimLeft($rcvDATA, Dec($_pacLen_)*2) ;remove that from message $_delimSTR_ = "30|"&$_pacLen_&"|" ;build delimited string If StringLeft($_PDU_content, 2) = "06" Then $_delimSTR_ &= "06|" $_PDU_content = StringTrimLeft($_PDU_content, 2) ;cut "06" (data type: OID) $_l_pl = _GetPacLen_(StringLeft($_PDU_content, 6)) ;Length of OID sequence $_pacLen_ = StringLeft($_PDU_content, $_l_pl) $_PDU_content = StringTrimLeft($_PDU_content, $_l_pl) ;cut length Local $_OID_val = StringLeft($_PDU_content, Dec($_pacLen_)*2) ;OID (hex) $_delimSTR_ &= $_pacLen_&"|"&$_OID_val&"|" Local $_Decoded_OID = _TranslateOID($_OID_val, "2d") ;OID (dec) $_PDU_content = StringTrimLeft($_PDU_content, Dec($_pacLen_)*2) Local $_data_type = StringLeft($_PDU_content, 2) ;returned data type $_PDU_content = StringTrimLeft($_PDU_content, 2) If StringLen($_PDU_content) >= 6 Then $_l_pl = _GetPacLen_(StringLeft($_PDU_content, 6)) ;Length of data sequence Else $_l_pl = _GetPacLen_(StringLeft($_PDU_content, 4)) ;Length of data sequence EndIf Local $_raw_data = StringTrimLeft($_PDU_content, $_l_pl) Local $_RealData = _ExtractData($_data_type, $_raw_data) _WriteArrayValues($SNMP_Received, $_snmpR_idx, $_Decoded_OID, $_RealData) $_snmpR_idx += 1 $_delimSTR_ &= $_data_type&"|"&StringLeft($_PDU_content, $_l_pl)&"|"&$_raw_data _WriteArrayValues($SNMP_Received, $_snmpR_idx, "Raw PDU (delimited string)", $_delimSTR_) $_snmpR_idx += 1 _WriteArrayValues($SNMP_Util, $_snmpA_idx, $_Decoded_OID, $_RealData) $_snmpA_idx += 1 $_delimSTR_ = "" Else Return SetError(2) ;bad SNMP Packet EndIf Until Int(StringLen($rcvDATA)) = 0 ReDim $SNMP_Received[$_snmpR_idx][3] ReDim $SNMP_Util[$_snmpA_idx][3] Return $SNMP_Util EndFunc ;==>_ShowSNMPReceived #endregion
  4. Good afternoon First off Thank you all for your inputs although I think I have confused just about everyone with my fine choice of words above :0, I will try to clarify what the data looks like, how its populated and what I need to do with such, first the data, the table will look like this from the source the snmp agent these values will fluctuate, the negative numbers are the only important ones, stored as int32 the values just from the snmp until will look like this these values are not all in $traffic_priortization at the same time, more so added as it increments in the loop, these values are populated with an snmp get request that code looks like this $SNMP_Command = _SNMPBuildPacket($SNMP_OID, $SNMP_Community ,$SNMP_Version, $SNMP_ReqID, "A0") ; A single GetRequest UDPSend($Socket, $SNMP_Command) _StartListener() ; 250ms timeout. If @error Then error checking condition i have removed for sake of example Else $Traffic_Prioritization = $SNMP_Util[1][1] The outcome I am is looking for is to retain the negative numbers in my functions,
  5. Good afternoon, I'm looking for some help with my project, I am working with negative 32bit integers I receive from an snmp request, but I have no issue here* once these numbers are processed they are no longer negative, which I require here is a code extract this cannot run** as many elements are missing and I cannot share the broader software this is part of, The value of $fiberint would be -400 from the snmp table, although it will be 65136 ($testfiber is just for comparison) before I have made any modifications to it, its binary value is 1111111001110000, that will make its signed 2sc -400 the value I am looking to utilize, How can I create a function to assign this value to a variable This snippet is part of a loop and this number cannot be hardcoded as it will change due to external factors Am I approaching this issue entirely wrong? doesn't change much to completely start over its only one method that uses negative numbers, I have scanned through many of the forum mentions of these topics and looked through the help file, only bitshift/ bitrotate stuck out Sorry if this is a small bit messy, any and all ideas welcome, I only have a few weeks with autoIt but willing to learn $Traffic_Prioritization = $SNMP_Util[1][1] Local $testfiber = 65136 Local $fiberint = Int($Traffic_Prioritization, $NUMBER_32BIT) ; $NUMBER_AUTO (0) $NUMBER_32BIT (1) $NUMBER_64BIT (2) Local $fiberbin = Binary($Traffic_Prioritization) Local $fiberhex = Hex($fiberint) Local $testfiberbin = Binary($testfiber) $Traffic_Prioritization_Array[$i - 1] = $fiberint GUICtrlSetData($idMyedit,"sfpport test: " & $fiberint & @CRLF,1) GUICtrlSetData($idMyedit,"fiber bin test: " & $fiberbin & @CRLF,1)
  6. of course it is!, it interprets the values with Two complement here I don't know the time I spent trying to troubleshoot this, I am learning data structures in college, but I learned more trying to figure this out..
  7. How's it going, Looking for help working with this UDF, with Negative numbers I am making an SNMP request to my agent for fiber tx and rx values in a loop, although some of these results should be negative although the udf is not interpreting these correctly, For example the values would be like "341" "- 62", "-400" and they would be reported as "341", "192", "65136" I know the values are correct as I am sniffing the packets with Wireshark and can see the response is -400 I cannot provide running code as there is far to much extra setup and without an agent it wouldn't be easily tested but its just a standard snmp packet i have tried converting to a signed INT, Number and checking hex, all report the same 65136 number, wireshark shows its a Integer32 Any information or ideas would be great, Thanks and have a great weekend!
×
×
  • Create New...