yumapro  20.10-12
YumaPro SDK
agt_ypsnmp_util.h
Go to the documentation of this file.
1 /*****************************************************************************
2 Various copyrights apply to this package, listed in various separate
3 parts below. Please make sure that you read all the parts.
4 
5 ---- Part 1: Sparta, Inc (BSD) -----
6 
7 Copyright (c) 2003-2010, Sparta, Inc
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 
13 * Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15 
16 * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19 
20 * Neither the name of Sparta, Inc nor the names of its contributors may
21  be used to endorse or promote products derived from this software
22  without specific prior written permission.
23 
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
25 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
28 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
31 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36 ---- Part 2: ScienceLogic, LLC (BSD) ----
37 
38 Copyright (c) 2006, ScienceLogic, LLC
39 All rights reserved.
40 
41 Redistribution and use in source and binary forms, with or without
42 modification, are permitted provided that the following conditions are
43 met:
44 
45 * Redistributions of source code must retain the above copyright notice,
46  this list of conditions and the following disclaimer.
47 
48 * Redistributions in binary form must reproduce the above copyright
49  notice, this list of conditions and the following disclaimer in the
50  documentation and/or other materials provided with the distribution.
51 
52 * Neither the name of ScienceLogic, LLC nor the names of its
53  contributors may be used to endorse or promote products derived
54  from this software without specific prior written permission.
55 
56 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
57 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
59 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
60 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
61 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
62 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
63 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
64 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
65 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
66 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
67 DAMAGE.
68 *************************************************************************/
69 
70 
71 /*************************************************************************
72  OVERVIEW
73 
74  This module implements Utility Functions for YP SNMP
75 
76 *************************************************************************/
77 
78 
79 /*
80  * Copyright (c) 2017 - 2020, YumaWorks. Inc., All Rights Reserved.
81  *
82  * Unless required by applicable law or agreed to in writing,
83  * software distributed under the License is distributed on an
84  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
85  * KIND, either express or implied. See the License for the
86  * specific language governing permissions and limitations
87  * under the License.
88  */
89 
90 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
91 #ifndef _H_agt_ypsnmp_util
92 #define _H_agt_ypsnmp_util
93 
94 /* FILE: agt_ypsnmp_util.h
95 *********************************************************************
96 * *
97 * P U R P O S E *
98 * *
99 *********************************************************************/
100 
107 /*********************************************************************
108 * *
109 * C H A N G E H I S T O R Y *
110 * *
111 *********************************************************************
112 
113 date init comment
114 ----------------------------------------------------------------------
115 10May17 am begun;
116 
117 */
118 
119 #ifndef _H_status_enum
120 #include "status_enum.h"
121 #endif
122 
123 #ifndef _H_yangapi
124 #include "yangapi.h"
125 #endif
126 
127 #ifdef __cplusplus
128 extern "C" {
129 #endif
130 
131 /********************************************************************
132 * *
133 * C O N S T A N T S *
134 * *
135 *********************************************************************/
136 
137 #define YPSNMP_TYPE_GAUGE32 (const xmlChar *)"gauge32"
138 #define YPSNMP_TYPE_GAUGE64 (const xmlChar *)"gauge64"
139 #define YPSNMP_TYPE_PHYS_ADDR (const xmlChar *)"phys-address"
140 #define YPSNMP_TYPE_TIMETICKS (const xmlChar *)"timeticks"
141 #define YPSNMP_TYPE_TIMESTAMP (const xmlChar *)"timestamp"
142 #define YPSNMP_TYPE_COUNTER32 (const xmlChar *)"counter32"
143 #define YPSNMP_TYPE_ZBCOUNTER32 (const xmlChar *)"zero-based-counter32"
144 #define YPSNMP_TYPE_COUNTER64 (const xmlChar *)"counter64"
145 #define YPSNMP_TYPE_ZBCOUNTER64 (const xmlChar *)"zero-based-counter64"
146 #define YPSNMP_TYPE_OID128 (const xmlChar *)"object-identifier-128"
147 
148 #define YPSNMP_APP_NAME (const char *)"snmpd"
149 
150 
151 /* max number of cache_entry_t in snmp_cacheQ */
152 #define MAX_SNMP_CACHE_SIZE 32
153 #define ADDR_BUFLEN 128
154 
155 /* mac address */
156 #define YPSNMP_PHYS_ADDR_LEN 6
157 
158 /* work around for the way fd_set is accessed in
159  * net-snmp/include/net-snmp/library/large_fd_set.h
160  */
161 #define fds_bits __fds_bits
162 
163  /*
164  * Definitions for Agent Extensibility Protocol (RFC 2257)
165  *
166  */
167 
168 /* currently only TCP endpoint is available
169  UDP is not working for AgentX protocol, the master cannot
170  trasfer packets via UDP.
171  The AgentX default socket is /var/agentx/master which
172  has to be changed to TCP type socket!!!!!! (tcp:localhost:705)
173 
174 */
175 #define YPSNMP_AGENTX_SOCKET (const char *)"tcp:localhost:705"
176 #define YPSNMP_AGENTX_NAME (const char *)"agentx"
177 
178  /*
179  * AgentX versions
180  */
181  /*
182  * Use values distinct from those used to represent SNMP versions
183  */
184 
185 #define AGENTX_VERSION_BASE 192 /* Binary: 11xxxxxx */
186 #define AGENTX_VERSION_1 (AGENTX_VERSION_BASE | 0x1)
187 
188 #define IS_AGENTX_VERSION(v) (((v)&AGENTX_VERSION_BASE) == AGENTX_VERSION_BASE)
189 
190  /*
191  * PDU types in AgentX
192  */
193 #define AGENTX_MSG_OPEN ((u_char)1)
194 #define AGENTX_MSG_CLOSE ((u_char)2)
195 #define AGENTX_MSG_REGISTER ((u_char)3)
196 #define AGENTX_MSG_UNREGISTER ((u_char)4)
197 #define AGENTX_MSG_GET ((u_char)5)
198 #define AGENTX_MSG_GETNEXT ((u_char)6)
199 #define AGENTX_MSG_GETBULK ((u_char)7)
200 #define AGENTX_MSG_TESTSET ((u_char)8)
201 #define AGENTX_MSG_COMMITSET ((u_char)9)
202 #define AGENTX_MSG_UNDOSET ((u_char)10)
203 #define AGENTX_MSG_CLEANUPSET ((u_char)11)
204 #define AGENTX_MSG_NOTIFY ((u_char)12)
205 #define AGENTX_MSG_PING ((u_char)13)
206 #define AGENTX_MSG_INDEX_ALLOCATE ((u_char)14)
207 #define AGENTX_MSG_INDEX_DEALLOCATE ((u_char)15)
208 #define AGENTX_MSG_ADD_AGENT_CAPS ((u_char)16)
209 #define AGENTX_MSG_REMOVE_AGENT_CAPS ((u_char)17)
210 #define AGENTX_MSG_RESPONSE ((u_char)18)
211 
212  /*
213  * Error codes from RFC 2257
214  */
215 #define AGENTX_ERR_OPEN_FAILED (256)
216 #define AGENTX_ERR_NOT_OPEN (257)
217 #define AGENTX_ERR_INDEX_WRONG_TYPE (258)
218 #define AGENTX_ERR_INDEX_ALREADY_ALLOCATED (259)
219 #define AGENTX_ERR_INDEX_NONE_AVAILABLE (260)
220 #define AGENTX_ERR_INDEX_NOT_ALLOCATED (261)
221 #define AGENTX_ERR_UNSUPPORTED_CONTEXT (262)
222 #define AGENTX_ERR_DUPLICATE_REGISTRATION (263)
223 #define AGENTX_ERR_UNKNOWN_REGISTRATION (264)
224 #define AGENTX_ERR_UNKNOWN_AGENTCAPS (265)
225 
226  /*
227  * added in 1999 revision
228  */
229 #define AGENTX_ERR_NOERROR SNMP_ERR_NOERROR
230 #define AGENTX_ERR_PARSE_FAILED (266)
231 #define AGENTX_ERR_REQUEST_DENIED (267)
232 #define AGENTX_ERR_PROCESSING_ERROR (268)
233 
234  /*
235  * Message processing models
236  */
237 #define AGENTX_MP_MODEL_AGENTXv1 (257)
238 
239 
240  /*
241  * PDU Flags
242  */
243 #define AGENTX_MSG_FLAG_INSTANCE_REGISTER 0x01
244 #define AGENTX_MSG_FLAG_NEW_INSTANCE 0x02
245 #define AGENTX_MSG_FLAG_ANY_INSTANCE 0x04
246 #define AGENTX_MSG_FLAG_NON_DEFAULT_CONTEXT 0x08
247 #define AGENTX_MSG_FLAG_NETWORK_BYTE_ORDER 0x10
248 
249 #define AGENTX_MSG_FLAGS_MASK 0xff
250 
251  /*
252  * Session Flags
253  */
254 #define AGENTX_FLAGS_NETWORK_BYTE_ORDER AGENTX_MSG_FLAG_NETWORK_BYTE_ORDER
255 
256 
257 /********************************************************************
258 * *
259 * T Y P E S *
260 * *
261 *********************************************************************/
262 
279 
282 
285 
288 
291 
294 } ypsnmp_getnext_mode_t;
295 
296 
298 typedef struct agent_nsap_t_ {
299 
301  int handle;
302 
304  netsnmp_transport *transport;
305 
307  void *opaque_ses;
308 
311 } agent_nsap_t;
312 
313 
315 typedef struct ypsnmp_agent_session_t_ {
317  int mode;
318 
320  netsnmp_session *session;
321 
323  netsnmp_pdu *pdu;
324 
326  int rw;
327 
329  int exact;
330 
332  int status;
333 
335  int index;
336 
338  int oldmode;
339 
341  int vbcount;
342 
345 
346 } ypsnmp_agent_session_t;
347 
348 
349 /********************************************************************
350 * *
351 * F U N C T I O N S *
352 * *
353 *********************************************************************/
354 
355 
376 extern val_value_t *
377  agt_ypsnmp_bestmatch_next_index (yangapi_cb_t *rcb);
378 
379 
388 extern val_value_t *
389  agt_ypsnmp_get_first_getnextlist (yangapi_cb_t *rcb);
390 
391 
400 extern val_value_t *
401  agt_ypsnmp_get_next_getnextlist (val_value_t *list);
402 
403 
414 extern boolean
415  agt_ypsnmp_match_obj (obj_template_t *targetobj,
416  obj_template_t *curobj);
417 
418 
429 extern boolean
430  agt_ypsnmp_match_index (yangapi_cb_t *rcb,
431  val_value_t *keyval);
432 
433 
447 extern obj_template_t *
448  agt_ypsnmp_get_table_obj (obj_template_t *obj);
449 
450 
464 extern obj_template_t *
465  agt_ypsnmp_get_parent_obj (obj_template_t *obj);
466 
467 
477 extern boolean
478  agt_ypsnmp_is_scalar_obj (obj_template_t *curobj);
479 
480 
491 extern boolean
492  agt_ypsnmp_is_augmented_obj (obj_template_t *curobj);
493 
494 
504 extern xmlChar *
505  agt_ypsnmp_convert_physaddr (val_value_t *val);
506 
507 
523 extern netsnmp_variable_list *
524  agt_ypsnmp_create_snmp_varbind_object (const oid *name,
525  size_t name_length,
526  u_char type,
527  const void *value,
528  size_t len);
529 
530 
540 extern void
541  agt_ypsnmp_append_varbind_to_list (netsnmp_variable_list **list,
542  netsnmp_variable_list *var);
543 
544 
554 extern obj_oid_t *
555  agt_ypsnmp_convert_varbind_to_oid (netsnmp_variable_list *var_ptr);
556 
557 
573 extern status_t
574  agt_ypsnmp_set_varbind (ses_cb_t *scb,
575  netsnmp_pdu *pdu,
576  val_value_t *val,
577  const obj_oid_t *oid_obj);
578 
579 
589 extern status_t
590  agt_ypsnmp_setup_peeraddr (ses_cb_t *scb,
591  netsnmp_pdu *pdu);
592 
593 
602 extern yangapi_method_t
603  agt_ypsnmp_get_yangapi_method (uint8 msg_code);
604 
605 
615 extern xmlChar *
616  agt_ypsnmp_make_restconf_uri (obj_template_t *obj);
617 
618 
626 extern void
627  agt_ypsnmp_log_pdu (netsnmp_pdu *pdu);
628 
629 
638 extern const void *
639  agt_ypsnmp_get_varbind_value (netsnmp_variable_list *var);
640 
641 
650 extern const xmlChar *
651  agt_ypsnmp_get_getnext_modename (ypsnmp_getnext_mode_t getnextmode);
652 
653 
663 extern obj_oid_t *
664  agt_ypsnmp_get_index_oid (obj_oid_t *full_oid,
665  uint32 index_length);
666 
667 
681 extern status_t
682  agt_ypsnmp_convert_oid2chars (xmlChar *str,
683  uint32 len,
684  const oid_t *useoid);
685 
686 
701 extern status_t
702  agt_ypsnmp_convert_str_oid2str (xmlChar *str,
703  uint32 len,
704  oid_t *useoid);
705 
706 
720 extern status_t
721  agt_ypsnmp_convert_str2oid (const xmlChar *str,
722  oid_t *useoid,
723  uint32 len);
724 
725 
783 extern status_t
784  agt_ypsnmp_indexoid_to_value (yangapi_cb_t *rcb,
785  obj_template_t *obj,
786  uint32 index_length);
787 
788 
801 extern status_t
802  agt_ypsnmp_value_to_indexoid (yangapi_cb_t *rcb,
803  val_value_t *list);
804 
805 
815 extern ypsnmp_agent_session_t *
816  agt_ypsnmp_init_agent_session (netsnmp_session * session,
817  netsnmp_pdu *pdu);
818 
819 
827 extern void
828  agt_ypsnmp_free_agent_session (ypsnmp_agent_session_t *asp);
829 
830 
838 extern void free_varbind (netsnmp_variable_list *var);
839 
840 
850 void free_varbind_yp (netsnmp_variable_list *var);
851 
852 
856 #ifdef __cplusplus
857 } /* end extern 'C' */
858 #endif
859 
860 #endif // _H_agt_ypsnmp_util
861 #endif // defined(WITH_SNMP) && defined(WITH_RESTCONF)
typ_get_basetype
ncx_btype_t typ_get_basetype(const typ_def_t *typdef)
Get the final base type of the specified typ_def_t.
Definition: typ.c:1764
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
agt_ypsnmp.h
Yuma Interface to net-snmp data structures. Agent interface.
smioid_new_object_oid_ex
obj_oid_t * smioid_new_object_oid_ex(oid_t *name, uint32 oid_len, uint32 start_pos)
Malloc and init a new obj_oid_t control block.
Definition: smioid_tree.c:317
VAL_ENUM
#define VAL_ENUM(V)
Access the enum value in the value ONLY if BCX_NT_ENUM.
Definition: val.h:429
agt_ypsnmp_convert_str2oid
status_t agt_ypsnmp_convert_str2oid(const xmlChar *str, oid_t *useoid, uint32 len)
Converts a string to its OID form.
Definition: agt_ypsnmp_util.c:1923
NCX_BT_INT32
@ NCX_BT_INT32
int32
Definition: ncxtypes.h:209
ERR_GENERAL_ERR
@ ERR_GENERAL_ERR
018 – used by the C++ API
Definition: status_enum.h:208
xml_strncpy
uint32 xml_strncpy(xmlChar *copyTo, const xmlChar *copyFrom, uint32 maxlen)
String copy for xmlChar – checks for buffer overflow.
Definition: xml_util.c:1518
agt_restconf.h
IETF RESTCONF Protocol Message Handler.
NCX_BT_BINARY
@ NCX_BT_BINARY
binary (base64)
Definition: ncxtypes.h:218
agt_ses.h
Server Session Management.
obj_get_typdef
typ_def_t * obj_get_typdef(obj_template_t *obj)
Get the typdef for the leaf or leaf-list.
Definition: obj.c:11991
ERR_NCX_MISSING_INDEX
@ ERR_NCX_MISSING_INDEX
306
Definition: status_enum.h:349
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
typ_get_named_typename
const xmlChar * typ_get_named_typename(const typ_def_t *typdef)
Get the type name of the named typ.
Definition: typ.c:578
agt_ypsnmp_free_agent_session
void agt_ypsnmp_free_agent_session(ypsnmp_agent_session_t *asp)
free the ypsnmp session and deallocate any associated memory
Definition: agt_ypsnmp_util.c:2612
VAL_STRING
#define VAL_STRING(V)
Access the value as a string ONLY if typ_is_string(typdef) is true.
Definition: val.h:414
val_find_enum_name2
const xmlChar * val_find_enum_name2(ncx_btype_t btyp, typ_def_t *typdef, int32 enunum)
Find the specified enum name for the value field that matches for NCX_BT_ENUM value Do not use val_va...
Definition: val.c:14545
ypsnmp_agent_session_t_::pdu
netsnmp_pdu * pdu
PDU pointer.
Definition: agt_ypsnmp_util.h:323
smioid_new_object_oid
obj_oid_t * smioid_new_object_oid(void)
Malloc and init a new obj_oid_t control block.
Definition: smioid_tree.c:288
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
NCX_CL_REF
@ NCX_CL_REF
internal reference to another type
Definition: ncxtypes.h:248
NCX_BT_BOOLEAN
@ NCX_BT_BOOLEAN
boolean
Definition: ncxtypes.h:206
val.h
Value Node Basic Support.
NCX_BT_INSTANCE_ID
@ NCX_BT_INSTANCE_ID
instance-identifier
Definition: ncxtypes.h:219
ypsnmp_agent_session_t_::status
int status
status flag
Definition: agt_ypsnmp_util.h:332
ypsnmp_agent_session_t_::vbcount
int vbcount
varbind count
Definition: agt_ypsnmp_util.h:341
ypsnmp_agent_session_t_::rw
int rw
RW flag.
Definition: agt_ypsnmp_util.h:326
val_make_simval_obj
val_value_t * val_make_simval_obj(obj_template_t *obj, const xmlChar *valstr, status_t *res)
Create and set a val_value_t as a simple type from an object template instead of individual fields Ca...
Definition: val_util.c:4389
VAL_UINT32
#define VAL_UINT32(V)
Access the value as an uint32 ONLY if NCX_BT_UINT32.
Definition: val.h:497
agt_ypsnmp_create_snmp_varbind_object
netsnmp_variable_list * agt_ypsnmp_create_snmp_varbind_object(const oid *name, size_t name_length, u_char type, const void *value, size_t len)
Allocates and creates a new netsnmp variable binding object.
Definition: agt_ypsnmp_util.c:1051
agt_ypsnmp_get_varbind_value
const void * agt_ypsnmp_get_varbind_value(netsnmp_variable_list *var)
Get the Varbind value.
Definition: agt_ypsnmp_util.c:1702
obj_next_key
obj_key_t * obj_next_key(obj_key_t *objkey)
Get the next key record.
Definition: obj.c:9559
status_enum.h
global error status code enumerations
obj_first_key
obj_key_t * obj_first_key(obj_template_t *obj)
Get the first key record.
Definition: obj.c:9472
agt_ypsnmp_convert_varbind_to_oid
obj_oid_t * agt_ypsnmp_convert_varbind_to_oid(netsnmp_variable_list *var_ptr)
Converts an SNMP OID string into an internal object.
Definition: agt_ypsnmp_util.c:1147
free_varbind_yp
void free_varbind_yp(netsnmp_variable_list *var)
Frees the variable and any malloc'd data associated with it.
Definition: agt_ypsnmp_util.c:2678
NCX_BT_LEAFREF
@ NCX_BT_LEAFREF
leafref (needs special processing)
Definition: ncxtypes.h:221
agt_ypsnmp_get_index_oid
obj_oid_t * agt_ypsnmp_get_index_oid(obj_oid_t *full_oid, uint32 index_length)
parse requested OID and strip out index OID
Definition: agt_ypsnmp_util.c:1784
ERR_TOO_MANY_ENTRIES
@ ERR_TOO_MANY_ENTRIES
012
Definition: status_enum.h:202
ypsnmp_agent_session_t_::index
int index
index flag
Definition: agt_ypsnmp_util.h:335
agt_ncxserver.h
NCX Server Transport and IO Library.
VAL_UINT16
#define VAL_UINT16(V)
Access the value as an uint16 ONLY if NCX_BT_UINT16.
Definition: val.h:491
val_compare
int32 val_compare(const val_value_t *val1, const val_value_t *val2)
Compare 2 val_value_t struct value contents.
Definition: val.c:9456
obj_is_key
boolean obj_is_key(const obj_template_t *obj)
Check if object is being used as a key leaf within a list.
Definition: obj.c:14278
agent_nsap_t_::transport
netsnmp_transport * transport
transport info
Definition: agt_ypsnmp_util.h:304
agent_nsap_t_::opaque_ses
void * opaque_ses
Opaque internal session pointer.
Definition: agt_ypsnmp_util.h:307
agent_nsap_t_::handle
int handle
handle
Definition: agt_ypsnmp_util.h:301
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
agt_not.h
NETCONF Notifications DM module support.
agt_ypsnmp_get_parent_obj
obj_template_t * agt_ypsnmp_get_parent_obj(obj_template_t *obj)
Find the complex parent of the current leaf object.
Definition: agt_ypsnmp_util.c:892
ypsnmp_agent_session_t_::mode
int mode
session mode
Definition: agt_ypsnmp_util.h:317
ses_msg.h
NETCONF Session Message Common definitions module.
NCX_BT_UINT8
@ NCX_BT_UINT8
uint8
Definition: ncxtypes.h:211
obj_is_list
boolean obj_is_list(const obj_template_t *obj)
Check if object is a YANG list.
Definition: obj.c:13349
VAL_TYPDEF
#define VAL_TYPDEF(V)
Access the typedef (simple types only)
Definition: val.h:393
smioid_free_object_oid
void smioid_free_object_oid(obj_oid_t *oid)
Clean and free a malloced get2 control block.
Definition: smioid_tree.c:358
NCX_BT_ENUM
@ NCX_BT_ENUM
enumeration
Definition: ncxtypes.h:204
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
NCX_BT_LIST
@ NCX_BT_LIST
internal, YANG list
Definition: ncxtypes.h:228
agt_ypsnmp_get_getnext_modename
const xmlChar * agt_ypsnmp_get_getnext_modename(ypsnmp_getnext_mode_t getnextmode)
Get the getnext mode name from its enum.
Definition: agt_ypsnmp_util.c:1744
val_convert_leafref
val_value_t * val_convert_leafref(const val_value_t *val)
Convert a value of type NCX_BT_LEAFREF to the value that the final leafref is pointing at.
Definition: val.c:14761
NCX_CL_SIMPLE
@ NCX_CL_SIMPLE
a restriction of a base type
Definition: ncxtypes.h:245
YPSNMP_MODE_SCAL_INDEXED
@ YPSNMP_MODE_SCAL_INDEXED
scal indexed
Definition: agt_ypsnmp_util.h:294
NCX_BT_UINT64
@ NCX_BT_UINT64
uint64
Definition: ncxtypes.h:214
agt_ypsnmp_bestmatch_next_index
val_value_t * agt_ypsnmp_bestmatch_next_index(yangapi_cb_t *rcb)
Find the next best matching list entry in the Queue.
Definition: agt_ypsnmp_util.c:601
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
VAL_INT64
#define VAL_INT64(V)
Access the value as an int64 ONLY if NCX_BT_INT64.
Definition: val.h:461
VAL_INT16
#define VAL_INT16(V)
Access the value as an int16 ONLY if NCX_BT_INT16.
Definition: val.h:452
val_gen_index_chain
status_t val_gen_index_chain(const obj_template_t *obj, val_value_t *val)
Create an index chain for the just-parsed table or container struct.
Definition: val_util.c:2632
agt_ypsnmp_value_to_indexoid
status_t agt_ypsnmp_value_to_indexoid(yangapi_cb_t *rcb, val_value_t *list)
Converts val_value list with keys into index OID.
Definition: agt_ypsnmp_util.c:2282
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
val_child_next
val_value_t * val_child_next(const val_value_t *curchild)
Get the next child present for the current node Parent must be set.
Definition: val_child.c:2326
val_child_add
status_t val_child_add(val_value_t *child, val_value_t *parent)
Add a child value node to a parent value node.
Definition: val_child.c:1542
val_util.h
Value Node Utilities.
typ_get_name
const xmlChar * typ_get_name(const typ_def_t *typdef)
Get the name for the specified typdef.
Definition: typ.c:1871
smioid_concat_object_oid
obj_oid_t * smioid_concat_object_oid(oid_t *name1, uint32 oid_len1, oid_t *name2, uint32 oid_len2)
Concatenate 2 OIDs into one OID.
Definition: smioid_tree.c:885
NCX_BT_INT64
@ NCX_BT_INT64
int64
Definition: ncxtypes.h:210
YPSNMP_MODE_SCAL_NOINDEX
@ YPSNMP_MODE_SCAL_NOINDEX
scal no index
Definition: agt_ypsnmp_util.h:291
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
obj_gen_object_id_oid
status_t obj_gen_object_id_oid(ncx_module_t *mod, const obj_template_t *obj, xmlChar **buff)
Malloc and Generate the object ID for an object node Used for canonical ID string comparison to gener...
Definition: obj.c:10085
NCX_BT_EMPTY
@ NCX_BT_EMPTY
empty
Definition: ncxtypes.h:205
NCX_BT_UINT16
@ NCX_BT_UINT16
uint16
Definition: ncxtypes.h:212
agent_nsap_t_::next
struct agent_nsap_t_ * next
next entry
Definition: agt_ypsnmp_util.h:310
YPSNMP_MODE_COMPLEX
@ YPSNMP_MODE_COMPLEX
complex
Definition: agt_ypsnmp_util.h:297
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ypsnmp_getnext_mode_t_
ypsnmp_getnext_mode_t_
There are several possible requests that can be sent to the netconfd SNMP server:
Definition: agt_ypsnmp_util.h:276
val_clone
val_value_t * val_clone(const val_value_t *val)
Clone a specified val_value_t struct and sub-trees.
Definition: val.c:7836
val_child.h
Value Node Child Access Support.
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
ypsnmp_agent_session_t_::exact
int exact
exact flag
Definition: agt_ypsnmp_util.h:329
VAL_INT8
#define VAL_INT8(V)
Access the value as an int8 ONLY if NCX_BT_INT8.
Definition: val.h:446
smioid_extract_integers
boolean smioid_extract_integers(const xmlChar *oid, obj_oid_t *oid_obj)
Split SMI oid string into integers using '.
Definition: smioid_tree.c:209
oid_t
unsigned long oid_t
data type used in SNMP
Definition: obj.h:1037
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
agt.h
Multi-Protocol Network Management Server.
VAL_INT32
#define VAL_INT32(V)
Access the value as an int32 ONLY if NCX_BT_INT32.
Definition: val.h:458
VAL_UINT64
#define VAL_UINT64(V)
Access the value as an uint64 ONLY if NCX_BT_UINT64.
Definition: val.h:503
YANGAPI_METHOD_NONE
@ YANGAPI_METHOD_NONE
not set
Definition: yangapi.h:116
agt_ypsnmp_init_agent_session
ypsnmp_agent_session_t * agt_ypsnmp_init_agent_session(netsnmp_session *session, netsnmp_pdu *pdu)
Allocate new ypsnmp session context.
Definition: agt_ypsnmp_util.c:2574
obj_is_container
boolean obj_is_container(const obj_template_t *obj)
Check if object is a YANG container.
Definition: obj.c:13405
typ_get_xref_typdef
typ_def_t * typ_get_xref_typdef(typ_def_t *typdef)
Get the xrefdef target typdef from a leafref or instance-identifier.
Definition: typ.c:5009
VAL_UINT
#define VAL_UINT(V)
Access the value as an uint32 ONLY if NCX_BT_UINT8, 16, 32.
Definition: val.h:482
smioid_dup_object_oid
obj_oid_t * smioid_dup_object_oid(obj_oid_t *copyfrom)
Duplicate OID.
Definition: smioid_tree.c:940
agt_ypsnmp_sec.h
Defines the SNMP security and authentication for incoming snmp requests and notifications.
obj_get_mod_name
const xmlChar * obj_get_mod_name(const obj_template_t *obj)
Get the module name for this object.
Definition: obj.c:12176
NCX_BT_SLIST
@ NCX_BT_SLIST
ncx:xsdlist extension (internal, deprecated)
Definition: ncxtypes.h:223
agt_ypsnmp_is_augmented_obj
boolean agt_ypsnmp_is_augmented_obj(obj_template_t *curobj)
Check if the object is an augmented object.
Definition: agt_ypsnmp_util.c:966
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
agt_ypsnmp_util.h
Utility Functions for YP SNMP.
agt_ypsnmp_is_scalar_obj
boolean agt_ypsnmp_is_scalar_obj(obj_template_t *curobj)
Check if the object is a scalar object.
Definition: agt_ypsnmp_util.c:935
agt_ypsnmp_convert_str_oid2str
status_t agt_ypsnmp_convert_str_oid2str(xmlChar *str, uint32 len, oid_t *useoid)
Converts a string OID to its string form.
Definition: agt_ypsnmp_util.c:1882
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
VAL_BOOL
#define VAL_BOOL(V)
Access the value as a boolean ONLY IF btyp == NCX_BT_BOOLEAN.
Definition: val.h:405
agt_ypsnmp_get_yangapi_method
yangapi_method_t agt_ypsnmp_get_yangapi_method(uint8 msg_code)
Get the YANGAPI method from the SNMP method.
Definition: agt_ypsnmp_util.c:1668
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
YANGAPI_METHOD_POST
@ YANGAPI_METHOD_POST
POST method.
Definition: yangapi.h:120
ERR_BUFF_OVFL
@ ERR_BUFF_OVFL
106
Definition: status_enum.h:218
val_child_first
val_value_t * val_child_first(const val_value_t *parent)
Get the first child present for this parent.
Definition: val_child.c:2294
obj_is_leaf
boolean obj_is_leaf(const obj_template_t *obj)
Check if object is a proper leaf.
Definition: obj.c:13323
agt_ypsnmp_append_varbind_to_list
void agt_ypsnmp_append_varbind_to_list(netsnmp_variable_list **list, netsnmp_variable_list *var)
Adds the given netsnmp variable binding object to the end of the list of given pdu.
Definition: agt_ypsnmp_util.c:1114
ERR_NCX_VALUE_NOT_SUPPORTED
@ ERR_NCX_VALUE_NOT_SUPPORTED
358
Definition: status_enum.h:401
obj_is_augment
boolean obj_is_augment(const obj_template_t *obj)
Check if the obj is an augment statement.
Definition: obj.c:13703
agt_ypsnmp_match_index
boolean agt_ypsnmp_match_index(yangapi_cb_t *rcb, val_value_t *keyval)
Checks if the current index in the walker is the target index for the request.
Definition: agt_ypsnmp_util.c:809
free_varbind
void free_varbind(netsnmp_variable_list *var)
Frees the variable and any malloc'd data associated with it.
Definition: agt_ypsnmp_util.c:2639
agt_ypsnmp_set_varbind
status_t agt_ypsnmp_set_varbind(ses_cb_t *scb, netsnmp_pdu *pdu, val_value_t *val, const obj_oid_t *oid_obj)
Set the return Varbind based on the found value.
Definition: agt_ypsnmp_util.c:1194
YANGAPI_METHOD_GET
@ YANGAPI_METHOD_GET
GET method.
Definition: yangapi.h:119
YPSNMP_MODE_TAB_INDEXED
@ YPSNMP_MODE_TAB_INDEXED
table indexed
Definition: agt_ypsnmp_util.h:288
NCX_BT_BITS
@ NCX_BT_BITS
bits
Definition: ncxtypes.h:203
NCX_BT_FLOAT64
@ NCX_BT_FLOAT64
hidden: just for XPath
Definition: ncxtypes.h:216
NCX_BT_UINT32
@ NCX_BT_UINT32
uint32
Definition: ncxtypes.h:213
agt_ypsnmp_convert_oid2chars
status_t agt_ypsnmp_convert_oid2chars(xmlChar *str, uint32 len, const oid_t *useoid)
Converts an OID to its character form.
Definition: agt_ypsnmp_util.c:1831
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
agent_nsap_t_
NSAP for the agent.
Definition: agt_ypsnmp_util.h:298
obj_get_basetype
ncx_btype_t obj_get_basetype(const obj_template_t *obj)
Get the NCX base type enum for the object type.
Definition: obj.c:12077
VAL_BTYPE
#define VAL_BTYPE(V)
Access the base type : same as VAL_TYPE.
Definition: val.h:548
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
ncx.h
YANG module utility functions.
agt_ypsnmp_get_table_obj
obj_template_t * agt_ypsnmp_get_table_obj(obj_template_t *obj)
Find the Table object of the current object.
Definition: agt_ypsnmp_util.c:846
YPSNMP_MODE_NONE
@ YPSNMP_MODE_NONE
not set
Definition: agt_ypsnmp_util.h:282
VAL_INT
#define VAL_INT(V)
Access the value as an int ONLY if NCX_BT_INT8, 16, 32.
Definition: val.h:443
agt_ypsnmp_get_first_getnextlist
val_value_t * agt_ypsnmp_get_first_getnextlist(yangapi_cb_t *rcb)
Get the first list val_value structure in getnext_listQ.
Definition: agt_ypsnmp_util.c:712
agt_ypsnmp_not.h
Defines and implements SNMP notification and trap handling.
agt_ypsnmp_indexoid_to_value
status_t agt_ypsnmp_indexoid_to_value(yangapi_cb_t *rcb, obj_template_t *obj, uint32 index_length)
Parse requested OID and strip out index OID.
Definition: agt_ypsnmp_util.c:2015
agt_ypsnmp_match_obj
boolean agt_ypsnmp_match_obj(obj_template_t *targetobj, obj_template_t *curobj)
Checks if the current object in the walker is the target object for the request.
Definition: agt_ypsnmp_util.c:764
ypsnmp_agent_session_t_::original_command
int original_command
agentX specific pointers
Definition: agt_ypsnmp_util.h:344
ypsnmp_agent_session_t_::session
netsnmp_session * session
session pointer
Definition: agt_ypsnmp_util.h:320
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
agt_ypsnmp_log_pdu
void agt_ypsnmp_log_pdu(netsnmp_pdu *pdu)
logs the received SNMP PDU packet contents
Definition: agt_ypsnmp_util.c:1591
ypsnmp_agent_session_t_::oldmode
int oldmode
old mode
Definition: agt_ypsnmp_util.h:338
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
smioid_tree.h
AVL Tree storage of SMI OID data.
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
NCX_CL_NAMED
@ NCX_CL_NAMED
a restriction of a named type
Definition: ncxtypes.h:247
agt_ypsnmp_make_restconf_uri
xmlChar * agt_ypsnmp_make_restconf_uri(obj_template_t *obj)
Make a RESTCONF URI string from the specified OID string.
Definition: agt_ypsnmp_util.c:1548
NCX_BT_DECIMAL64
@ NCX_BT_DECIMAL64
decimal64
Definition: ncxtypes.h:215
agt_ypsnmp_get_next_getnextlist
val_value_t * agt_ypsnmp_get_next_getnextlist(val_value_t *list)
Get the next list val_value structure in getnext_listQ.
Definition: agt_ypsnmp_util.c:735
YPSNMP_MODE_TAB_NOINDEX
@ YPSNMP_MODE_TAB_NOINDEX
table no index
Definition: agt_ypsnmp_util.h:285
NCX_BT_STRING
@ NCX_BT_STRING
string
Definition: ncxtypes.h:217
NCX_BT_INT8
@ NCX_BT_INT8
int8
Definition: ncxtypes.h:207
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
yangapi.h
YANG-API definitions (pre-RESTCONF)
agt_ypsnmp_convert_physaddr
xmlChar * agt_ypsnmp_convert_physaddr(val_value_t *val)
Converts the value of ifPhysAddress leaf element from yang syntax to SMI syntax expected by snmp clie...
Definition: agt_ypsnmp_util.c:1002
agt_ypsnmp_setup_peeraddr
status_t agt_ypsnmp_setup_peeraddr(ses_cb_t *scb, netsnmp_pdu *pdu)
Setup the scb->peeraddr for debugging and auditing.
Definition: agt_ypsnmp_util.c:1506
VAL_UINT8
#define VAL_UINT8(V)
Access the value as an uint8 ONLY if NCX_BT_UINT8.
Definition: val.h:485
obj_get_augment_targobj
obj_template_t * obj_get_augment_targobj(obj_template_t *obj)
Get the target object for an augments object.
Definition: obj.c:15905
NCX_BT_INT16
@ NCX_BT_INT16
int16
Definition: ncxtypes.h:208
ypsnmp_agent_session_t_
agent session
Definition: agt_ypsnmp_util.h:315