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