Re:Re:Re:Re: why ucd-snmp agent can only be get, can't be set always

ye_cl <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <579493773.317941187859749994.JavaMail.coremail@bj163app97.163.com>
Oh! I forgot the attached compressed file for my MIB module's figure   
在2007-08-23,ye_cl <[email protected]> 写道:
hi, Using the command of "./snmpd -c /usr/local/share/snmp/snmpd.conf -f &" to run the agent in target board's uClinux, Now I can set the agent from the client. I think the reason is that the snmpd.conf under /usr/local/share/snmp/ dir can't be read by the agent in uClinux by default,we must manually tell the agent where snmpd.conf is. Now I have another question. 
I built my MIB module by tool of MG-SOFT MIB Builder.The MIB module is SMIv2, the attached file is my MIB module's figure in MG-SOFT MIB Builder. I use "env MIBS=”+SCOM-SV260A-MIB” mib2c scomcenter" to produce my module's skeleton source files for node "scomcenter".Now the agent will receive a get request for oid "1.3.6.1.4.1" which is type of OBJECT IDENTIFIER, and then send the value of oid"1.3.6.1.4.1.19176.1.1.20.1.0" to client for response. In my scomcenter.c, I don't know how to implement it, the get request oid and the response oid are not the same, and not the same level in MIB tree. In the mib2c-produced skeleton source files, I can only respond the oid that is from the client's request,and oid's node type must be OBJECT-TYPE.Would you please give me some help? regards,
yecl
   
在2007-08-23,ye_cl <[email protected]> 写道:
 Hi,Dave, I use ./snmpd& to run the agent in mine target board, use "snmpget -v2c -c public 200.162.162.190 .1.3.6.1.4.1.19176.1.1.20.3.0.0" to get,and use "snmpset -v2c -c private 200.162.162.190 .1.3.6.1.4.1.19176.1.1.20.3.0.0 i 333" to set. I find there is always no response UDP packet sent from the agent,and the uClinux on target board will lose some memory every time I do set operation.
my 'my_mib.c' looks like, I only set DESTPORT: #include <config.h>#if TIME_WITH_SYS_TIME
# ifdef WIN32
#  include <sys/timeb.h>
# else
#  include <sys/time.h>
# endif
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif#if HAVE_WINSOCK_H
#include <winsock.h>
#endif#include "mibincl.h"
#include "snmpv3.h"
#include "snmpusm.h"
#include "agent_read_config.h"
#include "util_funcs.h"
#include "my_mib.h"static unsigned long dest_port = 3020;struct variable7 my_mib_variables[] = {
/*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
#define   TSOVERIPSTATUS        1
  { TSOVERIPSTATUS      , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,1,0 } },
#define   DESTIPADDR            2
  { DESTIPADDR          , ASN_OCTET_STR , RWRITE, var_my_mib, 5, { 1,1,20,2,0 } },
#define   DESTPORT              3
  { DESTPORT            , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,3,0 } },
#define   RESET                 4
  { RESET               , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,4,0 } },
#define   DEVICESTATUS          5
  { DEVICESTATUS        , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,5,0 } },
#define   SYSTEMBITRATE         6
  { SYSTEMBITRATE       , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,6,0 } },
#define   EFFECTIVEBITRATE      7
  { EFFECTIVEBITRATE    , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,7,0 } },
#define   UDPUARTPORT           8
  { UDPUARTPORT         , ASN_INTEGER   , RWRITE, var_my_mib, 5, { 1,1,20,8,0 } },
#define   DESCRIPTION           9
  { DESCRIPTION         , ASN_OCTET_STR , RONLY , var_my_mib, 2, { 2,1 } },
#define   LOCATED               10
  { LOCATED             , ASN_OCTET_STR , RONLY , var_my_mib, 2, { 2,2 } },};/* Define the OID pointer to the top of the mib tree that we're
   registering underneath */
oid my_mib_variables_oid[] = { 1,3,6,1,4,1,19176 };//void init_ucdDemoPublic(void) {
void init_my_mib(void) {
  REGISTER_MIB("my_mib", my_mib_variables, variable7,
               my_mib_variables_oid);
}unsigned char *
var_my_mib(struct variable *vp,
                oid     *name,
                size_t  *length,
                int     exact,
                size_t  *var_len,
                WriteMethod **write_method)
{
  /* variables we may use later */
  static long long_ret;
  static u_long ulong_ret;
  static unsigned char string[SPRINT_MAX_LEN];
  static oid objid[MAX_OID_LEN];
  static struct counter64 c64;
  if (header_generic(vp,name,length,exact,var_len,write_method)
                                  == MATCH_FAILED )
    return NULL;
  /*
   * this is where we do the value assignments for the mib results.
   */
  switch(vp->magic) {
    case TSOVERIPSTATUS:
        *write_method = write_tsoveripstatus;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case DESTIPADDR:
        *write_method = write_destipaddr;
        *string = 0;
        *var_len = strlen(string);
        return (unsigned char *) string;    case DESTPORT:
        *write_method = write_destport;
        return (u_char *) & dest_port;    case RESET:
        *write_method = write_reset;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case DEVICESTATUS:
        *write_method = write_devicestatus;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case SYSTEMBITRATE:
        *write_method = write_systembitrate;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case EFFECTIVEBITRATE:
        *write_method = write_effectivebitrate;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case UDPUARTPORT:
        *write_method = write_udpuartport;
        long_ret = 0;
        return (unsigned char *) &long_ret;    case DESCRIPTION:
       
        *string = 0;
        *var_len = strlen(string);
        return (unsigned char *) string;    case LOCATED:
       
        *string = 0;
        *var_len = strlen(string);
        return (unsigned char *) string;
    default:
      ERROR_MSG("");
  }
  return NULL;
}
int
write_destport(int      action,
            u_char   *var_val,
            u_char   var_val_type,
            size_t   var_val_len,
            u_char   *statP,
            oid      *name,
            size_t   name_len)
{
  static long *long_ret;
  int size;  switch ( action ) {
        case RESERVE1:
          if (var_val_type != ASN_INTEGER){
              fprintf(stderr, "write to destport not ASN_INTEGER\n");
              return SNMP_ERR_WRONGTYPE;
          }
          if (var_val_len > sizeof(long_ret)){
              fprintf(stderr,"write to destport: bad length\n");
              return SNMP_ERR_WRONGLENGTH;
          }
        if (var_val < 0) {
            fprintf(stderr, "write to destport: bad value\n");
            return SNMP_ERR_WRONGVALUE;
        }
          break;
        case RESERVE2:
          size = var_val_len;
          long_ret = (long *) var_val;
          break;
        case FREE:
             // Release any resources that have been allocated
          break;
        case ACTION:
             // The variable has been stored in long_ret for
             //you to use, and you have just been asked to do something with
             //it.  Note that anything done here must be reversable in the UNDO case
          break;
        case UNDO:
             // Back out any changes made in the ACTION case
          break;
        case COMMIT:
             // Things are working well, so it's now safe to make the change
             // permanently.  Make sure that anything done here can't fail!
          dest_port = (unsigned long)*long_ret;
          break;
  }
  return SNMP_ERR_NOERROR;
}....../*..And other write functions......*/
......
在2007-08-22,"Dave Shield" <[email protected]> 写道:
On 22/08/07, ye_cl <[email protected]> wrote: > I have a question about using ucd-snmp-4.1.2 on uClinux. That's a *VERY* old version of the code, and is no longer being maintained. That shouldn't affect your particular problem, but you should strongly consider upgrading to a more recent version. > When my snmpd is running on uClinux, I can only do get operation, > there is always the response of "request timed out" for set. What is the command that you are running? What does your file 'my_mib.c' look like? Dave ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Net-snmp-users mailing [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
你 玩 过 大 富 翁 吗?超 人 气 梦 幻 西 游 版 大 富 翁,点 击 免 费 试 玩 >>
全 国 万 名 职 场 女 性,齐 聚 非 常 美 女,惊 艳 2 0 0 7

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
MIBmodule.rar (application/octet-stream, 24.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.