Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
snmp-api.c
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
#include "contiki.h"
41
42
#include "
snmp-api.h
"
43
44
#include "
snmp-message.h
"
45
#include "
snmp-ber.h
"
46
47
/*---------------------------------------------------------------------------*/
48
void
49
snmp_api_set_string
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid,
char
*
string
)
50
{
51
memcpy(&varbind->
oid
, oid,
sizeof
(
snmp_oid_t
));
52
varbind->
value_type
=
BER_DATA_TYPE_OCTET_STRING
;
53
varbind->
value
.
string
.string = string;
54
varbind->
value
.
string
.length = strlen(
string
);
55
}
56
/*---------------------------------------------------------------------------*/
57
void
58
snmp_api_set_time_ticks
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid, uint32_t integer)
59
{
60
memcpy(&varbind->
oid
, oid,
sizeof
(
snmp_oid_t
));
61
varbind->
value_type
=
BER_DATA_TYPE_TIMETICKS
;
62
varbind->
value
.
integer
= integer;
63
}
64
/*---------------------------------------------------------------------------*/
65
void
66
snmp_api_set_oid
(
snmp_varbind_t
*varbind,
snmp_oid_t
*oid,
snmp_oid_t
*ret_oid)
67
{
68
memcpy(&varbind->
oid
, oid,
sizeof
(
snmp_oid_t
));
69
varbind->
value_type
=
BER_DATA_TYPE_OBJECT_IDENTIFIER
;
70
memcpy(&varbind->
value
.
oid
, ret_oid,
sizeof
(
snmp_oid_t
));
71
}
72
/*---------------------------------------------------------------------------*/
73
void
74
snmp_api_add_resource
(
snmp_mib_resource_t
*new_resource)
75
{
76
return
snmp_mib_add
(new_resource);
77
}
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
BER_DATA_TYPE_OBJECT_IDENTIFIER
#define BER_DATA_TYPE_OBJECT_IDENTIFIER
Object Identifier.
Definition
snmp-ber.h:90
BER_DATA_TYPE_TIMETICKS
#define BER_DATA_TYPE_TIMETICKS
TimeTicks.
Definition
snmp-ber.h:102
BER_DATA_TYPE_OCTET_STRING
#define BER_DATA_TYPE_OCTET_STRING
Octet String.
Definition
snmp-ber.h:78
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_add
void snmp_mib_add(snmp_mib_resource_t *new_resource)
Adds a resource into the linked list.
Definition
snmp-mib.c:123
snmp_mib_resource_t
struct snmp_mib_resource_s snmp_mib_resource_t
The MIB Resource struct.
snmp-api.h
SNMP Implementation of the public API.
snmp-ber.h
SNMP Implementation of the BER encoding.
snmp-message.h
SNMP Implementation of the messages.
snmp_varbind_s::value_type
uint8_t value_type
The type in this varbind.
Definition
snmp.h:167
snmp_varbind_s::value
union snmp_varbind_s::@231211044240357072065173253022077057072371074122 value
A union to represent the value in this varbind.
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-api.c
Generated on
for Contiki-NG by
1.17.0