NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Fri Jun 11 16:05:15 2010 +0000
Revision:
0:632c9925f013
Child:
5:dd63a1e02b1b

        

Who changed what in which revision?

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