Helpful ReplyHot!CustomSNMPApp.c setting

Author
peterverkaik
Super Member
  • Total Posts : 191
  • Reward points : 0
  • Joined: 2009/09/05 11:39:08
  • Location: 0
  • Status: offline
2014/09/24 21:52:54 (permalink)
0

CustomSNMPApp.c setting

Hi,
 
I am updating to use SNMP with our own PEN number (19999 instead of microchip's 17095).
 
In file CustomSNMPApp.c there is
 
/*
* This structure has been moved from snmp.c file to here.
*/
#ifdef STACK_USE_SMIV2
/*
* With SMIv2 standard which includes MODULE-IDENTITY number with the existing OID string.
* For New snmp.mib file with SMIv2 standard
*/
/*
* ENTERPRISEID - 17095(Microchip) as per BER encoding standard 0x81,0x85,0x47
* Need to be modified with respect to customer enterprise ID
*/
SNMPNONMIBRECDINFO gSnmpNonMibRecInfo[SNMP_MAX_NON_REC_ID_OID] =
{
#ifdef STACK_USE_SNMPV3_SERVER  
 /* SNMPv3 Static Variable OID string which is not part of mib.h file */
#endif   
 {{43,6,1,2,1,1},SNMP_V2C}, /* Max matching Subids of the iso+org (43),dod(6),internet(1),mgmt(2),MIB2(1),system(1) tree*/ 
 {{43,6,1,4,1,0x81,0x85,0x47,0x1,1},SNMP_V2C},
 /*Max matching Subids of the iso+org (43),dod(6),internet(1),private(4),ENTERPRISE(17095),MODULE-IDENTITY(1),product tree*/   
 
};
/*
 * if snmp.mib file doesnot have MODULE-IDENTITY number then this is the following structure should be used
 */
#else
/*
* OLD snmp.mib file with SMIv1 standard
*/
SNMPNONMIBRECDINFO gSnmpNonMibRecInfo[SNMP_MAX_NON_REC_ID_OID] =
{
#ifdef STACK_USE_SNMPV3_SERVER  
 {{43,6,1,4,1,0x81,0x85,0x47,6},SNMP_V3},  /* SNMPv3 PVT test MIB OID is not part of mib.h file */
#endif   
 {{43,6,1,2,1,1},SNMP_V2C}, /* Max matching Subids of the iso+org (43),dod(6),internet(1),mgmt(2),MIB2(1),system(1) tree*/ 
 {{43,6,1,4,1,0x81,0x85,0x47,0x1},SNMP_V2C},
 /*Max matching Subids of the iso+org (43),dod(6),internet(1),private(4),ENTERPRISE(17095),product tree*/   
 
};
#endif /* STACK_USE_SMIV2 */
 
 
The issue is this line
 {{43,6,1,4,1,0x81,0x85,0x47,0x1,1},SNMP_V2C},
 /*Max matching Subids of the iso+org (43),dod(6),internet(1),private(4),ENTERPRISE(17095),MODULE-IDENTITY(1),product tree
 
How are the bytes 0x81,0x85,0x47,0x1 computed from the 17095 PEN (Private Enterprise Number)?
I want to change 17095 to 19999, so these bytes must be updated.
 
regards peter
 
#1
freebsd
Super Member
  • Total Posts : 147
  • Reward points : 0
  • Joined: 2011/03/07 04:15:29
  • Location: 0
  • Status: offline
Re: CustomSNMPApp.c setting 2014/09/25 04:34:28 (permalink) ☄ Helpfulby Dag 2017/12/18 22:04:45
0
Hi Peter,
You can use following sample code to generate your bytes.

do
{
if ( d > 127 )
{
if ( tempOidlen == 0 )
adjustedOID[tempOidlen] = (uint8_t)(d % 128);
else
adjustedOID[tempOidlen] = (uint8_t)((d % 128) + 0x80);
tempOidlen++;
}
else
{
adjustedOID[tempOidlen++] = (uint8_t)(d + 0x80);
}
if(tempOidlen > len)
{
return 0;
}
d = d / 128;
} while( d > 0 );

#2
peterverkaik
Super Member
  • Total Posts : 191
  • Reward points : 0
  • Joined: 2009/09/05 11:39:08
  • Location: 0
  • Status: offline
Re: CustomSNMPApp.c setting 2014/09/26 04:40:04 (permalink) ☄ Helpfulby aparna4395 2015/04/07 23:30:56
1 (1)
Thanks!
 
I created macros to make it easier.
Should work for PEN's of size 14bits to 21 bits.
 
#define PEN1 19999
#define PENBYTE3 (PEN1 & 0x7F)
#define PEN2 (PEN1 >> 7)
#define PENBYTE2 ((PEN2 & 0x7F) | 0x80)
#define PEN3 (PEN2 >> 7)
#define PENBYTE1 (PEN3 | 0x80)
 
 {{43,6,1,4,1,PENBYTE1,PENBYTE2,PENBYTE3,0x1,1},SNMP_V2C},
 
regards peter
 
#3
Dag
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2014/10/31 11:53:36
  • Location: 0
  • Status: offline
Re: CustomSNMPApp.c setting 2017/12/18 22:07:19 (permalink)
0
Thanks Peter - I was pulling hairs till I found those hex codes in the source..
#4
Jump to:
© 2018 APG vNext Commercial Version 4.5