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