SNMP Subagent Programmer's Guide
Management Functions
4-18 119728—SNMP Subagent Programmer’s Guide
Writing Subagent Logic
Message Buffer Allocation
When you allocate a buffer for the message from the agent, use this form. 
mgmt_env
identifies the same pointer you use in the call to mgmt_read_nowait().
Example
The following example is from the Fault-Tolerant Hello World sample subagent. This 
subagent handles requests from as many as five NonStop agents. A loop initializes a 
structure containing values identifying each NonStop agent connection and allocates a 
buffer for holding the request.  When AWAITIOX indicates that an I/O operation has 
completed for one of the NonStop agents, the request is processed and 
mgmt_read_nowait() called again to repost a nowaited read to the agent:
for (i=1; i<argc; i++) {
 mgmt_init_env() is called
   mgmt_new_instance() is called
 agent_info[i].mgmt_env->sess->agent_msg_buffer =
 (char *) malloc (SNMP_MSG_MAX);
 agent_info[i].agent_filenumber = mgmt_read_nowait(
 (struct mgmt_env *) agent_info[i].mgmt_env, NULL);
}
...
status = AWAITIOX(&event_fileno,,&count_xferd,,
 100*helloPrintFreq);
...
if (event_fileno == agent_info[i].agent_filenumber) {
 mgmt_poll() is called
...
 if (agent_info[i].agent_filenumber !=
 /* restart the read */
 (event_fileno = mgmt_read_nowait (
 (struct mgmt_env *) agent_info[i].mgmt_env, NULL)) )
mgmt_env->sess->agent_msg_buffer =
 (char *) malloc(SNMP_MSG_MAX)










