~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/utilities/iquery.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    }
48
48
}
49
49
 
 
50
  /*
 
51
   * Set up a default session for running internal queries.
 
52
   * This needs to be done before the config files are read,
 
53
   *  so that it is available for "monitor" directives...
 
54
   */
50
55
int
51
56
_init_default_iquery_session( int majorID, int minorID,
52
57
                              void *serverargs, void *clientarg)
59
64
    return SNMPERR_SUCCESS;
60
65
}
61
66
 
 
67
  /*
 
68
   * ... Unfortunately, the internal engine ID is not set up
 
69
   * until later, so this default session is incomplete.
 
70
   * The resulting engineID probe runs into problems,
 
71
   * causing the very first internal query to time out.
 
72
   *   Updating the default session with the internal engineID
 
73
   * once it has been set, fixes this problem.
 
74
   */
 
75
int
 
76
_tweak_default_iquery_session( int majorID, int minorID,
 
77
                              void *serverargs, void *clientarg)
 
78
{
 
79
    u_char eID[SNMP_MAXBUF_SMALL];
 
80
    size_t elen;
 
81
    netsnmp_session *s = netsnmp_query_get_default_session();
 
82
 
 
83
    if (s && s->securityEngineIDLen == 0 ) {
 
84
        elen = snmpv3_get_engineID(eID, sizeof(eID));
 
85
        memdup( &(s->securityEngineID), eID, elen );
 
86
        s->securityEngineIDLen = elen;
 
87
    }
 
88
    return SNMPERR_SUCCESS;
 
89
}
 
90
 
62
91
void init_iquery(void){
63
92
    char *type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
64
93
                                       NETSNMP_DS_LIB_APPTYPE);
87
116
    snmp_register_callback(SNMP_CALLBACK_LIBRARY, 
88
117
                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
89
118
                           _init_default_iquery_session, NULL);
 
119
    snmp_register_callback(SNMP_CALLBACK_LIBRARY, 
 
120
                           SNMP_CALLBACK_POST_READ_CONFIG,
 
121
                           _tweak_default_iquery_session, NULL);
90
122
}
91
123
 
92
124
    /**************************
153
185
        memdup( &(ss->securityEngineID), engineID, engIDLen );
154
186
        ss->securityEngineIDLen = engIDLen;
155
187
        if ( version == SNMP_VERSION_3 ) {
156
 
            memdup(&(ss->securityName), secName, strlen(secName));
157
188
            ss->securityNameLen = strlen(secName);
 
189
            memdup(&(ss->securityName), (u_char*)secName, ss->securityNameLen);
158
190
        } else {
159
191
            memdup( &(ss->community), secName, strlen(secName));
160
192
            ss->community_len = strlen(secName);
161
193
        }
 
194
        ss->myvoid = netsnmp_check_outstanding_agent_requests;
 
195
        ss->flags |= SNMP_FLAGS_RESP_CALLBACK | SNMP_FLAGS_DONT_PROBE;
162
196
    }
163
197
#endif
164
198