ZG2100 Network interface source

Committer:
donatien
Date:
Fri Jul 09 15:37:23 2010 +0000
Revision:
0:b802fc31f1db
Child:
1:3a7c15057192

        

Who changed what in which revision?

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