2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
6 * Author: Harti Brandt <harti@freebsd.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $Begemot: bsnmp/snmpd/action.c,v 1.58 2004/08/06 08:47:09 brandt Exp $
31 * Variable access for SNMPd
33 #include <sys/types.h>
34 #include <sys/sysctl.h>
48 static const struct asn_oid
49 oid_begemotSnmpdModuleTable = OIDX_begemotSnmpdModuleTable;
52 * Get a string value from the KERN sysctl subtree.
55 act_getkernstring(int id)
63 if (sysctl(mib, 2, NULL, &len, NULL, 0) != 0)
65 if ((string = malloc(len)) == NULL)
67 if (sysctl(mib, 2, string, &len, NULL, 0) != 0) {
75 * Get an integer value from the KERN sysctl subtree.
78 act_getkernint(int id)
88 if (sysctl(mib, 2, &value, &len, NULL, 0) != 0)
91 if ((string = malloc(20)) == NULL)
93 sprintf(string, "%lu", value);
98 * Initialize global variables of the system group.
107 if ((systemg.name = act_getkernstring(KERN_HOSTNAME)) == NULL)
110 for (i = 0; i < 4; i++)
113 if ((v[0] = act_getkernstring(KERN_HOSTNAME)) == NULL)
115 if ((v[1] = act_getkernint(KERN_HOSTID)) == NULL)
117 if ((v[2] = act_getkernstring(KERN_OSTYPE)) == NULL)
119 if ((v[3] = act_getkernstring(KERN_OSRELEASE)) == NULL)
122 for (i = 0, len = 0; i < 4; i++)
123 len += strlen(v[i]) + 1;
125 if ((systemg.descr = malloc(len)) == NULL)
127 sprintf(systemg.descr, "%s %s %s %s", v[0], v[1], v[2], v[3]);
132 for (i = 0; i < 4; i++)
140 /*************************************************************
145 op_system_group(struct snmp_context *ctx, struct snmp_value *value,
146 u_int sub, u_int iidx __unused, enum snmp_op op)
148 asn_subid_t which = value->var.subs[sub - 1];
152 case SNMP_OP_GETNEXT:
162 if (community != COMM_INITIALIZE)
163 return (SNMP_ERR_NOT_WRITEABLE);
164 return (string_save(value, ctx, -1, &systemg.descr));
166 case LEAF_sysObjectId:
167 if (community != COMM_INITIALIZE)
168 return (SNMP_ERR_NOT_WRITEABLE);
169 return (oid_save(value, ctx, &systemg.object_id));
171 case LEAF_sysContact:
172 return (string_save(value, ctx, -1, &systemg.contact));
175 return (string_save(value, ctx, -1, &systemg.name));
177 case LEAF_sysLocation:
178 return (string_save(value, ctx, -1, &systemg.location));
180 return (SNMP_ERR_NO_CREATION);
182 case SNMP_OP_ROLLBACK:
186 string_rollback(ctx, &systemg.descr);
187 return (SNMP_ERR_NOERROR);
188 case LEAF_sysObjectId:
189 oid_rollback(ctx, &systemg.object_id);
190 return (SNMP_ERR_NOERROR);
191 case LEAF_sysContact:
192 string_rollback(ctx, &systemg.contact);
193 return (SNMP_ERR_NOERROR);
195 string_rollback(ctx, &systemg.name);
196 return (SNMP_ERR_NOERROR);
197 case LEAF_sysLocation:
198 string_rollback(ctx, &systemg.location);
199 return (SNMP_ERR_NOERROR);
208 return (SNMP_ERR_NOERROR);
209 case LEAF_sysObjectId:
211 return (SNMP_ERR_NOERROR);
212 case LEAF_sysContact:
214 return (SNMP_ERR_NOERROR);
217 return (SNMP_ERR_NOERROR);
218 case LEAF_sysLocation:
220 return (SNMP_ERR_NOERROR);
231 return (string_get(value, systemg.descr, -1));
232 case LEAF_sysObjectId:
233 return (oid_get(value, &systemg.object_id));
235 value->v.uint32 = get_ticks() - start_tick;
237 case LEAF_sysContact:
238 return (string_get(value, systemg.contact, -1));
240 return (string_get(value, systemg.name, -1));
241 case LEAF_sysLocation:
242 return (string_get(value, systemg.location, -1));
243 case LEAF_sysServices:
244 value->v.integer = systemg.services;
246 case LEAF_sysORLastChange:
247 value->v.uint32 = systemg.or_last_change;
250 return (SNMP_ERR_NOERROR);
253 /*************************************************************
258 op_debug(struct snmp_context *ctx, struct snmp_value *value, u_int sub,
259 u_int iidx __unused, enum snmp_op op)
261 asn_subid_t which = value->var.subs[sub - 1];
265 case SNMP_OP_GETNEXT:
271 case LEAF_begemotSnmpdDebugDumpPdus:
272 value->v.integer = TRUTH_MK(debug.dump_pdus);
275 case LEAF_begemotSnmpdDebugSnmpTrace:
276 value->v.uint32 = snmp_trace;
279 case LEAF_begemotSnmpdDebugSyslogPri:
280 value->v.integer = debug.logpri;
283 return (SNMP_ERR_NOERROR);
288 case LEAF_begemotSnmpdDebugDumpPdus:
289 if (!TRUTH_OK(value->v.integer))
290 return (SNMP_ERR_WRONG_VALUE);
291 ctx->scratch->int1 = debug.dump_pdus;
292 debug.dump_pdus = TRUTH_GET(value->v.integer);
293 return (SNMP_ERR_NOERROR);
295 case LEAF_begemotSnmpdDebugSnmpTrace:
296 ctx->scratch->int1 = snmp_trace;
297 snmp_trace = value->v.uint32;
298 return (SNMP_ERR_NOERROR);
300 case LEAF_begemotSnmpdDebugSyslogPri:
301 if (value->v.integer < 0 || value->v.integer > 8)
302 return (SNMP_ERR_WRONG_VALUE);
303 ctx->scratch->int1 = debug.logpri;
304 debug.logpri = (u_int)value->v.integer;
305 return (SNMP_ERR_NOERROR);
307 return (SNMP_ERR_NO_CREATION);
309 case SNMP_OP_ROLLBACK:
312 case LEAF_begemotSnmpdDebugDumpPdus:
313 debug.dump_pdus = ctx->scratch->int1;
314 return (SNMP_ERR_NOERROR);
316 case LEAF_begemotSnmpdDebugSnmpTrace:
317 snmp_trace = ctx->scratch->int1;
318 return (SNMP_ERR_NOERROR);
320 case LEAF_begemotSnmpdDebugSyslogPri:
321 debug.logpri = ctx->scratch->int1;
322 return (SNMP_ERR_NOERROR);
329 case LEAF_begemotSnmpdDebugDumpPdus:
330 case LEAF_begemotSnmpdDebugSnmpTrace:
331 return (SNMP_ERR_NOERROR);
333 case LEAF_begemotSnmpdDebugSyslogPri:
334 if (debug.logpri == 0)
337 setlogmask(LOG_UPTO(debug.logpri - 1));
338 return (SNMP_ERR_NOERROR);
345 /*************************************************************
350 op_or_table(struct snmp_context *ctx __unused, struct snmp_value *value,
351 u_int sub, u_int iidx __unused, enum snmp_op op)
353 struct objres *objres;
357 case SNMP_OP_GETNEXT:
358 if ((objres = NEXT_OBJECT_INT(&objres_list, &value->var, sub))
360 return (SNMP_ERR_NOSUCHNAME);
361 value->var.subs[sub] = objres->index;
362 value->var.len = sub + 1;
366 if ((objres = FIND_OBJECT_INT(&objres_list, &value->var, sub))
368 return (SNMP_ERR_NOSUCHNAME);
372 if ((objres = FIND_OBJECT_INT(&objres_list, &value->var, sub))
374 return (SNMP_ERR_NO_CREATION);
375 return (SNMP_ERR_NOT_WRITEABLE);
377 case SNMP_OP_ROLLBACK:
384 * Come here for GET, GETNEXT.
386 switch (value->var.subs[sub - 1]) {
389 value->v.oid = objres->oid;
392 case LEAF_sysORDescr:
393 return (string_get(value, objres->descr, -1));
395 case LEAF_sysORUpTime:
396 value->v.uint32 = objres->uptime;
399 return (SNMP_ERR_NOERROR);
402 /*************************************************************
407 op_snmp(struct snmp_context *ctx, struct snmp_value *value,
408 u_int sub, u_int iidx __unused, enum snmp_op op)
412 case SNMP_OP_GETNEXT:
416 switch (value->var.subs[sub - 1]) {
418 case LEAF_snmpInPkts:
419 value->v.uint32 = snmpd_stats.inPkts;
422 case LEAF_snmpInBadVersions:
423 value->v.uint32 = snmpd_stats.inBadVersions;
426 case LEAF_snmpInBadCommunityNames:
427 value->v.uint32 = snmpd_stats.inBadCommunityNames;
430 case LEAF_snmpInBadCommunityUses:
431 value->v.uint32 = snmpd_stats.inBadCommunityUses;
434 case LEAF_snmpInASNParseErrs:
435 value->v.uint32 = snmpd_stats.inASNParseErrs;
438 case LEAF_snmpEnableAuthenTraps:
439 value->v.integer = TRUTH_MK(snmpd.auth_traps);
442 case LEAF_snmpSilentDrops:
443 value->v.uint32 = snmpd_stats.silentDrops;
446 case LEAF_snmpProxyDrops:
447 value->v.uint32 = snmpd_stats.proxyDrops;
451 return (SNMP_ERR_NOSUCHNAME);
454 return (SNMP_ERR_NOERROR);
457 switch (value->var.subs[sub - 1]) {
458 case LEAF_snmpEnableAuthenTraps:
459 if (!TRUTH_OK(value->v.integer))
460 return (SNMP_ERR_WRONG_VALUE);
461 ctx->scratch->int1 = value->v.integer;
462 snmpd.auth_traps = TRUTH_GET(value->v.integer);
463 return (SNMP_ERR_NOERROR);
467 case SNMP_OP_ROLLBACK:
468 switch (value->var.subs[sub - 1]) {
469 case LEAF_snmpEnableAuthenTraps:
470 snmpd.auth_traps = ctx->scratch->int1;
471 return (SNMP_ERR_NOERROR);
476 switch (value->var.subs[sub - 1]) {
477 case LEAF_snmpEnableAuthenTraps:
478 return (SNMP_ERR_NOERROR);
485 /*************************************************************
487 * SNMPd statistics group
490 op_snmpd_stats(struct snmp_context *ctx __unused, struct snmp_value *value,
491 u_int sub, u_int iidx __unused, enum snmp_op op)
496 switch (value->var.subs[sub - 1]) {
498 case LEAF_begemotSnmpdStatsNoRxBufs:
499 value->v.uint32 = snmpd_stats.noRxbuf;
502 case LEAF_begemotSnmpdStatsNoTxBufs:
503 value->v.uint32 = snmpd_stats.noTxbuf;
506 case LEAF_begemotSnmpdStatsInTooLongPkts:
507 value->v.uint32 = snmpd_stats.inTooLong;
510 case LEAF_begemotSnmpdStatsInBadPduTypes:
511 value->v.uint32 = snmpd_stats.inBadPduTypes;
515 return (SNMP_ERR_NOSUCHNAME);
517 return (SNMP_ERR_NOERROR);
520 case SNMP_OP_ROLLBACK:
522 case SNMP_OP_GETNEXT:
529 * SNMPd configuration scalars
532 op_snmpd_config(struct snmp_context *ctx, struct snmp_value *value,
533 u_int sub, u_int iidx __unused, enum snmp_op op)
535 asn_subid_t which = value->var.subs[sub - 1];
539 case SNMP_OP_GETNEXT:
545 case LEAF_begemotSnmpdTransmitBuffer:
546 value->v.integer = snmpd.txbuf;
548 case LEAF_begemotSnmpdReceiveBuffer:
549 value->v.integer = snmpd.rxbuf;
551 case LEAF_begemotSnmpdCommunityDisable:
552 value->v.integer = TRUTH_MK(snmpd.comm_dis);
554 case LEAF_begemotSnmpdTrap1Addr:
555 return (ip_get(value, snmpd.trap1addr));
556 case LEAF_begemotSnmpdVersionEnable:
557 value->v.uint32 = snmpd.version_enable;
560 return (SNMP_ERR_NOSUCHNAME);
562 return (SNMP_ERR_NOERROR);
567 case LEAF_begemotSnmpdTransmitBuffer:
568 ctx->scratch->int1 = snmpd.txbuf;
569 if (value->v.integer < 484 ||
570 value->v.integer > 65535)
571 return (SNMP_ERR_WRONG_VALUE);
572 snmpd.txbuf = value->v.integer;
573 return (SNMP_ERR_NOERROR);
575 case LEAF_begemotSnmpdReceiveBuffer:
576 ctx->scratch->int1 = snmpd.rxbuf;
577 if (value->v.integer < 484 ||
578 value->v.integer > 65535)
579 return (SNMP_ERR_WRONG_VALUE);
580 snmpd.rxbuf = value->v.integer;
581 return (SNMP_ERR_NOERROR);
583 case LEAF_begemotSnmpdCommunityDisable:
584 ctx->scratch->int1 = snmpd.comm_dis;
585 if (!TRUTH_OK(value->v.integer))
586 return (SNMP_ERR_WRONG_VALUE);
587 if (TRUTH_GET(value->v.integer)) {
591 return (SNMP_ERR_WRONG_VALUE);
593 return (SNMP_ERR_NOERROR);
595 case LEAF_begemotSnmpdTrap1Addr:
596 return (ip_save(value, ctx, snmpd.trap1addr));
598 case LEAF_begemotSnmpdVersionEnable:
599 if (community != COMM_INITIALIZE)
600 return (SNMP_ERR_NOT_WRITEABLE);
601 ctx->scratch->int1 = snmpd.version_enable;
602 if (value->v.uint32 == 0 ||
603 (value->v.uint32 & ~VERS_ENABLE_ALL))
604 return (SNMP_ERR_WRONG_VALUE);
605 snmpd.version_enable = value->v.uint32;
606 return (SNMP_ERR_NOERROR);
610 case SNMP_OP_ROLLBACK:
613 case LEAF_begemotSnmpdTransmitBuffer:
614 snmpd.rxbuf = ctx->scratch->int1;
615 return (SNMP_ERR_NOERROR);
616 case LEAF_begemotSnmpdReceiveBuffer:
617 snmpd.txbuf = ctx->scratch->int1;
618 return (SNMP_ERR_NOERROR);
619 case LEAF_begemotSnmpdCommunityDisable:
620 snmpd.comm_dis = ctx->scratch->int1;
621 return (SNMP_ERR_NOERROR);
622 case LEAF_begemotSnmpdTrap1Addr:
623 ip_rollback(ctx, snmpd.trap1addr);
624 return (SNMP_ERR_NOERROR);
625 case LEAF_begemotSnmpdVersionEnable:
626 snmpd.version_enable = ctx->scratch->int1;
627 return (SNMP_ERR_NOERROR);
634 case LEAF_begemotSnmpdTransmitBuffer:
635 case LEAF_begemotSnmpdReceiveBuffer:
636 case LEAF_begemotSnmpdCommunityDisable:
637 return (SNMP_ERR_NOERROR);
638 case LEAF_begemotSnmpdTrap1Addr:
640 return (SNMP_ERR_NOERROR);
641 case LEAF_begemotSnmpdVersionEnable:
642 return (SNMP_ERR_NOERROR);
650 * The community table
653 op_community(struct snmp_context *ctx, struct snmp_value *value,
654 u_int sub, u_int iidx __unused, enum snmp_op op)
656 asn_subid_t which = value->var.subs[sub - 1];
661 case SNMP_OP_GETNEXT:
662 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
663 (c = NEXT_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
664 return (SNMP_ERR_NOSUCHNAME);
665 index_append(&value->var, sub, &c->index);
669 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
670 (c = FIND_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
671 return (SNMP_ERR_NOSUCHNAME);
675 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
676 (c = FIND_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
677 return (SNMP_ERR_NO_CREATION);
678 if (which != LEAF_begemotSnmpdCommunityString)
679 return (SNMP_ERR_NOT_WRITEABLE);
680 return (string_save(value, ctx, -1, &c->string));
682 case SNMP_OP_ROLLBACK:
683 if (which == LEAF_begemotSnmpdCommunityString) {
684 if ((c = FIND_OBJECT_OID(&community_list, &value->var,
688 string_rollback(ctx, &c->string);
689 return (SNMP_ERR_NOERROR);
694 if (which == LEAF_begemotSnmpdCommunityString) {
695 if ((c = FIND_OBJECT_OID(&community_list, &value->var,
700 return (SNMP_ERR_NOERROR);
710 case LEAF_begemotSnmpdCommunityString:
711 return (string_get(value, c->string, -1));
713 case LEAF_begemotSnmpdCommunityDescr:
714 return (string_get(value, c->descr, -1));
723 struct snmp_dependency dep;
724 u_char section[LM_SECTION_MAX + 1];
730 dep_modules(struct snmp_context *ctx, struct snmp_dependency *dep,
733 struct module_dep *mdep = (struct module_dep *)(void *)dep;
737 case SNMP_DEPOP_COMMIT:
738 if (mdep->path == NULL) {
739 /* unload - find the module */
740 TAILQ_FOREACH(mdep->m, &lmodules, link)
741 if (strcmp(mdep->m->section,
745 /* no such module - that's ok */
746 return (SNMP_ERR_NOERROR);
748 /* handle unloading in the finalizer */
749 return (SNMP_ERR_NOERROR);
752 if ((mdep->m = lm_load(mdep->path, mdep->section)) == NULL) {
754 return (SNMP_ERR_RES_UNAVAIL);
756 /* start in finalizer */
757 return (SNMP_ERR_NOERROR);
759 case SNMP_DEPOP_ROLLBACK:
760 if (mdep->path == NULL) {
761 /* rollback unload - the finalizer takes care */
762 return (SNMP_ERR_NOERROR);
766 return (SNMP_ERR_NOERROR);
768 case SNMP_DEPOP_FINISH:
769 if (mdep->path == NULL) {
770 if (mdep->m != NULL && ctx->code == SNMP_RET_OK)
773 if (mdep->m != NULL && ctx->code == SNMP_RET_OK &&
774 community != COMM_INITIALIZE)
778 return (SNMP_ERR_NOERROR);
784 op_modules(struct snmp_context *ctx, struct snmp_value *value,
785 u_int sub, u_int iidx, enum snmp_op op)
787 asn_subid_t which = value->var.subs[sub - 1];
789 u_char *section, *ptr;
791 struct module_dep *mdep;
796 case SNMP_OP_GETNEXT:
797 if ((m = NEXT_OBJECT_OID(&lmodules, &value->var, sub)) == NULL)
798 return (SNMP_ERR_NOSUCHNAME);
799 index_append(&value->var, sub, &m->index);
803 if ((m = FIND_OBJECT_OID(&lmodules, &value->var, sub)) == NULL)
804 return (SNMP_ERR_NOSUCHNAME);
808 m = FIND_OBJECT_OID(&lmodules, &value->var, sub);
809 if (which != LEAF_begemotSnmpdModulePath) {
811 return (SNMP_ERR_NO_CREATION);
812 return (SNMP_ERR_NOT_WRITEABLE);
815 /* the errors in the next few statements can only happen when
816 * m is NULL, hence the NO_CREATION error. */
817 if (index_decode(&value->var, sub, iidx,
819 return (SNMP_ERR_NO_CREATION);
821 /* check the section name */
822 if (seclen > LM_SECTION_MAX || seclen == 0) {
824 return (SNMP_ERR_NO_CREATION);
826 for (ptr = section; ptr < section + seclen; ptr++)
827 if (!isascii(*ptr) || !isalnum(*ptr)) {
829 return (SNMP_ERR_NO_CREATION);
831 if (!isalpha(section[0])) {
833 return (SNMP_ERR_NO_CREATION);
837 for (ptr = value->v.octetstring.octets;
838 ptr < value->v.octetstring.octets + value->v.octetstring.len;
842 return (SNMP_ERR_WRONG_VALUE);
847 if (value->v.octetstring.len == 0) {
849 return (SNMP_ERR_INCONS_VALUE);
852 if (value->v.octetstring.len != 0) {
854 return (SNMP_ERR_INCONS_VALUE);
858 asn_slice_oid(&idx, &value->var, sub, value->var.len);
860 /* so far, so good */
861 mdep = (struct module_dep *)(void *)snmp_dep_lookup(ctx,
862 &oid_begemotSnmpdModuleTable, &idx,
863 sizeof(*mdep), dep_modules);
866 return (SNMP_ERR_RES_UNAVAIL);
869 if (mdep->section[0] != '\0') {
870 /* two writes to the same entry - bad */
872 return (SNMP_ERR_INCONS_VALUE);
875 strncpy(mdep->section, section, seclen);
876 mdep->section[seclen] = '\0';
879 if (value->v.octetstring.len == 0)
882 if ((mdep->path = malloc(value->v.octetstring.len + 1)) == NULL)
883 return (SNMP_ERR_RES_UNAVAIL);
884 strncpy(mdep->path, value->v.octetstring.octets,
885 value->v.octetstring.len);
886 mdep->path[value->v.octetstring.len] = '\0';
888 ctx->scratch->ptr1 = mdep;
889 return (SNMP_ERR_NOERROR);
891 case SNMP_OP_ROLLBACK:
893 return (SNMP_ERR_NOERROR);
901 case LEAF_begemotSnmpdModulePath:
902 return (string_get(value, m->path, -1));
904 case LEAF_begemotSnmpdModuleComment:
905 return (string_get(value, m->config->comment, -1));
911 op_snmp_set(struct snmp_context *ctx __unused, struct snmp_value *value,
912 u_int sub, u_int iidx __unused, enum snmp_op op)
916 case SNMP_OP_GETNEXT:
920 switch (value->var.subs[sub - 1]) {
922 case LEAF_snmpSetSerialNo:
923 value->v.integer = snmp_serial_no;
929 return (SNMP_ERR_NOERROR);
932 switch (value->var.subs[sub - 1]) {
934 case LEAF_snmpSetSerialNo:
935 if (value->v.integer != snmp_serial_no)
936 return (SNMP_ERR_INCONS_VALUE);
942 return (SNMP_ERR_NOERROR);
944 case SNMP_OP_ROLLBACK:
945 return (SNMP_ERR_NOERROR);
948 if (snmp_serial_no++ == 2147483647)
950 return (SNMP_ERR_NOERROR);
959 op_transport_table(struct snmp_context *ctx __unused, struct snmp_value *value,
960 u_int sub, u_int iidx, enum snmp_op op)
962 asn_subid_t which = value->var.subs[sub - 1];
969 case SNMP_OP_GETNEXT:
970 if ((t = NEXT_OBJECT_OID(&transport_list, &value->var, sub))
972 return (SNMP_ERR_NOSUCHNAME);
973 index_append(&value->var, sub, &t->index);
977 if ((t = FIND_OBJECT_OID(&transport_list, &value->var, sub))
979 return (SNMP_ERR_NOSUCHNAME);
983 t = FIND_OBJECT_OID(&transport_list, &value->var, sub);
984 if (which != LEAF_begemotSnmpdTransportStatus) {
986 return (SNMP_ERR_NO_CREATION);
987 return (SNMP_ERR_NOT_WRITEABLE);
990 /* the errors in the next few statements can only happen when
991 * t is NULL, hence the NO_CREATION error. */
992 if (index_decode(&value->var, sub, iidx,
994 return (SNMP_ERR_NO_CREATION);
996 /* check the section name */
997 if (tnamelen >= TRANS_NAMELEN || tnamelen == 0) {
999 return (SNMP_ERR_NO_CREATION);
1001 for (ptr = tname; ptr < tname + tnamelen; ptr++) {
1002 if (!isascii(*ptr) || !isalnum(*ptr)) {
1004 return (SNMP_ERR_NO_CREATION);
1009 return (SNMP_ERR_NOT_WRITEABLE);
1011 case SNMP_OP_ROLLBACK:
1012 case SNMP_OP_COMMIT:
1013 return (SNMP_ERR_NOERROR);
1020 case LEAF_begemotSnmpdTransportStatus:
1021 value->v.integer = 1;
1024 case LEAF_begemotSnmpdTransportOid:
1025 memcpy(&value->v.oid, &t->vtab->id, sizeof(t->vtab->id));
1028 return (SNMP_ERR_NOERROR);