Logo
Home page Net-SNMP

Archive Search:

Require all words?

Site Search:
Google
agent_registry.h File Reference
Main Page   Data Structures   File List   Data Fields   Globals  

agent_registry.h File Reference

#include "snmp_agent.h"

Go to the source code of this file.


Data Structures

struct  register_parameters
struct  subtree_context_cache_s
struct  view_parameters

Defines

#define MIB_REGISTERED_OK   0
#define MIB_DUPLICATE_REGISTRATION   -1
#define MIB_REGISTRATION_FAILED   -2
#define MIB_UNREGISTERED_OK   0
#define MIB_NO_SUCH_REGISTRATION   -1
#define MIB_UNREGISTRATION_FAILED   -2
#define DEFAULT_MIB_PRIORITY   127
#define REGISTER_MIB(descr, var, vartype, theoid)
#define NUM_EXTERNAL_FDS   32
#define FD_REGISTERED_OK   0
#define FD_REGISTRATION_FAILED   -2
#define FD_UNREGISTERED_OK   0
#define FD_NO_SUCH_REGISTRATION   -1
#define SIG_REGISTERED_OK   0
#define SIG_REGISTRATION_FAILED   -2
#define SIG_UNREGISTERED_OK   0
#define NUM_EXTERNAL_SIGS   32

Typedefs

typedef subtree_context_cache_s subtree_context_cache

Functions

void setup_tree (void)
subtreefind_subtree (oid *, size_t, struct subtree *, const char *context_name)
subtreefind_subtree_next (oid *, size_t, struct subtree *, const char *context_name)
subtreefind_subtree_previous (oid *, size_t, struct subtree *, const char *context_name)
snmp_session * get_session_for_oid (oid *, size_t, const char *context_name)
int register_mib (const char *, struct variable *, size_t, size_t, oid *, size_t)
int register_mib_priority (const char *, struct variable *, size_t, size_t, oid *, size_t, int)
int register_mib_range (const char *, struct variable *, size_t, size_t, oid *, size_t, int, int, oid, struct snmp_session *)
int register_mib_context (const char *, struct variable *, size_t, size_t, oid *, size_t, int, int, oid, struct snmp_session *, const char *, int, int)
int register_mib_table_row (const char *, struct variable *, size_t, size_t, oid *, size_t, int, int, struct snmp_session *, const char *, int, int)
int unregister_mib (oid *, size_t)
int unregister_mib_priority (oid *, size_t, int)
int unregister_mib_range (oid *, size_t, int, int, oid)
int unregister_mib_context (oid *, size_t, int, int, oid, const char *)
void unregister_mibs_by_session (struct snmp_session *)
subtreefree_subtree (struct subtree *)
int compare_tree (const oid *, size_t, const oid *, size_t)
int in_a_view (oid *, size_t *, struct snmp_pdu *, int)
int check_access (struct snmp_pdu *pdu)
void register_mib_reattach (void)
int register_readfd (int, void(*func)(int, void *), void *)
int register_writefd (int, void(*func)(int, void *), void *)
int register_exceptfd (int, void(*func)(int, void *), void *)
int unregister_readfd (int)
int unregister_writefd (int)
int unregister_exceptfd (int)
int register_signal (int, void(*func)(int))
int unregister_signal (int)
subtreefind_first_subtree (const char *context_name)
subtree_context_cacheget_top_context_cache (void)

Variables

int external_readfd [NUM_EXTERNAL_FDS]
int external_readfdlen
int external_writefd [NUM_EXTERNAL_FDS]
int external_writefdlen
int external_exceptfd [NUM_EXTERNAL_FDS]
int external_exceptfdlen
void(* external_readfdfunc [NUM_EXTERNAL_FDS])(int, void *)
void(* external_writefdfunc [NUM_EXTERNAL_FDS])(int, void *)
void(* external_exceptfdfunc [NUM_EXTERNAL_FDS])(int, void *)
void * external_readfd_data [NUM_EXTERNAL_FDS]
void * external_writefd_data [NUM_EXTERNAL_FDS]
void * external_exceptfd_data [NUM_EXTERNAL_FDS]
int external_signal_scheduled [NUM_EXTERNAL_SIGS]
void(* external_signal_handler [NUM_EXTERNAL_SIGS])(int)

Define Documentation

#define DEFAULT_MIB_PRIORITY   127
 

Definition at line 46 of file agent_registry.h.

#define FD_NO_SUCH_REGISTRATION   -1
 

Definition at line 98 of file agent_registry.h.

#define FD_REGISTERED_OK   0
 

Definition at line 94 of file agent_registry.h.

#define FD_REGISTRATION_FAILED   -2
 

Definition at line 95 of file agent_registry.h.

#define FD_UNREGISTERED_OK   0
 

Definition at line 97 of file agent_registry.h.

#define MIB_DUPLICATE_REGISTRATION   -1
 

Definition at line 39 of file agent_registry.h.

#define MIB_NO_SUCH_REGISTRATION   -1
 

Definition at line 43 of file agent_registry.h.

#define MIB_REGISTERED_OK   0
 

Definition at line 38 of file agent_registry.h.

#define MIB_REGISTRATION_FAILED   -2
 

Definition at line 40 of file agent_registry.h.

#define MIB_UNREGISTERED_OK   0
 

Definition at line 42 of file agent_registry.h.

#define MIB_UNREGISTRATION_FAILED   -2
 

Definition at line 44 of file agent_registry.h.

#define NUM_EXTERNAL_FDS   32
 

Definition at line 92 of file agent_registry.h.

#define NUM_EXTERNAL_SIGS   32
 

Definition at line 125 of file agent_registry.h.

#define REGISTER_MIB descr,
var,
vartype,
theoid   
 

Value:

if (register_mib(descr, (struct variable *) var, sizeof(struct vartype), \
               sizeof(var)/sizeof(struct vartype),                     \
               theoid, sizeof(theoid)/sizeof(oid)) != MIB_REGISTERED_OK ) \
        DEBUGMSGTL(("register_mib", "%s registration failed\n", descr));

Definition at line 85 of file agent_registry.h.

#define SIG_REGISTERED_OK   0
 

Definition at line 120 of file agent_registry.h.

#define SIG_REGISTRATION_FAILED   -2
 

Definition at line 121 of file agent_registry.h.

#define SIG_UNREGISTERED_OK   0
 

Definition at line 123 of file agent_registry.h.


Typedef Documentation

typedef struct subtree_context_cache_s subtree_context_cache
 


Function Documentation

int check_access struct snmp_pdu *    pdu
 

Definition at line 866 of file agent_registry.c.

Referenced by handle_snmp_packet().

00867 {
00868   struct view_parameters view_parms;
00869   view_parms.pdu = pdu;
00870   view_parms.name = 0;
00871   view_parms.namelen = 0;
00872   view_parms.errorcode = 0;
00873 
00874   if (pdu->flags & UCD_MSG_FLAG_ALWAYS_IN_VIEW)
00875     return 0;           /* Enable bypassing of view-based access control */
00876 
00877   switch (pdu->version) {
00878   case SNMP_VERSION_1:
00879   case SNMP_VERSION_2c:
00880   case SNMP_VERSION_3:
00881     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
00882                         SNMPD_CALLBACK_ACM_CHECK_INITIAL,
00883                         &view_parms);
00884     return view_parms.errorcode;
00885   }
00886   return 1;
00887 }

int compare_tree const oid *    in_name1,
size_t    len1,
const oid *    in_name2,
size_t    len2
 

Definition at line 897 of file agent_registry.c.

Referenced by nullOidLen().

00901 {
00902     register int len, res;
00903     register const oid * name1 = in_name1;
00904     register const oid * name2 = in_name2;
00905 
00906     /* len = minimum of len1 and len2 */
00907     if (len1 < len2)
00908         len = len1;
00909     else
00910         len = len2;
00911     /* find first non-matching OID */
00912     while(len-- > 0){
00913         res = *(name1++) - *(name2++);
00914         if (res < 0)
00915             return -1;
00916         if (res > 0)
00917             return 1;
00918     }
00919     /* both OIDs equal up to length of shorter OID */
00920     if (len1 < len2)
00921         return -1;
00922 
00923     /* name1 matches name2 for length of name2, or they are equal */
00924     return 0;
00925 }

struct subtree* find_first_subtree const char *    context_name
 

Definition at line 74 of file agent_registry.c.

Referenced by find_subtree_previous(), get_session_for_oid(), unregister_mib_context(), and unregister_mibs_by_session().

00074                                              {
00075     subtree_context_cache *ptr;
00076     if (!context_name)
00077         context_name = "";
00078     DEBUGMSGTL(("find_first_subtree","looking for subtree for context: \"%s\"\n", context_name));
00079     for(ptr = context_subtrees; ptr; ptr = ptr->next) {
00080         if (strcmp(ptr->context_name, context_name) == 0) {
00081             DEBUGMSGTL(("find_first_subtree","found one for: \"%s\"\n", context_name));
00082             return ptr->first_subtree;
00083         }
00084     }
00085     DEBUGMSGTL(("find_first_subtree","Didn't find a subtree for: \"%s\"\n", context_name));
00086     return NULL;
00087 }

struct subtree* find_subtree oid *    name,
size_t    len,
struct subtree   subtree,
const char *    context_name
 

Definition at line 967 of file agent_registry.c.

Referenced by create_subtree_cache(), getStatPtr(), load_subtree(), and unregister_mib_context().

00971 {
00972   struct subtree *myptr;
00973 
00974   myptr = find_subtree_previous(name, len, subtree, context_name);
00975   if (myptr && snmp_oid_compare(name, len, myptr->end, myptr->end_len) < 0)
00976         return myptr;
00977 
00978   return NULL;
00979 }

struct subtree* find_subtree_next oid *    name,
size_t    len,
struct subtree   subtree,
const char *    context_name
 

Definition at line 947 of file agent_registry.c.

Referenced by getStatPtr(), and load_subtree().

00951 {
00952   struct subtree *myptr = NULL;
00953 
00954   myptr = find_subtree_previous(name, len, subtree, context_name);
00955   if ( myptr != NULL ) {
00956      myptr = myptr->next;
00957      while ( myptr && (myptr->variables == NULL || myptr->variables_len == 0) )
00958          myptr = myptr->next;
00959      return myptr;
00960   }
00961   else if (subtree && snmp_oid_compare(name, len, subtree->start, subtree->start_len) < 0)
00962      return subtree;
00963   else
00964      return NULL;
00965 }

struct subtree* find_subtree_previous oid *    name,
size_t    len,
struct subtree   subtree,
const char *    context_name
 

Definition at line 927 of file agent_registry.c.

Referenced by find_subtree(), find_subtree_next(), get_session_for_oid(), and load_subtree().

00931 {
00932   struct subtree *myptr, *previous = NULL;
00933 
00934   if ( subtree )
00935         myptr = subtree;
00936   else
00937         myptr = find_first_subtree(context_name);  /* look through everything */
00938 
00939   for( ; myptr != NULL; previous = myptr, myptr = myptr->next) {
00940     if (snmp_oid_compare(name, len, myptr->start, myptr->start_len) < 0) {
00941       return previous;
00942     }
00943   }
00944   return previous;
00945 }

struct subtree* free_subtree struct subtree   st
 

Definition at line 806 of file agent_registry.c.

Referenced by load_subtree(), register_mib_context2(), unregister_mib_context(), and unregister_mibs_by_session().

00807 {
00808   struct subtree *ret = NULL;
00809 
00810   if (st->variables != NULL &&
00811       snmp_oid_compare(st->name, st->namelen, st->start, st->start_len) == 0) {
00812     free(st->variables);
00813     st->variables = NULL;
00814   }
00815   if (st->next != NULL) {
00816     ret = st->next;
00817   }
00818   free(st);
00819   return ret;
00820 }

struct snmp_session* get_session_for_oid oid *    name,
size_t    len,
const char *    context_name
 

Definition at line 981 of file agent_registry.c.

00983 {
00984    struct subtree *myptr;
00985 
00986    myptr = find_subtree_previous(name, len, find_first_subtree(context_name),
00987                                  context_name);
00988    while ( myptr && myptr->variables == NULL )
00989         myptr = myptr->next;
00990 
00991    if ( myptr == NULL )
00992         return NULL;
00993    else
00994         return myptr->session;
00995 }

subtree_context_cache* get_top_context_cache void   
 

Definition at line 69 of file agent_registry.c.

00069                                                    {
00070     return context_subtrees;
00071 }

int in_a_view oid *    name,
size_t *    namelen,
struct snmp_pdu *    pdu,
int    type
 

Definition at line 831 of file agent_registry.c.

Referenced by check_acm(), create_subtree_cache(), and nullOidLen().

00835 {
00836 
00837   struct view_parameters view_parms;
00838   view_parms.pdu = pdu;
00839   view_parms.name = name;
00840   if (namelen)
00841       view_parms.namelen = *namelen;
00842   else
00843       view_parms.namelen = 0;
00844   view_parms.errorcode = 0;
00845 
00846   if (pdu->flags & UCD_MSG_FLAG_ALWAYS_IN_VIEW)
00847     return VACM_SUCCESS; /* Enable bypassing of view-based access control */
00848 
00849   /* check for v1 and counter64s, since snmpv1 doesn't support it */
00850   if (pdu->version == SNMP_VERSION_1 && type == ASN_COUNTER64)
00851     return VACM_NOTINVIEW;
00852   switch (pdu->version) {
00853   case SNMP_VERSION_1:
00854   case SNMP_VERSION_2c:
00855   case SNMP_VERSION_3:
00856     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_ACM_CHECK,
00857                         &view_parms);
00858     return view_parms.errorcode;
00859   }
00860   return VACM_NOSECNAME;
00861 }

int register_exceptfd int    fd,
void(*    func)(int, void *),
void *    data
 

Definition at line 1097 of file agent_registry.c.

01097                                                                      {
01098     if (external_exceptfdlen < NUM_EXTERNAL_FDS) {
01099         external_exceptfd[external_exceptfdlen] = fd;
01100         external_exceptfdfunc[external_exceptfdlen] = func;
01101         external_exceptfd_data[external_exceptfdlen] = data;
01102         external_exceptfdlen++;
01103         DEBUGMSGTL(("register_exceptfd", "registered fd %d\n", fd));
01104         return FD_REGISTERED_OK;
01105     } else {
01106         snmp_log(LOG_CRIT, "register_exceptfd: too many file descriptors\n");
01107         return FD_REGISTRATION_FAILED;
01108     }
01109 }

int register_mib const char *    moduleName,
struct variable   var,
size_t    varsize,
size_t    numvars,
oid *    mibloc,
size_t    mibloclen
 

Definition at line 565 of file agent_registry.c.

00571 {
00572   return register_mib_priority( moduleName, var, varsize, numvars,
00573                                 mibloc, mibloclen, DEFAULT_MIB_PRIORITY );
00574 }

int register_mib_context const char *    moduleName,
struct variable   var,
size_t    varsize,
size_t    numvars,
oid *    mibloc,
size_t    mibloclen,
int    priority,
int    range_subid,
oid    range_ubound,
struct snmp_session *    ss,
const char *    context,
int    timeout,
int    flags
 

Definition at line 481 of file agent_registry.c.

Referenced by register_mib_range().

00493                                 {
00494     return register_old_api(moduleName, var, varsize, numvars, mibloc,
00495                             mibloclen, priority,
00496                             range_subid, range_ubound,
00497                             ss, context, timeout, flags);
00498 }

int register_mib_priority const char *    moduleName,
struct variable   var,
size_t    varsize,
size_t    numvars,
oid *    mibloc,
size_t    mibloclen,
int    priority
 

Definition at line 552 of file agent_registry.c.

Referenced by register_mib().

00559 {
00560   return register_mib_range( moduleName, var, varsize, numvars,
00561                                 mibloc, mibloclen, priority, 0, 0, NULL );
00562 }

int register_mib_range const char *    moduleName,
struct variable   var,
size_t    varsize,
size_t    numvars,
oid *    mibloc,
size_t    mibloclen,
int    priority,
int    range_subid,
oid    range_ubound,
struct snmp_session *    ss
 

Definition at line 535 of file agent_registry.c.

Referenced by register_mib_priority().

00545 {
00546   return register_mib_context( moduleName, var, varsize, numvars,
00547                                 mibloc, mibloclen, priority,
00548                                 range_subid, range_ubound, ss, "", -1, 0);
00549 }

void register_mib_reattach void   
 

Definition at line 527 of file agent_registry.c.

00527                             {
00528     subtree_context_cache *ptr;
00529     for(ptr = context_subtrees; ptr; ptr = ptr->next) {
00530         register_mib_reattach_subtree(ptr->first_subtree);
00531     }
00532 }

int register_mib_table_row const char *    moduleName,
struct variable   var,
size_t    varsize,
size_t    numvars,
oid *    mibloc,
size_t    mibloclen,
int    priority,
int    var_subid,
struct snmp_session *    ss,
const char *    context,
int    timeout,
int    flags
 

Definition at line 578 of file agent_registry.c.

00590 {
00591   struct subtree *subtree;
00592   struct register_parameters reg_parms;
00593   int rc, x;
00594   u_char *v;
00595 
00596   for(x = 0; x < numvars; x++) {
00597 
00598     /* 
00599      * allocate a subtree for the mib registration
00600      */
00601     subtree = (struct subtree *) malloc(sizeof(struct subtree));
00602     if (subtree == NULL) {
00603       unregister_mib_context(mibloc, mibloclen, priority, 
00604                              var_subid, numvars, context);
00605       return MIB_REGISTRATION_FAILED;
00606     }
00607 
00608     /* 
00609      * fill in subtree
00610      */
00611     memcpy(subtree->name, mibloc, mibloclen*sizeof(oid));
00612     subtree->name[var_subid - 1] += x;
00613     subtree->namelen = (u_char) mibloclen;
00614 
00615     memcpy(subtree->start, mibloc, mibloclen*sizeof(oid));
00616     subtree->start[var_subid - 1] += x;
00617     subtree->start_len = (u_char) mibloclen;
00618 
00619     memcpy(subtree->end, mibloc, mibloclen*sizeof(oid));
00620     subtree->end[var_subid - 1] += x;
00621     subtree->end[mibloclen - 1]++;
00622     subtree->end_len = (u_char) mibloclen;
00623 
00624     memcpy(subtree->label, moduleName, strlen(moduleName)+1);
00625 
00626     if (var) {
00627       v = (u_char *)var + (x*varsize);
00628       subtree->variables = (struct variable *) malloc(varsize);
00629       memcpy(subtree->variables, v, varsize);
00630       subtree->variables_len = 1;
00631       subtree->variables_width = varsize;
00632     }
00633 
00634     subtree->priority = priority;
00635     subtree->timeout  = timeout;
00636     subtree->session = ss;
00637     subtree->flags = (u_char)flags;
00638     subtree->cacheid = -1;
00639 
00640     /*  Since we're not really making use of this in the normal way:  */
00641 
00642     subtree->range_subid = 0;
00643     subtree->range_ubound = 0;
00644 
00645     /*
00646      * load the subtree
00647      */
00648     rc = load_subtree(subtree, context);
00649     if ((rc != MIB_REGISTERED_OK)) {
00650       unregister_mib_context(mibloc, mibloclen, priority, 
00651                              var_subid, numvars, context);
00652       return rc;
00653     }
00654   }
00655 
00656   /*
00657    * fill out registration parameters
00658    */
00659   reg_parms.name = mibloc;
00660   reg_parms.namelen = mibloclen;
00661   reg_parms.priority = priority;
00662   reg_parms.flags = (u_char)flags;
00663   reg_parms.range_subid  = var_subid;
00664   reg_parms.range_ubound = (mibloc[var_subid-1] + numvars - 1);
00665   reg_parms.timeout = timeout;
00666   rc = snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, 1, &reg_parms);
00667   return rc;
00668 }

int register_readfd int    fd,
void(*    func)(int, void *),
void *    data
 

Definition at line 1069 of file agent_registry.c.

01069                                                                    {
01070     if (external_readfdlen < NUM_EXTERNAL_FDS) {
01071         external_readfd[external_readfdlen] = fd;
01072         external_readfdfunc[external_readfdlen] = func;
01073         external_readfd_data[external_readfdlen] = data;
01074         external_readfdlen++;
01075         DEBUGMSGTL(("register_readfd", "registered fd %d\n", fd));
01076         return FD_REGISTERED_OK;
01077     } else {
01078         snmp_log(LOG_CRIT, "register_readfd: too many file descriptors\n");
01079         return FD_REGISTRATION_FAILED;
01080     }
01081 }

int register_signal int    sig,
void(*    func)(int)
 

Definition at line 1184 of file agent_registry.c.

01185 {
01186 
01187     switch (sig) {
01188 #if defined(SIGCHLD)
01189     case SIGCHLD:
01190 #ifdef HAVE_SIGACTION
01191         {
01192                 static struct sigaction act;
01193                 act.sa_handler = agent_SIGCHLD_handler;
01194                 sigemptyset(&act.sa_mask);
01195                 act.sa_flags = 0;
01196                 sigaction(SIGCHLD, &act, NULL);
01197         }
01198 #else
01199         signal(SIGCHLD, agent_SIGCHLD_handler);
01200 #endif
01201         break;
01202 #endif
01203     default:
01204         snmp_log(LOG_CRIT,
01205                  "register_signal: signal %d cannot be handled\n", sig);
01206         return SIG_REGISTRATION_FAILED;
01207     }
01208 
01209     external_signal_handler[sig] = func;
01210     external_signal_scheduled[sig] = 0;
01211     
01212     DEBUGMSGTL(("register_signal", "registered signal %d\n", sig));
01213     return SIG_REGISTERED_OK;
01214 }

int register_writefd int    fd,
void(*    func)(int, void *),
void *    data
 

Definition at line 1083 of file agent_registry.c.

01083                                                                     {
01084     if (external_writefdlen < NUM_EXTERNAL_FDS) {
01085         external_writefd[external_writefdlen] = fd;
01086         external_writefdfunc[external_writefdlen] = func;
01087         external_writefd_data[external_writefdlen] = data;
01088         external_writefdlen++;
01089         DEBUGMSGTL(("register_writefd", "registered fd %d\n", fd));
01090         return FD_REGISTERED_OK;
01091     } else {
01092         snmp_log(LOG_CRIT, "register_writefd: too many file descriptors\n");
01093         return FD_REGISTRATION_FAILED;
01094     }
01095 }

void setup_tree void   
 

Definition at line 1006 of file agent_registry.c.

01007 {
01008 #ifdef USING_AGENTX_SUBAGENT_MODULE
01009   int role;
01010 
01011   role = ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE);
01012   ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE, MASTER_AGENT);
01013 #endif
01014 
01015   register_null(root_subtrees[0].name,  root_subtrees[0].namelen);
01016   register_null(root_subtrees[1].name,  root_subtrees[1].namelen);
01017   register_null(root_subtrees[2].name,  root_subtrees[2].namelen);
01018   
01019   /* Support for 'static' subtrees (subtrees_old) has now been dropped */
01020 
01021   /* No longer necessary to sort the mib tree - this is inherent in
01022      the construction of the subtree structure */
01023 
01024 #ifdef USING_AGENTX_SUBAGENT_MODULE
01025   ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE, role);
01026 #endif
01027 }

int unregister_exceptfd int    fd
 

Definition at line 1145 of file agent_registry.c.

01145                                 {
01146     int i, j;
01147 
01148     for (i = 0; i < external_exceptfdlen; i++) {
01149         if (external_exceptfd[i] == fd) {
01150             external_exceptfdlen--;
01151             for (j = i; j < external_exceptfdlen; j++) {
01152                 external_exceptfd[j] = external_exceptfd[j+1];
01153                 external_exceptfd_data[j] = external_exceptfd_data[j+1];
01154             }
01155             DEBUGMSGTL(("unregister_exceptfd", "unregistered fd %d\n", fd));
01156             return FD_UNREGISTERED_OK;
01157         }
01158     }
01159     return FD_NO_SUCH_REGISTRATION;
01160 }

int unregister_mib oid *    name,
size_t    len
 

Definition at line 774 of file agent_registry.c.

00776 {
00777   return unregister_mib_priority( name, len, DEFAULT_MIB_PRIORITY );
00778 }

int unregister_mib_context oid *    name,
size_t    len,
int    priority,
int    range_subid,
oid    range_ubound,
const char *    context
 

Definition at line 698 of file agent_registry.c.

Referenced by register_mib_context2(), register_mib_table_row(), and unregister_mib_range().

00700 {
00701   struct subtree *list, *myptr;
00702   struct subtree *prev, *child;             /* loop through children */
00703   struct register_parameters reg_parms;
00704 
00705   list = find_subtree( name, len, find_first_subtree(context), context );
00706   if ( list == NULL )
00707         return MIB_NO_SUCH_REGISTRATION;
00708 
00709   for ( child=list, prev=NULL;  child != NULL;
00710                                 prev=child, child=child->children ) {
00711       if (( snmp_oid_compare( child->name, child->namelen, name, len) == 0 )
00712           && ( child->priority == priority ))
00713                 break;  /* found it */
00714   }
00715   if ( child == NULL )
00716         return MIB_NO_SUCH_REGISTRATION;
00717 
00718   unload_subtree( child, prev );
00719   myptr = child;        /* remember this for later */
00720 
00721                 /*
00722                  *  Now handle any occurances in the following subtrees,
00723                  *      as a result of splitting this range.  Due to the
00724                  *      nature of the way such splits work, the first
00725                  *      subtree 'slice' that doesn't refer to the given
00726                  *      name marks the end of the original region.
00727                  *
00728                  *  This should also serve to register ranges.
00729                  */
00730 
00731   for ( list = myptr->next ; list != NULL ; list=list->next ) {
00732         for ( child=list, prev=NULL;  child != NULL;
00733                                       prev=child, child=child->children ) {
00734             if (( snmp_oid_compare( child->name, child->namelen,
00735                                                         name, len) == 0 )
00736                 && ( child->priority == priority )) {
00737 
00738                     unload_subtree( child, prev );
00739                     free_subtree( child );
00740                     break;
00741             }
00742         }
00743         if ( child == NULL )    /* Didn't find the given name */
00744             break;
00745   }
00746   free_subtree( myptr );
00747   
00748   reg_parms.name = name;
00749   reg_parms.namelen = len;
00750   reg_parms.priority = priority;
00751   reg_parms.range_subid  = range_subid;
00752   reg_parms.range_ubound = range_ubound;
00753   reg_parms.flags = 0x00;  /*  this is okay I think  */
00754   snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_UNREGISTER_OID,
00755                       &reg_parms);
00756 
00757   return MIB_UNREGISTERED_OK;
00758 }

int unregister_mib_priority oid *    name,
size_t    len,
int    priority
 

Definition at line 768 of file agent_registry.c.

Referenced by unregister_mib().

00769 {
00770   return unregister_mib_range( name, len, priority, 0, 0 );
00771 }

int unregister_mib_range oid *    name,
size_t    len,
int    priority,
int    range_subid,
oid    range_ubound
 

Definition at line 761 of file agent_registry.c.

Referenced by unregister_mib_priority().

00763 {
00764   return unregister_mib_context( name, len, priority, range_subid, range_ubound, "" );
00765 }

void unregister_mibs_by_session struct snmp_session *    ss
 

Definition at line 781 of file agent_registry.c.

00782 {
00783   struct subtree *list, *list2;
00784   struct subtree *child, *prev, *next_child;
00785 
00786   for( list = (find_first_subtree(ss->contextName)); list != NULL;
00787        list = list2) {
00788     list2 = list->next;
00789     for ( child=list, prev=NULL;  child != NULL; child=next_child ) {
00790 
00791       next_child = child->children;
00792       if (( (ss->flags & SNMP_FLAGS_SUBSESSION) && child->session == ss ) ||
00793           (!(ss->flags & SNMP_FLAGS_SUBSESSION) && child->session &&
00794                                       child->session->subsession == ss )) {
00795               unload_subtree( child, prev );
00796               free_subtree( child );
00797       }
00798       else
00799           prev = child;
00800     }
00801   }
00802 }

int unregister_readfd int    fd
 

Definition at line 1111 of file agent_registry.c.

01111                               {
01112     int i, j;
01113 
01114     for (i = 0; i < external_readfdlen; i++) {
01115         if (external_readfd[i] == fd) {
01116             external_readfdlen--;
01117             for (j = i; j < external_readfdlen; j++) {
01118                 external_readfd[j] = external_readfd[j+1];
01119                 external_readfd_data[j] = external_readfd_data[j+1];
01120             }
01121             DEBUGMSGTL(("unregister_readfd", "unregistered fd %d\n", fd));
01122             return FD_UNREGISTERED_OK;
01123         }
01124     }
01125     return FD_NO_SUCH_REGISTRATION;
01126 }

int unregister_signal int    sig
 

Definition at line 1216 of file agent_registry.c.

01216                                {
01217     signal(sig, SIG_DFL);
01218     DEBUGMSGTL(("unregister_signal", "unregistered signal %d\n", sig));
01219     return SIG_UNREGISTERED_OK;
01220 }

int unregister_writefd int    fd
 

Definition at line 1128 of file agent_registry.c.

01128                                {
01129     int i, j;
01130 
01131     for (i = 0; i < external_writefdlen; i++) {
01132         if (external_writefd[i] == fd) {
01133             external_writefdlen--;
01134             for (j = i; j < external_writefdlen; j++) {
01135                 external_writefd[j] = external_writefd[j+1];
01136                 external_writefd_data[j] = external_writefd_data[j+1];
01137             }
01138             DEBUGMSGTL(("unregister_writefd", "unregistered fd %d\n", fd));
01139             return FD_UNREGISTERED_OK;
01140         }
01141     }
01142     return FD_NO_SUCH_REGISTRATION;
01143 }

Variable Documentation

int external_exceptfd[NUM_EXTERNAL_FDS]
 

Definition at line 102 of file agent_registry.h.

void* external_exceptfd_data[NUM_EXTERNAL_FDS]
 

Definition at line 110 of file agent_registry.h.

void(* external_exceptfdfunc[NUM_EXTERNAL_FDS])(int, void *)
 

Definition at line 106 of file agent_registry.h.

int external_exceptfdlen
 

Definition at line 102 of file agent_registry.h.

int external_readfd[NUM_EXTERNAL_FDS]
 

Definition at line 100 of file agent_registry.h.

void* external_readfd_data[NUM_EXTERNAL_FDS]
 

Definition at line 108 of file agent_registry.h.

void(* external_readfdfunc[NUM_EXTERNAL_FDS])(int, void *)
 

Definition at line 104 of file agent_registry.h.

int external_readfdlen
 

Definition at line 100 of file agent_registry.h.

void(* external_signal_handler[NUM_EXTERNAL_SIGS])(int)
 

Definition at line 128 of file agent_registry.h.

int external_signal_scheduled[NUM_EXTERNAL_SIGS]
 

Definition at line 127 of file agent_registry.h.

int external_writefd[NUM_EXTERNAL_FDS]
 

Definition at line 101 of file agent_registry.h.

void* external_writefd_data[NUM_EXTERNAL_FDS]
 

Definition at line 109 of file agent_registry.h.

void(* external_writefdfunc[NUM_EXTERNAL_FDS])(int, void *)
 

Definition at line 105 of file agent_registry.h.

int external_writefdlen
 

Definition at line 101 of file agent_registry.h.


Generated on Sat Nov 10 14:09:54 2001 for net-snmp by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001
[an error occurred while processing this directive] [an error occurred while processing this directive]

Valid CSS!


Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.