SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lorcansmith 0:2a53a4c3238c 1 /**
lorcansmith 0:2a53a4c3238c 2 * @file
lorcansmith 0:2a53a4c3238c 3 * Abstract Syntax Notation One (ISO 8824, 8825) codec.
lorcansmith 0:2a53a4c3238c 4 */
lorcansmith 0:2a53a4c3238c 5
lorcansmith 0:2a53a4c3238c 6 /*
lorcansmith 0:2a53a4c3238c 7 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
lorcansmith 0:2a53a4c3238c 8 * All rights reserved.
lorcansmith 0:2a53a4c3238c 9 *
lorcansmith 0:2a53a4c3238c 10 * Redistribution and use in source and binary forms, with or without modification,
lorcansmith 0:2a53a4c3238c 11 * are permitted provided that the following conditions are met:
lorcansmith 0:2a53a4c3238c 12 *
lorcansmith 0:2a53a4c3238c 13 * 1. Redistributions of source code must retain the above copyright notice,
lorcansmith 0:2a53a4c3238c 14 * this list of conditions and the following disclaimer.
lorcansmith 0:2a53a4c3238c 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
lorcansmith 0:2a53a4c3238c 16 * this list of conditions and the following disclaimer in the documentation
lorcansmith 0:2a53a4c3238c 17 * and/or other materials provided with the distribution.
lorcansmith 0:2a53a4c3238c 18 * 3. The name of the author may not be used to endorse or promote products
lorcansmith 0:2a53a4c3238c 19 * derived from this software without specific prior written permission.
lorcansmith 0:2a53a4c3238c 20 *
lorcansmith 0:2a53a4c3238c 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
lorcansmith 0:2a53a4c3238c 22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
lorcansmith 0:2a53a4c3238c 23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
lorcansmith 0:2a53a4c3238c 24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
lorcansmith 0:2a53a4c3238c 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
lorcansmith 0:2a53a4c3238c 26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
lorcansmith 0:2a53a4c3238c 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
lorcansmith 0:2a53a4c3238c 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
lorcansmith 0:2a53a4c3238c 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
lorcansmith 0:2a53a4c3238c 30 * OF SUCH DAMAGE.
lorcansmith 0:2a53a4c3238c 31 *
lorcansmith 0:2a53a4c3238c 32 * Author: Christiaan Simons <christiaan.simons@axon.tv>
lorcansmith 0:2a53a4c3238c 33 */
lorcansmith 0:2a53a4c3238c 34
lorcansmith 0:2a53a4c3238c 35 #ifndef __LWIP_SNMP_ASN1_H__
lorcansmith 0:2a53a4c3238c 36 #define __LWIP_SNMP_ASN1_H__
lorcansmith 0:2a53a4c3238c 37
lorcansmith 0:2a53a4c3238c 38 #include "lwip/opt.h"
lorcansmith 0:2a53a4c3238c 39 #include "lwip/err.h"
lorcansmith 0:2a53a4c3238c 40 #include "lwip/pbuf.h"
lorcansmith 0:2a53a4c3238c 41 #include "lwip/snmp.h"
lorcansmith 0:2a53a4c3238c 42
lorcansmith 0:2a53a4c3238c 43 #if LWIP_SNMP
lorcansmith 0:2a53a4c3238c 44
lorcansmith 0:2a53a4c3238c 45 #ifdef __cplusplus
lorcansmith 0:2a53a4c3238c 46 extern "C" {
lorcansmith 0:2a53a4c3238c 47 #endif
lorcansmith 0:2a53a4c3238c 48
lorcansmith 0:2a53a4c3238c 49 #define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */
lorcansmith 0:2a53a4c3238c 50 #define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */
lorcansmith 0:2a53a4c3238c 51 #define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */
lorcansmith 0:2a53a4c3238c 52
lorcansmith 0:2a53a4c3238c 53 #define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */
lorcansmith 0:2a53a4c3238c 54 #define SNMP_ASN1_PRIMIT (0) /* (!0x20) */
lorcansmith 0:2a53a4c3238c 55
lorcansmith 0:2a53a4c3238c 56 /* universal tags */
lorcansmith 0:2a53a4c3238c 57 #define SNMP_ASN1_INTEG 2
lorcansmith 0:2a53a4c3238c 58 #define SNMP_ASN1_OC_STR 4
lorcansmith 0:2a53a4c3238c 59 #define SNMP_ASN1_NUL 5
lorcansmith 0:2a53a4c3238c 60 #define SNMP_ASN1_OBJ_ID 6
lorcansmith 0:2a53a4c3238c 61 #define SNMP_ASN1_SEQ 16
lorcansmith 0:2a53a4c3238c 62
lorcansmith 0:2a53a4c3238c 63 /* application specific (SNMP) tags */
lorcansmith 0:2a53a4c3238c 64 #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */
lorcansmith 0:2a53a4c3238c 65 #define SNMP_ASN1_COUNTER 1 /* u32_t */
lorcansmith 0:2a53a4c3238c 66 #define SNMP_ASN1_GAUGE 2 /* u32_t */
lorcansmith 0:2a53a4c3238c 67 #define SNMP_ASN1_TIMETICKS 3 /* u32_t */
lorcansmith 0:2a53a4c3238c 68 #define SNMP_ASN1_OPAQUE 4 /* octet string */
lorcansmith 0:2a53a4c3238c 69
lorcansmith 0:2a53a4c3238c 70 /* context specific (SNMP) tags */
lorcansmith 0:2a53a4c3238c 71 #define SNMP_ASN1_PDU_GET_REQ 0
lorcansmith 0:2a53a4c3238c 72 #define SNMP_ASN1_PDU_GET_NEXT_REQ 1
lorcansmith 0:2a53a4c3238c 73 #define SNMP_ASN1_PDU_GET_RESP 2
lorcansmith 0:2a53a4c3238c 74 #define SNMP_ASN1_PDU_SET_REQ 3
lorcansmith 0:2a53a4c3238c 75 #define SNMP_ASN1_PDU_TRAP 4
lorcansmith 0:2a53a4c3238c 76
lorcansmith 0:2a53a4c3238c 77 err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);
lorcansmith 0:2a53a4c3238c 78 err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);
lorcansmith 0:2a53a4c3238c 79 err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);
lorcansmith 0:2a53a4c3238c 80 err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);
lorcansmith 0:2a53a4c3238c 81 err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);
lorcansmith 0:2a53a4c3238c 82 err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);
lorcansmith 0:2a53a4c3238c 83
lorcansmith 0:2a53a4c3238c 84 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
lorcansmith 0:2a53a4c3238c 85 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
lorcansmith 0:2a53a4c3238c 86 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
lorcansmith 0:2a53a4c3238c 87 void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
lorcansmith 0:2a53a4c3238c 88 err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
lorcansmith 0:2a53a4c3238c 89 err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
lorcansmith 0:2a53a4c3238c 90 err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value);
lorcansmith 0:2a53a4c3238c 91 err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value);
lorcansmith 0:2a53a4c3238c 92 err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
lorcansmith 0:2a53a4c3238c 93 err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw);
lorcansmith 0:2a53a4c3238c 94
lorcansmith 0:2a53a4c3238c 95 #ifdef __cplusplus
lorcansmith 0:2a53a4c3238c 96 }
lorcansmith 0:2a53a4c3238c 97 #endif
lorcansmith 0:2a53a4c3238c 98
lorcansmith 0:2a53a4c3238c 99 #endif /* LWIP_SNMP */
lorcansmith 0:2a53a4c3238c 100
lorcansmith 0:2a53a4c3238c 101 #endif /* __LWIP_SNMP_ASN1_H__ */