summaryrefslogtreecommitdiff
path: root/local/mib2c-conf.d/node-get.m2i
blob: 96ee8e43926f6bc317586ca5b410f6374abb73cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#############################################################  -*- c -*-
## generic include for XXX. Do not use directly.
##
## $Id: node-get.m2i 12704 2005-08-30 00:38:54Z rstory $
########################################################################
@if $m2c_mark_boundary == 1@
/** START code generated by $RCSfile$ $Revision: 12704 $ */
@end@
########################################################################
##
@include m2c_setup_node.m2i@
@eval $m2c_node_realloc = 2@ // malloc
/**
 * Extract the current value of the $node data.
 *
 * Set a value using the data context for the row.
 *
@if $m2c_node_get_comments ne ""@
$m2c_node_get_comments
*
@end@
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param $m2c_node_param_ref_name
 *        Pointer to storage for a $node.decl variable
@if $m2c_node_needlength == 1@
 * @param $m2c_node_param_ref_lname
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by $node.
 *        On exit, this value should contain the data size (in bytes).
@end@
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
@if $m2c_node_needlength == 1@
*
 * @note If you need more than (*$m2c_node_param_ref_lname) bytes of memory,
 *       allocate it using malloc() and update $m2c_node_param_ref_name.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
@end@
 */
int
${node}_get( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_ref )
{
@ifconf syntax-$node.syntax-get.m2i@
@    include syntax-$node.syntax-get.m2i@
@else@
@    include generic-get-decl.m2i@

    DEBUGMSGTL(("verbose:${context}:${node}_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

/*
 * TODO:231:o: |-> Extract the current value of the $node data.
@if $m2c_node_needlength == 0@
 * copy $m2c_node_lh from $m2c_data_item_base
@else@
 * copy $m2c_node_lh data and $m2c_node_lhs from $m2c_data_item_base
@end@
 */
@    if ("$m2c_data_context" eq "generated") && ($m2c_node_skip_get != 1)@
@        include generic-ctx-get.m2i@
@    else@
@       if ($m2c_node_skip_get != 1)@
 /*
  * TODO:235:M: |-> Remove log message/SKIP once you've set $node data
  */
    snmp_log(LOG_ERR,"${context} node $node not implemented: skipping\n");
@       end@
    return MFD_SKIP;
@    end@
##   ------------------------------------------------------------------
@    if $node.decl =~ /long/i@ #   ASN_INTEGER ASN_COUNTER ASN_GAUGE
@       include generic-get-long.m2i@
@    elsif $node.decl =~ /char/i@ #         ASN_OCTET_STR ASN_OPAQUE
@       include generic-get-char.m2i@
@    elsif $node.decl =~ /oid/i@ #                    ASN_OBJECT_ID
@       include generic-get-oid.m2i@
@    elsif $node.decl =~ /U64/i@ #                    ASN_COUNTER64
@       include generic-get-U64.m2i@
@    else@
@        print ERROR: unknown node.decl: $node.decl@
@        exit@
@    end@
##   ------------------------------------------------------------------
@    if ($m2c_node_skip_mapping != 1) && ("$m2c_data_context" ne "generated")@
@        include generic-value-map.m2i@
@    end@
@    include generic-get-decl-bot.m2i@  // copy value out
@end@ # no syntax include

    return MFD_SUCCESS;
} /* ${node}_get */

##
########################################################################
@if $m2c_mark_boundary == 1@
/** END code generated by $RCSfile$ $Revision: 12704 $ */
@end@