yumapro  21.10T-9
YumaPro SDK
agt_ypsnmp.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) 2016 - 2020, 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
95 #define _H_agt_ypsnmp
96 
97 /* FILE: agt_ypsnmp.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 08-sep-16 rmb Begun.
120 */
121 
122 #ifndef _H_status_enum
123 #include "status_enum.h"
124 #endif
125 
126 #ifndef _H_agt_ypsnmp_util
127 #include "agt_ypsnmp_util.h"
128 #endif
129 
130 #ifndef _H_yangapi
131 #include "yangapi.h"
132 #endif
133 
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137 
138 /********************************************************************
139 * *
140 * C O N S T A N T S *
141 * *
142 *********************************************************************/
143 
144 
145 /********************************************************************
146 * *
147 * T Y P E S *
148 * *
149 *********************************************************************/
150 
151 
152 /********************************************************************
153 * *
154 * F U N C T I O N S *
155 * *
156 *********************************************************************/
157 
158 /* header only */
159 
160 
202 extern int
203  ypsnmp_snmp_packet (int op_type,
204  netsnmp_session *session,
205  int reqid,
206  netsnmp_pdu *pdu,
207  void *magic);
208 
209 
223 extern int
224  ypsnmp_check_packet (netsnmp_session * session,
225  netsnmp_transport *transport,
226  void *transport_data,
227  int transport_data_length);
228 
229 
240 extern int
241  ypsnmp_check_parse (netsnmp_session * session,
242  netsnmp_pdu *pdu,
243  int result);
244 
245 
253 extern status_t
254  agt_ypsnmp_init (void);
255 
256 
262 extern void
263  agt_ypsnmp_cleanup (void);
264 
265 
273 extern void
274  agt_ypsnmp_check_io (void);
275 
276 
288 extern status_t
290  yangapi_cb_t *rcb,
291  rpc_msg_t *msg,
292  status_t result);
293 
294 
303 extern status_t
305 
306 
316 extern status_t
318 
319 
323 #ifdef __cplusplus
324 } /* end extern 'C' */
325 #endif
326 
327 #endif // _H_agt_ypsnmp
328 #endif // defined(WITH_SNMP) && defined(WITH_RESTCONF)
int ypsnmp_snmp_packet(int op_type, netsnmp_session *session, int reqid, netsnmp_pdu *pdu, void *magic)
Register handle an incoming SNMP packet.
Definition: agt_ypsnmp.c:3100
void agt_ypsnmp_cleanup(void)
Cleanup the agt_ypsnmp module.
Definition: agt_ypsnmp.c:3390
status_t agt_ypsnmp_reply_handler(ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg, status_t result)
Handler called for sending a response.
Definition: agt_ypsnmp.c:3529
status_t agt_ypsnmp_handle_request(ypsnmp_agent_session_t *asp)
Incoming Packet handling function.
Definition: agt_ypsnmp.c:3774
Restapi Control Block Used by RESTCONF to hold parse and request processing state.
Definition: yangapi.h:224
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
status_t agt_ypsnmp_init(void)
Initialize the agt_ypsnmp module.
Definition: agt_ypsnmp.c:3306
int ypsnmp_check_parse(netsnmp_session *session, netsnmp_pdu *pdu, int result)
Check the PDU parse.
Definition: agt_ypsnmp.c:3280
one notification message that will be sent to all subscriptions in the stream and kept in the replay ...
Definition: agt_not.h:143
int ypsnmp_check_packet(netsnmp_session *session, netsnmp_transport *transport, void *transport_data, int transport_data_length)
Handler for all incoming messages (a.k.a.
Definition: agt_ypsnmp.c:3234
YANG-API definitions (pre-RESTCONF)
Utility Functions for YP SNMP.
agent session
Definition: agt_ypsnmp_util.h:315
Session Control Block.
Definition: ses.h:542
status_t
global error return code
Definition: status_enum.h:186
status_t agt_ypsnmp_notification_handler(agt_not_msg_t *notif)
Handler called for sending a notification.
Definition: agt_ypsnmp.c:3646
void agt_ypsnmp_check_io(void)
Check if any SNMP messages to process.
Definition: agt_ypsnmp.c:3436
global error status code enumerations