Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
snmp.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019-2020 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
* SNMP Implementation of the process
36
* \author
37
* Yago Fontoura do Rosario <yago.rosario@hotmail.com.br
38
*/
39
40
/**
41
* \addtogroup apps
42
* @{
43
*
44
* \addtogroup snmp An implementation of SNMP
45
* @{
46
*
47
* This is an implementation of the Simple Network Management Protocol
48
*/
49
50
#ifndef SNMP_H_
51
#define SNMP_H_
52
53
/**
54
* \addtogroup SNMPInternal SNMP Internal API
55
* @{
56
*
57
* This group contains all the functions that can be used inside the OS level.
58
*/
59
60
#include "contiki.h"
61
62
#include "
sys/log.h
"
63
64
#include "
snmp-conf.h
"
65
66
#include <stdlib.h>
67
#include <stdint.h>
68
69
/**
70
* \addtogroup SNMPCore SNMP Core
71
* @{
72
*
73
* This group contains the SNMP MIB implementation
74
*/
75
76
/**
77
* @brief SNMP Version 1 code
78
*/
79
#define SNMP_VERSION_1 0
80
/**
81
* @brief SNMP Version 2c code
82
*/
83
#define SNMP_VERSION_2C 1
84
85
/**
86
* @brief SNMP No Such Name error code
87
*/
88
#define SNMP_STATUS_NO_SUCH_NAME 2
89
90
/**
91
* @brief The SNMP header struct
92
*/
93
typedef
struct
snmp_header_s
{
94
/**
95
* @brief SNMP Version
96
*/
97
uint32_t
version
;
98
/**
99
* @brief Struct to wrap the community
100
*/
101
struct
snmp_msg_community
{
102
/**
103
* @brief A pointer to the community
104
*
105
* @remarks This pointer refers to the beginning of the string in the packet
106
*/
107
const
char
*
community
;
108
/**
109
* @brief The string length
110
*
111
* @remarks Do not use strlen on the community pointer since it is not null terminated
112
*/
113
uint32_t
length
;
114
} community;
115
/**
116
* @brief The PDU type
117
*/
118
uint8_t
pdu_type
;
119
/**
120
* @brief The request ID
121
*/
122
uint32_t
request_id
;
123
/**
124
* @brief The error status
125
*/
126
uint32_t
error_status
;
127
/**
128
* @brief The non repeaters
129
*/
130
uint32_t
non_repeaters
;
131
/**
132
* @brief The error index
133
*/
134
uint32_t
error_index
;
135
/**
136
* @brief The max repetitions
137
*/
138
uint32_t
max_repetitions
;
139
}
snmp_header_t
;
140
141
/**
142
* @brief The OID struct
143
*/
144
typedef
struct
snmp_oid_s
{
145
/**
146
* @brief The OID
147
*/
148
uint32_t
data
[
SNMP_MSG_OID_MAX_LEN
];
149
/**
150
* @brief The OID length
151
*
152
*/
153
uint8_t
length
;
154
}
snmp_oid_t
;
155
156
/**
157
* @brief The varbind struct
158
*/
159
typedef
struct
snmp_varbind_s
{
160
/**
161
* @brief The OID
162
*/
163
snmp_oid_t
oid
;
164
/**
165
* @brief The type in this varbind
166
*/
167
uint8_t
value_type
;
168
/**
169
* @brief A union to represent the value in this varbind
170
*
171
* @remarks A union is used since the varbind can only have one value of one type
172
*/
173
union
{
174
/**
175
* @brief The integer value
176
*/
177
uint32_t
integer
;
178
/**
179
* @brief A struct that contains the string
180
*/
181
struct
{
182
/**
183
* @brief A pointer to the string value from this varbind
184
*
185
* @remarks This pointer points to a string that cannot be changed
186
*/
187
const
char
*
string
;
188
/**
189
* @brief The string length
190
*
191
* @remarks Do not use strlen on the string since it might not be null terminated
192
*/
193
uint32_t
length
;
194
}
string
;
195
/**
196
* @brief The OID value
197
*/
198
snmp_oid_t
oid
;
199
}
value
;
200
}
snmp_varbind_t
;
201
202
/**
203
* @brief The packet struct
204
*
205
*/
206
typedef
struct
{
207
/**
208
* @brief The number of bytes used
209
*
210
*/
211
uint16_t
used
;
212
/**
213
* @brief The maximum number of bytes
214
*
215
*/
216
uint16_t
max
;
217
/**
218
* @brief The pointer used for the incoming packet
219
*
220
*/
221
uint8_t *
in
;
222
/**
223
* @brief The pointer used for the outgoing packet
224
*
225
*/
226
uint8_t *
out
;
227
}
snmp_packet_t
;
228
229
/**
230
* @brief Initializes the SNMP engine
231
*/
232
void
233
snmp_init
();
234
235
/** @}*/
236
237
/** @}*/
238
239
#endif
/* SNMP_H_ */
240
241
/** @} */
242
243
/** @} */
SNMP_MSG_OID_MAX_LEN
#define SNMP_MSG_OID_MAX_LEN
Default maximum number of IDs in one OID.
Definition
snmp-conf.h:86
snmp_oid_t
struct snmp_oid_s snmp_oid_t
The OID struct.
snmp_header_t
struct snmp_header_s snmp_header_t
The SNMP header struct.
snmp_varbind_t
struct snmp_varbind_s snmp_varbind_t
The varbind struct.
snmp_init
void snmp_init()
Initializes the SNMP engine.
Definition
snmp.c:57
value
static int value(int type)
Definition
cc2538-temp-sensor.c:49
log.h
Header file for the logging system.
snmp-conf.h
SNMP Implementation of the configurable macros.
snmp_header_s::snmp_msg_community
Struct to wrap the community.
Definition
snmp.h:101
snmp_header_s::snmp_msg_community::community
const char * community
A pointer to the community.
Definition
snmp.h:107
snmp_header_s::snmp_msg_community::length
uint32_t length
The string length.
Definition
snmp.h:113
snmp_header_s
The SNMP header struct.
Definition
snmp.h:93
snmp_header_s::request_id
uint32_t request_id
The request ID.
Definition
snmp.h:122
snmp_header_s::pdu_type
uint8_t pdu_type
The PDU type.
Definition
snmp.h:118
snmp_header_s::error_index
uint32_t error_index
The error index.
Definition
snmp.h:134
snmp_header_s::max_repetitions
uint32_t max_repetitions
The max repetitions.
Definition
snmp.h:138
snmp_header_s::error_status
uint32_t error_status
The error status.
Definition
snmp.h:126
snmp_header_s::version
uint32_t version
SNMP Version.
Definition
snmp.h:97
snmp_header_s::non_repeaters
uint32_t non_repeaters
The non repeaters.
Definition
snmp.h:130
snmp_oid_s
The OID struct.
Definition
snmp.h:144
snmp_oid_s::length
uint8_t length
The OID length.
Definition
snmp.h:153
snmp_oid_s::data
uint32_t data[16]
The OID.
Definition
snmp.h:148
snmp_packet_t
The packet struct.
Definition
snmp.h:206
snmp_packet_t::in
uint8_t * in
The pointer used for the incoming packet.
Definition
snmp.h:221
snmp_packet_t::out
uint8_t * out
The pointer used for the outgoing packet.
Definition
snmp.h:226
snmp_packet_t::max
uint16_t max
The maximum number of bytes.
Definition
snmp.h:216
snmp_packet_t::used
uint16_t used
The number of bytes used.
Definition
snmp.h:211
snmp_varbind_s
The varbind struct.
Definition
snmp.h:159
snmp_varbind_s::length
uint32_t length
The string length.
Definition
snmp.h:193
snmp_varbind_s::value_type
uint8_t value_type
The type in this varbind.
Definition
snmp.h:167
snmp_varbind_s::oid
snmp_oid_t oid
The OID.
Definition
snmp.h:163
snmp_varbind_s::string
const char * string
A pointer to the string value from this varbind.
Definition
snmp.h:187
snmp_varbind_s::integer
uint32_t integer
The integer value.
Definition
snmp.h:177
os
net
app-layer
snmp
snmp.h
Generated on
for Contiki-NG by
1.17.0