Re: (Previous email had a weird formatting) Custom Mib returning wrong values when Magic number is larger than 255

Neeraj Bansal <[email protected]> Fri, 20 Sep 2024 12:24:27 -0700
Newsgroups gmane.network.net-snmp.devel
Message-ID <CAP2FjR3Yh8sLeFfjz1TjVdYkoCk1a_GFr6sqreDJHHXYn=GD1g@mail.gmail.com>
--===============4901039040236789829==
Content-Type: multipart/alternative; boundary="000000000000732ebd062291fd65"

--000000000000732ebd062291fd65
Content-Type: text/plain; charset="UTF-8"

That makes sense Craig. Thank you for your input.

To summarize the issue, we are unable to use more than 255 OID entries and
would love to get any help on this issue.

Is there another way to use more than 255 custom OID's?

Thank You to anyone looking into this matter.

- Neeraj

On Mon, 29 Jul 2024 at 14:26, Craig Small <[email protected]> wrote:

> On Fri, 12 Jul 2024 at 08:31, Neeraj Bansal <[email protected]>
> wrote:
> > We recompile everything and install no problem, but instead of fixing
> our problem it caused net-snmp-5.9.3 to not be able to start. The error it
> gives is: Bad user id, which could be a red herring. example below:
> > [root@testboard: /root# /etc/init.d/S59netsnmp restart
> > Stopping SNMP daemon: [OK]
> > Starting SNMP daemon: Bad user id: snmp
> I think it is a red herring, that error is from the -u option.
>
> # /usr/sbin/snmpd -u blah
> Bad user id: blah
>
> I know that is not solving your main issue, but its got rid of one thing.
>
>  - Craig
>
>
>
> > [root@testboard: /root#
> >
> > So, we take our patches out and recompile and install, and it works
> again but still has the 255 custom oid limitation.
> >
> > A snippet from our header file. Too big to paste it all.
> >
> > #define TEMPC 1
> > #define TEMPF 2
> > #define   UPTIME_STR 3
> > #define   SERIALNUMBER 4
> > #define   ALLOFIT 5
> > #define   ROOTFSBUILD 6
> > #define   KERNELBUILD      7
> > #define   OSINFO    8
> > ......
> > #define PRODUCT_ID 250
> > #define RUNSCRIPT 251
> > #define TIMER1 252
> > #define TIMER2 253
> > #define TIMER3 254
> > #define TIMER4 255
> > #define TIMER5 256 <- This outpts an error because it wraps around and 0
> is not defined.
> > #define TIMER6 257 <- This outputs TEMPC value instead of TIMER6.
> > #define TIMER7 258
> > #define TIMER8 259
> > #define TIMER9 260
> > #define TIMER10 261
> >
> > #define    EXAMPLETIMETICKS 3333
> > #define EXAMPLEIPADDRESS        4444
> > #define   EXAMPLECOUNTER 7777
> > #define EXAMPLEGAUGE            8888
> > #define EXAMPLETRIGGERTRAP      9999
> > #define EXAMPLETRIGGERTRAP2     1000
> >
> > Notice the example defines above that were provided in the example C
> header file, those magic numbers would have never worked because of the
> u_char (8-bit) magic variable limitation.
> >
> > This is a code snippet from our custom mib C file.
> >
> > struct variable4 testboard_variables[] = {
> >    {ROOTFSBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {7, 1}},
> >    {KERNELBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {7, 2}},
> >    {OSINFO, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {7,
> 3}},
> >    {PRODUCT_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, etestboard_var, 2,
> {7, 4}},
> >    {UPTIME_STR, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {5, 1}},
> >    {SERIALNUMBER, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2,
> {5, 2}},
> >    {TEMPC, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {6,1}},
> >    {TEMPF, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_var, 2, {6,2}},
> >
> > We have poured over the souce code looking for any other instance of
> u_char magic that we may have missed, but they are only defined in the two
> files mentioned above.
> >
> > We need some help with this. What else do we need to do in the 5.9
> versions to make the magic number not wrap around to zero after 255 and not
> crash when we do that?
> >
> > Thanks,
> >
> > Neeraj Bansal
> > _______________________________________________
> > Net-snmp-coders mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
>

--000000000000732ebd062291fd65
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">That makes sense=C2=A0Craig. Thank you for your input.<div=
><br></div><div>To summarize the issue, we are unable to use more than 255 =
OID entries and would love to get any help on this issue.=C2=A0</div><div><=
br></div><div>Is there another way to use=C2=A0more than 255 custom=C2=A0OI=
D&#39;s?</div><div><br></div><div>Thank You to anyone looking into this mat=
ter.</div><div><br></div><div>- Neeraj</div></div><br><div class=3D"gmail_q=
uote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, 29 Jul 2024 at 14:26, C=
raig Small &lt;<a href=3D"mailto:[email protected]">[email protected]</=
a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On=
 Fri, 12 Jul 2024 at 08:31, Neeraj Bansal &lt;<a href=3D"mailto:neerajbansa=
[email protected]" target=3D"_blank">[email protected]</a>&gt; wro=
te:<br>
&gt; We recompile everything and install no problem, but instead of fixing =
our problem it caused net-snmp-5.9.3 to not be able to start. The error it =
gives is: Bad user id, which could be a red herring. example below:<br>
&gt; [root@testboard: /root# /etc/init.d/S59netsnmp restart<br>
&gt; Stopping SNMP daemon: [OK]<br>
&gt; Starting SNMP daemon: Bad user id: snmp<br>
I think it is a red herring, that error is from the -u option.<br>
<br>
# /usr/sbin/snmpd -u blah<br>
Bad user id: blah<br>
<br>
I know that is not solving your main issue, but its got rid of one thing.<b=
r>
<br>
=C2=A0- Craig<br>
<br>
<br>
<br>
&gt; [root@testboard: /root#<br>
&gt;<br>
&gt; So, we take our patches out and recompile and install, and it works ag=
ain but still has the 255 custom oid limitation.<br>
&gt;<br>
&gt; A snippet from our header file. Too big to paste it all.<br>
&gt;<br>
&gt; #define=E2=80=83 TEMPC=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=
=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=
=83=E2=80=83=E2=80=831<br>
&gt; #define=E2=80=83 TEMPF=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=
=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=
=83=E2=80=83=E2=80=832<br>
&gt; #define=C2=A0 =C2=A0UPTIME_STR=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=
=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=
=833<br>
&gt; #define=C2=A0 =C2=A0SERIALNUMBER=E2=80=83=E2=80=83=E2=80=83=E2=80=83=
=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=834<b=
r>
&gt; #define=C2=A0 =C2=A0ALLOFIT=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=
=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=
=E2=80=83=E2=80=835<br>
&gt; #define=C2=A0 =C2=A0ROOTFSBUILD=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=
=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83 6<br>
&gt; #define=C2=A0 =C2=A0KERNELBUILD=C2=A0 =C2=A0 =C2=A0 7<br>
&gt; #define=C2=A0 =C2=A0OSINFO=E2=80=83=E2=80=83=E2=80=83=E2=80=83=E2=80=
=83=E2=80=83=E2=80=83=E2=80=83=E2=80=83=C2=A0 =C2=A08<br>
&gt; ......<br>
&gt; #define PRODUCT_ID 250<br>
&gt; #define RUNSCRIPT 251<br>
&gt; #define TIMER1 252<br>
&gt; #define TIMER2 253<br>
&gt; #define TIMER3 254<br>
&gt; #define TIMER4 255<br>
&gt; #define TIMER5 256 &lt;- This outpts an error because it wraps around =
and 0 is not defined.<br>
&gt; #define TIMER6 257 &lt;- This outputs TEMPC value instead of TIMER6.<b=
r>
&gt; #define TIMER7 258<br>
&gt; #define TIMER8 259<br>
&gt; #define TIMER9 260<br>
&gt; #define TIMER10 261<br>
&gt;<br>
&gt; #define=C2=A0 =C2=A0 EXAMPLETIMETICKS=E2=80=83=E2=80=83=E2=80=83=E2=80=
=833333<br>
&gt; #define=E2=80=83=E2=80=83EXAMPLEIPADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 4=
444<br>
&gt; #define=C2=A0 =C2=A0EXAMPLECOUNTER=E2=80=83=E2=80=83=E2=80=83=E2=80=83=
=E2=80=83=E2=80=837777<br>
&gt; #define=E2=80=83=E2=80=83EXAMPLEGAUGE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 8888<br>
&gt; #define=E2=80=83=E2=80=83EXAMPLETRIGGERTRAP=C2=A0 =C2=A0 =C2=A0 9999<b=
r>
&gt; #define=E2=80=83=E2=80=83EXAMPLETRIGGERTRAP2=C2=A0 =C2=A0 =C2=A01000<b=
r>
&gt;<br>
&gt; Notice the example defines above that were provided in the example C h=
eader file, those magic numbers would have never worked because of the u_ch=
ar (8-bit) magic variable limitation.<br>
&gt;<br>
&gt; This is a code snippet from our custom mib C file.<br>
&gt;<br>
&gt; struct variable4 testboard_variables[] =3D {<br>
&gt;=C2=A0 =C2=A0 {ROOTFSBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testbo=
ard_var, 2, {7, 1}},<br>
&gt;=C2=A0 =C2=A0 {KERNELBUILD, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testbo=
ard_var, 2, {7, 2}},<br>
&gt;=C2=A0 =C2=A0 {OSINFO, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_v=
ar, 2, {7, 3}},<br>
&gt;=C2=A0 =C2=A0 {PRODUCT_ID, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, etestbo=
ard_var, 2, {7, 4}},<br>
&gt;=C2=A0 =C2=A0 {UPTIME_STR, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboa=
rd_var, 2, {5, 1}},<br>
&gt;=C2=A0 =C2=A0 {SERIALNUMBER, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testb=
oard_var, 2, {5, 2}},<br>
&gt;=C2=A0 =C2=A0 {TEMPC, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_va=
r, 2, {6,1}},<br>
&gt;=C2=A0 =C2=A0 {TEMPF, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, testboard_va=
r, 2, {6,2}},<br>
&gt;<br>
&gt; We have poured over the souce code looking for any other instance of u=
_char magic that we may have missed, but they are only defined in the two f=
iles mentioned above.<br>
&gt;<br>
&gt; We need some help with this. What else do we need to do in the 5.9 ver=
sions to make the magic number not wrap around to zero after 255 and not cr=
ash when we do that?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Neeraj Bansal<br>
&gt; _______________________________________________<br>
&gt; Net-snmp-coders mailing list<br>
&gt; <a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a><br>
&gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/net-snmp-coder=
s" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists=
/listinfo/net-snmp-coders</a><br>
</blockquote></div>

--000000000000732ebd062291fd65--


--===============4901039040236789829==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============4901039040236789829==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

--===============4901039040236789829==--