| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /********************************************************************* |
| 2 | * |
||
| 3 | * SNMP Defs for Microchip TCP/IP Stack |
||
| 4 | * |
||
| 5 | ********************************************************************* |
||
| 6 | * FileName: SNMP.h |
||
| 7 | * Dependencies: StackTsk.h |
||
| 8 | * UDP.h |
||
| 9 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 10 | * Compiler: Microchip C32 v1.05 or higher |
||
| 11 | * Microchip C30 v3.12 or higher |
||
| 12 | * Microchip C18 v3.30 or higher |
||
| 13 | * HI-TECH PICC-18 PRO 9.63PL2 or higher |
||
| 14 | * Company: Microchip Technology, Inc. |
||
| 15 | * |
||
| 16 | * Software License Agreement |
||
| 17 | * |
||
| 18 | * Copyright (C) 2002-2009 Microchip Technology Inc. All rights |
||
| 19 | * reserved. |
||
| 20 | * |
||
| 21 | * Microchip licenses to you the right to use, modify, copy, and |
||
| 22 | * distribute: |
||
| 23 | * (i) the Software when embedded on a Microchip microcontroller or |
||
| 24 | * digital signal controller product ("Device") which is |
||
| 25 | * integrated into Licensee's product; or |
||
| 26 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 27 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
| 28 | * used in conjunction with a Microchip ethernet controller for |
||
| 29 | * the sole purpose of interfacing with the ethernet controller. |
||
| 30 | * |
||
| 31 | * You should refer to the license agreement accompanying this |
||
| 32 | * Software for additional information regarding your rights and |
||
| 33 | * obligations. |
||
| 34 | * |
||
| 35 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
| 36 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
| 37 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
| 38 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
| 39 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
| 40 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
| 41 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
| 42 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
| 43 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
| 44 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
| 45 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
| 46 | * |
||
| 47 | * Author Date Comment |
||
| 48 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 49 | * Nilesh Rajbharti 1/9/03 Original (Rev 1.0) |
||
| 50 | * Amit Shirbhate 09/24/08 SNMPv2c Support added. |
||
| 51 | ********************************************************************/ |
||
| 52 | |||
| 53 | #ifndef SNMP_H |
||
| 54 | #define SNMP_H |
||
| 55 | |||
| 56 | |||
| 57 | /**************************************************************************** |
||
| 58 | Section: |
||
| 59 | Macros and Definitions |
||
| 60 | ***************************************************************************/ |
||
| 61 | |||
| 62 | #define DATA_TYPE_TABLE_SIZE (sizeof(dataTypeTable)/sizeof(dataTypeTable[0])) |
||
| 63 | |||
| 64 | |||
| 65 | //This is the file that contains SNMP BIB file. |
||
| 66 | //File name must contain all upper case letter and must match |
||
| 67 | //with what was included in MPFS image. |
||
| 68 | #if defined(STACK_USE_MPFS) |
||
| 69 | #define SNMP_BIB_FILE_NAME "SNMP.BIB" |
||
| 70 | #else |
||
| 71 | #define SNMP_BIB_FILE_NAME "snmp.bib" |
||
| 72 | #endif |
||
| 73 | |||
| 74 | |||
| 75 | //Change this to match your OID string length. |
||
| 76 | #define OID_MAX_LEN (15) |
||
| 77 | |||
| 78 | #define SNMP_START_OF_VAR (0) |
||
| 79 | #define SNMP_END_OF_VAR (0xff) |
||
| 80 | #define SNMP_INDEX_INVALID (0xff) |
||
| 81 | |||
| 82 | |||
| 83 | //Trap information. |
||
| 84 | //This table maintains list of intereseted receivers |
||
| 85 | //who should receive notifications when some interesting |
||
| 86 | //event occurs. |
||
| 87 | #define TRAP_TABLE_SIZE (2) |
||
| 88 | #define TRAP_COMMUNITY_MAX_LEN (8) |
||
| 89 | |||
| 90 | |||
| 91 | //This is the SNMP OID variable id. |
||
| 92 | //This id is assigned via MIB file. Only dynamic and AgentID |
||
| 93 | //variables can contian ID. MIB2BIB utility enforces this |
||
| 94 | //rules when BIB was generated. |
||
| 95 | typedef BYTE SNMP_ID; |
||
| 96 | typedef BYTE SNMP_INDEX; |
||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | /**************************************************************************** |
||
| 101 | Section: |
||
| 102 | Data Structures and Enumerations |
||
| 103 | ***************************************************************************/ |
||
| 104 | typedef struct |
||
| 105 | { |
||
| 106 | BYTE Size; |
||
| 107 | struct |
||
| 108 | { |
||
| 109 | BYTE communityLen; //Community name length |
||
| 110 | char community[TRAP_COMMUNITY_MAX_LEN]; //Community name array |
||
| 111 | IP_ADDR IPAddress; //IP address to which trap to be sent |
||
| 112 | struct |
||
| 113 | { |
||
| 114 | unsigned int bEnabled : 1; //Trap enabled flag |
||
| 115 | } Flags; |
||
| 116 | } table[TRAP_TABLE_SIZE]; |
||
| 117 | } TRAP_INFO; |
||
| 118 | |||
| 119 | typedef union |
||
| 120 | { |
||
| 121 | DWORD dword; //double word value |
||
| 122 | WORD word; //word value |
||
| 123 | BYTE byte; //byte value |
||
| 124 | BYTE v[sizeof(DWORD)]; //byte array |
||
| 125 | } SNMP_VAL; |
||
| 126 | |||
| 127 | typedef enum |
||
| 128 | { |
||
| 129 | READ_COMMUNITY=1, //Read only community |
||
| 130 | WRITE_COMMUNITY=2, //Read write community |
||
| 131 | INVALID_COMMUNITY=3 //Community invalid |
||
| 132 | }COMMUNITY_TYPE; |
||
| 133 | |||
| 134 | |||
| 135 | //This is the list of SNMP action a remote NMS can perform. |
||
| 136 | //This inforamtion is passed to application via |
||
| 137 | //callback SNMPValidateCommunity(). |
||
| 138 | //Application should validate the action for given community |
||
| 139 | //string. |
||
| 140 | typedef enum |
||
| 141 | { |
||
| 142 | SNMP_GET = 0xa0, //Snmp GET identifier |
||
| 143 | SNMP_GET_NEXT = 0xa1, //Snmp GET_NEXT identifier |
||
| 144 | SNMP_GET_RESPONSE = 0xa2, //Snmp GET_RESPONSE identifier |
||
| 145 | SNMP_SET = 0xa3, //Snmp SET identifier |
||
| 146 | SNMP_TRAP = 0xa4, //Snmp TRAP identifier |
||
| 147 | SNMP_V2C_GET_BULK = 0xa5, //Snmp GET_BULK identifier |
||
| 148 | SNMP_V2_TRAP = 0xa7, //Snmp v2 Trap Identifier |
||
| 149 | SNMP_ACTION_UNKNOWN = 0 //Snmp requested action unknown |
||
| 150 | } SNMP_ACTION; |
||
| 151 | |||
| 152 | typedef enum |
||
| 153 | { |
||
| 154 | COLD_START =0x0, |
||
| 155 | WARM_START =0x1, |
||
| 156 | LINK_DOWN =0x2, |
||
| 157 | LINK_UP =0x3, |
||
| 158 | AUTH_FAILURE =0x4, |
||
| 159 | EGP_NEBOR_LOSS =0x5, |
||
| 160 | ENTERPRISE_SPECIFIC =0x6 |
||
| 161 | |||
| 162 | } GENERIC_TRAP_NOTIFICATION_TYPE; |
||
| 163 | |||
| 164 | |||
| 165 | typedef enum |
||
| 166 | { |
||
| 167 | VENDOR_TRAP_DEFAULT =0x0, |
||
| 168 | BUTTON_PUSH_EVENT =0x1, |
||
| 169 | POT_READING_MORE_512 =0x2 |
||
| 170 | } VENDOR_SPECIFIC_TRAP_NOTIFICATION_TYPE; |
||
| 171 | |||
| 172 | |||
| 173 | /**************************************************************************** |
||
| 174 | Section: |
||
| 175 | Global Variables |
||
| 176 | ***************************************************************************/ |
||
| 177 | extern BYTE gSendTrapFlag;//Global flag to send Trap |
||
| 178 | extern BYTE gGenericTrapNotification;//Global flag for Generic trap notification |
||
| 179 | extern BYTE gSpecificTrapNotification;//Global flag for vendor specific trap notification |
||
| 180 | extern BYTE gOIDCorrespondingSnmpMibID;//Gloabal var to store SNMP ID of var for OID received in SNMP request. |
||
| 181 | extern BYTE gSetTrapSendFlag; |
||
| 182 | |||
| 183 | |||
| 184 | /**************************************************************************** |
||
| 185 | Section: |
||
| 186 | Function Prototypes |
||
| 187 | ***************************************************************************/ |
||
| 188 | void SNMPInit(void); |
||
| 189 | BOOL SNMPTask(void); |
||
| 190 | void SNMPSendTrap(void); |
||
| 191 | BYTE SNMPValidateCommunity(BYTE* community); |
||
| 192 | BOOL SNMPNotify(SNMP_ID var, SNMP_VAL val, SNMP_INDEX index); |
||
| 193 | BOOL SNMPSetVar(SNMP_ID var, SNMP_INDEX index,BYTE ref, SNMP_VAL val); |
||
| 194 | BOOL SNMPGetVar(SNMP_ID var, SNMP_INDEX index,BYTE* ref, SNMP_VAL* val); |
||
| 195 | BOOL SNMPIsNotifyReady(IP_ADDR* remoteHost); |
||
| 196 | void SNMPNotifyPrepare(IP_ADDR* remoteHost, char* community, BYTE communityLen, SNMP_ID agentIDVar, BYTE notificationCode, DWORD timestamp); |
||
| 197 | BOOL SNMPGetNextIndex(SNMP_ID var, SNMP_INDEX* index); |
||
| 198 | BOOL SNMPIsValidSetLen(SNMP_ID var, BYTE len); |
||
| 199 | |||
| 200 | #endif |
Powered by WebSVN v2.8.3