/*
 *  Copyright (c) 1996-2007 Digi International Inc., All Rights Reserved
 *
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *
 *  Restricted Rights Legend
 *
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 * =======================================================================
 * This header file contains declarations used in the SNMP library.
 *                                                                        
 *                                                                        
 * Edit Date/Ver   Edit Description
 * ==============  ===================================================
 *	05/23/02 DXL	- Added system group variable as extern to be accessed by dvt
 *
 *      08/05/03 JZW    - added manifest constants
 *                        TRAPADDR_ADD
 *                        TRAPADDR_DELETE
 *                        SNMP_TRAP_ALL - updated autodoc as needed
 */

#ifndef snmpapi_h
#define snmpapi_h

#include <nastatus.h>
#include "trdefs.h"
#include "trasn1.h"
#include "sockapi.h"

#ifdef __cplusplus
extern "C"
{
#endif

/*ad*
 * SNMP traps are alerts generated by agents on a managed device. NET+OS 
 * supports all standard trap types specified in RFC 1157. A trap may 
 * be sent by calling @link naSnmpSendTrap, when running SNMPv1 / SNMPv2c library, 
 * or by calling @link naSnmpSendNotifications, when running SNMPv3 library. 
 * The coldStart(0) generic is automatically sent by the agent at startup. 
 * It can be disabled by calling @link naSnmpDisableColdStartTrap before the 
 * SNMP agent is started. The authenticationFailure(4) trap is automatically sent
 * by the agent, however it can be sent by @link naSnmpSendTrap or @link 
 * naSnmpSendNotifications.
 *
 * @external
 * @category SNMP
 * @since 6.0
 * @name GENERIC_TRAP_TYPES "SNMP Generic Trap Types"
 * @include "snmpapi.h" 
 * @see @link naSnmpSendTrap
 * @see @link naSnmpSendNotifications
 *
 * @param SNMP_TRAP_WARMSTART               SNMP Agent reinitialized its configuration 
 *                                          tables via a warm restart.
 * @param SNMP_TRAP_LINKDOWN                Network interface on the SNMP Agent fails.
 * @param SNMP_TRAP_LINKUP                  Network interface on the SNMP Agent
 *                                          reinitializes.
 * @param SNMP_TRAP_AUTHENTICATIONFAILURE   SNMP Agent gets a request from an unrecognized 
 *                                          community name.
 * @param SNMP_TRAP_EGPNEIGHBORLOSS         SNMP Agent cannot communicate with its EGP 
 *                                          (Exterior Gateway Protocol) peer.
 * @param SNMP_TRAP_ENTERPRISESPECIFIC      Vendor specific error conditions and error codes.
*ad*/
#define SNMP_TRAP_WARMSTART             (0x1)
#define SNMP_TRAP_LINKDOWN              (0x2)
#define SNMP_TRAP_LINKUP                (0x3)
#define SNMP_TRAP_AUTHENTICATIONFAILURE (0x4)
#define SNMP_TRAP_EGPNEIGHBORLOSS       (0x5)
#define SNMP_TRAP_ENTERPRISESPECIFIC    (0x6)

#define ESPECIFIC_NOT_DEFINED           (0x0)


/* Specific Trap for PrinterV1Alert */
#define ESPECIFIC_PRINTER_ALERT     (0x1)
#define ESPECIFIC_JOB_ALERT         (0x2)


/*ad*
 * This defintion is used to determine the community level inside a trap message
 * generated by the @link naSnmpSendTrap function. It is also used for the securityName,
 * in the @link NaSnmpNotificationTarget_t structure, used to initialize the Target MIB 
 * and the Notification MIB by the @link naSnmpSetNotificationTargets function.
 *
 * @external
 * @category SNMP
 * @since 6.0
 * @name COMMUNITY_TYPES "SNMP Community Types"
 * @include "snmpapi.h"
 *
 * @see @link naSnmpSendTrap
 * @see @link naSnmpSetNotificationTargets
 *
 * @param SNMP_COMMUNITY_TYPE_PUBLIC    For the public (read) community
 * @param SNMP_COMMUNITY_TYPE_PRIVATE   For the private (read-write) community
*ad*/
#define SNMP_COMMUNITY_TYPE_PUBLIC      "public"
#define SNMP_COMMUNITY_TYPE_PRIVATE     "private"


/*ad*
 * BER Coded Object types
 *
 * @external
 * @category SNMP
 * @since 6.0
 * @name BER_TYPES "SNMP BER Coded Object types"
 *
 * @param ASN_BOOLEAN       (0x01)
 * @param ASN_INTEGER	    (0x02)
 * @param ASN_BIT_STR	    (0x03)
 * @param ASN_OCTET_STR     (0x04)
 * @param ASN_NULL          (0x05)
 * @param ASN_OBJECT_ID     (0x06)
 *
 * @see @link variable_t 
*ad*/
#define ASN_BOOLEAN                     (0x01)
#define ASN_INTEGER	                    (0x02)
#define ASN_BIT_STR	                    (0x03)
#define ASN_OCTET_STR                   (0x04)
#define ASN_NULL                        (0x05)
#define ASN_OBJECT_ID                   (0x06)

/*ad*
 * Structures used to pass enterprise specific variables.
 *
 * @external
 * @category SNMP
 * @since 6.0
 *
 *
 * @param oid_value		Value of OID in unsigned long format
 * @param value			Value of the variable of specified type and length
 * @param oid_length	Number of digits in OID
 * @param value_type	BER coded type
 * @param value_length	Length of the value in bytes
 *
 * @see @link BER_TYPES 
*ad*/
struct variable_t 
{
    unsigned long oid_value[24];  
    unsigned char value[256];     
    unsigned char oid_length;     
    unsigned char value_type;     
    unsigned char value_length;   
};

/*ad*
 * Maximum length of trap enterprise field of SNMPv1 traps.
 *
 * @external
 * @category SNMP
 * @since 7.0
 *
 * @see @link NaSnmpTrap_t
*ad*/
#define NA_SNMP_ENT_MAX_LEN       64


NaStatus naSnmpStart(void);

NaStatus naSnmpDisableColdStartTrap(void);
NaStatus naSnmpSetPortNumber (unsigned short port);
NaStatus naSnmpGetPortNumber (unsigned short *port);
int snmpd_load(void);
unsigned int naSnmpGetEnterpriseNumber(oid * enterpriseNumberPtr);
void naSnmpSetEnterpriseNumber(oid enterpriseNumber, unsigned int enterpriseLength);
NaStatus naSnmpSetSysObjectID(oid * sysOid, int oidLen);
NaStatus naSnmpGetSysObjectID(oid * sysOid, int * sysOidLen);
NaStatus naSnmpGetSysDescr(char * sysDescr);
NaStatus naSnmpSetSysDescr(char * sysDescr);
NaStatus naSnmpSetSysContact(char * sysContact);
NaStatus naSnmpGetSysContact(char * sysContact);
NaStatus naSnmpGetSysName(char * sysName);
NaStatus naSnmpSetSysName(char * sysName);
NaStatus naSnmpGetSysLocation(char * sysLocation);
NaStatus naSnmpSetSysLocation(char * sysLocation);
NaStatus naSnmpSetSysServices(char sysServices);
NaStatus naInitializeCustomMibs(const void * custSnmpSubtrees, const void * custConceptualTables);
       
#ifdef __cplusplus
}
#endif

#endif


