Hello.
I am trying the features.
First some general questions:
If I want to build with all code then I give configure the flag
--disable-minimalist (or nothing as this is the default) - Is this
correct?
If I want to build with all code that is required or wanted by something
I have configured then I give configure the flag --enable-minimalist -
Is this correct?
If I want to build with all code that is required by something I have
configured the I should give what flag to configure?
Then a few a question on coding:
I have one file that declares two features, A and AA. Additionally the
file implements some general code that isn't part of any feature.
The general parts of the file wants A
AA requires A
AA is a child of netsnmp_unused
Now I have tried to generate the correct file so I have:
netsnmp_feature_child_of(AA,netsnmp_unused)
netsnmp_feature_want(A)
#ifdef NETSNMP_FEATURE_REQUIRE_AA
netsnmp_feature_require(A)
#endif
This works so-and-so.
--enable-minimalist builds A but not AA.
--with-features=AA builds A and AA.
--with-out-features=A doesn't seem to trigger the generation of
features.h so make fails.
--enable-minimalist --with-out-features=A builds A but not AA. I
expected it to build neither.
--with-features=AA --with-out-features=A doesn't seem to trigger the
generation of features.h so make fails.
--enable-minimalist --with-features=AA --with-out-features=A builds A
and AA. I expected an error message since the configuration is
inconsistent.
Is my source file correct?
Do --with-out-features work?
/MF
(The attached file is my test code (diff against
9d46ef9bd81967e29dbffee7bd2e50887551bf7c) A is log_addresses and AA is
addrcache_age)
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
index b38ef4a..312b642 100644
--- a/agent/snmp_agent.c
+++ b/agent/snmp_agent.c
@@ -126,6 +126,11 @@ netsnmp_feature_child_of(set_all_requests_error, netsnmp_unused)
netsnmp_feature_child_of(addrcache_age, netsnmp_unused)
netsnmp_feature_child_of(delete_subtree_cache, netsnmp_unused)
+netsnmp_feature_want(log_addresses)
+
+#ifdef NETSNMP_FEATURE_REQUIRE_ADDRCACHE_AGE
+netsnmp_feature_require(log_addresses)
+#endif /* NETSNMP_FEATURE_REQUIRE_ADDRCACHE_AGE */
NETSNMP_INLINE void
netsnmp_agent_add_list_data(netsnmp_agent_request_info *ari,
@@ -192,6 +197,8 @@ netsnmp_free_agent_request_info(netsnmp_agent_request_info *ari)
oid version_sysoid[] = { NETSNMP_SYSTEM_MIB };
int version_sysoid_len = OID_LENGTH(version_sysoid);
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
+
#define SNMP_ADDRCACHE_SIZE 10
#define SNMP_ADDRCACHE_MAXAGE 300 /* in seconds */
@@ -209,6 +216,7 @@ struct addrCache {
static struct addrCache addrCache[SNMP_ADDRCACHE_SIZE];
int log_addresses = 0;
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
typedef struct _agent_nsap {
@@ -704,6 +712,7 @@ agent_check_and_process(int block)
}
#endif /* NETSNMP_FEATURE_REMOVE_AGENT_CHECK_AND_PROCESS */
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
/*
* Set up the address cache.
*/
@@ -848,6 +857,8 @@ netsnmp_addrcache_add(const char *addr)
return rc;
}
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
+
/*
* Age the entries in the address cache.
*
@@ -961,10 +972,12 @@ netsnmp_agent_check_packet(netsnmp_session * session,
snmp_increment_statistic(STAT_SNMPINPKTS);
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
if (addr_string != NULL) {
netsnmp_addrcache_add(addr_string);
SNMP_FREE(addr_string);
}
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
return 1;
}
diff --git a/agent/snmp_vars.c b/agent/snmp_vars.c
index fe0e877..a35802a 100644
--- a/agent/snmp_vars.c
+++ b/agent/snmp_vars.c
@@ -62,6 +62,8 @@ PERFORMANCE OF THIS SOFTWARE.
*/
#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-features.h>
+
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
@@ -155,6 +157,8 @@ PERFORMANCE OF THIS SOFTWARE.
#include "snmp_perl.h"
+netsnmp_feature_want(log_addresses)
+
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
@@ -376,7 +380,9 @@ shutdown_agent(void) {
clear_snmp_enum();
clear_callback();
shutdown_secmod();
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
netsnmp_addrcache_destroy();
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
#ifdef NETSNMP_CAN_USE_NLIST
free_kmem();
#endif
diff --git a/agent/snmpd.c b/agent/snmpd.c
index fa651fc..b92a0ca 100644
--- a/agent/snmpd.c
+++ b/agent/snmpd.c
@@ -171,6 +171,7 @@ typedef long fd_mask;
netsnmp_feature_want(logging_file)
netsnmp_feature_want(logging_stdio)
netsnmp_feature_want(logging_syslog)
+netsnmp_feature_want(log_addresses)
/*
* Globals.
@@ -278,8 +279,10 @@ usage(char *prog)
"\t\t\t (config search path: %s)\n%s%s",
netsnmp_get_version(),
"\tWeb: http://www.net-snmp.org/\n"
- "\tEmail: [email protected]\n"
- "\n -a\t\t\tlog addresses\n"
+ "\tEmail: [email protected]\n\n"
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
+ " -a\t\t\tlog addresses\n"
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
" -A\t\t\tappend to the logfile rather than truncating it\n"
" -c FILE[,...]\t\tread FILE(s) as configuration file(s)\n"
" -C\t\t\tdo not read the default configuration files\n",
@@ -438,7 +441,11 @@ SnmpDaemonMain(int argc, TCHAR * argv[])
main(int argc, char *argv[])
#endif
{
- char options[128] = "aAc:CdD::fhHI:l:L:m:M:n:p:P:qrsS:UvV-:Y:";
+ char options[128] =
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
+ "a"
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
+ "Ac:CdD::fhHI:l:L:m:M:n:p:P:qrsS:UvV-:Y:";
int arg, i, ret;
int dont_fork = 0, do_help = 0;
int log_set = 0;
@@ -571,9 +578,11 @@ main(int argc, char *argv[])
handle_long_opt(optarg);
break;
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
case 'a':
log_addresses++;
break;
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
case 'A':
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
@@ -1108,7 +1117,9 @@ main(int argc, char *argv[])
#ifdef WIN32SERVICE
agent_status = AGENT_RUNNING;
#endif
+#ifndef NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES
netsnmp_addrcache_initialise();
+#endif /* NETSNMP_FEATURE_REMOVE_LOG_ADDRESSES */
/*
* Let systemd know we're up.
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders