Atsushi Hattori
/
20210627_Logger
hattori&ide
EthernetNetIf/LPC1768/lwip/include/lwip/snmp_msg.h@0:f77369cabd75, 18 months ago (annotated)
- Committer:
- hattori_atsushi
- Date:
- Sun Dec 18 08:16:01 2022 +0000
- Revision:
- 0:f77369cabd75
hattori
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hattori_atsushi | 0:f77369cabd75 | 1 | /** |
hattori_atsushi | 0:f77369cabd75 | 2 | * @file |
hattori_atsushi | 0:f77369cabd75 | 3 | * SNMP Agent message handling structures. |
hattori_atsushi | 0:f77369cabd75 | 4 | */ |
hattori_atsushi | 0:f77369cabd75 | 5 | |
hattori_atsushi | 0:f77369cabd75 | 6 | /* |
hattori_atsushi | 0:f77369cabd75 | 7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. |
hattori_atsushi | 0:f77369cabd75 | 8 | * All rights reserved. |
hattori_atsushi | 0:f77369cabd75 | 9 | * |
hattori_atsushi | 0:f77369cabd75 | 10 | * Redistribution and use in source and binary forms, with or without modification, |
hattori_atsushi | 0:f77369cabd75 | 11 | * are permitted provided that the following conditions are met: |
hattori_atsushi | 0:f77369cabd75 | 12 | * |
hattori_atsushi | 0:f77369cabd75 | 13 | * 1. Redistributions of source code must retain the above copyright notice, |
hattori_atsushi | 0:f77369cabd75 | 14 | * this list of conditions and the following disclaimer. |
hattori_atsushi | 0:f77369cabd75 | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
hattori_atsushi | 0:f77369cabd75 | 16 | * this list of conditions and the following disclaimer in the documentation |
hattori_atsushi | 0:f77369cabd75 | 17 | * and/or other materials provided with the distribution. |
hattori_atsushi | 0:f77369cabd75 | 18 | * 3. The name of the author may not be used to endorse or promote products |
hattori_atsushi | 0:f77369cabd75 | 19 | * derived from this software without specific prior written permission. |
hattori_atsushi | 0:f77369cabd75 | 20 | * |
hattori_atsushi | 0:f77369cabd75 | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
hattori_atsushi | 0:f77369cabd75 | 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
hattori_atsushi | 0:f77369cabd75 | 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
hattori_atsushi | 0:f77369cabd75 | 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
hattori_atsushi | 0:f77369cabd75 | 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
hattori_atsushi | 0:f77369cabd75 | 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
hattori_atsushi | 0:f77369cabd75 | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
hattori_atsushi | 0:f77369cabd75 | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
hattori_atsushi | 0:f77369cabd75 | 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
hattori_atsushi | 0:f77369cabd75 | 30 | * OF SUCH DAMAGE. |
hattori_atsushi | 0:f77369cabd75 | 31 | * |
hattori_atsushi | 0:f77369cabd75 | 32 | * Author: Christiaan Simons <christiaan.simons@axon.tv> |
hattori_atsushi | 0:f77369cabd75 | 33 | */ |
hattori_atsushi | 0:f77369cabd75 | 34 | |
hattori_atsushi | 0:f77369cabd75 | 35 | #ifndef __LWIP_SNMP_MSG_H__ |
hattori_atsushi | 0:f77369cabd75 | 36 | #define __LWIP_SNMP_MSG_H__ |
hattori_atsushi | 0:f77369cabd75 | 37 | |
hattori_atsushi | 0:f77369cabd75 | 38 | #include "lwip/opt.h" |
hattori_atsushi | 0:f77369cabd75 | 39 | #include "lwip/snmp.h" |
hattori_atsushi | 0:f77369cabd75 | 40 | #include "lwip/snmp_structs.h" |
hattori_atsushi | 0:f77369cabd75 | 41 | #include "lwip/ip_addr.h" |
hattori_atsushi | 0:f77369cabd75 | 42 | #include "lwip/err.h" |
hattori_atsushi | 0:f77369cabd75 | 43 | |
hattori_atsushi | 0:f77369cabd75 | 44 | #if LWIP_SNMP |
hattori_atsushi | 0:f77369cabd75 | 45 | |
hattori_atsushi | 0:f77369cabd75 | 46 | #if SNMP_PRIVATE_MIB |
hattori_atsushi | 0:f77369cabd75 | 47 | /* When using a private MIB, you have to create a file 'private_mib.h' that contains |
hattori_atsushi | 0:f77369cabd75 | 48 | * a 'struct mib_array_node mib_private' which contains your MIB. */ |
hattori_atsushi | 0:f77369cabd75 | 49 | #include "private_mib.h" |
hattori_atsushi | 0:f77369cabd75 | 50 | #endif |
hattori_atsushi | 0:f77369cabd75 | 51 | |
hattori_atsushi | 0:f77369cabd75 | 52 | #ifdef __cplusplus |
hattori_atsushi | 0:f77369cabd75 | 53 | extern "C" { |
hattori_atsushi | 0:f77369cabd75 | 54 | #endif |
hattori_atsushi | 0:f77369cabd75 | 55 | |
hattori_atsushi | 0:f77369cabd75 | 56 | /* The listen port of the SNMP agent. Clients have to make their requests to |
hattori_atsushi | 0:f77369cabd75 | 57 | this port. Most standard clients won't work if you change this! */ |
hattori_atsushi | 0:f77369cabd75 | 58 | #ifndef SNMP_IN_PORT |
hattori_atsushi | 0:f77369cabd75 | 59 | #define SNMP_IN_PORT 161 |
hattori_atsushi | 0:f77369cabd75 | 60 | #endif |
hattori_atsushi | 0:f77369cabd75 | 61 | /* The remote port the SNMP agent sends traps to. Most standard trap sinks won't |
hattori_atsushi | 0:f77369cabd75 | 62 | work if you change this! */ |
hattori_atsushi | 0:f77369cabd75 | 63 | #ifndef SNMP_TRAP_PORT |
hattori_atsushi | 0:f77369cabd75 | 64 | #define SNMP_TRAP_PORT 162 |
hattori_atsushi | 0:f77369cabd75 | 65 | #endif |
hattori_atsushi | 0:f77369cabd75 | 66 | |
hattori_atsushi | 0:f77369cabd75 | 67 | #define SNMP_ES_NOERROR 0 |
hattori_atsushi | 0:f77369cabd75 | 68 | #define SNMP_ES_TOOBIG 1 |
hattori_atsushi | 0:f77369cabd75 | 69 | #define SNMP_ES_NOSUCHNAME 2 |
hattori_atsushi | 0:f77369cabd75 | 70 | #define SNMP_ES_BADVALUE 3 |
hattori_atsushi | 0:f77369cabd75 | 71 | #define SNMP_ES_READONLY 4 |
hattori_atsushi | 0:f77369cabd75 | 72 | #define SNMP_ES_GENERROR 5 |
hattori_atsushi | 0:f77369cabd75 | 73 | |
hattori_atsushi | 0:f77369cabd75 | 74 | #define SNMP_GENTRAP_COLDSTART 0 |
hattori_atsushi | 0:f77369cabd75 | 75 | #define SNMP_GENTRAP_WARMSTART 1 |
hattori_atsushi | 0:f77369cabd75 | 76 | #define SNMP_GENTRAP_AUTHFAIL 4 |
hattori_atsushi | 0:f77369cabd75 | 77 | #define SNMP_GENTRAP_ENTERPRISESPC 6 |
hattori_atsushi | 0:f77369cabd75 | 78 | |
hattori_atsushi | 0:f77369cabd75 | 79 | struct snmp_varbind |
hattori_atsushi | 0:f77369cabd75 | 80 | { |
hattori_atsushi | 0:f77369cabd75 | 81 | /* next pointer, NULL for last in list */ |
hattori_atsushi | 0:f77369cabd75 | 82 | struct snmp_varbind *next; |
hattori_atsushi | 0:f77369cabd75 | 83 | /* previous pointer, NULL for first in list */ |
hattori_atsushi | 0:f77369cabd75 | 84 | struct snmp_varbind *prev; |
hattori_atsushi | 0:f77369cabd75 | 85 | |
hattori_atsushi | 0:f77369cabd75 | 86 | /* object identifier length (in s32_t) */ |
hattori_atsushi | 0:f77369cabd75 | 87 | u8_t ident_len; |
hattori_atsushi | 0:f77369cabd75 | 88 | /* object identifier array */ |
hattori_atsushi | 0:f77369cabd75 | 89 | s32_t *ident; |
hattori_atsushi | 0:f77369cabd75 | 90 | |
hattori_atsushi | 0:f77369cabd75 | 91 | /* object value ASN1 type */ |
hattori_atsushi | 0:f77369cabd75 | 92 | u8_t value_type; |
hattori_atsushi | 0:f77369cabd75 | 93 | /* object value length (in u8_t) */ |
hattori_atsushi | 0:f77369cabd75 | 94 | u8_t value_len; |
hattori_atsushi | 0:f77369cabd75 | 95 | /* object value */ |
hattori_atsushi | 0:f77369cabd75 | 96 | void *value; |
hattori_atsushi | 0:f77369cabd75 | 97 | |
hattori_atsushi | 0:f77369cabd75 | 98 | /* encoding varbind seq length length */ |
hattori_atsushi | 0:f77369cabd75 | 99 | u8_t seqlenlen; |
hattori_atsushi | 0:f77369cabd75 | 100 | /* encoding object identifier length length */ |
hattori_atsushi | 0:f77369cabd75 | 101 | u8_t olenlen; |
hattori_atsushi | 0:f77369cabd75 | 102 | /* encoding object value length length */ |
hattori_atsushi | 0:f77369cabd75 | 103 | u8_t vlenlen; |
hattori_atsushi | 0:f77369cabd75 | 104 | /* encoding varbind seq length */ |
hattori_atsushi | 0:f77369cabd75 | 105 | u16_t seqlen; |
hattori_atsushi | 0:f77369cabd75 | 106 | /* encoding object identifier length */ |
hattori_atsushi | 0:f77369cabd75 | 107 | u16_t olen; |
hattori_atsushi | 0:f77369cabd75 | 108 | /* encoding object value length */ |
hattori_atsushi | 0:f77369cabd75 | 109 | u16_t vlen; |
hattori_atsushi | 0:f77369cabd75 | 110 | }; |
hattori_atsushi | 0:f77369cabd75 | 111 | |
hattori_atsushi | 0:f77369cabd75 | 112 | struct snmp_varbind_root |
hattori_atsushi | 0:f77369cabd75 | 113 | { |
hattori_atsushi | 0:f77369cabd75 | 114 | struct snmp_varbind *head; |
hattori_atsushi | 0:f77369cabd75 | 115 | struct snmp_varbind *tail; |
hattori_atsushi | 0:f77369cabd75 | 116 | /* number of variable bindings in list */ |
hattori_atsushi | 0:f77369cabd75 | 117 | u8_t count; |
hattori_atsushi | 0:f77369cabd75 | 118 | /* encoding varbind-list seq length length */ |
hattori_atsushi | 0:f77369cabd75 | 119 | u8_t seqlenlen; |
hattori_atsushi | 0:f77369cabd75 | 120 | /* encoding varbind-list seq length */ |
hattori_atsushi | 0:f77369cabd75 | 121 | u16_t seqlen; |
hattori_atsushi | 0:f77369cabd75 | 122 | }; |
hattori_atsushi | 0:f77369cabd75 | 123 | |
hattori_atsushi | 0:f77369cabd75 | 124 | /** output response message header length fields */ |
hattori_atsushi | 0:f77369cabd75 | 125 | struct snmp_resp_header_lengths |
hattori_atsushi | 0:f77369cabd75 | 126 | { |
hattori_atsushi | 0:f77369cabd75 | 127 | /* encoding error-index length length */ |
hattori_atsushi | 0:f77369cabd75 | 128 | u8_t erridxlenlen; |
hattori_atsushi | 0:f77369cabd75 | 129 | /* encoding error-status length length */ |
hattori_atsushi | 0:f77369cabd75 | 130 | u8_t errstatlenlen; |
hattori_atsushi | 0:f77369cabd75 | 131 | /* encoding request id length length */ |
hattori_atsushi | 0:f77369cabd75 | 132 | u8_t ridlenlen; |
hattori_atsushi | 0:f77369cabd75 | 133 | /* encoding pdu length length */ |
hattori_atsushi | 0:f77369cabd75 | 134 | u8_t pdulenlen; |
hattori_atsushi | 0:f77369cabd75 | 135 | /* encoding community length length */ |
hattori_atsushi | 0:f77369cabd75 | 136 | u8_t comlenlen; |
hattori_atsushi | 0:f77369cabd75 | 137 | /* encoding version length length */ |
hattori_atsushi | 0:f77369cabd75 | 138 | u8_t verlenlen; |
hattori_atsushi | 0:f77369cabd75 | 139 | /* encoding sequence length length */ |
hattori_atsushi | 0:f77369cabd75 | 140 | u8_t seqlenlen; |
hattori_atsushi | 0:f77369cabd75 | 141 | |
hattori_atsushi | 0:f77369cabd75 | 142 | /* encoding error-index length */ |
hattori_atsushi | 0:f77369cabd75 | 143 | u16_t erridxlen; |
hattori_atsushi | 0:f77369cabd75 | 144 | /* encoding error-status length */ |
hattori_atsushi | 0:f77369cabd75 | 145 | u16_t errstatlen; |
hattori_atsushi | 0:f77369cabd75 | 146 | /* encoding request id length */ |
hattori_atsushi | 0:f77369cabd75 | 147 | u16_t ridlen; |
hattori_atsushi | 0:f77369cabd75 | 148 | /* encoding pdu length */ |
hattori_atsushi | 0:f77369cabd75 | 149 | u16_t pdulen; |
hattori_atsushi | 0:f77369cabd75 | 150 | /* encoding community length */ |
hattori_atsushi | 0:f77369cabd75 | 151 | u16_t comlen; |
hattori_atsushi | 0:f77369cabd75 | 152 | /* encoding version length */ |
hattori_atsushi | 0:f77369cabd75 | 153 | u16_t verlen; |
hattori_atsushi | 0:f77369cabd75 | 154 | /* encoding sequence length */ |
hattori_atsushi | 0:f77369cabd75 | 155 | u16_t seqlen; |
hattori_atsushi | 0:f77369cabd75 | 156 | }; |
hattori_atsushi | 0:f77369cabd75 | 157 | |
hattori_atsushi | 0:f77369cabd75 | 158 | /** output response message header length fields */ |
hattori_atsushi | 0:f77369cabd75 | 159 | struct snmp_trap_header_lengths |
hattori_atsushi | 0:f77369cabd75 | 160 | { |
hattori_atsushi | 0:f77369cabd75 | 161 | /* encoding timestamp length length */ |
hattori_atsushi | 0:f77369cabd75 | 162 | u8_t tslenlen; |
hattori_atsushi | 0:f77369cabd75 | 163 | /* encoding specific-trap length length */ |
hattori_atsushi | 0:f77369cabd75 | 164 | u8_t strplenlen; |
hattori_atsushi | 0:f77369cabd75 | 165 | /* encoding generic-trap length length */ |
hattori_atsushi | 0:f77369cabd75 | 166 | u8_t gtrplenlen; |
hattori_atsushi | 0:f77369cabd75 | 167 | /* encoding agent-addr length length */ |
hattori_atsushi | 0:f77369cabd75 | 168 | u8_t aaddrlenlen; |
hattori_atsushi | 0:f77369cabd75 | 169 | /* encoding enterprise-id length length */ |
hattori_atsushi | 0:f77369cabd75 | 170 | u8_t eidlenlen; |
hattori_atsushi | 0:f77369cabd75 | 171 | /* encoding pdu length length */ |
hattori_atsushi | 0:f77369cabd75 | 172 | u8_t pdulenlen; |
hattori_atsushi | 0:f77369cabd75 | 173 | /* encoding community length length */ |
hattori_atsushi | 0:f77369cabd75 | 174 | u8_t comlenlen; |
hattori_atsushi | 0:f77369cabd75 | 175 | /* encoding version length length */ |
hattori_atsushi | 0:f77369cabd75 | 176 | u8_t verlenlen; |
hattori_atsushi | 0:f77369cabd75 | 177 | /* encoding sequence length length */ |
hattori_atsushi | 0:f77369cabd75 | 178 | u8_t seqlenlen; |
hattori_atsushi | 0:f77369cabd75 | 179 | |
hattori_atsushi | 0:f77369cabd75 | 180 | /* encoding timestamp length */ |
hattori_atsushi | 0:f77369cabd75 | 181 | u16_t tslen; |
hattori_atsushi | 0:f77369cabd75 | 182 | /* encoding specific-trap length */ |
hattori_atsushi | 0:f77369cabd75 | 183 | u16_t strplen; |
hattori_atsushi | 0:f77369cabd75 | 184 | /* encoding generic-trap length */ |
hattori_atsushi | 0:f77369cabd75 | 185 | u16_t gtrplen; |
hattori_atsushi | 0:f77369cabd75 | 186 | /* encoding agent-addr length */ |
hattori_atsushi | 0:f77369cabd75 | 187 | u16_t aaddrlen; |
hattori_atsushi | 0:f77369cabd75 | 188 | /* encoding enterprise-id length */ |
hattori_atsushi | 0:f77369cabd75 | 189 | u16_t eidlen; |
hattori_atsushi | 0:f77369cabd75 | 190 | /* encoding pdu length */ |
hattori_atsushi | 0:f77369cabd75 | 191 | u16_t pdulen; |
hattori_atsushi | 0:f77369cabd75 | 192 | /* encoding community length */ |
hattori_atsushi | 0:f77369cabd75 | 193 | u16_t comlen; |
hattori_atsushi | 0:f77369cabd75 | 194 | /* encoding version length */ |
hattori_atsushi | 0:f77369cabd75 | 195 | u16_t verlen; |
hattori_atsushi | 0:f77369cabd75 | 196 | /* encoding sequence length */ |
hattori_atsushi | 0:f77369cabd75 | 197 | u16_t seqlen; |
hattori_atsushi | 0:f77369cabd75 | 198 | }; |
hattori_atsushi | 0:f77369cabd75 | 199 | |
hattori_atsushi | 0:f77369cabd75 | 200 | /* Accepting new SNMP messages. */ |
hattori_atsushi | 0:f77369cabd75 | 201 | #define SNMP_MSG_EMPTY 0 |
hattori_atsushi | 0:f77369cabd75 | 202 | /* Search for matching object for variable binding. */ |
hattori_atsushi | 0:f77369cabd75 | 203 | #define SNMP_MSG_SEARCH_OBJ 1 |
hattori_atsushi | 0:f77369cabd75 | 204 | /* Perform SNMP operation on in-memory object. |
hattori_atsushi | 0:f77369cabd75 | 205 | Pass-through states, for symmetry only. */ |
hattori_atsushi | 0:f77369cabd75 | 206 | #define SNMP_MSG_INTERNAL_GET_OBJDEF 2 |
hattori_atsushi | 0:f77369cabd75 | 207 | #define SNMP_MSG_INTERNAL_GET_VALUE 3 |
hattori_atsushi | 0:f77369cabd75 | 208 | #define SNMP_MSG_INTERNAL_SET_TEST 4 |
hattori_atsushi | 0:f77369cabd75 | 209 | #define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5 |
hattori_atsushi | 0:f77369cabd75 | 210 | #define SNMP_MSG_INTERNAL_SET_VALUE 6 |
hattori_atsushi | 0:f77369cabd75 | 211 | /* Perform SNMP operation on object located externally. |
hattori_atsushi | 0:f77369cabd75 | 212 | In theory this could be used for building a proxy agent. |
hattori_atsushi | 0:f77369cabd75 | 213 | Practical use is for an enterprise spc. app. gateway. */ |
hattori_atsushi | 0:f77369cabd75 | 214 | #define SNMP_MSG_EXTERNAL_GET_OBJDEF 7 |
hattori_atsushi | 0:f77369cabd75 | 215 | #define SNMP_MSG_EXTERNAL_GET_VALUE 8 |
hattori_atsushi | 0:f77369cabd75 | 216 | #define SNMP_MSG_EXTERNAL_SET_TEST 9 |
hattori_atsushi | 0:f77369cabd75 | 217 | #define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10 |
hattori_atsushi | 0:f77369cabd75 | 218 | #define SNMP_MSG_EXTERNAL_SET_VALUE 11 |
hattori_atsushi | 0:f77369cabd75 | 219 | |
hattori_atsushi | 0:f77369cabd75 | 220 | #define SNMP_COMMUNITY_STR_LEN 64 |
hattori_atsushi | 0:f77369cabd75 | 221 | struct snmp_msg_pstat |
hattori_atsushi | 0:f77369cabd75 | 222 | { |
hattori_atsushi | 0:f77369cabd75 | 223 | /* lwIP local port (161) binding */ |
hattori_atsushi | 0:f77369cabd75 | 224 | struct udp_pcb *pcb; |
hattori_atsushi | 0:f77369cabd75 | 225 | /* source IP address */ |
hattori_atsushi | 0:f77369cabd75 | 226 | ip_addr_t sip; |
hattori_atsushi | 0:f77369cabd75 | 227 | /* source UDP port */ |
hattori_atsushi | 0:f77369cabd75 | 228 | u16_t sp; |
hattori_atsushi | 0:f77369cabd75 | 229 | /* request type */ |
hattori_atsushi | 0:f77369cabd75 | 230 | u8_t rt; |
hattori_atsushi | 0:f77369cabd75 | 231 | /* request ID */ |
hattori_atsushi | 0:f77369cabd75 | 232 | s32_t rid; |
hattori_atsushi | 0:f77369cabd75 | 233 | /* error status */ |
hattori_atsushi | 0:f77369cabd75 | 234 | s32_t error_status; |
hattori_atsushi | 0:f77369cabd75 | 235 | /* error index */ |
hattori_atsushi | 0:f77369cabd75 | 236 | s32_t error_index; |
hattori_atsushi | 0:f77369cabd75 | 237 | /* community name (zero terminated) */ |
hattori_atsushi | 0:f77369cabd75 | 238 | u8_t community[SNMP_COMMUNITY_STR_LEN + 1]; |
hattori_atsushi | 0:f77369cabd75 | 239 | /* community string length (exclusive zero term) */ |
hattori_atsushi | 0:f77369cabd75 | 240 | u8_t com_strlen; |
hattori_atsushi | 0:f77369cabd75 | 241 | /* one out of MSG_EMPTY, MSG_DEMUX, MSG_INTERNAL, MSG_EXTERNAL_x */ |
hattori_atsushi | 0:f77369cabd75 | 242 | u8_t state; |
hattori_atsushi | 0:f77369cabd75 | 243 | /* saved arguments for MSG_EXTERNAL_x */ |
hattori_atsushi | 0:f77369cabd75 | 244 | struct mib_external_node *ext_mib_node; |
hattori_atsushi | 0:f77369cabd75 | 245 | struct snmp_name_ptr ext_name_ptr; |
hattori_atsushi | 0:f77369cabd75 | 246 | struct obj_def ext_object_def; |
hattori_atsushi | 0:f77369cabd75 | 247 | struct snmp_obj_id ext_oid; |
hattori_atsushi | 0:f77369cabd75 | 248 | /* index into input variable binding list */ |
hattori_atsushi | 0:f77369cabd75 | 249 | u8_t vb_idx; |
hattori_atsushi | 0:f77369cabd75 | 250 | /* ptr into input variable binding list */ |
hattori_atsushi | 0:f77369cabd75 | 251 | struct snmp_varbind *vb_ptr; |
hattori_atsushi | 0:f77369cabd75 | 252 | /* list of variable bindings from input */ |
hattori_atsushi | 0:f77369cabd75 | 253 | struct snmp_varbind_root invb; |
hattori_atsushi | 0:f77369cabd75 | 254 | /* list of variable bindings to output */ |
hattori_atsushi | 0:f77369cabd75 | 255 | struct snmp_varbind_root outvb; |
hattori_atsushi | 0:f77369cabd75 | 256 | /* output response lengths used in ASN encoding */ |
hattori_atsushi | 0:f77369cabd75 | 257 | struct snmp_resp_header_lengths rhl; |
hattori_atsushi | 0:f77369cabd75 | 258 | }; |
hattori_atsushi | 0:f77369cabd75 | 259 | |
hattori_atsushi | 0:f77369cabd75 | 260 | struct snmp_msg_trap |
hattori_atsushi | 0:f77369cabd75 | 261 | { |
hattori_atsushi | 0:f77369cabd75 | 262 | /* lwIP local port (161) binding */ |
hattori_atsushi | 0:f77369cabd75 | 263 | struct udp_pcb *pcb; |
hattori_atsushi | 0:f77369cabd75 | 264 | /* destination IP address in network order */ |
hattori_atsushi | 0:f77369cabd75 | 265 | ip_addr_t dip; |
hattori_atsushi | 0:f77369cabd75 | 266 | |
hattori_atsushi | 0:f77369cabd75 | 267 | /* source enterprise ID (sysObjectID) */ |
hattori_atsushi | 0:f77369cabd75 | 268 | struct snmp_obj_id *enterprise; |
hattori_atsushi | 0:f77369cabd75 | 269 | /* source IP address, raw network order format */ |
hattori_atsushi | 0:f77369cabd75 | 270 | u8_t sip_raw[4]; |
hattori_atsushi | 0:f77369cabd75 | 271 | /* generic trap code */ |
hattori_atsushi | 0:f77369cabd75 | 272 | u32_t gen_trap; |
hattori_atsushi | 0:f77369cabd75 | 273 | /* specific trap code */ |
hattori_atsushi | 0:f77369cabd75 | 274 | u32_t spc_trap; |
hattori_atsushi | 0:f77369cabd75 | 275 | /* timestamp */ |
hattori_atsushi | 0:f77369cabd75 | 276 | u32_t ts; |
hattori_atsushi | 0:f77369cabd75 | 277 | /* list of variable bindings to output */ |
hattori_atsushi | 0:f77369cabd75 | 278 | struct snmp_varbind_root outvb; |
hattori_atsushi | 0:f77369cabd75 | 279 | /* output trap lengths used in ASN encoding */ |
hattori_atsushi | 0:f77369cabd75 | 280 | struct snmp_trap_header_lengths thl; |
hattori_atsushi | 0:f77369cabd75 | 281 | }; |
hattori_atsushi | 0:f77369cabd75 | 282 | |
hattori_atsushi | 0:f77369cabd75 | 283 | /** Agent Version constant, 0 = v1 oddity */ |
hattori_atsushi | 0:f77369cabd75 | 284 | extern const s32_t snmp_version; |
hattori_atsushi | 0:f77369cabd75 | 285 | /** Agent default "public" community string */ |
hattori_atsushi | 0:f77369cabd75 | 286 | extern const char snmp_publiccommunity[7]; |
hattori_atsushi | 0:f77369cabd75 | 287 | |
hattori_atsushi | 0:f77369cabd75 | 288 | extern struct snmp_msg_trap trap_msg; |
hattori_atsushi | 0:f77369cabd75 | 289 | |
hattori_atsushi | 0:f77369cabd75 | 290 | /** Agent setup, start listening to port 161. */ |
hattori_atsushi | 0:f77369cabd75 | 291 | void snmp_init(void); |
hattori_atsushi | 0:f77369cabd75 | 292 | void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); |
hattori_atsushi | 0:f77369cabd75 | 293 | void snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst); |
hattori_atsushi | 0:f77369cabd75 | 294 | |
hattori_atsushi | 0:f77369cabd75 | 295 | /** Varbind-list functions. */ |
hattori_atsushi | 0:f77369cabd75 | 296 | struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len); |
hattori_atsushi | 0:f77369cabd75 | 297 | void snmp_varbind_free(struct snmp_varbind *vb); |
hattori_atsushi | 0:f77369cabd75 | 298 | void snmp_varbind_list_free(struct snmp_varbind_root *root); |
hattori_atsushi | 0:f77369cabd75 | 299 | void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb); |
hattori_atsushi | 0:f77369cabd75 | 300 | struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root); |
hattori_atsushi | 0:f77369cabd75 | 301 | |
hattori_atsushi | 0:f77369cabd75 | 302 | /** Handle an internal (recv) or external (private response) event. */ |
hattori_atsushi | 0:f77369cabd75 | 303 | void snmp_msg_event(u8_t request_id); |
hattori_atsushi | 0:f77369cabd75 | 304 | err_t snmp_send_response(struct snmp_msg_pstat *m_stat); |
hattori_atsushi | 0:f77369cabd75 | 305 | err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap); |
hattori_atsushi | 0:f77369cabd75 | 306 | void snmp_coldstart_trap(void); |
hattori_atsushi | 0:f77369cabd75 | 307 | void snmp_authfail_trap(void); |
hattori_atsushi | 0:f77369cabd75 | 308 | |
hattori_atsushi | 0:f77369cabd75 | 309 | #ifdef __cplusplus |
hattori_atsushi | 0:f77369cabd75 | 310 | } |
hattori_atsushi | 0:f77369cabd75 | 311 | #endif |
hattori_atsushi | 0:f77369cabd75 | 312 | |
hattori_atsushi | 0:f77369cabd75 | 313 | #endif /* LWIP_SNMP */ |
hattori_atsushi | 0:f77369cabd75 | 314 | |
hattori_atsushi | 0:f77369cabd75 | 315 | #endif /* __LWIP_SNMP_MSG_H__ */ |