In SNMP, Can we remove .0 from the end of a Scalar OID? - snmp

I have a situation, I have defined a scalar OID in my MIB but when I try to get value of the OID from the Agent using SNMP Get, it says "No OID exists" but when I append .0 at the end of the OID it replies with the value. I need to know can I make sure that this .0 at the end of the OID should not be required?

The OID convention (.0 for scalar objects) is part of SNMP standards, so cannot be altered for you alone.

Related

SNMP Mac ID formatting issue

I need clarity related MAC SNMP oid .1.3.6.1.2.1.2.2.1.6.
The oid is retrieving data in two formats - octet string and hex string. Ex:
1) octet string .1.3.6.1.2.1.2.2.1.6.2 STRING: 00:01:80:5c:df:1c
2) hex string. .1.3.6.1.2.1.2.2.1.6.1 STRING: 30:30:3a:30:30:3a:30:30:3a:30:30:3a:30:30:3a:30:30
Hence while writing code logic, we need to handle both variety. But How to identify the retrieving data is octet string or hex string? Is this related to little endian or big endian concept? Any OID will provide us inform type of data. Kindly help.
This is specified in the relevant MIB. You should work with MIBs, not just numerical OIDs out of context. An OID just tells you which object is being referred to, but there is so much more information in the MIB about those objects, including their type and how they ought to be interpreted.
In fact there is no such thing as a HEX STRING; these are usually OCTET STRINGs with a display-hint that they should be shown to the user in hex-pair notation.
OCTET STRINGs don't have endianness; they're strings. Sequences.

Microsoft Outlook calendar generates invalid unique identifiers for the UID property?

I exported a .ics file from Microsoft Outlook calendar. The .ics file contained this UID property:
UID:Ooldc6nEFUK0B6AS7oLh8w==
Here is another UID generated by Microsoft Outlook calendar:
UID:sSfe/XDnb0qy6JvmOrlKMg==
According to RFC 7986, the value of both of those UIDs is invalid. Specifically, the first one contains the invalid equals ( = ) symbol and the second one contains the invalid forward slash ( / ) symbol (as well as the invalid equals symbol).
Do you agree that the above UID values are invalid?
Do you know what rules Microsoft Outlook calendar follows in generating UID values? Perhaps they generate UID values as Base64 strings?
I am creating a .ics validator tool. Should my tool flag the above UID values as invalid? What rules should I use in my validator tool for validating UID values?
Here's what RFC 7986 says about UID values:
This specification updates [RFC5545] by stating that "UID" values MUST
NOT include any data that might identify a user, host, domain, or any
other security- or privacy-sensitive information. It is RECOMMENDED
that calendar user agents now generate "UID" values that are
hex-encoded random Universally Unique Identifier (UUID) values as
defined in Sections 4.4 and 4.5 of [RFC4122].
If calendar user agents choose to use other forms of opaque identifiers for the "UID" value, they MUST have a length less than 255
octets and MUST conform to the "iana-token" ABNF syntax defined in
Section 3.1 of [RFC5545].
Here’s how RFC 5545 defines “iana-token”:
iana-token = 1*(ALPHA / DIGIT / "-")

PySNMP unicode support

Does PySNMP support Unicode for sending snmptrap. I sent trap with unicode character in it but I get the result in hex. Is there any work around to get the value in Unicode. e.g. Here is my snmp trap command
sudo snmptrap -v2c -c public 192.168.2.162 '' .1.2.3.4.5.6.7.8.9
ifIndex i 2 ifAdminStatus i 1 1.3.6.1.4.1.9.9.599.1.3.1.1.1.0 s "विवेक
सुवेदी"
But in the place of "विवेक सुवेदी", I got 0xe0a4b5e0a4bfe0a4b5e0a587e0a49520e0a4b8e0a581e0a4b5e0a587e0a4a6e0a580
. Is there any way to get unicode?
AFAIK, to properly render UTF-8 strings, MIB object (1.3.6.1.4.1.9.9.599.1.3.1.1.1.0) should be typed as some TEXTUAL-CONVENTION having DISPLAY-STRING="255t" that indicates UTF-8 string.
If that is not the case, SNMP will treat it as a binary string and will not attempt to render it properly. The same happens if you do not use MIB resolution (what converts pure ASN.1/SNMP types into MIB-defined subtypes) and deal with pure ASN.1 objects.
In the latter case a hackerish solution is to skip .prettyPrint()-ing values through SNMP and use them as-is via .asOctets:
>>> print(OctetString(u'кириллица'.encode('utf-8')).asOctets())
кириллица
The problem here is that you might have to programmatically apply this logic to specific OIDs -- this is what MIB is designed for. ;)

SNMP4J - OID Output Options - Hex-STRING as STRING

I'm using SNMP4J to read info of devices with SNMP. Now I found some devices which represent the system name (OID iso.3.6.1.2.1.1.5.0) as a Hex-STRING instead of a STRING.
To show the system name I use the following code:
Variable var = response.getVariable(new OID(".1.3.6.1.2.1.1.5.0"));
System.out.println(var.toString());
Where response is a PDU object.
If the system name is represented as a STRING value, this goes as I expected. When it is represented as a Hex-STRING, it just prints the Hex value.
Example:
Take the name of the system as "SYSTEM NAME".
With STRING it prints "SYSTEM NAME".
With Hex-STRING it prints "53:59:53:54:45:4d:20:4e:41:4d:45"
Now with snmpwalk in command line I can just use the -Oa flag. This makes all Hex-STRING values show as STRING. Is it possible to use this flag in SNMP4J or is there a similar option?
I'm not sure where you're getting the term "Hex-STRING" from. SNMP does not define such a data type. I suggest you read through the relevant RFC documents, they are publicly available from IETF. The wikipedia article for SNMP (http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol#References) has an excellent reference list, you can start with browsing the ones marked as "STD".
In SNMP, all strings are subtypes (or in a different word, "restrictions") of OCTET-STRING, a byte string of indeterminate length. It may contain any data, even non-printable stuff, representing a jpeg image or whatever.
Some textual-conventions have been defined, which restrict the data to some specific byte range, or length. A DisplayString is defined to only contain bytes from the NVT ASCII character set, so the user may trust it to be printable.
In fact, sysName is defined to be a DisplayString with a max length of 255 characters.
sysName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
Since a good SNMP manager is aware of RFC1213-MIB, which defines both sysName and DisplayString, the manager should assume that the data received is printable ASCII characters.
When you say "When it is represented as a Hex-STRING", what do you mean? "Represented" where, on the agent or in your Java code or when using the net-snmp "snmpwalk" command?
The var.toString() call should convert the contents of the variable into something that could be safely printed in a terminal, so it's possible that SNMP4j is converting any binary string to a hex string.

MAPI: Format of PR_SEARCH_KEY

Does anyone know the format of the MAPI property PR_SEARCH_KEY?
The online documentation has this to say about it:
The search key is formed by
concatenating the address type (in
uppercase characters), the colon
character ':', the e-mail address in
canonical form, and the terminating
null character.
And the exchange document MS-OXOABK says this:
The PidTagSearchKey property of type
PtypBinary is a binary value formed by
concatenating the ASCII string "EX: "
followed by the DN for the object
converted to all upper case, followed
by a zero byte value.
However all the MAPI messages I've seen with this property have it as some sort of binary 16 byte sequence that looks like a GUID. Does anyone else have any more information about it? Is it always 16 bytes?
Thanks!
I believe that the property PR_SEARCH_KEY will be of different formats for different objects (as alluded to by Moishe).
A MAPI message object will have a unique value assigned on creation for PR_SEARCH_KEY, however if the object is copied this property value is copied also. I presume when you reply to an e-mail, Exchange will assign the PR_SEARCH_KEY value to be the original message's value.
You will need to inspect each object type to understand how the PR_SEARCH_KEY is formed but I doubt if it's always 16 bytes for all MAPI types.
This link USENET discussion has a good discussion with Dmitry Streblechenko involved who is an expert on Extended MAPI.
The sentence before the ones you quoted from the online docs reads, "MAPI uses specific rules for constructing search keys for message recipients" which makes me think that it's talking about the PR_SEARCH_KEY property on MAPI_MAILUSER objects -- or at least not on MAPI_MESSAGE objects.

Resources