Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/snmp_asn1.h need to be fixed.

0001 /**
0002  * @file
0003  * Abstract Syntax Notation One (ISO 8824, 8825) codec.
0004  */
0005  
0006 /*
0007  * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
0008  * All rights reserved.
0009  *
0010  * Redistribution and use in source and binary forms, with or without modification,
0011  * are permitted provided that the following conditions are met:
0012  *
0013  * 1. Redistributions of source code must retain the above copyright notice,
0014  *    this list of conditions and the following disclaimer.
0015  * 2. Redistributions in binary form must reproduce the above copyright notice,
0016  *    this list of conditions and the following disclaimer in the documentation
0017  *    and/or other materials provided with the distribution.
0018  * 3. The name of the author may not be used to endorse or promote products
0019  *    derived from this software without specific prior written permission.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
0022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
0023  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
0024  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
0026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
0030  * OF SUCH DAMAGE.
0031  *
0032  * Author: Christiaan Simons <christiaan.simons@axon.tv>
0033  */
0034 
0035 #ifndef __LWIP_SNMP_ASN1_H__
0036 #define __LWIP_SNMP_ASN1_H__
0037 
0038 #include "lwip/opt.h"
0039 #include "lwip/err.h"
0040 #include "lwip/pbuf.h"
0041 #include "lwip/snmp.h"
0042 
0043 #if LWIP_SNMP
0044 
0045 #ifdef __cplusplus
0046 extern "C" {
0047 #endif
0048 
0049 #define SNMP_ASN1_UNIV   (!0x80 | !0x40)
0050 #define SNMP_ASN1_APPLIC (!0x80 |  0x40)
0051 #define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
0052 
0053 #define SNMP_ASN1_CONSTR (0x20)
0054 #define SNMP_ASN1_PRIMIT (!0x20)
0055 
0056 /* universal tags */
0057 #define SNMP_ASN1_INTEG  2
0058 #define SNMP_ASN1_OC_STR 4
0059 #define SNMP_ASN1_NUL    5
0060 #define SNMP_ASN1_OBJ_ID 6
0061 #define SNMP_ASN1_SEQ    16
0062 
0063 /* application specific (SNMP) tags */
0064 #define SNMP_ASN1_IPADDR 0    /* octet string size(4) */
0065 #define SNMP_ASN1_COUNTER 1   /* u32_t */
0066 #define SNMP_ASN1_GAUGE 2     /* u32_t */
0067 #define SNMP_ASN1_TIMETICKS 3 /* u32_t */
0068 #define SNMP_ASN1_OPAQUE 4    /* octet string */
0069 
0070 /* context specific (SNMP) tags */
0071 #define SNMP_ASN1_PDU_GET_REQ 0
0072 #define SNMP_ASN1_PDU_GET_NEXT_REQ 1
0073 #define SNMP_ASN1_PDU_GET_RESP 2
0074 #define SNMP_ASN1_PDU_SET_REQ 3
0075 #define SNMP_ASN1_PDU_TRAP 4
0076 
0077 err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);
0078 err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);
0079 err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);
0080 err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);
0081 err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);
0082 err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);
0083 
0084 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
0085 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
0086 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
0087 void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
0088 err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
0089 err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
0090 err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value);
0091 err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value);
0092 err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
0093 err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw);
0094 
0095 #ifdef __cplusplus
0096 }
0097 #endif
0098 
0099 #endif /* LWIP_SNMP */
0100 
0101 #endif /* __LWIP_SNMP_ASN1_H__ */