The package provides a number of high-level include files that may be used by the general application programmer when writing applications against the Net-SNMP package APIs. In particular, these files are the following three:
File | Description |
---|---|
net-snmp/net-snmp-config.h | this file contains a number of configuration directives which are used to define whether other include files are included by the rest of the include files. this file is installed for convenience purposes and may be used by simple packages when possible. However, certain package authors may find it problematic to use if the package it is being used in also has its own configuration file generated by the autoconf mechanisms. Please see below for details on dealing with these issues. |
net-snmp/net-snmp-includes.h | This file is a high level wrapper around the rest of the more detailed include files. Generally speaking, if an application which is to include functionality from the base SNMP library it should include this file. At the die-hard developers may wish to include each sub-include file only as needed, as it will ease the burden on the C preprocessor. |
net-snmp/agent/net-snmp-agent-includes.h | This file is a high level wrapper around the agent specific include files. Specifically, this fall should be included by developers who are developing modules to be used within an SNMP agent. Again, hard-core developers who wish to speed up the work of the C processor can be more selective than this, however this fall is here for easiest use. |
So, for most applications all that a management application programmer should need to do would be include the following two lines:
#include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h>
Agent developers will need to add one additional line to their code files:
#include <net-snmp/agent/net-snmp-agent-includes.h>
However, problems arise when another package also uses autoconf generated configuration files. Generally, these configuration files conflict with each other due to special package symbols that autoconf inserts into the configuration files. Thus, including our particular configuration file (net-snmp/net-snmp-config.h) ahead of or below your own package's configuration file will cause conflicts.
To get around this problem, your package should probably not be including our generated configuration file but should be instead using its own. A minimal template for how to accomplish this safely is included below:
#include <stdio.h> #include <netinet/in.h> #include <sys/types.h> /* If you have sys/time.h on your machine: */ #include <sys/time.h> /* Else pick one of these instead: #include <time.h> #include <sys/timeb.h> */ /* if on windows: */ #ifdef WIN32 #include <winsock.h> #endif /* put a proper extern in front of certain functions */ #define NETSNMP_IMPORT extern /* don't use inline constructs (define to <i>inline</i> if you want them) */ #define NETSNMP_INLINE /* run man signal and see what the user function is supposed to return to avoid warnings, or leave as "void" below if you don't care about any warnings you might be seeing */ #define RETSIGTYPE void /* tell the Net-SNMP core functionality headers that we've done the minimal requirements */ #define NET_SNMP_CONFIG_H /* include the core Net-SNMP functionality headers */ #include <net-snmp/net-snmp-includes.h>
Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.