1 #ifdef BRCM_SNMP_MIB_SUPPORT
3 * This file was generated by mib2c and is intended for use as
4 * a mib module for the ucd-snmp snmpd agent.
9 * This should always be included first before anything else
11 #include <net-snmp/net-snmp-config.h>
13 #include <sys/types.h>
28 * minimal include directives
30 #include <net-snmp/net-snmp-includes.h>
31 #include <net-snmp/agent/net-snmp-agent-includes.h>
33 #include "header_complex.h"
34 #include "snmpNotifyFilterProfileTable.h"
38 * snmpNotifyFilterProfileTable_variables_oid:
39 * this is the top level oid that we want to register under. This
40 * is essentially a prefix, with the suffix appearing in the
45 oid snmpNotifyFilterProfileTable_variables_oid[] =
46 { 1, 3, 6, 1, 6, 3, 13, 1, 2 };
50 * variable2 snmpNotifyFilterProfileTable_variables:
51 * this variable defines function callbacks and type return information
52 * for the snmpNotifyFilterProfileTable mib section
56 struct variable2 snmpNotifyFilterProfileTable_variables[] = {
58 * magic number , variable type , ro/rw , callback fn , L, oidsuffix
60 #define SNMPNOTIFYFILTERPROFILENAME 3
61 {SNMPNOTIFYFILTERPROFILENAME, ASN_OCTET_STR, RWRITE,
62 var_snmpNotifyFilterProfileTable, 2, {1, 1}},
63 #define SNMPNOTIFYFILTERPROFILESTORTYPE 4
64 {SNMPNOTIFYFILTERPROFILESTORTYPE, ASN_INTEGER, RWRITE,
65 var_snmpNotifyFilterProfileTable, 2, {1, 2}},
66 #define SNMPNOTIFYFILTERPROFILEROWSTATUS 5
67 {SNMPNOTIFYFILTERPROFILEROWSTATUS, ASN_INTEGER, RWRITE,
68 var_snmpNotifyFilterProfileTable, 2, {1, 3}},
72 * (L = length of the oidsuffix)
77 * global storage of our data, saved in and configured by header_complex()
79 static struct header_complex_index *snmpNotifyFilterProfileTableStorage =
86 * init_snmpNotifyFilterProfileTable():
87 * Initialization routine. This is called when the agent starts up.
88 * At a minimum, registration of your variables should take place here.
91 init_snmpNotifyFilterProfileTable(void)
93 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "initializing... "));
97 * register ourselves with the agent to handle our mib tree
99 REGISTER_MIB("snmpNotifyFilterProfileTable",
100 snmpNotifyFilterProfileTable_variables, variable2,
101 snmpNotifyFilterProfileTable_variables_oid);
105 * register our config handler(s) to deal with registrations
107 snmpd_register_config_handler("snmpNotifyFilterProfileTable",
108 parse_snmpNotifyFilterProfileTable, NULL,
115 * we need to be called back later to store our data
117 snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
118 store_snmpNotifyFilterProfileTable, NULL);
122 * place any other initialization junk you need here
126 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "done.\n"));
131 * snmpNotifyFilterProfileTable_add(): adds a structure node to our data set
134 snmpNotifyFilterProfileTable_add(struct snmpNotifyFilterProfileTable_data
137 netsnmp_variable_list *vars = NULL;
140 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "adding data... "));
142 * add the index variables to the varbind list, which is
143 * used by header_complex to index the data
146 snmp_varlist_add_variable(&vars, NULL, 0, ASN_PRIV_IMPLIED_OCTET_STR,
147 (u_char *) thedata->snmpTargetParamsName,
148 thedata->snmpTargetParamsNameLen);
150 header_complex_add_data(&snmpNotifyFilterProfileTableStorage, vars,
152 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "registered an entry\n"));
155 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "done.\n"));
156 return SNMPERR_SUCCESS;
161 * parse_snmpNotifyFilterProfileTable():
162 * parses .conf file entries needed to configure the mib.
165 parse_snmpNotifyFilterProfileTable(const char *token, char *line)
168 struct snmpNotifyFilterProfileTable_data *StorageTmp =
169 SNMP_MALLOC_STRUCT(snmpNotifyFilterProfileTable_data);
171 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "parsing config... "));
173 if (StorageTmp == NULL) {
174 config_perror("malloc failure");
179 read_config_read_data(ASN_OCTET_STR, line,
180 &StorageTmp->snmpTargetParamsName,
181 &StorageTmp->snmpTargetParamsNameLen);
182 if (StorageTmp->snmpTargetParamsName == NULL) {
183 config_perror("invalid specification for snmpTargetParamsName");
188 read_config_read_data(ASN_OCTET_STR, line,
189 &StorageTmp->snmpNotifyFilterProfileName,
190 &StorageTmp->snmpNotifyFilterProfileNameLen);
193 read_config_read_data(ASN_INTEGER, line,
194 &StorageTmp->snmpNotifyFilterProfileStorType,
198 read_config_read_data(ASN_INTEGER, line,
200 snmpNotifyFilterProfileRowStatus, &tmpint);
202 snmpNotifyFilterProfileTable_add(StorageTmp);
204 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "done.\n"));
211 * store_snmpNotifyFilterProfileTable():
212 * stores .conf file entries needed to configure the mib.
215 store_snmpNotifyFilterProfileTable(int majorID, int minorID,
216 void *serverarg, void *clientarg)
218 char line[SNMP_MAXBUF];
221 struct snmpNotifyFilterProfileTable_data *StorageTmp;
222 struct header_complex_index *hcindex;
225 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "storing data... "));
227 for (hcindex = snmpNotifyFilterProfileTableStorage; hcindex != NULL;
228 hcindex = hcindex->next) {
230 (struct snmpNotifyFilterProfileTable_data *) hcindex->data;
232 if (StorageTmp->snmpNotifyFilterProfileStorType == ST_NONVOLATILE) {
234 memset(line, 0, sizeof(line));
235 strcat(line, "snmpNotifyFilterProfileTable ");
236 cptr = line + strlen(line);
239 read_config_store_data(ASN_OCTET_STR, cptr,
240 &StorageTmp->snmpTargetParamsName,
242 snmpTargetParamsNameLen);
244 read_config_store_data(ASN_OCTET_STR, cptr,
246 snmpNotifyFilterProfileName,
248 snmpNotifyFilterProfileNameLen);
250 read_config_store_data(ASN_INTEGER, cptr,
252 snmpNotifyFilterProfileStorType,
255 read_config_store_data(ASN_INTEGER, cptr,
257 snmpNotifyFilterProfileRowStatus,
260 snmpd_store_config(line);
263 DEBUGMSGTL(("snmpNotifyFilterProfileTable", "done.\n"));
271 * var_snmpNotifyFilterProfileTable():
272 * Handle this table separately from the scalar value case.
273 * The workings of this are basically the same as for var_snmpNotifyFilterProfileTable above.
276 var_snmpNotifyFilterProfileTable(struct variable *vp,
281 WriteMethod ** write_method)
285 struct snmpNotifyFilterProfileTable_data *StorageTmp = NULL;
288 DEBUGMSGTL(("snmpNotifyFilterProfileTable",
289 "var_snmpNotifyFilterProfileTable: Entering... \n"));
291 * this assumes you have registered all your data properly
293 if ((StorageTmp = (struct snmpNotifyFilterProfileTable_data *)
294 header_complex((struct header_complex_index *)
295 snmpNotifyFilterProfileTableStorage, vp, name,
296 length, exact, var_len, write_method)) == NULL) {
297 if (vp->magic == SNMPNOTIFYFILTERPROFILEROWSTATUS)
298 *write_method = write_snmpNotifyFilterProfileRowStatus;
303 * this is where we do the value assignments for the mib results.
307 case SNMPNOTIFYFILTERPROFILENAME:
308 *write_method = write_snmpNotifyFilterProfileName;
309 *var_len = StorageTmp->snmpNotifyFilterProfileNameLen;
310 return (u_char *) StorageTmp->snmpNotifyFilterProfileName;
312 case SNMPNOTIFYFILTERPROFILESTORTYPE:
313 *write_method = write_snmpNotifyFilterProfileStorType;
314 *var_len = sizeof(StorageTmp->snmpNotifyFilterProfileStorType);
315 return (u_char *) & StorageTmp->snmpNotifyFilterProfileStorType;
317 case SNMPNOTIFYFILTERPROFILEROWSTATUS:
318 *write_method = write_snmpNotifyFilterProfileRowStatus;
319 *var_len = sizeof(StorageTmp->snmpNotifyFilterProfileRowStatus);
320 return (u_char *) & StorageTmp->snmpNotifyFilterProfileRowStatus;
333 write_snmpNotifyFilterProfileName(int action,
338 oid * name, size_t name_len)
341 struct snmpNotifyFilterProfileTable_data *StorageTmp = NULL;
342 static size_t tmplen;
345 (sizeof(snmpNotifyFilterProfileTable_variables_oid) / sizeof(oid) +
349 DEBUGMSGTL(("snmpNotifyFilterProfileTable",
350 "write_snmpNotifyFilterProfileName entering action=%d... \n",
352 if ((StorageTmp = (struct snmpNotifyFilterProfileTable_data *)
353 header_complex((struct header_complex_index *)
354 snmpNotifyFilterProfileTableStorage, NULL,
356 (snmpNotifyFilterProfileTable_variables_oid)
357 / sizeof(oid) + 3 - 1], &newlen, 1, NULL,
359 return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
364 if (var_val_type != ASN_OCTET_STR) {
366 "write to snmpNotifyFilterProfileName not ASN_OCTET_STR\n");
367 return SNMP_ERR_WRONGTYPE;
374 * memory reseveration, final preparation...
381 * Release any resources that have been allocated
388 * The variable has been stored in string for
389 * you to use, and you have just been asked to do something with
390 * it. Note that anything done here must be reversable in the UNDO case
392 tmpvar = StorageTmp->snmpNotifyFilterProfileName;
393 tmplen = StorageTmp->snmpNotifyFilterProfileNameLen;
394 memdup((u_char **) & StorageTmp->snmpNotifyFilterProfileName,
395 var_val, var_val_len);
396 StorageTmp->snmpNotifyFilterProfileNameLen = var_val_len;
402 * Back out any changes made in the ACTION case
404 SNMP_FREE(StorageTmp->snmpNotifyFilterProfileName);
405 StorageTmp->snmpNotifyFilterProfileName = tmpvar;
406 StorageTmp->snmpNotifyFilterProfileNameLen = tmplen;
412 * Things are working well, so it's now safe to make the change
413 * permanently. Make sure that anything done here can't fail!
418 return SNMP_ERR_NOERROR;
424 write_snmpNotifyFilterProfileStorType(int action,
429 oid * name, size_t name_len)
432 struct snmpNotifyFilterProfileTable_data *StorageTmp = NULL;
435 (sizeof(snmpNotifyFilterProfileTable_variables_oid) / sizeof(oid) +
439 DEBUGMSGTL(("snmpNotifyFilterProfileTable",
440 "write_snmpNotifyFilterProfileStorType entering action=%d... \n",
442 if ((StorageTmp = (struct snmpNotifyFilterProfileTable_data *)
443 header_complex((struct header_complex_index *)
444 snmpNotifyFilterProfileTableStorage, NULL,
446 (snmpNotifyFilterProfileTable_variables_oid)
447 / sizeof(oid) + 3 - 1], &newlen, 1, NULL,
449 return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
454 if (var_val_type != ASN_INTEGER) {
456 "write to snmpNotifyFilterProfileStorType not ASN_INTEGER\n");
457 return SNMP_ERR_WRONGTYPE;
464 * memory reseveration, final preparation...
471 * Release any resources that have been allocated
478 * The variable has been stored in long_ret for
479 * you to use, and you have just been asked to do something with
480 * it. Note that anything done here must be reversable in the UNDO case
482 tmpvar = StorageTmp->snmpNotifyFilterProfileStorType;
483 StorageTmp->snmpNotifyFilterProfileStorType = *((long *) var_val);
489 * Back out any changes made in the ACTION case
491 StorageTmp->snmpNotifyFilterProfileStorType = tmpvar;
497 * Things are working well, so it's now safe to make the change
498 * permanently. Make sure that anything done here can't fail!
503 return SNMP_ERR_NOERROR;
512 write_snmpNotifyFilterProfileRowStatus(int action,
517 oid * name, size_t name_len)
519 struct snmpNotifyFilterProfileTable_data *StorageTmp = NULL;
520 static struct snmpNotifyFilterProfileTable_data *StorageNew,
524 (sizeof(snmpNotifyFilterProfileTable_variables_oid) / sizeof(oid) +
526 static int old_value;
528 netsnmp_variable_list *vars;
529 struct header_complex_index *hciptr;
532 StorageTmp = (struct snmpNotifyFilterProfileTable_data *)
533 header_complex((struct header_complex_index *)
534 snmpNotifyFilterProfileTableStorage, NULL,
536 (snmpNotifyFilterProfileTable_variables_oid) /
537 sizeof(oid) + 3 - 1], &newlen, 1, NULL, NULL);
542 if (var_val_type != ASN_INTEGER || var_val == NULL) {
544 "write to snmpNotifyFilterProfileRowStatus not ASN_INTEGER\n");
545 return SNMP_ERR_WRONGTYPE;
547 set_value = *((long *) var_val);
551 * check legal range, and notReady is reserved for us, not a user
553 if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY)
554 return SNMP_ERR_INCONSISTENTVALUE;
560 * stage one: test validity
562 if (StorageTmp == NULL) {
564 * create the row now?
569 * ditch illegal values now
571 if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE)
572 return SNMP_ERR_INCONSISTENTVALUE;
576 * row exists. Check for a valid state change
578 if (set_value == RS_CREATEANDGO
579 || set_value == RS_CREATEANDWAIT) {
581 * can't create a row that exists
583 return SNMP_ERR_INCONSISTENTVALUE;
586 * XXX: interaction with row storage type needed
596 * memory reseveration, final preparation...
598 if (StorageTmp == NULL &&
599 (set_value == RS_CREATEANDGO
600 || set_value == RS_CREATEANDWAIT)) {
606 snmp_varlist_add_variable(&vars, NULL, 0,
607 ASN_PRIV_IMPLIED_OCTET_STR, NULL, 0);
609 if (header_complex_parse_oid
612 [sizeof(snmpNotifyFilterProfileTable_variables_oid) /
613 sizeof(oid) + 2]), newlen, vars) != SNMPERR_SUCCESS) {
615 return SNMP_ERR_INCONSISTENTNAME;
619 SNMP_MALLOC_STRUCT(snmpNotifyFilterProfileTable_data);
620 memdup((u_char **) & (StorageNew->snmpTargetParamsName),
621 vars->val.string, vars->val_len);
622 StorageNew->snmpTargetParamsNameLen = vars->val_len;
623 StorageNew->snmpNotifyFilterProfileStorType = ST_NONVOLATILE;
625 StorageNew->snmpNotifyFilterProfileRowStatus = set_value;
637 * XXX: free, zero vars
640 * Release any resources that have been allocated
649 * The variable has been stored in set_value for you to
650 * use, and you have just been asked to do something with
651 * it. Note that anything done here must be reversable in
656 if (StorageTmp == NULL &&
657 (set_value == RS_CREATEANDGO ||
658 set_value == RS_CREATEANDWAIT)) {
660 * row creation, so add it
662 if (StorageNew != NULL)
663 snmpNotifyFilterProfileTable_add(StorageNew);
665 * XXX: ack, and if it is NULL?
667 } else if (set_value != RS_DESTROY) {
671 old_value = StorageTmp->snmpNotifyFilterProfileRowStatus;
672 StorageTmp->snmpNotifyFilterProfileRowStatus =
676 * destroy... extract it for now
680 header_complex_find_entry
681 (snmpNotifyFilterProfileTableStorage, StorageTmp);
682 StorageDel = (struct snmpNotifyFilterProfileTable_data *)
683 header_complex_extract_entry((struct
684 header_complex_index **)
685 &snmpNotifyFilterProfileTableStorage,
697 * Back out any changes made in the ACTION case
699 if (StorageTmp == NULL &&
700 (set_value == RS_CREATEANDGO ||
701 set_value == RS_CREATEANDWAIT)) {
703 * row creation, so remove it again
706 header_complex_find_entry
707 (snmpNotifyFilterProfileTableStorage, StorageNew);
708 StorageDel = (struct snmpNotifyFilterProfileTable_data *)
709 header_complex_extract_entry((struct header_complex_index
711 &snmpNotifyFilterProfileTableStorage,
716 } else if (StorageDel != NULL) {
718 * row deletion, so add it again
720 snmpNotifyFilterProfileTable_add(StorageDel);
722 } else if (set_value != RS_DESTROY) {
723 StorageTmp->snmpNotifyFilterProfileRowStatus = old_value;
732 * Things are working well, so it's now safe to make the change
733 * permanently. Make sure that anything done here can't fail!
735 if (StorageDel != NULL) {
738 * XXX: free it, its dead
742 && StorageTmp->snmpNotifyFilterProfileRowStatus ==
744 StorageTmp->snmpNotifyFilterProfileRowStatus = RS_ACTIVE;
745 } else if (StorageTmp &&
746 StorageTmp->snmpNotifyFilterProfileRowStatus ==
748 StorageTmp->snmpNotifyFilterProfileRowStatus = RS_NOTINSERVICE;
752 return SNMP_ERR_NOERROR;
758 get_FilterName(char *targetName, size_t targetName_len,
759 size_t * profileName_len)
761 netsnmp_variable_list *vars = NULL;
762 struct snmpNotifyFilterProfileTable_data *data;
765 * put requested info into var structure
767 snmp_varlist_add_variable(&vars, NULL, 0, ASN_PRIV_IMPLIED_OCTET_STR,
768 (u_char *) targetName, targetName_len);
771 * get the data from the header_complex storage
773 data = (struct snmpNotifyFilterProfileTable_data *)
774 header_complex_get(snmpNotifyFilterProfileTableStorage, vars);
782 * return the requested information (if this row is active)
784 if (data && data->snmpNotifyFilterProfileRowStatus == RS_ACTIVE) {
785 *profileName_len = data->snmpNotifyFilterProfileNameLen;
786 return data->snmpNotifyFilterProfileName;
789 *profileName_len = 0;
793 #endif /* BRCM_SNMP_MIB_SUPPORT */