SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-85
Security Checker
Source Code
The Security Checker source code appears in Examples 2-18 through 2-20:
Example 2-18 shows the main control block, contained in helloscc.
Example 2-19 shows the authentication function, contained in authentc.
Example 2-20 shows the access functions, contained in securitc.
Numbers in the examples correspond to comments in the discussions located between 
here and the examples.
Global Declarations
The main difference between the global declarations used by Security Checker and those 
used by Nowaited Hello World is the addition of several variables and include files:
1. A group of four variables is declared for use by mgmt_security().
2. These two variables, used for authentication, are declared globally because they are 
used by the authentication and access functions.
3. The files containing the authentication and access functions are included.
Main Control Block
This logic calls the management and authentication functions and initializes the global 
variables used for authentication:
4. The password, the third argument of the invocation line, is stored.
5. The management environment is initialized.
6. The MIB is registered.
7. A nowaited read from the NonStop agent is started after the necessary message 
buffer has been allocated.
8. When a message is received from the NonStop agent, authentication begins.
9. After initializing the authentication flag so that authentication failure is assumed, 
mgmt_security() is called to retrieve the manager station’s community string to 
“community” and the manager station’s IP address to “hostaddr.”
10. The authentication function is called, and the status returned by the function is 
assigned to the authentication flag. A status of 1 indicates the password used at 
invocation is valid. A status of 0 signals an invalid password.
11. When mgmt_poll() is called, the appropriate subagent’s access function is invoked 
to process the request. 
12. If the request changed the value of helloPrintFreq, Security Checker sends a trap. 
Before calling mgmt_trap(), the subagent assigns a value to the authentication flag 
so that when the run-time library calls GET_helloPrintFreq to retrieve the value to 
include in the trap, the access function can succeed.










