Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
snmp-api.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 public API
36
* \author
37
* Yago Fontoura do Rosario <yago.rosario@hotmail.com.br
38
*/
39
40
/**
41
* \addtogroup snmp
42
* @{
43
*/
44
45
#ifndef SNMP_API_H_
46
#define SNMP_API_H_
47
48
#include "
snmp.h
"
49
#include "
snmp-mib.h
"
50
51
/**
52
* \addtogroup SNMPAPI SNMP Public API
53
* @{
54
*
55
* This group contains all the functions that can be used outside the OS level.
56
*/
57
58
/**
59
* @brief Initializes statically an oid with the "null" terminator
60
*
61
* @remarks This should be used inside handlers when declaring an oid
62
*
63
* @param name A name for the oid
64
* @param ... The Oid (comma-separeted)
65
*/
66
#define OID(name, ...) \
67
static snmp_oid_t name = { \
68
.data = { __VA_ARGS__ }, \
69
.length = (sizeof((uint32_t[]){ __VA_ARGS__ }) / sizeof(uint32_t)) \
70
};
71
72
/**
73
* @brief Declare a MIB resource
74
*
75
* @param name A name for the MIB resource
76
* @param handler The handler function for this resource
77
* @param ... The OID (comma-separated)
78
*/
79
#define MIB_RESOURCE(name, handler, ...) \
80
snmp_mib_resource_t name = { \
81
NULL, \
82
{ \
83
.data = { __VA_ARGS__ }, \
84
.length = (sizeof((uint32_t[]){ __VA_ARGS__ }) / sizeof(uint32_t)) \
85
}, \
86
handler \
87
};
88
89
/**
90
* @brief Function to set a varbind with a string
91
*
92
* This function should be used inside a handler to set the varbind correctly
93
*
94
* @param varbind The varbind from the handler
95
* @param oid The oid from the handler
96
* @param string The string
97
*/
98
void
99
snmp_api_set_string
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid,
char
*
string
);
100
101
/**
102
* @brief Function to set a varbind with a time tick
103
*
104
* This function should be used inside a handler to set the varbind correctly
105
*
106
* @param varbind The varbind from the handler
107
* @param oid The oid from the handler
108
* @param integer The time tick value
109
*/
110
void
111
snmp_api_set_time_ticks
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid, uint32_t integer);
112
113
/**
114
* @brief Function to set a varbind with a oid
115
*
116
* This function should be used inside a handler to set the varbind correctly
117
*
118
* @param varbind The varbind from the handler
119
* @param oid The oid from the handler
120
* @param ret_oid The oid value
121
*/
122
void
123
snmp_api_set_oid
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid,
snmp_oid_t
*ret_oid);
124
125
/**
126
* @brief Function to add a new resource
127
*
128
* @param new_resource The resource
129
*/
130
void
131
snmp_api_add_resource
(
snmp_mib_resource_t
*new_resource);
132
133
/** @}*/
134
135
#endif
/* SNMP_API_H_ */
136
/** @} */
snmp_api_set_string
void snmp_api_set_string(snmp_varbind_t *varbind, snmp_oid_t *oid, char *string)
Function to set a varbind with a string.
Definition
snmp-api.c:49
snmp_api_set_time_ticks
void snmp_api_set_time_ticks(snmp_varbind_t *varbind, snmp_oid_t *oid, uint32_t integer)
Function to set a varbind with a time tick.
Definition
snmp-api.c:58
snmp_api_add_resource
void snmp_api_add_resource(snmp_mib_resource_t *new_resource)
Function to add a new resource.
Definition
snmp-api.c:74
snmp_api_set_oid
void snmp_api_set_oid(snmp_varbind_t *varbind, snmp_oid_t *oid, snmp_oid_t *ret_oid)
Function to set a varbind with a oid.
Definition
snmp-api.c:66
snmp_oid_t
struct snmp_oid_s snmp_oid_t
The OID struct.
snmp_varbind_t
struct snmp_varbind_s snmp_varbind_t
The varbind struct.
snmp_mib_resource_t
struct snmp_mib_resource_s snmp_mib_resource_t
The MIB Resource struct.
snmp-mib.h
SNMP Implementation of the MIB.
snmp.h
SNMP Implementation of the process.
os
net
app-layer
snmp
snmp-api.h
Generated on
for Contiki-NG by
1.17.0