yumapro  20.10-12
YumaPro SDK
agt_ypsnmp_agentx.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 an snmp abstraction layer that acts as a
75  an intermediate between the yang data store and the snmp library.
76  This module makes use of restconf apis to interface with the data
77  store(s) and provides sort of a gateway functionality by converting
78  requests and responses between snmp and restconf interface.
79 *************************************************************************/
80 
81 
82 /*
83  * Copyright (c) 2017, YumaWorks. Inc., All Rights Reserved.
84  *
85  * Unless required by applicable law or agreed to in writing,
86  * software distributed under the License is distributed on an
87  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
88  * KIND, either express or implied. See the License for the
89  * specific language governing permissions and limitations
90  * under the License.
91  */
92 
93 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
94 #ifndef _H_agt_ypsnmp_agentx
95 #define _H_agt_ypsnmp_agentx
96 
97 /* FILE: agt_ypsnmp_agentx.h
98 *********************************************************************
99 * *
100 * P U R P O S E *
101 * *
102 *********************************************************************/
103 
111 /*********************************************************************
112 * *
113 * C H A N G E H I S T O R Y *
114 * *
115 *********************************************************************
116 
117 date init comment
118 ----------------------------------------------------------------------
119 12-Oct-17 am Begun.
120 */
121 
122 #ifndef _H_status_enum
123 #include "status_enum.h"
124 #endif
125 
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 
138 /********************************************************************
139 * *
140 * T Y P E S *
141 * *
142 *********************************************************************/
143 
144 
145 /********************************************************************
146 * *
147 * F U N C T I O N S *
148 * *
149 *********************************************************************/
150 
151 
152 
172 extern status_t
173  agt_ypsnmp_agentx_init (void);
174 
175 
182 extern void
184 
185 
192 extern void
194 
195 
209 extern int
211  netsnmp_session *session,
212  int reqid,
213  netsnmp_pdu *pdu,
214  void *magic);
215 
216 
230 extern int
232  netsnmp_session *session,
233  int reqid,
234  netsnmp_pdu *pdu,
235  void *magic);
236 
237 
248 extern boolean
250 
251 
263 extern ses_cb_t *
265 
266 
271 #ifdef __cplusplus
272 } /* end extern 'C' */
273 #endif
274 
275 #endif // _H_agt_ypsnmp
276 #endif // defined(WITH_SNMP) && defined(WITH_RESTCONF)
log_info_append
void void void void void void log_info_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_INFO log entry.
agt_ypsnmp.h
Yuma Interface to net-snmp data structures. Agent interface.
agt_restconf.h
IETF RESTCONF Protocol Message Handler.
agt_ses.h
Server Session Management.
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
agt_ypsnmp_agentx_check_io
void agt_ypsnmp_agentx_check_io(void)
Check if any SNMP messages to process.
Definition: agt_ypsnmp_agentx.c:1073
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
val.h
Value Node Basic Support.
status_enum.h
global error status code enumerations
agt_ncxserver.h
NCX Server Transport and IO Library.
agt_ypsnmp_agentx_handle_response
int agt_ypsnmp_agentx_handle_response(int op, netsnmp_session *session, int reqid, netsnmp_pdu *pdu, void *magic)
Handle the AgentX response.
agt_not.h
NETCONF Notifications DM module support.
agt_ypsnmp_agentx_synch_input
int agt_ypsnmp_agentx_synch_input(int op, netsnmp_session *session, int reqid, netsnmp_pdu *pdu, void *magic)
Synch input.
Definition: agt_ypsnmp_agentx.c:884
ses_msg.h
NETCONF Session Message Common definitions module.
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
agt_ses_new_snmp_session
ses_cb_t * agt_ses_new_snmp_session(void)
Create a dummy SNMP session control block.
Definition: agt_ses.c:737
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
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
val_util.h
Value Node Utilities.
agt_ypsnmp_handle_request
status_t agt_ypsnmp_handle_request(ypsnmp_agent_session_t *asp)
Incoming Packet handling function.
Definition: agt_ypsnmp.c:3774
obj_is_data_node
boolean obj_is_data_node(const obj_template_t *obj)
Check if the object is a real node type.
Definition: obj.c:13830
agentx_parse
int agentx_parse(netsnmp_session *session, netsnmp_pdu *pdu, u_char *data, size_t len)
Utility functions for parsing an AgentX packet.
Definition: agt_ypsnmp_proto.c:1371
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
agt_ypsnmp_agentx_connected
boolean agt_ypsnmp_agentx_connected(void)
Check if the AgentX agent succ connected to the master agent.
Definition: agt_ypsnmp_agentx.c:1166
val_child.h
Value Node Child Access Support.
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
agt_ses_free_snmp_session
void agt_ses_free_snmp_session(ses_cb_t *scb)
Free a dummy snmp session control block.
Definition: agt_ses.c:782
LOGINFO
#define LOGINFO
Check if at least log-level=info.
Definition: log.h:279
agt.h
Multi-Protocol Network Management Server.
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
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
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
agt_ypsnmp_util.h
Utility Functions for YP SNMP.
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
agt_ypsnmp_agentx_cleanup
void agt_ypsnmp_agentx_cleanup(void)
Cleanup the agt_ypsnmp AgetnX module.
Definition: agt_ypsnmp_agentx.c:1023
log_error_append
void void log_error_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_ERROR log entry.
agentx_check_packet
int agentx_check_packet(u_char *packet, size_t packet_len)
Check the packet.
Definition: agt_ypsnmp_proto.c:1782
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
agt_ypsnmp_not.h
Defines and implements SNMP notification and trap handling.
agt_ypsnmp_proto.h
SNMP Protocol Handler.
agentx_realloc_build
int agentx_realloc_build(netsnmp_session *session, netsnmp_pdu *pdu, u_char **buf, size_t *buf_len, size_t *out_len)
Realloc an AgentX PDU.
Definition: agt_ypsnmp_proto.c:1739
agt_ypsnmp_get_agentx_scb
ses_cb_t * agt_ypsnmp_get_agentx_scb(void)
Get the AgentX specific session control block.
Definition: agt_ypsnmp_agentx.c:1190
smioid_tree.h
AVL Tree storage of SMI OID data.
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
AGT_SELECT_TIMEOUT_USEC
#define AGT_SELECT_TIMEOUT_USEC
number of microseconds for each select timeout set to 1/100th sec
Definition: agt.h:391
obj_has_name
boolean obj_has_name(const obj_template_t *obj)
Check if the specified object type has a name.
Definition: obj.c:10667
agt_ypsnmp_agentx.h
Yuma Interface to net-snmp data structures. AgentX interface.
yangapi.h
YANG-API definitions (pre-RESTCONF)
agt_ypsnmp_agentx_init
status_t agt_ypsnmp_agentx_init(void)
Initialize the agt_ypsnmp AgentX module.
Definition: agt_ypsnmp_agentx.c:931
smioid_tree_get
hb_tree * smioid_tree_get(void)
Get the SMI OID tree.
Definition: smioid_tree.c:1016