Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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