Contiki-NG
snmp-message.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*---------------------------------------------------------------------------*/
32 
33 /**
34  * \file
35  * An implementation of the Simple Network Management Protocol (RFC 3411-3418)
36  * \author
37  * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br
38  */
39 
40 /**
41  * \addtogroup snmp
42  * @{
43  */
44 
45 #ifndef SNMP_MESSAGE_H_
46 #define SNMP_MESSAGE_H_
47 
48 #include "snmp.h"
49 
50 #define SNMP_DATA_TYPE_TIME_TICKS 0x43
51 #define SNMP_DATA_TYPE_NO_SUCH_INSTANCE 0x81
52 #define SNMP_DATA_TYPE_END_OF_MIB_VIEW 0x82
53 
54 #define SNMP_DATA_TYPE_PDU_GET_REQUEST 0xA0
55 #define SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST 0xA1
56 #define SNMP_DATA_TYPE_PDU_GET_RESPONSE 0xA2
57 #define SNMP_DATA_TYPE_PDU_SET_REQUEST 0xA3
58 #define SNMP_DATA_TYPE_PDU_TRAP 0xA4
59 #define SNMP_DATA_TYPE_PDU_GET_BULK 0xA5
60 
61 /**
62  * @brief Encodes a SNMP message
63  *
64  * @param out A pointer to the end of the buffer
65  * @param out_len A pointer to the buffer length
66  * @param header The SNMP header struct
67  * @param varbinds The varbinds array
68  * @param varbinds_length The number of varbinds
69  *
70  * @return
71  */
72 unsigned char *
73 snmp_message_encode(unsigned char *out, uint32_t *out_len, snmp_header_t *header,
74  snmp_varbind_t *varbinds, uint32_t varbinds_length);
75 /**
76  * @brief
77  *
78  * @param buf A pointer to the beginning of the buffer
79  * @param buf_len A pointer to the buffer length
80  * @param header The SNMP header struct
81  * @param varbinds The varbinds array
82  * @param varbinds_length A pointer to the number of varbinds
83  *
84  * @return
85  */
86 uint8_t *
87 snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header,
88  snmp_varbind_t *varbinds, uint32_t *varbinds_length);
89 
90 #endif /* SNMP_MESSAGE_H_ */
91 
92 /** @} */
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
The varbind struct.
Definition: snmp.h:157
The SNMP header struct.
Definition: snmp.h:92
unsigned char * snmp_message_encode(unsigned char *out, uint32_t *out_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbinds_length)
Encodes a SNMP message.
Definition: snmp-message.c:50
uint8_t * snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t *varbinds_length)
Definition: snmp-message.c:114