Support multiple notifications when sending snmo v2 traps
This commit is contained in:
parent
302d61d1d1
commit
4553419cc2
1 changed files with 12 additions and 9 deletions
|
|
@ -230,8 +230,8 @@ done:
|
|||
* The OID is read from the YANG definition. If the notification contains data, all values
|
||||
* are bound to the corresponding OIDs and sent with the snmp trap.
|
||||
*
|
||||
* @param[in] s Socket
|
||||
* @param[in] arg expected to be clixon_handle
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] xn Notification data received from backend
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
|
|
@ -292,6 +292,7 @@ snmp_stream_cb(int s,
|
|||
clixon_handle h = (clixon_handle)arg;
|
||||
int eof;
|
||||
cxobj *xtop = NULL; /* top xml */
|
||||
cxobj *xncont = NULL; /* notification content xml */
|
||||
cxobj *xn; /* notification xml */
|
||||
cbuf *cbmsg = NULL;
|
||||
int ret;
|
||||
|
|
@ -313,11 +314,13 @@ snmp_stream_cb(int s,
|
|||
clixon_err(OE_XML, EFAULT, "Invalid notification");
|
||||
goto done;
|
||||
}
|
||||
if ((xn = xpath_first(xtop, NULL, "notification")) == NULL)
|
||||
goto ok;
|
||||
/* forward notification as snmp trap */
|
||||
if(snmp_publish_notification(h, xn) < 0)
|
||||
/* forward notification(s) as snmp trap */
|
||||
while ((xncont = xml_child_each(xtop, xncont, CX_ELMNT)) != NULL){
|
||||
if (strcmp(xml_name(xncont), "notification") == 0) {
|
||||
if(snmp_publish_notification(h, xncont) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
ok:
|
||||
retval = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue