net-snmp 5.7
types.h
00001 #ifndef NET_SNMP_TYPES_H
00002 #define NET_SNMP_TYPES_H
00003 
00008 #include <stdio.h>
00009 
00010 #ifndef NET_SNMP_CONFIG_H
00011 #error "Please include <net-snmp/net-snmp-config.h> before this file"
00012 #endif
00013 
00014                         /*
00015                          * For 'timeval' 
00016                          */
00017 #if TIME_WITH_SYS_TIME
00018 # include <sys/time.h>
00019 # include <time.h>
00020 #else
00021 # if HAVE_SYS_TIME_H
00022 #  include <sys/time.h>
00023 # else
00024 #  include <time.h>
00025 # endif
00026 #endif
00027 
00028 #ifdef HAVE_INTTYPES_H
00029 #include <inttypes.h>
00030 #endif
00031 #include <sys/types.h>
00032 #if ! defined(_WINSOCKAPI_) && ! defined(_WINSOCK_H)
00033 /*
00034  * If neither the Microsoft winsock header file nor the MinGW winsock header
00035  * file has already been included, do this now.
00036  */
00037 # if defined(HAVE_WINSOCK2_H) && defined(HAVE_WS2TCPIP_H)
00038 #  if !defined(HAVE_WIN32_PLATFORM_SDK) && _MSC_VER -0 <= 1200 \
00039     && _WIN32_WINNT -0 >= 0x0400
00040     /*
00041      * When using the MSVC 6 header files, including <winsock2.h> when
00042      * _WIN32_WINNT >= 0x0400 results in a compilation error. Hence include
00043      * <windows.h> instead, because <winsock2.h> is included from inside
00044      * <windows.h> when _WIN32_WINNT >= 0x0400. The SDK version of <windows.h>
00045      * does not include <winsock2.h> however.
00046      */
00047 #   include <windows.h>
00048 #  else
00049 #   include <winsock2.h>
00050 #  endif
00051 #   include <ws2tcpip.h>
00052 # elif defined(HAVE_WINSOCK_H)
00053 #  include <winsock.h>
00054 # endif
00055 #endif
00056 
00057 #if defined(WIN32) && !defined(cygwin)
00058 typedef HANDLE netsnmp_pid_t;
00059 #define NETSNMP_NO_SUCH_PROCESS INVALID_HANDLE_VALUE
00060 #else
00061 /*
00062  * Note: on POSIX-compliant systems, pid_t is defined in <sys/types.h>.
00063  * And if pid_t has not been defined in <sys/types.h>, AC_TYPE_PID_T ensures
00064  * that a pid_t definition is present in net-snmp-config.h.
00065  */
00066 typedef pid_t netsnmp_pid_t;
00067 #define NETSNMP_NO_SUCH_PROCESS -1
00068 #endif
00069 
00070 #if HAVE_NETINET_IN_H
00071 #include <netinet/in.h>         /* For definition of in_addr_t */
00072 #endif
00073 
00074 #include <net-snmp/library/oid.h>
00075 
00076 #ifdef __cplusplus
00077 extern "C" {
00078 #endif
00079 
00080 #ifndef HAVE_SOCKLEN_T
00081 typedef u_int socklen_t;
00082 #endif
00083 
00084 #ifndef HAVE_IN_ADDR_T
00085   /*
00086    * The type in_addr_t must match the type of sockaddr_in::sin_addr.
00087    * For MSVC and MinGW32, this is u_long.
00088    */
00089 typedef u_long in_addr_t;
00090 #endif
00091 
00092 #ifndef HAVE_SSIZE_T
00093 #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
00094 typedef int ssize_t;
00095 #else
00096 typedef long ssize_t;
00097 #endif
00098 #endif
00099 
00100 #ifndef HAVE_NFDS_T
00101 typedef unsigned long int nfds_t;
00102 #endif
00103 
00104     /*
00105      *  For the initial release, this will just refer to the
00106      *  relevant UCD header files.
00107      *    In due course, the types and structures relevant to the
00108      *  Net-SNMP API will be identified, and defined here directly.
00109      *
00110      *  But for the time being, this header file is primarily a placeholder,
00111      *  to allow application writers to adopt the new header file names.
00112      */
00113 
00114 typedef union {
00115    long           *integer;
00116    u_char         *string;
00117    oid            *objid;
00118    u_char         *bitstring;
00119    struct counter64 *counter64;
00120 #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
00121    float          *floatVal;
00122    double         *doubleVal;
00123    /*
00124     * t_union *unionVal; 
00125     */
00126 #endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
00127 } netsnmp_vardata;
00128 
00129 
00130 #define MAX_OID_LEN         128 /* max subid's in an oid */
00131 
00138 typedef struct variable_list {
00140    struct variable_list *next_variable;    
00142    oid            *name;   
00144    size_t          name_length;    
00146    u_char          type;   
00148     netsnmp_vardata val;
00150    size_t          val_len;
00152    oid             name_loc[MAX_OID_LEN];  
00154    u_char          buf[40];
00156    void           *data;
00158    void            (*dataFreeHook)(void *);    
00159    int             index;
00160 } netsnmp_variable_list;
00161 
00162 
00168 typedef struct snmp_pdu {
00169 
00170 #define non_repeaters   errstat
00171 #define max_repetitions errindex
00172 
00173     /*
00174      * Protocol-version independent fields
00175      */
00177     long            version;
00179     int             command;
00181     long            reqid;  
00183     long            msgid;
00185     long            transid;
00187     long            sessid;
00189     long            errstat;
00191     long            errindex;       
00193     u_long          time;   
00194     u_long          flags;
00195 
00196     int             securityModel;
00198     int             securityLevel;  
00199     int             msgParseModel;
00200 
00206     void           *transport_data;
00207     int             transport_data_length;
00208 
00213     const oid      *tDomain;
00214     size_t          tDomainLen;
00215 
00216     netsnmp_variable_list *variables;
00217 
00218 
00219     /*
00220      * SNMPv1 & SNMPv2c fields
00221      */
00223     u_char         *community;
00225     size_t          community_len;  
00226 
00227     /*
00228      * Trap information
00229      */
00231     oid            *enterprise;     
00232     size_t          enterprise_length;
00234     long            trap_type;
00236     long            specific_type;
00238     unsigned char   agent_addr[4];  
00239 
00240     /*
00241      *  SNMPv3 fields
00242      */
00244     u_char         *contextEngineID;
00246     size_t          contextEngineIDLen;     
00248     char           *contextName;
00250     size_t          contextNameLen;
00252     u_char         *securityEngineID;
00254     size_t          securityEngineIDLen;    
00256     char           *securityName;
00258     size_t          securityNameLen;        
00259     
00260     /*
00261      * AgentX fields
00262      *      (also uses SNMPv1 community field)
00263      */
00264     int             priority;
00265     int             range_subid;
00266     
00267     void           *securityStateRef;
00268 } netsnmp_pdu;
00269 
00270 
00273         struct snmp_session;
00274 typedef struct snmp_session netsnmp_session;
00275 
00276 #define USM_AUTH_KU_LEN     32
00277 #define USM_PRIV_KU_LEN     32
00278 
00279 typedef int        (*snmp_callback) (int, netsnmp_session *, int,
00280                                           netsnmp_pdu *, void *);
00281 typedef int     (*netsnmp_callback) (int, netsnmp_session *, int,
00282                                           netsnmp_pdu *, void *);
00283 
00284 struct netsnmp_container_s;
00285 
00289 struct snmp_session {
00290     /*
00291      * Protocol-version independent fields
00292      */
00294     long            version;
00296     int             retries;
00298     long            timeout;        
00299     u_long          flags;
00300     struct snmp_session *subsession;
00301     struct snmp_session *next;
00302 
00304     char           *peername;
00306     u_short         remote_port;
00308     char           *localname;
00310     u_short         local_port;     
00314     u_char         *(*authenticator) (u_char *, size_t *, u_char *, size_t);
00316     netsnmp_callback callback;      
00320     void           *callback_magic;
00322     int             s_errno;
00324     int             s_snmp_errno;   
00326     long            sessid; 
00327 
00328     /*
00329      * SNMPv1 & SNMPv2c fields
00330      */
00332     u_char         *community;
00334     size_t          community_len;  
00336     size_t          rcvMsgMaxSize;
00338     size_t          sndMsgMaxSize;  
00339 
00340     /*
00341      * SNMPv3 fields
00342      */
00344     u_char          isAuthoritative;
00346     u_char         *contextEngineID;
00348     size_t          contextEngineIDLen;     
00350     u_int           engineBoots;
00352     u_int           engineTime;
00354     char           *contextName;
00356     size_t          contextNameLen;
00358     u_char         *securityEngineID;
00360     size_t          securityEngineIDLen;    
00362     char           *securityName;
00364     size_t          securityNameLen;
00365 
00367     oid            *securityAuthProto;
00369     size_t          securityAuthProtoLen;
00371     u_char          securityAuthKey[USM_AUTH_KU_LEN];       
00373     size_t          securityAuthKeyLen;
00375     u_char          *securityAuthLocalKey;       
00377     size_t          securityAuthLocalKeyLen;       
00378 
00380     oid            *securityPrivProto;
00382     size_t          securityPrivProtoLen;
00384     u_char          securityPrivKey[USM_PRIV_KU_LEN];       
00386     size_t          securityPrivKeyLen;
00388     u_char          *securityPrivLocalKey;       
00390     size_t          securityPrivLocalKeyLen;       
00391 
00393     int             securityModel;
00395     int             securityLevel;  
00397     char           *paramName;
00398 
00402     void           *securityInfo;
00403 
00407    struct netsnmp_container_s *transport_configuration;
00408 
00415     void           *myvoid;
00416 };
00417 
00418 
00419 #include <net-snmp/library/types.h>
00420 #include <net-snmp/definitions.h>
00421 #include <net-snmp/library/snmp_api.h>
00422 
00423 #ifdef __cplusplus
00424 }
00425 #endif
00426 
00427 #endif                          /* NET_SNMP_TYPES_H */