SNMP sysObjectID

Discussion to talk about software related topics only.
SeeCwriter
Posts: 635
Joined: Mon May 12, 2008 10:55 am

SNMP sysObjectID

Post by SeeCwriter »

I'm implementing the system group in my MIB and I'm at a loss as to how to use sysObjectID. The description in RFC-1213 is confusing, and the SNMP books I'm using aren't any better.

The sysObjectID is defined as an OBJECT IDENTIFIER that is read-only at OID 1.3.6.1.2.1.1.2. What type is an OBJECT IDENTIFIER? Is it a string, an integer, or what?
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: SNMP sysObjectID

Post by pbreed »

An OID is a spot on the Asn1 tree...

1.3.6.1.2.1.1.2. is an OID.....

All of the indexes into the MIB are OID's

The SysOid is "Device identifier.."

This is usually the oid assigned to a specific company or entity with additional suffix added to specify the model of the thing.

NetBurners oid is:

1.3.6.1.4.1.8174

So as we create products they might have oid's like:

1.3.6.1.4.1.8174.1.1 IE NetBurner product group 1 product 1
1.3.6.1.4.1.8174.2.1 IE NetBurner product group 2 product 1
1.3.6.1.4.1.8174.2.2 IE NetBurner product group 2 product 2

etc.....
SeeCwriter
Posts: 635
Joined: Mon May 12, 2008 10:55 am

Re: SNMP sysObjectID

Post by SeeCwriter »

I'm not sure you explained what value is returned when sysObjectID is queried. Or I'm just slow.
In looking through the NB code produced by snmptranslate, the callback read function for sysObjectID
returns a pointer to an int. Which seems to be different than what my MIB book is saying. The book, SNMP
MIB Handbook, uses the following brief Microsoft MIB to explain the sysObjectID:

MSFT-MIB DEFINITIONS ::= BEGIN
IMPORTS
enterprises
FROM RFC1155-SMI;

microsoft OBJECT IDENTIFIER ::= { enterprises 311 }
software OBJECT IDENTIFIER ::= { microsoft 1 }
systems OBJECT IDENTIFIER ::= { software 1 }
os OBJECT IDENTIFIER ::= { systems 3 }
windowsNT OBJECT IDENTIFIER ::= { os 1 }
windows OBJECT IDENTIFIER ::= { os 2 }
workstation OBJECT IDENTIFIER ::= { windowsNT 1 } -- sysObjectID value
server OBJECT IDENTIFIER ::= { windowsNT 2 }
dc OBJECT IDENTIFIER ::= { windowsNT 3 }

END

The book says, in this example, the value of "workstation" is the value of sysObjectID. Does that mean that sysObjectID is
OID string "1.3.6.1.4.1.311.1.1.3.1.1", which seems to be different than the code snmptranlate produced.
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: SNMP sysObjectID

Post by pbreed »

An OID IS NOT A STRING It is a native ASN1 type. (ASN1 is the encoding used in SNMP)
The OID tree name space is the root of ALL SNMP you really need to understand what an OID is
or SNMP will never make ANY sense you you.

It is a list of integers that define the path through the tree that makes up OID name space.
Its not encoded as a string, it can be printed as a string, just like the 32 bit IP address 0A010102 Can be printed as "10.1.1.2"
See here:
http://www.obj-sys.com/asn1tutorial/node10.html

We encode them as lists of integers....
1.3.6.1.4.1.8174

Starting at the root of the OID name space tree
1 Take the first leaf (iso)
3 Take the 3 leaf under that
6 take the 6 leaf under that
1 take the 1 leaf under that
4 take the 4 leaf under that
1 take the 1 leaf under that
8174 take the 8174 leaf under that...
That happens to point to the name space that was assigned to netburner...

Another way to write this would be:
iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) netburner(8174)
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: SNMP sysObjectID

Post by pbreed »

SeeCwriter
Posts: 635
Joined: Mon May 12, 2008 10:55 am

Re: SNMP sysObjectID

Post by SeeCwriter »

I read your links. Applying what your link to the ASN1 Tutorial seems to teach to the Microsoft example,
the sysObjectID value would be 1361413111131. Which I think exceeds the range of a DWORD. And it doesn't
explain how one determines where to put the periods. Is the Enterprise ID 311 or 3111? Is the last node 1
or 31 or 131?

There's still something I'm missing.
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: SNMP sysObjectID

Post by pbreed »

An OID is a variable length array of integers.....(integers in the math sense not 4 byte integers in the c sense)

The best way to return one if its fixed is to convert a string to an oid and return that.....

Look at SYSOID ans SysOid in the snmp examples...
SeeCwriter
Posts: 635
Joined: Mon May 12, 2008 10:55 am

Re: SNMP sysObjectID

Post by SeeCwriter »

I understand how OIDs work. I just don't understand how a dotted OID integer string is converted to a DWORD value.
I understand how it's done with IP addresses. Perhaps there are macros or functions to convert OID strings to
DWORDs and DWORDs to dotted strings, like there is for network addresses.

There is no SysOid in the examples. But there is SYSOID, and I've used it before. It sets the root OID for the MIB.
Which brings up another question. In the previous MIBs I built, I did not include the system objects
(1.3.6.1.2.1.1), so SYSOID was set to the enterprise OID ("1.3.6.1.4.1.30679"). My question is, when I
include the system objects, does SYSOID need to be set to "1.3.6.1" instead?
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: SNMP sysObjectID

Post by pbreed »

In the examples....

In the mibcls.cpp file...

SNMPREADFUNC( sysObjectID,
"1.3.6.1.2.1.1.2.0.",
ASN_typeObjID,
ReadFuncsysObjectID,
READ_COMMUNITY_MASK );

This creates the sysObjectID entry in the snmp tree.
It calls ReadFuncsysObjectID

That function is:


int SysOid[20];

/*Variable : -R-- ObjID sysObjectID(2)-1.3.6.1.2.1.1.2.*/
snmp_typeObjID ReadFuncsysObjectID()
{
/* You must fill this in */
GetOid( SYSOID, SysOid );
return SysOid;
}


Where SYSOID is defined as :
const char * SYSOID="1.3.6.1.4.1.8174.2.40";

The GetOid converts from the string to the internal list of integers oid format.

The actual internal format of OID's as implmented by the netburner system is an array of ints, where the first entry has the number of entries...

So 1.3.6.1.4.1.8174.2.40 would be:
int InternalRepofOid[] ={9,1,3,6,1,4,1,8174,2,40};

When it gets put on the wire it will follow BER rules for making an oid out fo the set... but internally we represent Oid's as an array of integers with the first being the number of elements to follow...
SeeCwriter
Posts: 635
Joined: Mon May 12, 2008 10:55 am

Re: SNMP sysObjectID

Post by SeeCwriter »

You know, this whole thread was practically pointless. The NB SNMP library already implements the system MIB objects.
I did increase my understanding of some MIB details, but wasted several days trying to do what was already provided.

I apologize for wasting your time.
Post Reply