Beispiel #1
0
int
init_snmpv3_post_config(int majorid, int minorid, void *serverarg,
                        void *clientarg) {

  int engineIDLen;
  u_char *c_engineID;

  c_engineID = snmpv3_generate_engineID(&engineIDLen);

  if ( engineIDLen < 0 ) {
    /* Somethine went wrong - help! */
    return SNMPERR_GENERR;
  }

  /* if our engineID has changed at all, the boots record must be set to 1 */
  if (engineIDLen != (int)oldEngineIDLength ||
      oldEngineID == NULL || c_engineID == NULL ||
      memcmp(oldEngineID, c_engineID, engineIDLen) != 0) {
    engineBoots = 1;
  }

  /* set our local engineTime in the LCD timing cache */
  set_enginetime(c_engineID, engineIDLen, 
                 snmpv3_local_snmpEngineBoots(), 
                 snmpv3_local_snmpEngineTime(),
                 TRUE);

  free(c_engineID);
  return SNMPERR_SUCCESS;
}
Beispiel #2
0
u_char *var_snmpEngine (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 unsigned char engineID[SNMP_MAXBUF];

    *write_method = (WriteMethod *) 0;    /* assume it isnt writable for the time being */
    *var_len = sizeof (long_ret);    /* assume an integer and change later if not */

    if (header_generic (vp, name, length, exact, var_len, write_method))
        return NULL;

    /*
     * this is where we do the value assignments for the mib results. 
     */
    switch (vp->magic)
    {

        case SNMPENGINEID:
            *var_len = snmpv3_get_engineID (engineID, SNMP_MAXBUF);
            /*
             * XXX  Set ERROR_MSG() upon error? 
             */
            return (unsigned char *) engineID;

        case SNMPENGINEBOOTS:
#ifndef NETSNMP_NO_WRITE_SUPPORT
#ifdef NETSNMP_ENABLE_TESTING_CODE
            *write_method = write_engineBoots;
#endif                            /* NETSNMP_ENABLE_TESTING_CODE */
#endif                            /* !NETSNMP_NO_WRITE_SUPPORT */
            long_ret = snmpv3_local_snmpEngineBoots ();
            return (unsigned char *) &long_ret;

        case SNMPENGINETIME:
#ifndef NETSNMP_NO_WRITE_SUPPORT
#ifdef NETSNMP_ENABLE_TESTING_CODE
            *write_method = write_engineTime;
#endif                            /* NETSNMP_ENABLE_TESTING_CODE */
#endif                            /* !NETSNMP_NO_WRITE_SUPPORT */
            long_ret = snmpv3_local_snmpEngineTime ();
            return (unsigned char *) &long_ret;

        case SNMPENGINEMAXMESSAGESIZE:
            long_ret = 1500;
            return (unsigned char *) &long_ret;

        default:
            DEBUGMSGTL (("snmpd", "unknown sub-id %d in var_snmpEngine\n", vp->magic));
    }
    return NULL;
}
Beispiel #3
0
/*
 * write_engineTime():
 * 
 * This is technically not a writable mib object, but we
 * allow it so we can run some time synchronization tests.
 */
int
write_engineTime (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)
{
    /*
     * variables we may use later 
     */
    static long long_ret;

    size_t size;

    int bigsize = SNMP_MAXBUF_MEDIUM;

    u_char engineIDBuf[SNMP_MAXBUF_MEDIUM];

    int engineIDBufLen = 0;

    if (var_val_type != ASN_INTEGER)
    {
        DEBUGMSGTL (("snmpEngine", "write to engineTime not ASN_INTEGER\n"));
        return SNMP_ERR_WRONGTYPE;
    }
    if (var_val_len > sizeof (long_ret))
    {
        DEBUGMSGTL (("snmpEngine", "write to engineTime: bad length\n"));
        return SNMP_ERR_WRONGLENGTH;
    }
    long_ret = *((long *) var_val);
    if (action == COMMIT)
    {
        engineIDBufLen = snmpv3_get_engineID (engineIDBuf, SNMP_MAXBUF_MEDIUM);
        /*
         * set our local engineTime in the LCD timing cache 
         */
        snmpv3_set_engineBootsAndTime (snmpv3_local_snmpEngineBoots (), long_ret);
        set_enginetime (engineIDBuf, engineIDBufLen,
                        snmpv3_local_snmpEngineBoots (), snmpv3_local_snmpEngineTime (), TRUE);
    }
    return SNMP_ERR_NOERROR;
}