/*
 * Copyright Notice:
 * Copyright Treck Incorporated  1997 - 2004
 * Copyright Elmic Systems Japan 1997 - 2004
 * No portions or the complete contents of this file may be copied or
 * distributed in any form (including but not limited to printed or electronic
 * forms) without the expressed written consent of Treck Incorporated OR
 * Elmic Systems.  Copyright laws and International Treaties protect the
 * contents of this file.  Unauthorized use is prohibited.
 * All rights reserved.
 *
 * Description:  Global SNMP agent structure
 * Filename:     trregstr.h
 * Author:       Leonard
 * Date Created: 12/04/01
 * $Source: /cvs_tick/treck_stack/snmpd/trregstr.h,v $
 *
 * Modification History
 * $Revision: 1.9.36.1 $
 * $Date: 2006/11/28 15:00:56 $
 * $Author: jrakhval $
 * $ProjectName: /home/mks/proj/snmpdprj $
 * $ProjectRevision: 4.0.2.53 $
 */

/***********************************************************
        Copyright 1988 by Carnegie Mellon University
 
                      All Rights Reserved
 
Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in 
supporting documentation, and that the name of CMU not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  
 
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/


#ifndef _TRREGSTR_H_
#define _TRREGSTR_H_

#ifndef _TRCONSTS_H_
#include "trconsts.h"
#endif /* _TRCONSTS_H_ */

#ifdef __cplusplus
extern "C" {
#endif

#define TM_SNMP_MAX_NUM_TRAP_SINKS          5
#define TM_SNMP_MAX_NUM_READ_COMMUNITIES    5
#define TM_SNMP_MAX_NUM_WRITE_COMMUNITIES   5
#define TM_SNMP_MAX_COMMUNITY_LEN           24

#define TM_DEFAULT_ENTERPRISE_NUMBER        ((oid)29999)
#define TM_DEFAULT_ENTERPRISE_LENGTH        8

#define TM_SNMP_RECORD_LOCKED               -7

#define TM_SNMP_COMMUNITY_LOCK_DELAY        5       /*msec */

#define NUM_SYSORENTRIES	5

#define TM_SNMP_MAX_NUM_REPEATER    10

#ifndef TM_TRECK_OS
#define TM_SNMP_LOG_BUFFER_LEN              4096
#endif /* !TM_TRECK_OS */

/* Flags for ttSnmpd.coldStartTrapFlags */
#define TM_SNMP_CLDSTRT_TRAP_NO_DFLT 0x01 /* set means dont use dflts        */
#define TM_SNMP_CLDSTRT_TRAP_NO_V1   0x02 /* set means dont send the v1 one  */
#define TM_SNMP_CLDSTRT_TRAP_NO_V2C  0x04 /* set means dont send the v2c one */
#define TM_SNMP_CLDSTRT_TRAP_NO_V3   0x08 /* set means dont send the v3 one  */
#define TM_SNMP_CLDSTRT_TRAP_NONE    0x0F
#define TM_SNMP_CLDSTRT_TRAP_ALL     0x01

#ifdef NET_OS_SPECIFIC
#define TM_SNMP_TRAP_NO_V1           TM_SNMP_CLDSTRT_TRAP_NO_V1
#define TM_SNMP_TRAP_NO_V2C          TM_SNMP_CLDSTRT_TRAP_NO_V2C
#endif

typedef int (TM_CODE_FAR *ttSnmpWriteMethodPtr)(
    int, tt8BitPtr , tt8Bit, int, ttOidPtr, int);
typedef int (TM_CODE_FAR *ttSnmpCreateMethodPtr)(ttOidPtr, int, oid);
typedef int (TM_CODE_FAR *ttSnmpDeleteMethodPtr)(ttOidPtr, int);

typedef struct tsSnmpLockRecord
{
    int snmpCommunityLock;
    int snmpTrapLock;
} ttSnmpLockRecord;
typedef ttSnmpLockRecord     TM_FAR * ttSnmpLockRecordPtr;
typedef const ttSnmpLockRecord TM_FAR * ttConstSnmpLockRecordPtr;
    
typedef struct tsSnmpCache
{
    tt32Bit   snmpIfcIndex;
    ttVoidPtr snmpIfcDevPtr;
} ttSnmpCache;
typedef ttSnmpCache     TM_FAR * ttSnmpCachePtr;
typedef const ttSnmpCache TM_FAR * ttConstSnmpCachePtr;
    
union tuSnmpGlobalReturn
{
    tt8Bit  snmpBufReturn[256];
    tt32Bit snmpLongReturn;
    tt64Bit snmpLongLongReturn;
};
    
#ifdef TM_SNMP_AGENT_V3
typedef struct tsSnmpSecurityInit
{
    tt32Bit                 snmpSaltInteger;
    struct tsSnmpEngineData snmpEngine;
} ttSnmpSecurityInit;
typedef ttSnmpSecurityInit     TM_FAR * ttSnmpSecurityInitPtr;
typedef const ttSnmpSecurityInit TM_FAR * ttConstSnmpSecurityInitPtr;

typedef struct tsSnmpTablesInit
{
    ttSnmpUsmUserTablePtr               snmpUsmUserEntryStart;
    ttSnmpVacmContextTablePtr           snmpVacmContextEntryStart;
    ttSnmpVacmSec2GroupTablePtr         snmpVacmSec2GroupEntryStart;
    ttSnmpVacmAccessTablePtr            snmpVacmAccessEntryStart;
    ttSnmpVacmViewTreeFamilyTablePtr    snmpVacmViewTreeFamilyEntryStart;
    ttSnmpCommunityTablePtr             snmpCommunityTableEntryStart; 
    ttSnmpTargetAddrTableEntryPtr       snmpTargetAddrTableEntryStart;
    ttSnmpTargetParamsTableEntryPtr     snmpTargetParamsTableEntryStart;
    ttSnmpNotifyTableEntryPtr           snmpNotifyTableEntryStart;
    ttSnmpNotifyFilterProfileTableEntryPtr
        snmpNotifyFilterProfileTableEntryStart;
    ttSnmpNotifyFilterTableEntryPtr     snmpNotifyFilterTableEntryStart;
} ttSnmpTablesInit;
typedef ttSnmpTablesInit     TM_FAR * ttSnmpTablesInitPtr;
typedef const ttSnmpTablesInit TM_FAR * ttConstSnmpTablesInitPtr;

typedef struct tsSnmpTablesV3
{
    ttSnmpUsmStats              snmpUsmStats;
    ttSnmpMpdStats              snmpMpdStats;
    ttSnmpSpinLock              snmpSpinLocks;
    ttSnmpSetSerialNo           snmpSetSerialNo;
    ttSnmpTargetStats           snmpTargetStats;
} ttSnmpTablesV3;
typedef ttSnmpTablesV3     TM_FAR * ttSnmpTablesV3Ptr;
typedef const ttSnmpTablesV3 TM_FAR * ttConstSnmpTablesV3Ptr;
#endif /* SNMP_AGENT_V3 */
    
#define TM_SNMP_ROUND_MAX_COMMUNITY_LEN     (((TM_SNMP_MAX_COMMUNITY_LEN + 3) / 4) * 4)

typedef struct tsSnmpd
{
    ttSnmpSetHandlingPtr        snmpSetListStart;
    ttSnmpWriteMethodPtr        snmpWriteMethod;
    ttSnmpCreateMethodPtr       snmpCreateMethod;
    ttSnmpDeleteMethodPtr       snmpDeleteMethod;

#ifdef TM_SNMP_AGENT_V2C
    ttSnmpRepeaterPtr           snmpRepeaterList;
#endif  /* TM_SNMP_AGENT_V2C */

#ifndef TM_TRECK_OS
    ttCharPtr                   snmpLogBuffer;
#endif /* !TM_TRECK_OS */
    ttNgSnmpTrapParmsPtr        snmpTrap;
    ttMibSysorPtr               my_mib_sysor;
    tt32Bit                     snmpStartTime;
	char                        coldStartTrapComName[
                                             TM_SNMP_ROUND_MAX_COMMUNITY_LEN];
#ifndef TM_SNMP_AGENT_V3
    char                        snmpReadCommunities[
                                    TM_SNMP_MAX_NUM_READ_COMMUNITIES][
                                        TM_SNMP_ROUND_MAX_COMMUNITY_LEN];
    char                        snmpWriteCommunities[
                                    TM_SNMP_MAX_NUM_WRITE_COMMUNITIES][
                                             TM_SNMP_ROUND_MAX_COMMUNITY_LEN];
#endif /* TM_SNMP_AGENT_V3 */

#ifdef TM_LOCK_NEEDED
/* snmpdStopLockEntry is used to synchronize between tfSnmpdStop and
   tfSnmpdMain. Without this lock, tfSnmpdMain could call tfSnmpFreeGlobals
   before tfSnmpdStop has completed processing. */
    ttLockEntry                 snmpdStopLockEntry;
#endif /* TM_LOCK_NEEDED */
    ttSnmpLockRecord            snmpRecordLock;
    ttSnmpCache                 snmpCache;
    union tuSnmpGlobalReturn    snmpGlobalReturnU;
    ttMibSnmp                   mibSnmp;
    ttMibSystem                 mibSystem;
#ifdef TM_SNMP_AGENT_V3
    ttSnmpSecurityInit          snmpInitSecurity;
    ttSnmpTablesInit            snmpInitTables;
    ttSnmpTablesV3              snmpV3Tables;
#endif /* SNMP_AGENT_V3 */
	struct ttSockaddrStorage    coldStartTrapDest;
#ifndef TM_TRECK_OS
    int                         snmpLogBufferLength;
    int                         snmpLogMsgEnd;
#endif /* !TM_TRECK_OS */
    int                         snmpMib2Status;
    int                         snmpInTotalReqVars;
    int                         snmpSocket;
    ttUser16Bit                 snmpPort;
#define TM_SNMP_STATE_AGENT_RUNNING     (tt16Bit)0x0001
#define TM_SNMP_STATE_BLOCKING_ON       (tt16Bit)0x0002
#define TM_SNMP_STATE_AGENT_STOPPING    (tt16Bit)0x0004
/* LSB set to 1 indicates agent is running */
    tt16Bit                     snmpState;
	tt16Bit                     coldStartTrapFlags;
} ttSnmpd;
typedef ttSnmpd     TM_FAR * ttSnmpdPtr;
typedef const ttSnmpd TM_FAR * ttConstSnmpdPtr;

#ifdef __cplusplus
}
#endif

#endif /* #ifndef _TRREGSTR_H_ */

/* Processed by Treck Shipping Tool v2.48 
 * 2005/11/16 15:13:15      For: Digi
 * File Name: trregstr.h    File Revision: 4.0.2.7 
 * Project Name: snmpdprj   Project Release: 4.0.2.53
 * Input checksum: 52944    Output checksum: 18210
 */
