]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/ethernet/lwIP_130/src/include/lwip/snmp_asn1.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / Common / ethernet / lwIP_130 / src / include / lwip / snmp_asn1.h
1 /**\r
2  * @file\r
3  * Abstract Syntax Notation One (ISO 8824, 8825) codec.\r
4  */\r
5  \r
6 /*\r
7  * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.\r
8  * All rights reserved.\r
9  *\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
12  *\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
20  *\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
30  * OF SUCH DAMAGE.\r
31  *\r
32  * Author: Christiaan Simons <christiaan.simons@axon.tv>\r
33  */\r
34 \r
35 #ifndef __LWIP_SNMP_ASN1_H__\r
36 #define __LWIP_SNMP_ASN1_H__\r
37 \r
38 #include "lwip/opt.h"\r
39 #include "lwip/err.h"\r
40 #include "lwip/pbuf.h"\r
41 #include "lwip/snmp.h"\r
42 \r
43 #ifdef __cplusplus\r
44 extern "C" {\r
45 #endif\r
46 \r
47 #define SNMP_ASN1_UNIV   (!0x80 | !0x40)\r
48 #define SNMP_ASN1_APPLIC (!0x80 |  0x40)\r
49 #define SNMP_ASN1_CONTXT ( 0x80 | !0x40)\r
50 \r
51 #define SNMP_ASN1_CONSTR (0x20)\r
52 #define SNMP_ASN1_PRIMIT (!0x20)\r
53 \r
54 /* universal tags */\r
55 #define SNMP_ASN1_INTEG  2\r
56 #define SNMP_ASN1_OC_STR 4\r
57 #define SNMP_ASN1_NUL    5\r
58 #define SNMP_ASN1_OBJ_ID 6\r
59 #define SNMP_ASN1_SEQ    16\r
60 \r
61 /* application specific (SNMP) tags */\r
62 #define SNMP_ASN1_IPADDR 0    /* octet string size(4) */\r
63 #define SNMP_ASN1_COUNTER 1   /* u32_t */\r
64 #define SNMP_ASN1_GAUGE 2     /* u32_t */\r
65 #define SNMP_ASN1_TIMETICKS 3 /* u32_t */\r
66 #define SNMP_ASN1_OPAQUE 4    /* octet string */\r
67 \r
68 /* context specific (SNMP) tags */\r
69 #define SNMP_ASN1_PDU_GET_REQ 0\r
70 #define SNMP_ASN1_PDU_GET_NEXT_REQ 1\r
71 #define SNMP_ASN1_PDU_GET_RESP 2\r
72 #define SNMP_ASN1_PDU_SET_REQ 3\r
73 #define SNMP_ASN1_PDU_TRAP 4\r
74 \r
75 err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);\r
76 err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);\r
77 err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);\r
78 err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);\r
79 err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);\r
80 err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);\r
81 \r
82 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);\r
83 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);\r
84 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);\r
85 void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);\r
86 err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);\r
87 err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);\r
88 err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value);\r
89 err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value);\r
90 err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);\r
91 err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw);\r
92 \r
93 #ifdef __cplusplus\r
94 }\r
95 #endif\r
96 \r
97 #endif /* __LWIP_SNMP_ASN1_H__ */\r