for connected embedded systems
![]() |
![]() |
![]() |
![]() |
read_main_config_file()
Read the snmpd.conf file
Synopsis:
#include <snmp/snmp_api.h>
int read_main_config_file(
struct snmpd_conf_data * info );
Arguments:
- info
- A pointer to a snmpd_conf_data structure that the function can fill with the configuration information. For more information about this structure, see below.
Library:
libsnmp
Use the -l snmp option to qcc to link against this library.
Description:
The read_main_config_file() function fills the info structure with data from the snmpd.conf file (see the Utilities Reference). This information is useful if you wish to know what configuration information the SNMP agent was started with.
The string pointers in this structure, if not NULL, point to strings obtained by using malloc(); you can free them by calling free().
![]() |
If the data for a member of the structure isn't available, the structure member isn't modified. You should use memset() to set the structure to 0 before calling read_main_config_file(). |
To locate the snmpd.conf file, this function first checks the SNMPCONFIGFILE environment variable. If this isn't found, the default, snmpd.conf, is used. If the specified file couldn't be accessed, the structure members aren't updated.
The snmpd_conf_data structure is defined in <snmp_api.h>, and contains the following members:
struct snmpd_conf_data{
char* main_config_fname;
char* party_conf_fname;
char* view_conf_fname;
char* context_conf_fname;
char* acl_conf_fname;
char* sysContact;
char* sysLocation;
char* sysName;
char* private_community;
char* public_community;
char* trap_sink;
char* trap_community;
int conf_authentraps;
};
The members of this structure are:
- main_config_fname
- snmpd.conf file location.
- party_conf_fname
- party.conf file location.
- view_conf_fname
- view.conf file location.
- context_conf_fname
- context.conf file location.
- acl_conf_fname
- acl.conf file location.
- sysContact
- system.sysContact string.
- sysLocation
- system.sysLocation string.
- sysName
- system.sysName string.
- private_community
- Private level community string name to use.
- public_community
- Public level community string name to use.
- trap_sink
- Destination host to send trap messages.
- trap_community
- Community name to use for trap messages.
- conf_authentraps
- Enable authentication traps (1 means enable, 2 means disable).
Returns:
- 0
- Success.
- -1
- An error occurred (errno is set).
Errors:
- ENOENT
- The snmpd.conf file wasn't found.
Files:
- snmpd.conf
- Default SNMP configuration file. For more information, see the Utilities Reference.
Environment variables:
- SNMPCONFIGFILE
- Location of the SNMP configuration file.
Classification:
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
See also:
snmp_close(), snmp_free_pdu(), snmp_open(), snmp_pdu, snmp_pdu_create(), snmp_read(), snmp_select_info(), snmp_send(), snmp_session, snmp_timeout()
snmpd, snmpd.conf in the Utilities Reference
![]() |
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)
