Home |
Function xn_snmp_config |
Function xn_snmp_configxn_snmp_config configures and initializes the SNMP agent. struct oid { word id[32]; // array of sub-identifiers int len; // number of entries in id }; typedef struct snmp_config_info { char snmp_version[256]; char snmp_contact[256]; char snmp_location[256]; char snmp_sysname[256]; int num_community_get; char community_get[2][20]; int num_community_set; char community_set[2][20]; char community_out_trap[20]; int snmp_services; struct oid snmp_sys_objid; int num_trap_managers; byte trap_manager[1][4]; dword msgMaxSize; } snmp_config_info; int xn_snmp_config(snmp_config_info * snmp_info); Parameterssnmp_infoPointer to the configuration information. return valueReturns 0 if successful, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. In addition to the error values listed below, all error values generated by socket may also be set. Error Codes further describes each error. Possible values for this function are:
xn_snmp_config must be called prior to calling xn_snmp_daemon. xn_snmp_config will allocate one UDP socket. The members of structure snmp_config must be filled as follows:
Example:#define ENTERPRISE_OID 43,6,1,4,1 #define ENTERPRISE_SIZE 5 #define MY_ENTERPRISE 5715 static struct oid EnterpriseOID = {{ENTERPRISE_OID, MY_ENTERPRISE}, ENTERPRISE_SIZE + 1}; void do_snmp_init(const BYTE * SNMPManagerAddr) { struct snmp_config_info snmp_info; memset(&snmp_info, 0, sizeof(snmp_info)); strcpy(snmp_info.snmp_version, "Embedded PC, On Time RTOS-32 4.0"); strcpy(snmp_info.snmp_contact, "Joe Smith (508)448-9340"); strcpy(snmp_info.snmp_location, "broom closet, 3rd floor"); strcpy(snmp_info.snmp_sysname, "SNMP Demo"); snmp_info.num_community_get = 1; strcpy(snmp_info.community_get[0], "public"); snmp_info.num_community_set = 1; strcpy(snmp_info.community_set[0], "private"); strcpy(snmp_info.community_out_trap, "private-traps"); // system services (FTP, End-to-end) snmp_info.snmp_services = 0x48; // vendor authoritative ID within enterprise mib OIDCPY(snmp_info.snmp_sys_objid, EnterpriseOID); // tell the SNMP agent where to send traps to snmp_info.num_trap_managers = 1; memcpy(snmp_info.trap_manager[0], SNMPManagerAddr, 4); if (xn_snmp_config(&snmp_info) == SOCKET_ERROR) Error("do_snmp_init - xn_snmp_config failed"); }
|