| 
     
      
      
      From: mihir L. <mih...@ya...> - 2001-03-08 17:31:39
       
   | 
Hello, I'm having a problem with supporting counter64 values. I set up the counter64 structure with high and low values and return it as in: return (u_char *)&c64; from the var_func() of the appropriate variable. However when I query this variable it get's a no value returned by agent error. I have verified control is being transferred into my var_func() and a value is being returned. Could someone throw some light as to what's going on or is there any example of counter64 values? I'm using ucd-4.2, running on NetBSD. thanks. __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/  | 
| 
     
      
      
      From: Mattias B. <ma...@dy...> - 2002-03-26 11:50:56
       
   | 
Hello! I have implemented an IFMIB (IfXtable) with folllowing
Counter64 types.
-----------
struct variable4 ifmib_variables[] = {
    {IFNAME, ASN_OCTET_STR, RONLY, var_interfacesx, 3, {1, 1,IFNAME}},
    {IFINMULTICASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFINMULTICASTPKTS}},
    {IFINBROADCASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFINBROADCASTPKTS }},
    {IFOUTMULTICASTPKTS, ASN_COUNTER, RONLY,var_interfacesx, 3, {1, 1,IFOUTMULTICASTPKTS }},
    {IFOUTBROADCASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFOUTBROADCASTPKTS }},
    {IFHCINOCTETS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINOCTETS}},
    {IFHCINUCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINUCASTPKTS }},
    {IFHCINMULTICASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINMULTICASTPKTS }},
    {IFHCINBROADCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINBROADCASTPKTS }},
    {IFHCOUTOCTETS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTOCTETS }},
    {IFHCOUTUCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTUCASTPKTS }},
    {IFHCOUTMULTICASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTMULTICASTPKTS }},
    {IFHCOUTBROADCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTBROADCASTPKTS }},
    {IFLINKUPDOWNTRAPENABLE, ASN_INTEGER, RWRITE, var_interfacesx, 3, {1, 1,IFLINKUPDOWNTRAPENABLE }},
    {IFHIGHSPEED, ASN_GAUGE, RONLY, var_interfacesx, 3, {1, 1,IFHIGHSPEED }},
    {IFPROMISCUOUSMODE, ASN_INTEGER, RONLY, var_interfacesx, 3, {1, 1,IFPROMISCUOUSMODE }},
    {IFCONNECTORPRESENT, ASN_INTEGER, RONLY, var_interfacesx, 3, {1, 1, IFCONNECTORPRESENT}},
};
----------
in init_interfaces();
------------
REGISTER_MIB("mibII/ifMIB", ifmib_variables, variable4, \
               ifmib_variables_oid);
---------
An extraction from var_interfacesx() :
----------
	case IFHCINOCTETS:
#ifdef STRUCT_IFNET_HAS_IF_IBYTES
          long_return = (u_long)  ifnet.if_ibytes;
#else
#if NO_DUMMY_VALUES
	  return NULL;
#endif
	  long_return = (u_long)  ifnet.if_ipackets * 308; /* XXX */
#endif
	  return (u_char *) &long_return;
-------------
Now the question.
The agent stops completely when i issue snmpget of version 2c and it wants to process the
first Counter64 value. Have I forgotten do do anything or initialize values or register the mib the proper way?
Thank you!
/Mattias 
-- 
--------------------------------------------------------------------------
 Mattias Barthel Software Developer		Phone:   +46-8-563 121 28
 Dynarc AB					Mobile:  +46-70-261 21 28
 Norgegatan 2					Fax:     +46-8-563 121 21
 164 32 KISTA SWEDEN				E-mail: ma...@dy...
--------------------------------------------------------------------------
 | 
| 
     
      
      
      From: Mattias B. <ma...@dy...> - 2002-04-02 07:41:34
       
   | 
  Hello! I have implemented an IFMIB (IfXtable) with folllowing
  Counter64 types.
  
  -----------
  struct variable4 ifmib_variables[] = {
      {IFNAME, ASN_OCTET_STR, RONLY, var_interfacesx, 3, {1, 1,IFNAME}},
      {IFINMULTICASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFINMULTICASTPKTS}},
      {IFINBROADCASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFINBROADCASTPKTS }},
      {IFOUTMULTICASTPKTS, ASN_COUNTER, RONLY,var_interfacesx, 3, {1, 1,IFOUTMULTICASTPKTS }},
      {IFOUTBROADCASTPKTS, ASN_COUNTER, RONLY, var_interfacesx, 3, {1, 1,IFOUTBROADCASTPKTS }},
      {IFHCINOCTETS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINOCTETS}},
      {IFHCINUCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINUCASTPKTS }},
      {IFHCINMULTICASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINMULTICASTPKTS }},
      {IFHCINBROADCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCINBROADCASTPKTS }},
      {IFHCOUTOCTETS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTOCTETS }},
      {IFHCOUTUCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTUCASTPKTS }},
      {IFHCOUTMULTICASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTMULTICASTPKTS }},
      {IFHCOUTBROADCASTPKTS, ASN_COUNTER64, RONLY, var_interfacesx, 3, {1, 1,IFHCOUTBROADCASTPKTS }},
      {IFLINKUPDOWNTRAPENABLE, ASN_INTEGER, RWRITE, var_interfacesx, 3, {1, 1,IFLINKUPDOWNTRAPENABLE }},
      {IFHIGHSPEED, ASN_GAUGE, RONLY, var_interfacesx, 3, {1, 1,IFHIGHSPEED }},
      {IFPROMISCUOUSMODE, ASN_INTEGER, RONLY, var_interfacesx, 3, {1, 1,IFPROMISCUOUSMODE }},
      {IFCONNECTORPRESENT, ASN_INTEGER, RONLY, var_interfacesx, 3, {1, 1, IFCONNECTORPRESENT}},
  };
  
  ----------
  in init_interfaces();
  ------------
  REGISTER_MIB("mibII/ifMIB", ifmib_variables, variable4, \
                 ifmib_variables_oid);
  
  
  
  ---------
  An extraction from var_interfacesx() :
  ----------
  	case IFHCINOCTETS:
  #ifdef STRUCT_IFNET_HAS_IF_IBYTES
            long_return = (u_long)  ifnet.if_ibytes;
  #else
  #if NO_DUMMY_VALUES
  	  return NULL;
  #endif
  	  long_return = (u_long)  ifnet.if_ipackets * 308; /* XXX */
  #endif
  	  return (u_char *) &long_return;
  
  -------------
  
  Now the question.
  The agent stops completely when i issue snmpget of version 2c and it wants to process the
  first Counter64 value. Have I forgotten do do anything or initialize values or register the mib the proper way?
  
  
  
  
  Thank you!
  
  /Mattias 
  
  
  -- 
  --------------------------------------------------------------------------
   Mattias Barthel Software Developer		Phone:   +46-8-563 121 28
   Dynarc AB					Mobile:  +46-70-261 21 28
   Norgegatan 2					Fax:     +46-8-563 121 21
   164 32 KISTA SWEDEN				E-mail: ma...@dy...
  --------------------------------------------------------------------------
 | 
| 
     
      
      
      From: Wes H. <har...@us...> - 2002-04-02 15:13:24
       
   | 
>>>>> On 02 Apr 2002 09:40:02 +0200, Mattias Barthel <ma...@dy...> said: Mattias> Hello! I have implemented an IFMIB (IfXtable) with folllowing Mattias> Counter64 types. ... Mattias> return (u_char *) &long_return; Mattias> The agent stops completely when i issue snmpget of version 2c Mattias> and it wants to process the first Counter64 value. Have I Mattias> forgotten do do anything or initialize values or register the Mattias> mib the proper way? You must return a pointer to a "struct counter64" for counter64 variable types. Not a pointer to a long. -- Wes Hardaker NAI Labs Network Associates  | 
| 
     
      
      
      From: Mattias B. <ma...@dy...> - 2002-04-03 14:51:38
       
   | 
Ok, sorry. So now to the problem again with some new input:
---------------------
$ snmpget -r0 -t1 -v2c spirou public ifMIB.ifMIBObjects.ifXTable.7.1
Timeout: No Response from spirou.
---------------------
(gdb) run -f -L -d
Starting program: /sci/libexec/snmpd -f -L -d
/tmp/snmpd.conf: line 19: Unknown token: syscontact.
/tmp/snmpd.conf: line 20: Unknown token: syslocation.
UCD-SNMP version 4.1.1
Received 45 bytes from 62.65.1.42:1563
0000: 30 2B 02 01  01 04 06 70  75 62 6C 69  63 A0 1E 02    0+.....public...
0016: 04 47 60 33  45 02 01 00  02 01 00 30  10 30 0E 06    .G`3E......0.0..
0032: 0A 2B 06 01  02 01 1F 01  01 07 01 05  00             .+...........
Received SNMP packet(s) from 62.65.1.42
  GET message
    -- .iso.3.6.1.2.1.31.1.1.7.1
Breakpoint 1, var_interfacesx (vp=0x9fbfb434, name=0xc9818, length=0xc9808, 
    exact=1, var_len=0x9fbfb8e0, write_method=0x9fbfb8e8)
    at mibII/interfaces.c:1522
Source file is more recent than executable.
1522        DEBUGMSG(("INTERFACES", "varinterfacesx!!!!!!!!!!!!!!!!\n"));
(gdb) n
1523        interface = header_ifEntry(vp, name, length, exact, var_len, write_method);
(gdb) p *length
$1 = 11
(gdb) n
1524        if ( interface == MATCH_FAILED )
(gdb) 
1527        Interface_Scan_By_Index(interface, Name, &ifnet, &in_ifaddr);
(gdb) 
1528        DEBUGMSG(("INTERFACES", "After Interface_Scan_By_Index!!!!!!!!!!!!!!!!\n"));
(gdb) 
1529        switch (vp->magic){
(gdb) 
1584                  counter64_return.high = (u_long) 0;
(gdb) 
1585                  counter64_return.low = (u_long)  ifnet.if_ipackets;
(gdb) 
1587                  counter64_return.low -= (u_long) ifnet.if_imcasts;
(gdb) 
1591                return (u_char *) &counter64_return;
(gdb) 
1662                *length = sizeof(struct counter64);
(gdb) 
1663                return (u_char *) &counter64_return;
(gdb) p *length
$2 = 8
(gdb) c
Continuing.
    >> .iso.3.6.1.2.1.31.1 = Counter64: 15810
Breakpoint 2, asn_build_unsigned_int64 (data=0x9fbf98e0 "", 
    datalength=0x9fbf98ac, type=70, cp=0xc9a18, countersize=4) at asn1.c:1360
1360        int add_null_byte = 0;
(gdb) n
1363      if (countersize != sizeof(struct counter64)){
(gdb) p countersize
$4 = 4
(gdb) n
1364        _asn_size_err("build uint64", countersize, sizeof(struct counter64));
(gdb) 
1365        return NULL;
(gdb) 
----------------------
It doesn't seem to have any effect to set what length points at to struct counter64.
The variabel countersize in asn_build_unsigned_int64 still comes out as 4.
/Mattias
> >>>>> On 03 Apr 2002 14:13:46 +0200, Mattias Barthel <ma...@dy...> said:
> 
> Mattias> After having changed the return type to counter64 it still
> Mattias> behaves the same way:
> 
> First off, please write to the net...@li...
> mailing list instead of writing to me personally with questions
> regarding the net-snmp (or ucd-snmp) package.  You're question is much
> more likely to be responded to in a timely matter if you do so.  In
> addition some people on the -users list have knowledge which I do not,
> so you may receive a more complete or more correct answer from them as
> well.
> 
> 
> 
> Mattias> In interfaces.c, var_interfacesx()
> Mattias> ---------------------
> Mattias> case IFHCINOCTETS:
> Mattias> counter64_return.high = (u_long) 0;
> Mattias> #ifdef STRUCT_IFNET_HAS_IF_IBYTES
> Mattias> DEBUGMSG(("mibII/interfacesx IFHCINOCTETS %d\n", ifnet.if_ibytes));
> Mattias> counter64_return.low = (u_long)  ifnet.if_ibytes;
> Mattias> #else
> Mattias> #if NO_DUMMY_VALUES
> Mattias> return NULL;
> Mattias> #endif
> Mattias> counter64_return.low = (u_long)  ifnet.if_ipackets * 308; /* XXX */
> Mattias> #endif
> Mattias> return (u_char *) &counter64_return;
> 
> add:
> 
>    *length = sizeof(struct counter64);
> 
> before the return.
> 
> -- 
> "Ninjas aren't dangerous.  They're more afraid of you than you are of them."
> 
--------------------------------------------------------------------------
 Mattias Barthel Software Developer		Phone:   +46-8-563 121 28
 Dynarc AB					Mobile:  +46-70-261 21 28
 Norgegatan 2					Fax:     +46-8-563 121 21
 164 32 KISTA SWEDEN				E-mail: ma...@dy...
--------------------------------------------------------------------------
 | 
| 
     
      
      
      From: Mattias B. <ma...@dy...> - 2002-04-04 10:13:32
       
   | 
Since the lack of input from the list I am now changing
the counter64 types to 32-bit counter (SMIv1) as a temporary
solution just to get it running. I know it is a horribile crime
against the standards but I can't afford a showstopper like this.
/M
> Ok, sorry. So now to the problem again with some new input:
> ---------------------
> $ snmpget -r0 -t1 -v2c spirou public ifMIB.ifMIBObjects.ifXTable.7.1
> Timeout: No Response from spirou.
> 
> ---------------------
> (gdb) run -f -L -d
> Starting program: /sci/libexec/snmpd -f -L -d
> /tmp/snmpd.conf: line 19: Unknown token: syscontact.
> /tmp/snmpd.conf: line 20: Unknown token: syslocation.
> UCD-SNMP version 4.1.1
> 
> Received 45 bytes from 62.65.1.42:1563
> 0000: 30 2B 02 01  01 04 06 70  75 62 6C 69  63 A0 1E 02    0+.....public...
> 0016: 04 47 60 33  45 02 01 00  02 01 00 30  10 30 0E 06    .G`3E......0.0..
> 0032: 0A 2B 06 01  02 01 1F 01  01 07 01 05  00             .+...........
> 
> Received SNMP packet(s) from 62.65.1.42
>   GET message
>     -- .iso.3.6.1.2.1.31.1.1.7.1
> 
> Breakpoint 1, var_interfacesx (vp=0x9fbfb434, name=0xc9818, length=0xc9808, 
>     exact=1, var_len=0x9fbfb8e0, write_method=0x9fbfb8e8)
>     at mibII/interfaces.c:1522
> Source file is more recent than executable.
> 1522        DEBUGMSG(("INTERFACES", "varinterfacesx!!!!!!!!!!!!!!!!\n"));
> (gdb) n
> 1523        interface = header_ifEntry(vp, name, length, exact, var_len, write_method);
> (gdb) p *length
> $1 = 11
> (gdb) n
> 1524        if ( interface == MATCH_FAILED )
> (gdb) 
> 1527        Interface_Scan_By_Index(interface, Name, &ifnet, &in_ifaddr);
> (gdb) 
> 1528        DEBUGMSG(("INTERFACES", "After Interface_Scan_By_Index!!!!!!!!!!!!!!!!\n"));
> (gdb) 
> 1529        switch (vp->magic){
> (gdb) 
> 1584                  counter64_return.high = (u_long) 0;
> (gdb) 
> 1585                  counter64_return.low = (u_long)  ifnet.if_ipackets;
> (gdb) 
> 1587                  counter64_return.low -= (u_long) ifnet.if_imcasts;
> (gdb) 
> 1591                return (u_char *) &counter64_return;
> (gdb) 
> 1662                *length = sizeof(struct counter64);
> (gdb) 
> 1663                return (u_char *) &counter64_return;
> (gdb) p *length
> $2 = 8
> (gdb) c
> Continuing.
>     >> .iso.3.6.1.2.1.31.1 = Counter64: 15810
> 
> Breakpoint 2, asn_build_unsigned_int64 (data=0x9fbf98e0 "", 
>     datalength=0x9fbf98ac, type=70, cp=0xc9a18, countersize=4) at asn1.c:1360
> 1360        int add_null_byte = 0;
> (gdb) n
> 1363      if (countersize != sizeof(struct counter64)){
> (gdb) p countersize
> $4 = 4
> (gdb) n
> 1364        _asn_size_err("build uint64", countersize, sizeof(struct counter64));
> (gdb) 
> 1365        return NULL;
> (gdb) 
> ----------------------
> It doesn't seem to have any effect to set what length points at to struct counter64.
> The variabel countersize in asn_build_unsigned_int64 still comes out as 4.
> 
> /Mattias
> 
> > >>>>> On 03 Apr 2002 14:13:46 +0200, Mattias Barthel <ma...@dy...> said:
> > 
> > Mattias> After having changed the return type to counter64 it still
> > Mattias> behaves the same way:
> > 
> > First off, please write to the net...@li...
> > mailing list instead of writing to me personally with questions
> > regarding the net-snmp (or ucd-snmp) package.  You're question is much
> > more likely to be responded to in a timely matter if you do so.  In
> > addition some people on the -users list have knowledge which I do not,
> > so you may receive a more complete or more correct answer from them as
> > well.
> > 
> > 
> > 
> > Mattias> In interfaces.c, var_interfacesx()
> > Mattias> ---------------------
> > Mattias> case IFHCINOCTETS:
> > Mattias> counter64_return.high = (u_long) 0;
> > Mattias> #ifdef STRUCT_IFNET_HAS_IF_IBYTES
> > Mattias> DEBUGMSG(("mibII/interfacesx IFHCINOCTETS %d\n", ifnet.if_ibytes));
> > Mattias> counter64_return.low = (u_long)  ifnet.if_ibytes;
> > Mattias> #else
> > Mattias> #if NO_DUMMY_VALUES
> > Mattias> return NULL;
> > Mattias> #endif
> > Mattias> counter64_return.low = (u_long)  ifnet.if_ipackets * 308; /* XXX */
> > Mattias> #endif
> > Mattias> return (u_char *) &counter64_return;
> > 
> > add:
> > 
> >    *length = sizeof(struct counter64);
> > 
> > before the return.
> > 
> > -- 
> > "Ninjas aren't dangerous.  They're more afraid of you than you are of them."
> > 
> 
> --------------------------------------------------------------------------
>  Mattias Barthel Software Developer		Phone:   +46-8-563 121 28
>  Dynarc AB					Mobile:  +46-70-261 21 28
>  Norgegatan 2					Fax:     +46-8-563 121 21
>  164 32 KISTA SWEDEN				E-mail: ma...@dy...
> --------------------------------------------------------------------------
--------------------------------------------------------------------------
 Mattias Barthel Software Developer		Phone:   +46-8-563 121 28
 Dynarc AB					Mobile:  +46-70-261 21 28
 Norgegatan 2					Fax:     +46-8-563 121 21
 164 32 KISTA SWEDEN				E-mail: ma...@dy...
--------------------------------------------------------------------------
 | 
| 
     
      
      
      From: Wes H. <har...@us...> - 2002-04-04 15:45:13
       
   | 
>>>>> On 03 Apr 2002 16:50:05 +0200, Mattias Barthel <ma...@dy...> said: Mattias> 1662 *length = sizeof(struct counter64); My fault for telling you the wrong variable to set. You should be setting *var_len to the structure size, not *length. Mattias> Since the lack of input from the list I am now changing the Mattias> counter64 types to 32-bit counter (SMIv1) as a temporary Mattias> solution just to get it running. I know it is a horribile Mattias> crime against the standards but I can't afford a showstopper Mattias> like this. If you want professional support, I suggest you go with a commercial product rather than an open source solution. We don't exist to support this package for free and do so on our own time. We can't always turn around an answer within 24 hours like you'd like. We find your attitude rather insulting. -- Wes Hardaker NAI Labs Network Associates  | 
| 
     
      
      
      From: Mattias B. <ma...@dy...> - 2002-04-04 17:23:49
       
   | 
That did the trick!!!! Thanks a lot for your help Wes and I am sorry if my last mail was in a harsh tone. It is just that we have a soon-coming release and I was a bit stressed about this. Thanks again! /M Wes Hardaker <har...@us...> writes: > >>>>> On 03 Apr 2002 16:50:05 +0200, Mattias Barthel <ma...@dy...> said: > > Mattias> 1662 *length = sizeof(struct counter64); > > My fault for telling you the wrong variable to set. You should be > setting *var_len to the structure size, not *length. > > Mattias> Since the lack of input from the list I am now changing the > Mattias> counter64 types to 32-bit counter (SMIv1) as a temporary > Mattias> solution just to get it running. I know it is a horribile > Mattias> crime against the standards but I can't afford a showstopper > Mattias> like this. > > If you want professional support, I suggest you go with a commercial > product rather than an open source solution. We don't exist to > support this package for free and do so on our own time. We can't > always turn around an answer within 24 hours like you'd like. We find > your attitude rather insulting. > > -- > Wes Hardaker > NAI Labs > Network Associates > -- -------------------------------------------------------------------------- Mattias Barthel Software Developer Phone: +46-8-563 121 28 Dynarc AB Mobile: +46-70-261 21 28 Norgegatan 2 Fax: +46-8-563 121 21 164 32 KISTA SWEDEN E-mail: ma...@dy... --------------------------------------------------------------------------  | 
| 
     
      
      
      From: Wes H. <har...@us...> - 2001-03-08 21:25:51
       
  
        
          
            Attachments:
            patch
          
        
       
     | 
>>>>> On Thu, 8 Mar 2001 09:33:22 -0800 (PST), mihir Lala <mih...@ya...> said: mihir> I'm having a problem with supporting counter64 values. I set mihir> up the counter64 structure with high and low values and return mihir> it as in: mihir> return (u_char *)&c64; Please apply the following patch to snmtplib/asn1.c: -- Wes Hardaker NAI Labs Network Associates  |