📄 v3_ntfy.c
字号:
/* v3_ntfy.c - v3_ntfy.c routines *//* * Copyright 2000-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//* * Copyright 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: v3_ntfy.c,v $ * Revision 1.2 2001/11/06 21:20:31 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:44 tneale * Tornado shuffle * * Revision 9.5 2001/03/26 19:49:04 josh * fixing the previous patch up a bit * * Revision 9.4 2001/03/21 22:00:28 josh * fix a table ordering bug in the snmpNotifyFilterTable * * Revision 9.3 2001/01/19 22:22:29 paul * Update copyright. * * Revision 9.2 2000/03/17 00:19:31 meister * Update copyright message * * Revision 9.1 2000/01/02 22:56:01 josh * patching up a memory leak here, a broken compare there...per * sar's comments * * Revision 9.0 1999/10/21 20:39:51 josh * updating version stamp * * Revision 1.3 1999/10/21 19:15:04 josh * fix a MEMCMP() in SNMP_Notify_Filter_Lookup() so that it works * correctly * * Revision 1.2 1999/09/27 21:11:48 josh * fixing nits, rewriting engine id <--> address code, adding installation * option * * Revision 1.1 1999/08/24 18:53:42 josh * Initial code for Notify support * * *//* [clearcase]modification history-------------------01d,12may05,job fix apigen comments01c,18apr05,job update copyright notices01b,22feb05,job apigen for documented APIs01a,24nov03,job update copyright information*//*DESCRIPTIONThis library contains v3_ntfy.c routines.INCLUDE FILES: snmp.h, v3_ntfy.h*/#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/v3_ntfy.h>#include <wrn/wm/snmp/engine/v3_trgt.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/****************************************************************************\NOMANUALNAME: notify listPURPOSE: This is the list of notify objects that we know about. It is ordered by notify name, the same as the indexing for the mib.****************************************************************************//****************************************************************************NAME: notify_find_beforePURPOSE: Search through the list until we find the notify structure we are looking for. We return a pointer to the pointer that would point to the requested notify if it were to exist. The calling routine is responsible for determining if the requested notify exists. This construction allows us to reuse this code for all of the find routines (lookup and install).PARAMETERS: bits8_t * pointer to name buffer ALENGTH_T number of bytes in nameRETURNS: SNMP_NOTIFY_T ** pointer to pointer that would point to the notify if it were to exist.****************************************************************************/static SNMP_NOTIFY_T ** notify_find_before(bits8_t *notify_name, ALENGTH_T notify_name_len){SNMP_NOTIFY_T **notify;ALENGTH_T min_name_len;int compare;for(notify = &root_notify; *notify; notify = &(*notify)->next) { min_name_len = min(notify_name_len, EBufferUsed(&((*notify)->notify_name))); if ((compare = MEMCMP(EBufferStart(&((*notify)->notify_name)), notify_name, min_name_len)) >= 0) { if (compare) break; else if (min_name_len < notify_name_len) continue; break; } }return(notify);}/********************************************************************************* SNMP_Notify_Lookup - find a notify entry matching the specified indices* SYNOPSIS** \cs* SNMP_NOTIFY_T * SNMP_Notify_Lookup * ( * bits8_t * notify_name,* ALENGTH_T notify_name_len* )* \ce** DESCRIPTION** This routine finds a notify entry matching the specified indices.** Parameters:* \is* \i <*notify_name>* Specify the notify name, which corresponds to the MIB object * <snmpNotifyName>.* \i <notify_name_len>* Specify the length in bytes of the notify name.* \ie** RETURNS: If successful, this routine returns a pointer to the notify entry. * Otherwise, it returns 0.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Create(), SNMP_Notify_Deinstall(), * SNMP_Notify_Destroy(), SNMP_Notify_Install(), SNMP_Notify_Name(), * SNMP_Notify_Next_Notify(), SNMP Notify Table Field Routines*/SNMP_NOTIFY_T * SNMP_Notify_Lookup(bits8_t *notify_name, ALENGTH_T notify_name_len){SNMP_NOTIFY_T **notify;notify = notify_find_before(notify_name, notify_name_len);if (*notify && (notify_name_len == EBufferUsed(&((*notify)->notify_name))) && (MEMCMP(EBufferStart(&((*notify)->notify_name)), notify_name, notify_name_len) == 0)) return(*notify);return(0);}/****************************************************************************\NOMANUALNAME: SNMP_Notify_NextPURPOSE: Find the next notify after the named one. the indexing information is of the form: <notify_name> but as this is a next we might not have all of it...PARAMETERS: int tcount number of subids OIDC_T *tlist list of subids RETURNS: SNMP_NOTIFY_T * pointer to notify or 0 if none found****************************************************************************/SNMP_NOTIFY_T * SNMP_Notify_Next(int tcount, OIDC_T *tlist){SNMP_NOTIFY_T *notify;bits8_t *notify_name;OIDC_T min_name_len = 0, *temp_oid, len;if (tcount == 0) return(root_notify);for (notify = root_notify; notify; notify = notify->next) { notify_name = EBufferStart(&(notify)->notify_name); min_name_len = min(tcount, EBufferUsed(&(notify->notify_name))); temp_oid = tlist; for (len = min_name_len; len && (*notify_name == *temp_oid); len--, notify_name++, temp_oid++) /* empty loop */ ; if (len) { if (*notify_name > *temp_oid) return(notify); } else { if (EBufferUsed(&(notify->notify_name)) > tcount) return(notify); } }return(0);}/********************************************************************************* SNMP_Notify_Next_Notify - find the next notify entry in the notify table* SYNOPSIS** \cs* SNMP_NOTIFY_T * SNMP_Notify_Next_Notify* (* SNMP_NOTIFY_T * notify * )* \ce** DESCRIPTION** This routine finds the notify entry in the notify table after the specified * notify entry. Use this routine to step through the notify table to find all * installed notifies.** Parameters:* \is* \i <*notify>* Point to the notify entry.* \ie** RETURNS: If successful, this routine returns a pointer to the next notify. If * there is no successor or the specified <notify> is not installed, it returns * 0. If the <notify> is specified as 0, then it returns a pointer to the first * notify entry in the table.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Create(), SNMP_Notify_Deinstall(), * SNMP_Notify_Destroy(), SNMP_Notify_Install(), SNMP_Notify_Lookup(), * SNMP_Notify_Name(), SNMP Notify Table Field Routines*/SNMP_NOTIFY_T * SNMP_Notify_Next_Notify (SNMP_NOTIFY_T *notify){if (notify) return(notify->next);return(root_notify);}/********************************************************************************* SNMP_Notify_Destroy - destroy the specified <notify> and frees associated resources* SYNOPSIS** \cs* void SNMP_Notify_Destroy* (* SNMP_NOTIFY_T * notify * )* \ce** DESCRIPTION** This routine destroys the specified notify entry, frees the space for the * entry, and frees the space for any resources the entry might contain.** \&NOTE: If the specified notify entry has been installed, call * SNMP_Notify_Deinstall() before calling this routine.** Parameters:* \is* \i <*notify>* Specify the notify entry to remove from the notify table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Create(), SNMP_Notify_Deinstall(), * SNMP_Notify_Install(), SNMP_Notify_Lookup(), SNMP_Notify_Name(), * SNMP_Notify_Next_Notify(), SNMP Notify Table Field Routines*/void SNMP_Notify_Destroy(SNMP_NOTIFY_T *notify){EBufferClean(¬ify->notify_tag);SNMP_memory_free_lt(notify);}/********************************************************************************* SNMP_Notify_Create - create a notify structure* SYNOPSIS** \cs* SNMP_NOTIFY_T * SNMP_Notify_Create* (* void * )* \ce** DESCRIPTION** This routine creates a notify structure ('snmpNotifyTable'), initialized to * the default values specified in RFC 2573. It attempts to allocate space for * the entry. To make an entry visible to the engine, use SNMP_Notify_Install().** Parameters:* None.** RETURNS: If successful, this routine sets the entry to a default state and * returns a pointer to the entry. Otherwise, it returns 0.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Deinstall(), SNMP_Notify_Destroy(), * SNMP_Notify_Install(), SNMP_Notify_Lookup(), SNMP_Notify_Name(), * SNMP_Notify_Next_Notify(), SNMP Notify Table Field Routines*/SNMP_NOTIFY_T * SNMP_Notify_Create(void){SNMP_NOTIFY_T *notify;notify = (SNMP_NOTIFY_T *) SNMP_memory_alloc_lt(sizeof(SNMP_NOTIFY_T));if (notify == 0) return(0);SNMP_Notify_Set_Defaults(notify);return(notify);}/********************************************************************************* SNMP_Notify_Install - install the specified notify entry in the notify table* SYNOPSIS** \cs* int SNMP_Notify_Install * ( * SNMP_NOTIFY_T * notify,* bits8_t * notify_name,* ALENGTH_T notify_name_len* )* \ce** DESCRIPTION** This routine installs the specified notify entry in the notify table using * <notify_name> as an index.** \&NOTE: Once a notify has been installed, you must call * SNMP_Notify_Deinstall() before calling SNMP_Notify_Destroy() to remove it.** Parameters:* \is* \i <*notify>* Point to the notify entry.* \i <*notify_name>* Specify the notify name, which corresponds to the MIB object * <snmpNotifyName>.* \i <*notify_name_len>* Specify the length in bytes of the notify name.* \ie** RETURNS: If successful, this routine returns a value of 0. If an entry * already exists with the same indices or another error occurs, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Create(), SNMP_Notify_Deinstall(),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -