libnsh  0.3
Net-SNMP helper C-library
nsh.h
Go to the documentation of this file.
1 /* libnsh - Net-SNMP helper C-library
2  *
3  * Copyright (c) 2016 Jonas Johansson <jonasj76@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21  * THE SOFTWARE.
22  */
23 
24 #ifndef NSH_H_
25 #define NSH_H_
26 
27 #include "table.h"
28 #include "private.h"
29 #include "deprecated.h"
30 
43 #define nsh_register_scalar_ro(name) \
44  _nsh_register_scalar(name, HANDLER_CAN_RONLY)
45 
58 #define nsh_register_scalar_rw(name) \
59  _nsh_register_scalar(name, HANDLER_CAN_RWRITE)
60 
78 #define nsh_scalar_handler_const(name, type, value) \
79  _nsh_scalar_handler(name, type, 0, NULL, sizeof(long), value, NULL)
80 
101 #define nsh_scalar_handler_ro(name, type, callback, size) \
102  _nsh_scalar_handler(name, type, 0, callback, size, 0, NULL)
103 
122 #define nsh_scalar_str_handler_ro(name, callback, max_length) \
123  _nsh_scalar_handler(name, ASN_OCTET_STR, 0, callback, max_length, 1, NULL)
124 
149 #define nsh_scalar_group_handler_ro(name, type, id, callback, size, isstring) \
150  _nsh_scalar_handler(name, type, id, callback, size, isstring, NULL)
151 
175 #define nsh_scalar_handler_rw(name, type, nsh_get_cb, size, nsh_set_cb) \
176  _nsh_scalar_handler(name, type, 0, nsh_get_cb, size, 0, nsh_set_cb)
177 
196 #define nsh_scalar_str_handler_rw(name, nsh_get_cb, max_length, nsh_set_cb) \
197  _nsh_scalar_handler(name, ASN_OCTET_STR, 0, nsh_get_cb, max_length, 1, nsh_set_cb)
198 
225 #define nsh_scalar_group_handler_rw(name, type, id, nsh_get_cb, size, isstring, nsh_set_cb) \
226  _nsh_scalar_handler(name, type, id, nsh_get_cb, size, isstring, nsh_set_cb)
227 
241 typedef int (*nsh_get_cb)(void *value, int len, int id);
242 
253 typedef int (*nsh_set_cb)(void *value, int id);
254 
270 #define nsh_table(name, get_first_cb, get_next_cb, free_cb, table_data, head, num_table, index_list, num_indexes) \
271  nsh_table_get_next(get_next_cb, table_data, index_list, num_indexes) \
272  nsh_table_get_first(get_first_cb, get_next_cb, head) \
273  nsh_table_free(free_cb, table_data, head) \
274  nsh_table_reg_t name = {.free = free_cb, \
275  .get_first = get_first_cb, \
276  .get_next = get_next_cb, \
277  .idx = index_list, \
278  .num_idx = num_indexes, \
279  .min_column = NSH_DFLT_MIN_COLUMN, \
280  .max_column = num_table, \
281  .timeout = NSH_DFLT_TIMEOUT, \
282  };
283 
284 #endif /* NSH_H_ */
285 
int(* nsh_set_cb)(void *value, int id)
Definition: nsh.h:253
int(* nsh_get_cb)(void *value, int len, int id)
Definition: nsh.h:241