Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
lwip_snmp_msg.h
00001 /** 00002 * @file 00003 * SNMP Agent message handling structures (internal API, do not use in client code). 00004 */ 00005 00006 /* 00007 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 00008 * Copyright (c) 2016 Elias Oenal. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. The name of the author may not be used to endorse or promote products 00020 * derived from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00025 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00027 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00030 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00031 * OF SUCH DAMAGE. 00032 * 00033 * Author: Christiaan Simons <christiaan.simons@axon.tv> 00034 * Martin Hentschel <info@cl-soft.de> 00035 * Elias Oenal <lwip@eliasoenal.com> 00036 */ 00037 00038 #ifndef LWIP_HDR_APPS_SNMP_MSG_H 00039 #define LWIP_HDR_APPS_SNMP_MSG_H 00040 00041 #include "lwip/apps/snmp_opts.h" 00042 00043 #if LWIP_SNMP 00044 00045 #include "lwip/apps/snmp.h" 00046 #include "lwip/apps/snmp_core.h" 00047 #include "snmp_pbuf_stream.h" 00048 #include "lwip/ip_addr.h" 00049 #include "lwip/err.h" 00050 00051 #if LWIP_SNMP_V3 00052 #include "snmpv3_priv.h" 00053 #endif 00054 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 /* version defines used in PDU */ 00061 #define SNMP_VERSION_1 0 00062 #define SNMP_VERSION_2c 1 00063 #define SNMP_VERSION_3 3 00064 00065 struct snmp_varbind_enumerator { 00066 struct snmp_pbuf_stream pbuf_stream; 00067 u16_t varbind_count; 00068 }; 00069 00070 typedef enum { 00071 SNMP_VB_ENUMERATOR_ERR_OK = 0, 00072 SNMP_VB_ENUMERATOR_ERR_EOVB = 1, 00073 SNMP_VB_ENUMERATOR_ERR_ASN1ERROR = 2, 00074 SNMP_VB_ENUMERATOR_ERR_INVALIDLENGTH = 3 00075 } snmp_vb_enumerator_err_t; 00076 00077 void snmp_vb_enumerator_init(struct snmp_varbind_enumerator *enumerator, struct pbuf *p, u16_t offset, u16_t length); 00078 snmp_vb_enumerator_err_t snmp_vb_enumerator_get_next(struct snmp_varbind_enumerator *enumerator, struct snmp_varbind *varbind); 00079 00080 struct snmp_request { 00081 /* Communication handle */ 00082 void *handle; 00083 /* source IP address */ 00084 const ip_addr_t *source_ip; 00085 /* source UDP port */ 00086 u16_t source_port; 00087 /* incoming snmp version */ 00088 u8_t version; 00089 /* community name (zero terminated) */ 00090 u8_t community[SNMP_MAX_COMMUNITY_STR_LEN + 1]; 00091 /* community string length (exclusive zero term) */ 00092 u16_t community_strlen; 00093 /* request type */ 00094 u8_t request_type; 00095 /* request ID */ 00096 s32_t request_id; 00097 /* error status */ 00098 s32_t error_status; 00099 /* error index */ 00100 s32_t error_index; 00101 /* non-repeaters (getBulkRequest (SNMPv2c)) */ 00102 s32_t non_repeaters; 00103 /* max-repetitions (getBulkRequest (SNMPv2c)) */ 00104 s32_t max_repetitions; 00105 00106 /* Usually response-pdu (2). When snmpv3 errors are detected report-pdu(8) */ 00107 u8_t request_out_type; 00108 00109 #if LWIP_SNMP_V3 00110 s32_t msg_id; 00111 s32_t msg_max_size; 00112 u8_t msg_flags; 00113 s32_t msg_security_model; 00114 u8_t msg_authoritative_engine_id[SNMP_V3_MAX_ENGINE_ID_LENGTH]; 00115 u8_t msg_authoritative_engine_id_len; 00116 s32_t msg_authoritative_engine_boots; 00117 s32_t msg_authoritative_engine_time; 00118 u8_t msg_user_name[SNMP_V3_MAX_USER_LENGTH]; 00119 u8_t msg_user_name_len; 00120 u8_t msg_authentication_parameters[SNMP_V3_MAX_AUTH_PARAM_LENGTH]; 00121 u8_t msg_authentication_parameters_len; 00122 u8_t msg_privacy_parameters[SNMP_V3_MAX_PRIV_PARAM_LENGTH]; 00123 u8_t msg_privacy_parameters_len; 00124 u8_t context_engine_id[SNMP_V3_MAX_ENGINE_ID_LENGTH]; 00125 u8_t context_engine_id_len; 00126 u8_t context_name[SNMP_V3_MAX_ENGINE_ID_LENGTH]; 00127 u8_t context_name_len; 00128 #endif 00129 00130 struct pbuf *inbound_pbuf; 00131 struct snmp_varbind_enumerator inbound_varbind_enumerator; 00132 u16_t inbound_varbind_offset; 00133 u16_t inbound_varbind_len; 00134 u16_t inbound_padding_len; 00135 00136 struct pbuf *outbound_pbuf; 00137 struct snmp_pbuf_stream outbound_pbuf_stream; 00138 u16_t outbound_pdu_offset; 00139 u16_t outbound_error_status_offset; 00140 u16_t outbound_error_index_offset; 00141 u16_t outbound_varbind_offset; 00142 #if LWIP_SNMP_V3 00143 u16_t outbound_msg_global_data_offset; 00144 u16_t outbound_msg_global_data_end; 00145 u16_t outbound_msg_security_parameters_str_offset; 00146 u16_t outbound_msg_security_parameters_seq_offset; 00147 u16_t outbound_msg_security_parameters_end; 00148 u16_t outbound_msg_authentication_parameters_offset; 00149 u16_t outbound_scoped_pdu_seq_offset; 00150 u16_t outbound_scoped_pdu_string_offset; 00151 #endif 00152 00153 u8_t value_buffer[SNMP_MAX_VALUE_SIZE]; 00154 }; 00155 00156 /** A helper struct keeping length information about varbinds */ 00157 struct snmp_varbind_len { 00158 u8_t vb_len_len; 00159 u16_t vb_value_len; 00160 u8_t oid_len_len; 00161 u16_t oid_value_len; 00162 u8_t value_len_len; 00163 u16_t value_value_len; 00164 }; 00165 00166 /** Agent community string */ 00167 extern const char *snmp_community; 00168 /** Agent community string for write access */ 00169 extern const char *snmp_community_write; 00170 /** handle for sending traps */ 00171 extern void *snmp_traps_handle; 00172 00173 void snmp_receive(void *handle, struct pbuf *p, const ip_addr_t *source_ip, u16_t port); 00174 err_t snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port); 00175 u8_t snmp_get_local_ip_for_dst(void *handle, const ip_addr_t *dst, ip_addr_t *result); 00176 err_t snmp_varbind_length(struct snmp_varbind *varbind, struct snmp_varbind_len *len); 00177 err_t snmp_append_outbound_varbind(struct snmp_pbuf_stream *pbuf_stream, struct snmp_varbind *varbind); 00178 00179 #ifdef __cplusplus 00180 } 00181 #endif 00182 00183 #endif /* LWIP_SNMP */ 00184 00185 #endif /* LWIP_HDR_APPS_SNMP_MSG_H */
Generated on Tue Jul 12 2022 13:54:30 by
1.7.2