This chapter contains a description of all NetX Duo SNMP agent services (listed below) in alphabetical order.
In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.
Specify authentication key for trap messages
UINT nx_snmp_agent_auth_trap_key_use(
NX_SNMP_AGENT *agent_ptr,
NX_SNMP_SECURITY_KEY *key);
This service specifies the key to be used for setting authentication parameters in the SNMPv3 security header in trap messages. Supplying a NX_NULL value for the key disables authentication.
Note: The key must be previously created. See nx_snmp_agent_md5_key_create or nx_snmp_agent_sha_key_create.
Initialization, Threads
/* Use previously created "my_key" for SNMPv3 trap message authentication. */
status = nx_snmp_agent_auth_trap_key_use(&my_agent, &my_key);
/* If status is NX_SUCCESS the SNMP Agent will use "my_key" for
for authentication parameters in trap messages. */
Specify authentication key for response messages
UINT nx_snmp_agent_authenticate_key_use(
NX_SNMP_AGENT *agent_ptr,
NX_SNMP_SECURITY_KEY *key);
This service specifies the key to be used for authentication parameters in the SNMPv3 security parameter for all requests made after it is set. Supplying a NX_NULL value for the key disables authentication.
Note: The key must be previously created. See nx_snmp_agent_md5_key_create or nx_snmp_agent_sha_key_create.
Initialization, Threads
/* Use previously created "my_key" for SNMPv3 authentication. */
status = nx_snmp_agent_authenticate_key_use(&my_agent, &my_key);
/* If status is NX_SUCCESS the SNMP Agent will use "my_key" for
for setting the authentication parameters of SNMPv3 requests. */
Retrieve community name
UINT nx_snmp_agent_community_get(
NX_SNMP_AGENT *agent_ptr,
UCHAR **community_string_ptr);
This service retrieves the community name from the most recent SNMP request received by the SNMP Agent.
Initialization, Threads
UCHAR *string_ptr;
/* Pickup the community string pointer for my_agent. */
status = nx_snmp_agent_community_get(&my_agent, &string_ptr);
/* If status is NX_SUCCESS the pointer "string_ptr" points to the
last community name supplied to the SNMP agent. */
Indicate if last SNMP request is GET or SET type
UINT nx_snmp_agent_request_get_type_test(
NX_SNMP_AGENT *agent_ptr,
UINT *is_get_type);
This service indicates if the most recent request from the SNMP Manager is a GET (GET, GETNEXT, or GETBULK) or SET type. It is intended for use with the username callback where the SNMPv1 or SNMPv2 application will want to compare the received community string to the SNMP Agent public string if the request is a GET type, or to the SNMP Agent private string if the request is a SET type.
Initialization, Threads
UINT is_get_type;
/* Determine if the current SNMP request is a GET or SET type. */
status = nx_snmp_agent_request_get_type_test(&my_agent, &is_get_type);
/* If status is NX_SUCCESS, is_get_type will indicate the request type. */
Set context engine (SNMP v3 only)
UINT nx_snmp_agent_context_engine_set(
NX_SNMP_AGENT *agent_ptr,
UCHAR *context_engine,
UINT context_engine_size);
This service sets the context engine of the SNMP Agent. It is only applicable for SNMPv3 processing. This should be called before creating security keys if the application is using authentication and encryption, since the context engine ID is used in the key creation process. If not, NetX Duo SNMP provides a default context engine id at the top of nxd_snmp.c:
UCHAR _nx_snmp_default_context_engine[NX_SNMP_MAX_CONTEXT_STRING] =
{0x80, 0x00, 0x03, 0x10, 0x01, 0xc0, 0xa8, 0x64, 0xaf};
Initialization, Threads
UCHAR my_engine[] = {0x80, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
/* Set the context engine for my_agent. */
status = nx_snmp_agent_context_engine_set(&my_agent, my_engine, 9);
/* If status is NX_SUCCESS the context engine has been set. */
Set context name (SNMP v3 only)
UINT nx_snmp_agent_context_name_set(
NX_SNMP_AGENT *agent_ptr,
UCHAR *context_name,
UINT context_name_size);
This service sets the context name of the SNMP Agent. It is only applicable for SNMPv3 processing. If not called, NetX Duo SNMP Agent will leave the context name blank.
Initialization, Threads
/* Set the context name for my_agent. */
status = nx_snmp_agent_context_name_set(&my_agent, "my_context_name", 15);
/* If status is NX_SUCCESS the context name has been set. */
Create SNMP agent
UINT nx_snmp_agent_create(
NX_SNMP_AGENT *agent_ptr,
CHAR *snmp_agent_name,
NX_IP *ip_ptr,
VOID *stack_ptr,
ULONG stack_size,
NX_PACKET_POOL *pool_ptr,
UINT (*snmp_agent_username_process)(
struct NX_SNMP_AGENT_STRUCT *agent_ptr,
UCHAR *username),
UINT (*snmp_agent_get_process)(
struct NX_SNMP_AGENT_STRUCT *agent_ptr,
UCHAR *object_requested,
NX_SNMP_OBJECT_DATA *object_data),
UINT (*snmp_agent_getnext_process)(
struct NX_SNMP_AGENT_STRUCT *agent_ptr,
UCHAR *object_requested,
NX_SNMP_OBJECT_DATA *object_data),
UINT (*snmp_agent_set_process)(
struct NX_SNMP_AGENT_STRUCT
*agent_ptr, UCHAR *object_requested,
NX_SNMP_OBJECT_DATA *object_data));
This service creates a SNMP Agent on the specified IP instance.
Initialization, Threads
NX_SNMP_AGENT my_agent;
/* Create the SNMP Agent "my_agent." */
status = nx_snmp_agent_create(&my_agent, "My SNMP Agent", &ip_0, stack_start_ptr,
4096, &pool_0, my_username_processing, my_get_processing,
my_getnext_processing, my_set_processing);
/* If status is NX_SUCCESS the SNMP Agent "my_agent" has been created. */
Get the SNMP packet version
UINT nx_snmp_agent_current_version_get(
NX_SNMP_AGENT *agent_ptr,
UINT *version);
This service retrieves the SNMP version parsed from the most recent SNMP packet received.
Threads
UINT snmp_version;
NX_SNMP_AGENT my_agent;
/* Get the version of the last received SNMP packet. */
status = nx_snmp_agent_current_version_get (&my_agent, &snmp_version);
/* If status is NX_SUCCESS, snmp_version contains
the received packet SNMP version. */
Verify private string matches Agent private string
UINT nx_snmp_agent_private_string_test(
NX_SNMP_AGENT *agent_ptr,
UCHAR *community_string,
UINT *is_private);
This service compares the null terminated input community string with the SNMP agent private string and indicates if they match.
Threads
UINT is_private;
UCHAR *community_string_ptr;
NX_SNMP_AGENT my_agent;
/* Determine if the community string matches the agent private string */
status = nx_snmp_agent_private_string_test(&my_agent, community_string_ptr,
&is_private);
/* If status is NX_SUCCESS, is_private will indicate if there is a match.
If is_private is NX_TRUE, they match. */
Verify received public string matches Agent’s public string
UINT nx_snmp_agent_public_string_test(
NX_SNMP_AGENT *agent_ptr,
UCHAR *community_string,
UINT *is_public);
This service compares a null terminated input community string with the SNMP agent public string and indicates if they match.
Threads
UINT is_public;
UCHAR *community_string_ptr;
NX_SNMP_AGENT my_agent;
/* Determine if the community string matches the agent public string */
status = nx_snmp_agent_public_string_test(&my_agent, community_string_ptr,
&is_public);
/* If status is NX_SUCCESS, is_public will indicate if there is a match.
If is_public is true they match. */
Set the SNMP agent status for each SNMP version
UINT nx_snmp_agent_version_set(
NX_SNMP_AGENT *agent_ptr,
UINT enabled_v1,
UINT enable_v2,
UINT enable_v3);
This service sets the status (enabled/disabled) for each of the SNMP versions, V1, V2 and V3 on the SNMP agent. Note that the user configurable options, NX_SNMP_DISABLE_V1, NX_SNMP_DISABLE_V2, and NX_SNMP_DISABLE_V3, will override these run time settings. By default, the SNMP agent is enabled for all three versions.
Threads
UINT v1_on = NX_TRUE;
UINT v2_on = NX_TRUE;
UINT v3_on = NX_FALSE;
NX_SNMP_AGENT my_agent;
/* Enable/Disable each SNMP protocol (version) for the SNMP Agent) */
status = nx_snmp_agent_version_set(&my_agent, v1_on, v2_on, v3_on);
/* If status is NX_SUCCESS, my_agent is enabled only for V1 and V2 assuming
NX_SNMP_DISABLE_V1 and NX_SNMP_DISABLE_V2 are not defined. */
Set the SNMP agent private string
UINT nx_snmp_agent_private_string_set(
NX_SNMP_AGENT *agent_ptr,
UCHAR *community_string);
This service sets the SNMP agent private community string with the input null terminated string. The default value is NULL (no private string set), such that any SNMP packet received with a “private” community string will not be accepted by the SNMP agent for read/write access. The input string must be less than or equal to the user configurable NX_SNMP_MAX_USER_NAME-1 (to allow room for null termination) size.
Threads
NX_SNMP_AGENT my_agent;
/* Set the SNMP agent's private community string */
status = nx_snmp_agent_private_string_set(&my_agent, "private"));
/* If status is NX_SUCCESS, the SNMP agent private string is set. */
Set the SNMP agent public string
UINT nx_snmp_agent_public_string_set(
NX_SNMP_AGENT *agent_ptr,
UCHAR *community_string);
This service sets the SNMP agent public community string with the input null terminated string. The community string must be less than or equal to the user configurable NX_SNMP_MAX_USER_NAME-1 (to allow room for null termination) size.
Threads
NX_SNMP_AGENT my_agent;
/* Set the SNMP agent's public string. */
nx_snmp_agent_public_string_set(&my_agent, "my_public"));
/* If status is NX_SUCCESS, the SNMP agent public string is set. */
Delete SNMP agent
UINT nx_snmp_agent_delete(NX_SNMP_AGENT *agent_ptr);
This service deletes a previously created SNMP Agent.
Initialization, Threads
/* Delete the SNMP Agent "my_agent." */
status = nx_snmp_agent_delete(&my_agent);
/* If status is NX_SUCCESS the SNMP Agent "my_agent" has been deleted. */
Set the SNMP agent network interface
UINT nx_snmp_agent_set_interface(
NX_SNMP_AGENT *agent_ptr,
UINT if_index);
This service sets the SNMP network interface for the SNMP Agent as specified by the input interface index. This is only useful for SNMP host applications with NetX Duo 5.6 or higher which support multiple network interfaces. The default value if not specified by the host is zero, for the primary interface.
Initialization, Threads
/* Set the SNMP Agent "my_agent" to the secondary interface. */
if_index = 1;
status = nx_snmp_agent_set_interface(&my_agent, if_index);
/* If status is NX_SUCCESS the SNMP agent interface is set. */
Create md5 key (SNMP v3 only)
UINT nx_snmp_agent_md5_key_create(
NX_SNMP_AGENT *agent_ptr,
UCHAR *password,
NX_SNMP_SECURITY_KEY *destination_key);
This service creates a MD5 key that can be used for authentication and encryption.
This service is deprecated. Developers are encouraged to migrate to nx_snmp_agent_md5_key_create_extended.
Initialization, Threads
NX_SNMP_SECURITY_KEY my_key;
/* Create the MD5 key for "my_agent." */
status = nx_snmp_agent_md5_key_create(&my_agent, "authpw", &my_key);
/* If status is NX_SUCCESS an MD5 key has been created. */
Create md5 key (SNMP v3 only)
UINT nx_snmp_agent_md5_key_create_extended(
NX_SNMP_AGENT *agent_ptr,
UCHAR *password,
UINT password_length,
NX_SNMP_SECURITY_KEY *destination_key);
This service creates a MD5 key that can be used for authentication and encryption.
This service replaces nx_snmp_agent_md5_key_create. This version requires caller to supply password length.
Initialization, Threads
NX_SNMP_SECURITY_KEY my_key;
/* Create the MD5 key for "my_agent." */
status = nx_snmp_agent_md5_key_create_extended(&my_agent, "authpw", 6, &my_key);
/* If status is NX_SUCCESS the key for the password "authpw" has been created. */
Specify encryption key for trap messages
UINT nx_snmp_agent_priv_trap_key_use(
NX_SNMP_AGENT *agent_ptr,
NX_SNMP_SECURITY_KEY *key);
This service specifies that a previously created privacy key is to be used for encryption and decryption of SNMPv3 trap messages.
Note: An authentication key must be previously created. SNMP v3 privacy (encryption) requires authentication. See nx_snmp_agent_auth_trap_key_use for details.
Initialization, Threads
/* Use the "my_privacy_key" for the SNMP Agent "my_agent" trap messages. */
status = nx_snmp_agent_priv_trap_key_use(&my_agent, &my_privacy_key);
/* If status is NX_SUCCESS the privacy key is registered with the SNMP agent. */
Specify encryption key for response messages
UINT nx_snmp_agent_privacy_key_use(
NX_SNMP_AGENT *agent_ptr,
NX_SNMP_SECURITY_KEY *key);
This service specifies that the previously created key is to be used for encryption and decryption of SNMPv3 response messages.
Note: An authentication key must have previously been specified. SNMP v3 encryption requires creation of an authentication key as well. See nx_snmp_agent_authentication_key_use for details.
Initialization, Threads
/* Use the "my_privacy_key" for the SNMP Agent "my_agent." */
status = nx_snmp_agent_privacy_key_use(&my_agent, &my_privacy_key);
/* If status is NX_SUCCESS the privacy key is registered with the SNMP agent. */
Create SHA key (SNMP v3 only)
UINT nx_snmp_agent_sha_key_create(
NX_SNMP_AGENT *agent_ptr,
UCHAR *password,
NX_SNMP_SECURITY_KEY *destination_key);
This service creates a SHA key that can be used for authentication and encryption.
This service is deprecated. Developers are encouraged to migrate to nx_snmp_agent_sha_key_create_extended.
Initialization, Threads
NX_SNMP_SECURITY_KEY my_key;
/* Create the SHA key for "my_agent." */
status = nx_snmp_agent_sha_key_create(&my_agent, "authpw", &my_key);
/* If status is NX_SUCCESS the key for the password "authpw" has been created. */
Create SHA key (SNMP v3 only)
UINT nx_snmp_agent_sha_key_create_extended(
NX_SNMP_AGENT *agent_ptr,
UCHAR *password,
UINT password_length,
NX_SNMP_SECURITY_KEY *destination_key);
This service creates a SHA key that can be used for authentication and encryption.
This service replaces nx_snmp_agent_sha_key_create. This version requires caller to supply password length.
Initialization, Threads
NX_SNMP_SECURITY_KEY my_key;
/* Create the SHA key for "my_agent." */
status = nx_snmp_agent_sha_key_create_extended(&my_agent, "authpw", 6, &my_key);
/* If status is NX_SUCCESS the key for the password "authpw" has been created. */
Start SNMP agent
UINT nx_snmp_agent_start(NX_SNMP_AGENT *agent_ptr);
This service binds the UDP socket to the SNMP port 161 and starts the SNMP Agent thread task.
Initialization, Threads
/* Start the previously created SNMP Agent "my_agent." */
status = nx_snmp_agent_start(&my_agent);
/* If status is NX_SUCCESS the SNMP Agent "my_agent" has been started. */
Stop SNMP agent
UINT nx_snmp_agent_stop(NX_SNMP_AGENT *agent_ptr);
This service stops the SNMP Agent thread task and unbinds the UDP socket to the SNMP port.
Threads
/* Stop the previously created and started SNMP Agent "my_agent." */
status = nx_snmp_agent_stop(&my_agent);
/* If status is NX_SUCCESS the SNMP Agent "my_agent" has been stopped. */
Send SNMPv1 trap (IPv4 only)
UINT nx_snmp_agent_trap_send(
NX_SNMP_AGENT *agent_ptr,
ULONG ip_address,
UCHAR *enterprise,
UINT trap_type,
UINT trap_code,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMP trap to the SNMP Manager at the specified IPv4 address. The preferred method for sending an SNMP trap in NetX Duo is to use the nxd_snmp_agent_trap_send service. nx_snmp_agent_trap_send is included in NetX Duo to support existing NetX SNMP Agent applications.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
ULONG dest_ip_address = IP_ADDRESS(1,2,3,4);
/* Build list of objects to supply in the trap. */
trap_list[0].nx_snmp_object_string_ptr = "1.3.6.1.2.1.2.2.1.1.0";
trap_list[0].nx_snmp_object_data.nx_snmp_object_data_type = NX_SNMP_INTEGER;
trap_list[0].nx_snmp_object_data.nx_snmp_object_data_msw = counter;
trap_list[1].nx_snmp_object_string_ptr = "1.3.6.1.2.1.1.3.0";
trap_list[1].nx_snmp_object_data.nx_snmp_object_data_type = NX_SNMP_TIME_TICS;
trap_list[1].nx_snmp_object_data.nx_snmp_object_data_msw = tx_time_get();
trap_list[2].nx_snmp_object_string_ptr = NX_NULL; /* Terminate list! */
/* Send trap to SNMP manager at 193.2.2.61. */
status = nx_snmp_agent_trap_send(&my_agent,dest_ip_address,
"1.3.6.7.7.7", NX_SNMP_TRAP_LINKUP, counter++,
tx_time_get(), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv1 trap (IPv4 and IPv6)
UINT nxd_snmp_agent_trap_send(
NX_SNMP_AGENT *agent_ptr,
ULONG ip_address,
UCHAR *enterprise, UINT trap_type,
UINT trap_code,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMP trap to the SNMP Manager at the specified IP address. The equivalent method for sending an SNMP trap in NetX is the nxd_snmp_agent_trap_send service.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
NXD_ADDRESS dest_ip_address;
dest_ip_address.nxd_ip_version = NX_IP_VERSION_V6 ;
dest_ip_address.nxd_ip_address.v6[0] = 0x20010db8;
dest_ip_address.nxd_ip_address.v6[1] = 0xf101;
dest_ip_address.nxd_ip_address.v6[2] = 0x00000000;
dest_ip_address.nxd_ip_address.v6[3] = 0x00000101;
/* Build list of objects to supply in the trap. */
trap_list[0].nx_snmp_object_string_ptr = "1.3.6.1.2.1.2.2.1.1.0";
trap_list[0].nx_snmp_object_data.nx_snmp_object_data_type = NX_SNMP_INTEGER;
trap_list[0].nx_snmp_object_data.nx_snmp_object_data_msw = counter;
trap_list[1].nx_snmp_object_string_ptr = "1.3.6.1.2.1.1.3.0";
trap_list[1].nx_snmp_object_data.nx_snmp_object_data_type = NX_SNMP_TIME_TICS;
trap_list[1].nx_snmp_object_data.nx_snmp_object_data_msw = tx_time_get();
trap_list[2].nx_snmp_object_string_ptr = NX_NULL; /* Terminate list! */
/* Send trap to SNMP manager at 193.2.2.61. */
status = nxd_snmp_agent_trap_send(&my_agent,&dest_ip_address,
"1.3.6.7.7.7", NX_SNMP_TRAP_LINKUP, counter++, tx_time_get(),
trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv2 trap (IPv4 only)
UINT nx_snmp_agent_trapv2_send(
NX_SNMP_AGENT *agent_ptr,
NXD_ADDRESS *ip_address,
UCHAR *community,
UINT trap_type,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMPv2 trap to the SNMP Manager at the specified IPv4 address. The preferred method for sending an SNMP trap in NetX Duo is to use the nxd_snmp_agent_trapv2_send service. nx_snmp_agent_trapv2_send is included in NetX Duo to support existing NetX SNMP Agent applications.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
ULONG dest_ip_address = IP_ADDRESS(1,2,3,4);
/* Build an empty object list, since it is not needed for the
NX_SNMP_TRAP_COLDSTART trap. */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nx_snmp_agent_trapv2_send(&my_agent,dest_ip_address, "public",
NX_SNMP_TRAP_COLDSTART, tx_time_get(), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv2 trap specifying OID directly
UINT nx_snmp_agent_trapv2_oid_send(
NX_SNMP_AGENT *agent_ptr,
ULONG ip_address,
UCHAR *community,
UCHAR *oid,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMPv2 trap to the SNMP Manager at the specified IP address (IPv4 only) and allows the caller to specify the OID directly. The preferred method for sending an SNMP trap with specified OID in NetX Duo is to use the nxd_snmp_agent_trapv2_oid_send service. nx_snmp_agent_trapv2_oid_ send is included in NetX Duo to support existing NetX SNMP Agent applications.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
/* Build an empty object list */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nx_snmp_agent_trapv2_oid_send(&my_agent, IP_ADDRESS(193,2,2,61),
"public", (UCHAR *)"0.9.9.9.9.9.9.9.9.9",
(tx_time_get()), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv2 trap (IPv4 and IPv6)
UINT nxd_snmp_agent_trapv2_send(
NX_SNMP_AGENT *agent_ptr,
NXD_ADDRESS *ip_address,
UCHAR *community, UINT trap_type,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMP V2 trap to the SNMP Manager at the specified IP address.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
NXD_ADDRESS dest_ip_address;
dest_ip_address.nxd_ip_version = NX_IP_VERSION_V6 ;
dest_ip_address.nxd_ip_address.v6[0] = 0x20010db8;
dest_ip_address.nxd_ip_address.v6[1] = 0xf101;
dest_ip_address.nxd_ip_address.v6[2] = 0x00000000;
dest_ip_address.nxd_ip_address.v6[3] = 0x00000101;
/* Build an empty object list, since it is not needed for the
NX_SNMP_TRAP_COLDSTART trap. */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send a standard event trap to SNMP manager at 193.2.2.61. */
Status = nxd_snmp_agent_trapv2_send(&my_agent,&dest_ip_address, "public",
NX_SNMP_TRAP_COLDSTART, tx_time_get(),
trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv2 trap specifying OID directly
UINT nxd_snmp_agent_trapv2_oid_send(
NX_SNMP_AGENT *agent_ptr,
NXD_ADDRESS *ip_address,
UCHAR *community,
UCHAR *oid, ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMP v2 trap to the SNMP Manager at the specified IP address (IPv4/IPv6) and allows the caller to specify the OID directly.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
NXD_ADDRESS address;
/* Build an empty object list */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
address.nxd_ip_version = NX_IP_VERSION_V4;
address.nxd_ip_address.v4 = IP_ADDRESS(193,2,2,61)
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nxd_snmp_agent_trapv2_oid_send(&my_agent, &address,
"public", (UCHAR *)"0.9.9.9.9.9.9.9.9.9",
tx_time_get(), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv3 trap (IPv4 only)
UINT nx_snmp_agent_trapv3_send(
NX_SNMP_AGENT *agent_ptr,
ULONG ip_address,
UCHAR *username,
UINT trap_type,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMPv3 trap to the SNMP Manager at the specified IPv4 address. The preferred method for sending an SNMP trap in NetX Duo is to use the nxd_snmp_agent_trapv3_send service. nx_snmp_agent_trapv3_send is included in NetX Duo to support existing NetX SNMP Agent applications.
Initialization, Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
ULONG dest_ip_address = IP_ADDRESS(1,2,3,4);
/* Build an empty object list, since it is not needed for the
NX_SNMP_TRAP_COLDSTART trap. */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nx_snmp_agent_trapv3_send(&my_agent, dest_ip_address, "public",
NX_SNMP_TRAP_COLDSTART, tx_time_get(), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv3 trap specifying OID directly
UINT nx_snmp_agent_trapv3_oid_send(
NX_SNMP_AGENT *agent_ptr,
ULONG ip_address,
UCHAR *username,
UCHAR *oid,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMPv3 trap to the SNMP Manager at the specified IP address (IPv4 only) and allows the caller to specify the OID directly. The preferred method for sending an SNMP trap with specified OID in NetX Duo is to use the nxd_snmp_agent_trapv3_oid_send service. nx_snmp_agent_trapv3_oid_ send is included in NetX Duo to support existing NetX SNMP Agent applications.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
/* Build an empty object list */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nx_snmp_agent_trapv3_oid_send(&my_agent, IP_ADDRESS(193,2,2,61),
"public", (UCHAR *)"0.9.9.9.9.9.9.9.9.9",
(tx_time_get()), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv3 trap (IPv4 and IPv6)
UINT nxd_snmp_agent_trapv3_send(
NX_SNMP_AGENT *agent_ptr,
NXD_ADDRESS *ip_address,
UCHAR *username, UINT trap_type,
ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMP trap to the SNMP Manager at the specified IP address. This trap is basically the same as the SNMP v2 trap, except the trap message format is contained in the SNMP v3 PDU.
Threads
NX_SNMP_TRAP_OBJECT trap_list[5];
NXD_ADDRESS dest_ip_address;
dest_ip_address.nxd_ip_version = NX_IP_VERSION_V6 ;
dest_ip_address.nxd_ip_address.v6[0] = 0x20010db8;
dest_ip_address.nxd_ip_address.v6[1] = 0xf101;
dest_ip_address.nxd_ip_address.v6[2] = 0x00000000;
dest_ip_address.nxd_ip_address.v6[3] = 0x00000101;
/* Build an empty object list, since it is not needed for the
NX_SNMP_TRAP_COLDSTART trap. */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nxd_snmp_agent_trapv3_send(&my_agent, &dest_ip_address, "public",
NX_SNMP_TRAP_COLDSTART, tx_time_get(),
trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Send SNMPv3 trap specifying OID directly
UINT nxd_snmp_agent_trapv3_oid_send(
NX_SNMP_AGENT *agent_ptr,
NXD_ADDRESS *ip_address,
UCHAR *username,
UCHAR *oid, ULONG elapsed_time,
NX_SNMP_TRAP_OBJECT *object_list_ptr);
This service sends an SNMPv3 trap to the SNMP Manager at the specified IP address (IPv4/IPv6) and allows the caller to specify the OID directly.
Threads
NXD_ADDRESS ip_address;
NX_SNMP_TRAP_OBJECT trap_list[5];
/* Build an empty object list */
trap_list[0].nx_snmp_object_string_ptr = NX_NULL;
ip_address.nxd_ip_version = NX_IP_VERSION_V4;
ip_address.nxd_ip_address.v4 = IP_ADDRESS(193,2,2,61);
/* Send trap to SNMP manager at 193.2.2.61. */
Status = nxd_snmp_agent_trapv3_oid_send(&my_agent, &ip_address,
"public", (UCHAR *)"0.9.9.9.9.9.9.9.9.9",
tx_time_get(), trap_list);
/* If status is NX_SUCCESS the SNMP trap has been sent. */
Set the number of reboots (if SNMPv3 enabled)
UINT nx_snmp_agent_v3_context_boots_set(
NX_SNMP_AGENT *agent_ptr,
UINT boots);
This service sets the number of reboots recorded by the SNMP agent. This service is only available if SNMPv3 is enabled for the SNMP agent because boot count is only used in the SNMPv3 protocol.
Initialization, Threads
UINT my_boots = 4;
if (my_agent.nx_snmp_agent_v3_enabled == NX_TRUE)
{
status = nx_snmp_agent_v3_context_boots_set(&my_agent, my_boots);
}
/* If status is NX_SUCCESS the SNMP boot count is set. */
Compare two objects
UINT nx_snmp_object_compare(
UCHAR *object,
UCHAR *reference_object);
This service compares the supplied object ID with the reference object ID. Both object IDs are in the ASCII SMI notation, e.g., both object must start with the ASCII string “1.3.6”.
This service is deprecated. Developers are encouraged to migrate to nx_snmp_object_compare_extended.
Initialization, Threads
/* Compare "requested_object" with the sysDescr object ID of
"1.3.6.1.2.1.1.1.0". */
Status = nx_snmp_object_compare(requested_object, "1.3.6.1.2.1.1.1.0");
/* If status is NX_SUCCESS, requested_object is the sysDescr object.
Otherwise, if status is NX_SNMP_NEXT_ENTRY, the requested object is
less than the sysDescr. If status is NX_SNMP_ERROR, the object is
greater than sysDescr. */
Compare two objects
UINT nx_snmp_object_compare_extended(
UCHAR *request_object,
UINT requested_object_length,
UCHAR *reference_object
UINT reference_object_length);
This service compares the supplied object ID with the reference object ID. Both object IDs are in the ASCII SMI notation, e.g., both object must start with the ASCII string “1.3.6”.
This service replaces nx_snmp_object_compare. This version requires callers to supply length information.
Initialization, Threads
/* Compare "requested_object" with the sysDescr object ID of
"1.3.6.1.2.1.1.1.0". */
Status = nx_snmp_object_compare_extended(requested_object, 17,
"1.3.6.1.2.1.1.1.0", 17);
/* If status is NX_SUCCESS, requested_object is the sysDescr object.
Otherwise, if status is NX_SNMP_NEXT_ENTRY, the requested object is
less than the sysDescr. If status is NX_SNMP_ERROR, the object is
greater than sysDescr. */
Copy an object
UINT nx_snmp_object_copy(
UCHAR *source_object_name,
UCHAR *destination_object_name);
This service copies the source object in ASCII SIM notation to the destination object.
This service is deprecated. Developers are encouraged to migrate to nx_snmp_object_copy_extended.
Initialization, Threads
/* Copy "my_object" to "my_new_object". */
size = nx_snmp_object_copy(my_object, my_new_object);
/* Size contains the number of bytes copied. */
Copy an object
UINT nx_snmp_object_copy_extended(
UCHAR *source_object_name,
UINT source_object_name_length,
UCHAR *destination_object_name_buffer,
UINT destination_object_name_buffer_size);
This service copies the source object in ASCII SIM notation to the destination object.
This service replaces nx_snmp_object_copy. This version requires callers to supply length information.
Initialization, Threads
UCHAR my_object = "1.3.6.1.2.1.1.1.0";
UCHAR my_new_object[32];
/* Copy "my_object" to "my_new_object". */
size = nx_snmp_object_copy(my_object, 17, my_new_object, sizeof(my_new_object));
/* Size contains the number of bytes copied. */
Get counter object
UINT nx_snmp_object_counter_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the counter object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the ifInOctets (1.3.6.1.2.1.2.2.1.10.0) MIB-2 object. */
status = nx_snmp_object_counter_get(&ifInOctets, my_object);
/* If status is NX_SUCCESS, the ifInOctets object has been
retrieved and is ready to be returned. */
Set counter object
UINT nx_snmp_object_counter_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the counter at the address specified by the destination pointer with the counter value in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the ifInOctets (1.3.6.1.2.1.2.2.1.10.0) MIB-2 object with
the counter object value contained in my_object. */
status = nx_snmp_object_counter_set(&ifInOctets, my_object);
/* If status is NX_SUCCESS, the ifInOctets object has been
set. */
Get 64-bit counter object
UINT nx_snmp_object_counter64_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the 64-bit counter object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of my_64_bit_counter and place it into my_object
for return. */
status = nx_snmp_object_counter64_get(&my_64_bit_counter, my_object);
/* If status is NX_SUCCESS, the my_64_bit_counter object has been
retrieved and is ready to be returned. */
Set 64-bit counter object
UINT nx_snmp_object_counter64_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the 64-bit counter at the address specified by the destination pointer with the counter value in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of my_64_bit_counter with the value in my_object. */
status = nx_snmp_object_counter64_set(&my_64_bit_counter, my_object);
/* If status is NX_SUCCESS, the my_64_bit_counter object has been
set. */
Set end-of-mib value
UINT nx_snmp_object_end_of_mib(
VOID *not_used_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service creates an object signaling the end of the MIB and is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Place an end-of-mib value in my_object. */
status = nx_snmp_object_end_of_mib(NX_NULL, my_object);
/* If status is NX_SUCCESS, the my_object is now an end-of-mib object. */
Get gauge object
UINT nx_snmp_object_gauge_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the gauge object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of ifSpeed (1.3.6.1.2.1.2.2.1.5.0) and place it in my_object
for return. */
status = nx_snmp_object_gauge_get(&ifSpeed, my_object);
/* If status is NX_SUCCESS, the my_object now contains the ifSpeed gauge value. */
Set gauge object
UINT nx_snmp_object_gauge_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the gauge at the address specified by the destination pointer with the gauge value in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of "my_gauge" from the gauge value in my_object. */
status = nx_snmp_object_gauge_set(&my_gauge, my_object);
/* If status is NX_SUCCESS, the my_gauge now contains the new gauge value. */
Get object id
UINT nx_snmp_object_id_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the object ID (in ASCII SIM notation) at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of sysObjectID(1.3.6.1.2.1.1.2.0) and place it in my_object
for return. */
status = nx_snmp_object_id_get(&sysObjectID, my_object);
/* If status is NX_SUCCESS, the my_object now contains the sysObjectID value. */
Set object id
UINT nx_snmp_object_id_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the object ID (in ASCII SIM notation) at the address specified by the destination pointer with the object ID in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the string "my_object_id" with the object ID value contained
in my_object. */
status = nx_snmp_object_id_set(my_object_id, my_object);
/* If status is NX_SUCCESS, the my_object_id now contains the object ID value. */
Get integer object
UINT nx_snmp_object_integer_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the integer object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of sysServices (1.3.6.1.2.1.1.7.0) and place it in my_object
for return. */
status = nx_snmp_object_integer_get(&sysServices, my_object);
/* If status is NX_SUCCESS, the my_object now contains the sysServices value. */
Set integer object
UINT nx_snmp_object_integer_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the integer at the address specified by the destination pointer with the integer value in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of ifAdminStatus from the integer value in my_object. */
status = nx_snmp_object_integer_set(&ifAdminStatus, my_object);
/* If status is NX_SUCCESS, ifAdminStatus now contains the new integer value. */
Get IP address object (IPv4 only)
UINT nx_snmp_object_ip_address_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the IP address object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of ipAdEntAddr (1.3.6.1.2.1.4.20.1.1.0) and place it in my_object
for return. */
status = nx_snmp_object_ip_address_get(&ipAdEntAddr, my_object);
/* If status is NX_SUCCESS, the my_object now contains the ipAdEntAddr value. */
Get IP address object (IPv6 only)
UINT nx_snmp_object_ipv6_address_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the IPv6 address object at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of ipAdEntAddr (1.3.6.1.2.1.4.20.1.1.0) and place it in my_object
for return. */
status = nx_snmp_object_ipv6_address_get(&ipAdEntAddr, my_object);
/* If status is NX_SUCCESS, the my_object now contains the ipAdEntAddr value. */
Set IPv4 address object
UINT nx_snmp_object_ip_address_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the IPv4 address at the address specified by the destination pointer with the IP address in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of atNetworkAddress to the IP address in my_object. */
status = nx_snmp_object_ip_address_set(&atNetworkAddress, my_object);
/* If status is NX_SUCCESS, atNetWorkAddress now contains the new IP address. */
Set IPv6 address object
UINT nx_snmp_object_ipv6_address_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the IPv6 address at the address specified by the destination pointer with the IP address in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of atNetworkAddress to the IP address in my_object. */
status = nx_snmp_object_ipv6_address_set(&atNetworkAddress, my_object);
/* If status is NX_SUCCESS, atNetWorkAddress now contains the new IP address. */
Set no-instance object
UINT nx_snmp_object_no_instance(
VOID *not_used_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service creates an object signaling that there was no instance of the specified object and is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Place no-instance value in my_object. */
status = nx_snmp_object_no_instance(NX_NULL, my_object);
/* If status is NX_SUCCESS, the my_object is now a no-instance object. */
Set not-found object
UINT nx_snmp_object_not_found(
VOID *not_used_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service creates an object signaling the object was not found and is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Place not-found value in my_object. */
status = nx_snmp_object_not_found(NX_NULL, my_object);
/* If status is NX_SUCCESS, the my_object is now a not-found object. */
Get octet string object
UINT nx_snmp_object_octet_string_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data,
UINT length);
This service retrieves the octet string at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of the 6-byte ifPhysAddress (1.3.6.1.2.1.2.2.1.6.0) and place
it in my_object for return. */
status = nx_snmp_object_octet_string_get(ifPhysAddress, my_object, 6);
/* If status is NX_SUCCESS, the my_object now contains the ifPhysAddress value. */
Set octet string object
UINT nx_snmp_object_octet_string_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the octet string at the address specified by the destination pointer with the octet string in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of sysContact (1.3.6.1.2.1.1.4.0) from the
octet string in my_object. */
status = nx_snmp_object_octet_string_set(sysContact, my_object);
/* If status is NX_SUCCESS, sysContact now contains the new octet string. */
Get ASCII string object
UINT nx_snmp_object_string_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the ASCII string at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of the sysDescr (1.3.6.1.2.1.1.1.0) and place
it in my_object for return. */
status = nx_snmp_object_string_get(sysDescr, my_object);
/* If status is NX_SUCCESS, the my_object now contains the sysDescr string. */
Set ASCII string object
UINT nx_snmp_object_string_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the ASCII string at the address specified by the destination pointer with the ASCII string in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of sysContact (1.3.6.1.2.1.1.4.0) from the
ASCII string in my_object. */
status = nx_snmp_object_string_set(sysContact, my_object);
/* If status is NX_SUCCESS, sysContact now contains the new ASCII string. */
Get timetics object
UINT nx_snmp_object_timetics_get(
VOID *source_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service retrieves the timetics at the address specified by the source pointer and places it in the NetX Duo object data structure. This routine is typically called from the GET or GETNEXT application callback routine.
Initialization, Threads
/* Get the value of the sysUpTime (1.3.6.1.2.1.1.3.0) and place
it in my_object for return. */
status = nx_snmp_object_timetics_get(sysUpTime, my_object);
/* If status is NX_SUCCESS, the my_object now contains the sysUpTime value. */
Set timetics object
UINT nx_snmp_object_timetics_set(
VOID *destination_ptr,
NX_SNMP_OBJECT_DATA *object_data);
This service sets the timetics variable at the address specified by the destination pointer with the timetics in the NetX Duo object data structure. This routine is typically called from the SET application callback routine.
Initialization, Threads
/* Set the value of "my_time" from the timetics value in my_object. */
status = nx_snmp_object_timetics_set(&my_time, my_object);
/* If status is NX_SUCCESS, my_time now contains the new timetics. */