90#if defined(WITH_SNMP) && defined(WITH_RESTCONF)
91#ifndef _H_agt_ypsnmp_util
92#define _H_agt_ypsnmp_util
119#ifndef _H_status_enum
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"
148#define YPSNMP_APP_NAME (const char *)"snmpd"
152#define MAX_SNMP_CACHE_SIZE 32
153#define ADDR_BUFLEN 128
156#define YPSNMP_PHYS_ADDR_LEN 6
161#define fds_bits __fds_bits
175#define YPSNMP_AGENTX_SOCKET (const char *)"tcp:localhost:705"
176#define YPSNMP_AGENTX_NAME (const char *)"agentx"
185#define AGENTX_VERSION_BASE 192
186#define AGENTX_VERSION_1 (AGENTX_VERSION_BASE | 0x1)
188#define IS_AGENTX_VERSION(v) (((v)&AGENTX_VERSION_BASE) == AGENTX_VERSION_BASE)
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)
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)
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)
237#define AGENTX_MP_MODEL_AGENTXv1 (257)
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
249#define AGENTX_MSG_FLAGS_MASK 0xff
254#define AGENTX_FLAGS_NETWORK_BYTE_ORDER AGENTX_MSG_FLAG_NETWORK_BYTE_ORDER
276typedef enum ypsnmp_getnext_mode_t_ {
298typedef struct agent_nsap_t_ {
315typedef struct ypsnmp_agent_session_t_ {
523extern netsnmp_variable_list *
542 netsnmp_variable_list *var);
650extern const xmlChar *
665 uint32 index_length);
683 const oid_t *useoid);
783 uint32 index_length);
ypsnmp_getnext_mode_t
There are several possible requests that can be sent to the netconfd SNMP server:
Definition: agt_ypsnmp_util.h:276
@ YPSNMP_MODE_TAB_INDEXED
table indexed
Definition: agt_ypsnmp_util.h:284
@ YPSNMP_MODE_SCAL_INDEXED
scal indexed
Definition: agt_ypsnmp_util.h:290
@ YPSNMP_MODE_TAB_NOINDEX
table no index
Definition: agt_ypsnmp_util.h:281
@ YPSNMP_MODE_NONE
not set
Definition: agt_ypsnmp_util.h:278
@ YPSNMP_MODE_COMPLEX
complex
Definition: agt_ypsnmp_util.h:293
@ YPSNMP_MODE_SCAL_NOINDEX
scal no index
Definition: agt_ypsnmp_util.h:287
void free_varbind(netsnmp_variable_list *var)
Frees the variable and any malloc'd data associated with it.
Definition: agt_ypsnmp_util.c:2641
boolean agt_ypsnmp_is_augmented_obj(obj_template_t *curobj)
Check if the object is an augmented object.
Definition: agt_ypsnmp_util.c:968
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:2284
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:1053
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:1884
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:737
boolean agt_ypsnmp_is_scalar_obj(obj_template_t *curobj)
Check if the object is a scalar object.
Definition: agt_ypsnmp_util.c:937
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:1746
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:603
void free_varbind_yp(netsnmp_variable_list *var)
Frees the variable and any malloc'd data associated with it.
Definition: agt_ypsnmp_util.c:2680
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:2017
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:1925
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:1508
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:714
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:1116
yangapi_method_t agt_ypsnmp_get_yangapi_method(uint8 msg_code)
Get the YANGAPI method from the SNMP method.
Definition: agt_ypsnmp_util.c:1670
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:766
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:848
const void * agt_ypsnmp_get_varbind_value(netsnmp_variable_list *var)
Get the Varbind value.
Definition: agt_ypsnmp_util.c:1704
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:811
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:1196
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:2576
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:1149
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:1786
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:1550
void agt_ypsnmp_log_pdu(netsnmp_pdu *pdu)
logs the received SNMP PDU packet contents
Definition: agt_ypsnmp_util.c:1593
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:1004
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:894
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:2614
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:1833
yangapi_method_t
HTTP methods used by YANG-API and RESTCONF.
Definition: yangapi.h:111
status_t
global error return code
Definition: status_enum.h:210
unsigned long oid_t
data type used in SNMP
Definition: obj.h:1207
global error status code enumerations
NSAP for the agent.
Definition: agt_ypsnmp_util.h:298
int handle
handle
Definition: agt_ypsnmp_util.h:301
struct agent_nsap_t_ * next
next entry
Definition: agt_ypsnmp_util.h:310
netsnmp_transport * transport
transport info
Definition: agt_ypsnmp_util.h:304
void * opaque_ses
Opaque internal session pointer.
Definition: agt_ypsnmp_util.h:307
defines the snmp oid value, stored as an array of integers for easier comparision when performing AVL...
Definition: obj.h:1215
One YANG data-def-stmt.
Definition: obj.h:1229
Session Control Block.
Definition: ses.h:573
one value to match one type
Definition: val.h:912
Restapi Control Block Used by RESTCONF to hold parse and request processing state.
Definition: yangapi.h:351
agent session
Definition: agt_ypsnmp_util.h:315
int original_command
agentX specific pointers
Definition: agt_ypsnmp_util.h:344
int mode
session mode
Definition: agt_ypsnmp_util.h:317
netsnmp_pdu * pdu
PDU pointer.
Definition: agt_ypsnmp_util.h:323
int rw
RW flag.
Definition: agt_ypsnmp_util.h:326
int vbcount
varbind count
Definition: agt_ypsnmp_util.h:341
int exact
exact flag
Definition: agt_ypsnmp_util.h:329
int status
status flag
Definition: agt_ypsnmp_util.h:332
int index
index flag
Definition: agt_ypsnmp_util.h:335
netsnmp_session * session
session pointer
Definition: agt_ypsnmp_util.h:320
int oldmode
old mode
Definition: agt_ypsnmp_util.h:338
YANG-API definitions (pre-RESTCONF)