NetBurner 3.5.7
PDF Version
snmp.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5
6/*
7This file provides null functions for the SNMP counters and functions
8to allow the system to compile without SNMP.
9*/
10
11#ifndef _NB_SNMP_H
12#define _NB_SNMP_H
13
14#ifdef ENABLE_SNMP
15#define SNMP
16
17struct SNMP_Request; /* Forward declaration */
18#include <snmp/asn1.h>
19#include <snmp/mibII_vars.h>
20#include <snmp/snmp_table.h>
21#include <config_obj.h>
22#include <servlets.h>
23
24#define SNMPCOUNTIF(x,i) {InterfaceBlock * pif=GetInterfaceBlock(i); if(pif) pif->x++; }
25#define SNMPCOUNT(x) (x++)
26#define SNMPDEC(x) (x--)
27#define SNMPADD(x,y) (x=x+y)
28
29
30/*****************************************************************************
31Start the snmp processor.
32 int priority = the UCOS task priority to run at
33Returns:
34 0=CMD_OK
35 -1=CMD_FAIL
36
37*****************************************************************************/
38[[deprecated]]int StartSnmpProcessor( int priority );
39
40
41class SnmpServlet: public servlet
42{
43protected:
44 int m_fd; //fd to hold UDP Socket
45 int m_port;
46
47//Servlet virtual functions
48 virtual int AddToSelectSet(fd_set &rd_set, fd_set &wr_set, fd_set &er_set);
49 virtual void ProcessSelectResult(fd_set &rd_set, fd_set &wr_set, fd_set &er_set);
50public:
55 SnmpServlet(int port=161);
56};
57
58
59extern const char *SYSDESC;
60extern const char *SYSOID;
61
62
63class snmp_config : public config_obj
64{
65public:
66 config_string SysContact{"", "SysContact"};
67 config_string SysName{"", "SysName"};
68 config_string SysLocation{"", "SysLocation"};
69 config_pass ReadCommunity{"public", "ReadCommunity"};
70 config_pass WriteCommunity{"public", "WriteCommunity"};
71 config_IPADDR4 trap_destination{"0.0.0.0", "TrapDest", "SNMP Trap destination"};
72 config_bool trap_enable_flags{false, "TrapEnable"};
73 ConfigEndMarker; // No new data members below this line
74 snmp_config() : config_obj(sys,"SNMP", "SNMP Configuration") {bDirty=false;}
75 bool bDirty;
76};
77
78extern snmp_config TheSnmpConfig;
79
80
81#define READ_COMMUNITY_MASK (0x0001)
82#define WRITE_COMMUNITY_MASK (0x0002)
83
84/* Overwrite this function pointer to do your own more complex community name processing */
85extern uint32_t ( *SnmpCommunityDecodeFunc )( const unsigned char *name );
86
87
88/* Trap functionality */
89
90class ASN; /* Forward definiton */
91typedef void ( PutTrapVarBindsFunc )( ASN *put_asn );
92
93
94/* Functions to send an SNMP trap */
95/*
96
97IPADDR dest the trap destination IP address, if passed in as NULL it uses the trap_destination value form the SysInfo structre
98const char* community_name, the commu nity name to pass in the trap.
99int generic_trap The Geric trap number;
100int specific_trap the specific trap number.
101PutTrapVarBindsFunc * pDataCallbackFunction a function pointer to call back to fill in any custom trap varbinds.
102See the examples\snmp program for an example of this.
103*/
104void SnmpBasicTrap( IPADDR dest,
105 const char *community_name,
106 int generic_trap,
107 int specific_trap );
108void SnmpTrapWithData( IPADDR dest,
109 const char *community_name,
110 int generic_trap,
111 int specific_trap,
112 PutTrapVarBindsFunc *pDataCallbackFunction );
113
114#else
115/*
116 This provides null functions for the SNMP counters and functions
117 to allow the system to compile without SNMP.
118*/
119
120#define SNMPCOUNTIF(x,y) ((void)0)
121#define SNMPCOUNT(x) ((void)0)
122#define SNMPDEC(x) ((void)0)
123#define SNMPADD(x, y) ((void)0)
124
125#endif
126#endif
127
128
129
130
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
Configuration Variable for IPADDR4 (IPv4) object types.
Definition config_obj.h:1498
Boolean Configuration Variable.
Definition config_obj.h:998
Base class used to create configuration objects.
Definition config_obj.h:321
Password string Configuration Variable.
Definition config_obj.h:1346
String Configuration Variable.
Definition config_obj.h:1128