38 #ifndef LWIP_HDR_APPS_SNMP_ASN1_H 39 #define LWIP_HDR_APPS_SNMP_ASN1_H 47 #include "snmp_pbuf_stream.h" 53 #define SNMP_ASN1_TLV_INDEFINITE_LENGTH 0x80 55 #define SNMP_ASN1_CLASS_MASK 0xC0 56 #define SNMP_ASN1_CONTENTTYPE_MASK 0x20 57 #define SNMP_ASN1_DATATYPE_MASK 0x1F 58 #define SNMP_ASN1_DATATYPE_EXTENDED 0x1F 61 #define SNMP_ASN1_CONTEXT_PDU_GET_REQ 0 62 #define SNMP_ASN1_CONTEXT_PDU_GET_NEXT_REQ 1 63 #define SNMP_ASN1_CONTEXT_PDU_GET_RESP 2 64 #define SNMP_ASN1_CONTEXT_PDU_SET_REQ 3 65 #define SNMP_ASN1_CONTEXT_PDU_TRAP 4 66 #define SNMP_ASN1_CONTEXT_PDU_GET_BULK_REQ 5 67 #define SNMP_ASN1_CONTEXT_PDU_INFORM_REQ 6 68 #define SNMP_ASN1_CONTEXT_PDU_V2_TRAP 7 69 #define SNMP_ASN1_CONTEXT_PDU_REPORT 8 71 #define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_OBJECT 0 72 #define SNMP_ASN1_CONTEXT_VARBIND_END_OF_MIB_VIEW 2 74 struct snmp_asn1_tlv {
80 #define SNMP_ASN1_TLV_HDR_LENGTH(tlv) ((tlv).type_len + (tlv).length_len) 81 #define SNMP_ASN1_TLV_LENGTH(tlv) ((tlv).type_len + (tlv).length_len + (tlv).value_len) 82 #define SNMP_ASN1_SET_TLV_PARAMS(tlv, type_, length_len_, value_len_) do { (tlv).type = (type_); (tlv).type_len = 0; (tlv).length_len = (length_len_); (tlv).value_len = (value_len_); } while (0); 84 err_t snmp_asn1_dec_tlv(
struct snmp_pbuf_stream *pbuf_stream,
struct snmp_asn1_tlv *tlv);
85 err_t snmp_asn1_dec_u32t(
struct snmp_pbuf_stream *pbuf_stream, u16_t len, u32_t *value);
86 err_t snmp_asn1_dec_s32t(
struct snmp_pbuf_stream *pbuf_stream, u16_t len, s32_t *value);
87 err_t snmp_asn1_dec_oid(
struct snmp_pbuf_stream *pbuf_stream, u16_t len, u32_t *oid, u8_t *oid_len, u8_t oid_max_len);
88 err_t snmp_asn1_dec_raw(
struct snmp_pbuf_stream *pbuf_stream, u16_t len, u8_t *buf, u16_t *buf_len, u16_t buf_max_len);
90 err_t snmp_ans1_enc_tlv(
struct snmp_pbuf_stream *pbuf_stream,
struct snmp_asn1_tlv *tlv);
92 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
93 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
94 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
95 void snmp_asn1_enc_oid_cnt(
const u32_t *oid, u16_t oid_len, u16_t *octets_needed);
96 err_t snmp_asn1_enc_oid(
struct snmp_pbuf_stream *pbuf_stream,
const u32_t *oid, u16_t oid_len);
97 err_t snmp_asn1_enc_s32t(
struct snmp_pbuf_stream *pbuf_stream, u16_t octets_needed, s32_t value);
98 err_t snmp_asn1_enc_u32t(
struct snmp_pbuf_stream *pbuf_stream, u16_t octets_needed, u32_t value);
99 err_t snmp_asn1_enc_raw(
struct snmp_pbuf_stream *pbuf_stream,
const u8_t *raw, u16_t raw_len);
102 err_t snmp_asn1_dec_u64t(
struct snmp_pbuf_stream *pbuf_stream, u16_t len, u64_t *value);
103 void snmp_asn1_enc_u64t_cnt(u64_t value, u16_t *octets_needed);
104 err_t snmp_asn1_enc_u64t(
struct snmp_pbuf_stream *pbuf_stream, u16_t octets_needed, u64_t value);
SNMP core API for implementing MIBs.
SNMP server options list.