2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
5 * Copyright (c) 2004-2006
9 * Author: Harti Brandt <harti@freebsd.org>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * $Begemot: action.c 517 2006-10-31 08:52:04Z brandt_h $
34 * Variable access for SNMPd
36 #include <sys/types.h>
37 #include <sys/sysctl.h>
39 #include <sys/utsname.h>
52 static const struct asn_oid
53 oid_begemotSnmpdModuleTable = OIDX_begemotSnmpdModuleTable;
56 static const struct asn_oid
57 oid_freeBSDVersion = OIDX_freeBSDVersion;
61 * Get a string value from the KERN sysctl subtree.
64 act_getkernstring(int id)
72 if (sysctl(mib, 2, NULL, &len, NULL, 0) != 0)
74 if ((string = malloc(len)) == NULL)
76 if (sysctl(mib, 2, string, &len, NULL, 0) != 0) {
84 * Get an integer value from the KERN sysctl subtree.
87 act_getkernint(int id)
97 if (sysctl(mib, 2, &value, &len, NULL, 0) != 0)
100 if ((string = malloc(20)) == NULL)
102 sprintf(string, "%lu", value);
107 * Initialize global variables of the system group.
120 if (uname(&uts) == -1)
123 if ((systemg.name = strdup(uts.nodename)) == NULL)
126 if ((hostid = act_getkernint(KERN_HOSTID)) == NULL)
129 len = strlen(uts.nodename) + 1;
130 len += strlen(hostid) + 1;
131 len += strlen(uts.sysname) + 1;
132 len += strlen(uts.release) + 1;
134 if ((systemg.descr = malloc(len)) == NULL) {
138 sprintf(systemg.descr, "%s %s %s %s", uts.nodename, hostid, uts.sysname,
143 * Construct a FreeBSD oid
145 systemg.object_id = oid_freeBSDVersion;
147 while ((p = strsep(&rel, ".")) != NULL &&
148 systemg.object_id.len < ASN_MAXOIDLEN) {
149 systemg.object_id.subs[systemg.object_id.len] = 0;
151 num = strtoul(p, &end, 10);
154 systemg.object_id.subs[systemg.object_id.len] = num;
156 systemg.object_id.len++;
167 /*************************************************************
172 op_system_group(struct snmp_context *ctx, struct snmp_value *value,
173 u_int sub, u_int iidx __unused, enum snmp_op op)
175 asn_subid_t which = value->var.subs[sub - 1];
179 case SNMP_OP_GETNEXT:
189 if (community != COMM_INITIALIZE)
190 return (SNMP_ERR_NOT_WRITEABLE);
191 return (string_save(value, ctx, -1, &systemg.descr));
193 case LEAF_sysObjectId:
194 if (community != COMM_INITIALIZE)
195 return (SNMP_ERR_NOT_WRITEABLE);
196 return (oid_save(value, ctx, &systemg.object_id));
198 case LEAF_sysContact:
199 return (string_save(value, ctx, -1, &systemg.contact));
202 return (string_save(value, ctx, -1, &systemg.name));
204 case LEAF_sysLocation:
205 return (string_save(value, ctx, -1, &systemg.location));
207 return (SNMP_ERR_NO_CREATION);
209 case SNMP_OP_ROLLBACK:
213 string_rollback(ctx, &systemg.descr);
214 return (SNMP_ERR_NOERROR);
215 case LEAF_sysObjectId:
216 oid_rollback(ctx, &systemg.object_id);
217 return (SNMP_ERR_NOERROR);
218 case LEAF_sysContact:
219 string_rollback(ctx, &systemg.contact);
220 return (SNMP_ERR_NOERROR);
222 string_rollback(ctx, &systemg.name);
223 return (SNMP_ERR_NOERROR);
224 case LEAF_sysLocation:
225 string_rollback(ctx, &systemg.location);
226 return (SNMP_ERR_NOERROR);
235 return (SNMP_ERR_NOERROR);
236 case LEAF_sysObjectId:
238 return (SNMP_ERR_NOERROR);
239 case LEAF_sysContact:
241 return (SNMP_ERR_NOERROR);
244 return (SNMP_ERR_NOERROR);
245 case LEAF_sysLocation:
247 return (SNMP_ERR_NOERROR);
258 return (string_get(value, systemg.descr, -1));
259 case LEAF_sysObjectId:
260 return (oid_get(value, &systemg.object_id));
262 value->v.uint32 = get_ticks() - start_tick;
264 case LEAF_sysContact:
265 return (string_get(value, systemg.contact, -1));
267 return (string_get(value, systemg.name, -1));
268 case LEAF_sysLocation:
269 return (string_get(value, systemg.location, -1));
270 case LEAF_sysServices:
271 value->v.integer = systemg.services;
273 case LEAF_sysORLastChange:
274 value->v.uint32 = systemg.or_last_change;
277 return (SNMP_ERR_NOERROR);
280 /*************************************************************
285 op_debug(struct snmp_context *ctx, struct snmp_value *value, u_int sub,
286 u_int iidx __unused, enum snmp_op op)
288 asn_subid_t which = value->var.subs[sub - 1];
292 case SNMP_OP_GETNEXT:
298 case LEAF_begemotSnmpdDebugDumpPdus:
299 value->v.integer = TRUTH_MK(debug.dump_pdus);
302 case LEAF_begemotSnmpdDebugSnmpTrace:
303 value->v.uint32 = snmp_trace;
306 case LEAF_begemotSnmpdDebugSyslogPri:
307 value->v.integer = debug.logpri;
310 return (SNMP_ERR_NOERROR);
315 case LEAF_begemotSnmpdDebugDumpPdus:
316 if (!TRUTH_OK(value->v.integer))
317 return (SNMP_ERR_WRONG_VALUE);
318 ctx->scratch->int1 = debug.dump_pdus;
319 debug.dump_pdus = TRUTH_GET(value->v.integer);
320 return (SNMP_ERR_NOERROR);
322 case LEAF_begemotSnmpdDebugSnmpTrace:
323 ctx->scratch->int1 = snmp_trace;
324 snmp_trace = value->v.uint32;
325 return (SNMP_ERR_NOERROR);
327 case LEAF_begemotSnmpdDebugSyslogPri:
328 if (value->v.integer < 0 || value->v.integer > 8)
329 return (SNMP_ERR_WRONG_VALUE);
330 ctx->scratch->int1 = debug.logpri;
331 debug.logpri = (u_int)value->v.integer;
332 return (SNMP_ERR_NOERROR);
334 return (SNMP_ERR_NO_CREATION);
336 case SNMP_OP_ROLLBACK:
339 case LEAF_begemotSnmpdDebugDumpPdus:
340 debug.dump_pdus = ctx->scratch->int1;
341 return (SNMP_ERR_NOERROR);
343 case LEAF_begemotSnmpdDebugSnmpTrace:
344 snmp_trace = ctx->scratch->int1;
345 return (SNMP_ERR_NOERROR);
347 case LEAF_begemotSnmpdDebugSyslogPri:
348 debug.logpri = ctx->scratch->int1;
349 return (SNMP_ERR_NOERROR);
356 case LEAF_begemotSnmpdDebugDumpPdus:
357 case LEAF_begemotSnmpdDebugSnmpTrace:
358 return (SNMP_ERR_NOERROR);
360 case LEAF_begemotSnmpdDebugSyslogPri:
361 if (debug.logpri == 0)
364 setlogmask(LOG_UPTO(debug.logpri - 1));
365 return (SNMP_ERR_NOERROR);
372 /*************************************************************
377 op_or_table(struct snmp_context *ctx __unused, struct snmp_value *value,
378 u_int sub, u_int iidx __unused, enum snmp_op op)
380 struct objres *objres;
384 case SNMP_OP_GETNEXT:
385 if ((objres = NEXT_OBJECT_INT(&objres_list, &value->var, sub))
387 return (SNMP_ERR_NOSUCHNAME);
388 value->var.subs[sub] = objres->index;
389 value->var.len = sub + 1;
393 if ((objres = FIND_OBJECT_INT(&objres_list, &value->var, sub))
395 return (SNMP_ERR_NOSUCHNAME);
399 if ((objres = FIND_OBJECT_INT(&objres_list, &value->var, sub))
401 return (SNMP_ERR_NO_CREATION);
402 return (SNMP_ERR_NOT_WRITEABLE);
404 case SNMP_OP_ROLLBACK:
411 * Come here for GET, GETNEXT.
413 switch (value->var.subs[sub - 1]) {
416 value->v.oid = objres->oid;
419 case LEAF_sysORDescr:
420 return (string_get(value, objres->descr, -1));
422 case LEAF_sysORUpTime:
423 value->v.uint32 = objres->uptime;
426 return (SNMP_ERR_NOERROR);
429 /*************************************************************
434 op_snmp(struct snmp_context *ctx, struct snmp_value *value,
435 u_int sub, u_int iidx __unused, enum snmp_op op)
439 case SNMP_OP_GETNEXT:
443 switch (value->var.subs[sub - 1]) {
445 case LEAF_snmpInPkts:
446 value->v.uint32 = snmpd_stats.inPkts;
449 case LEAF_snmpInBadVersions:
450 value->v.uint32 = snmpd_stats.inBadVersions;
453 case LEAF_snmpInBadCommunityNames:
454 value->v.uint32 = snmpd_stats.inBadCommunityNames;
457 case LEAF_snmpInBadCommunityUses:
458 value->v.uint32 = snmpd_stats.inBadCommunityUses;
461 case LEAF_snmpInASNParseErrs:
462 value->v.uint32 = snmpd_stats.inASNParseErrs;
465 case LEAF_snmpEnableAuthenTraps:
466 value->v.integer = TRUTH_MK(snmpd.auth_traps);
469 case LEAF_snmpSilentDrops:
470 value->v.uint32 = snmpd_stats.silentDrops;
473 case LEAF_snmpProxyDrops:
474 value->v.uint32 = snmpd_stats.proxyDrops;
478 return (SNMP_ERR_NOSUCHNAME);
481 return (SNMP_ERR_NOERROR);
484 switch (value->var.subs[sub - 1]) {
485 case LEAF_snmpEnableAuthenTraps:
486 if (!TRUTH_OK(value->v.integer))
487 return (SNMP_ERR_WRONG_VALUE);
488 ctx->scratch->int1 = value->v.integer;
489 snmpd.auth_traps = TRUTH_GET(value->v.integer);
490 return (SNMP_ERR_NOERROR);
494 case SNMP_OP_ROLLBACK:
495 switch (value->var.subs[sub - 1]) {
496 case LEAF_snmpEnableAuthenTraps:
497 snmpd.auth_traps = ctx->scratch->int1;
498 return (SNMP_ERR_NOERROR);
503 switch (value->var.subs[sub - 1]) {
504 case LEAF_snmpEnableAuthenTraps:
505 return (SNMP_ERR_NOERROR);
512 /*************************************************************
514 * SNMPd statistics group
517 op_snmpd_stats(struct snmp_context *ctx __unused, struct snmp_value *value,
518 u_int sub, u_int iidx __unused, enum snmp_op op)
523 switch (value->var.subs[sub - 1]) {
525 case LEAF_begemotSnmpdStatsNoRxBufs:
526 value->v.uint32 = snmpd_stats.noRxbuf;
529 case LEAF_begemotSnmpdStatsNoTxBufs:
530 value->v.uint32 = snmpd_stats.noTxbuf;
533 case LEAF_begemotSnmpdStatsInTooLongPkts:
534 value->v.uint32 = snmpd_stats.inTooLong;
537 case LEAF_begemotSnmpdStatsInBadPduTypes:
538 value->v.uint32 = snmpd_stats.inBadPduTypes;
542 return (SNMP_ERR_NOSUCHNAME);
544 return (SNMP_ERR_NOERROR);
547 case SNMP_OP_ROLLBACK:
549 case SNMP_OP_GETNEXT:
556 * SNMPd configuration scalars
559 op_snmpd_config(struct snmp_context *ctx, struct snmp_value *value,
560 u_int sub, u_int iidx __unused, enum snmp_op op)
562 asn_subid_t which = value->var.subs[sub - 1];
566 case SNMP_OP_GETNEXT:
572 case LEAF_begemotSnmpdTransmitBuffer:
573 value->v.integer = snmpd.txbuf;
575 case LEAF_begemotSnmpdReceiveBuffer:
576 value->v.integer = snmpd.rxbuf;
578 case LEAF_begemotSnmpdCommunityDisable:
579 value->v.integer = TRUTH_MK(snmpd.comm_dis);
581 case LEAF_begemotSnmpdTrap1Addr:
582 return (ip_get(value, snmpd.trap1addr));
583 case LEAF_begemotSnmpdVersionEnable:
584 value->v.uint32 = snmpd.version_enable;
587 return (SNMP_ERR_NOSUCHNAME);
589 return (SNMP_ERR_NOERROR);
594 case LEAF_begemotSnmpdTransmitBuffer:
595 ctx->scratch->int1 = snmpd.txbuf;
596 if (value->v.integer < 484 ||
597 value->v.integer > 65535)
598 return (SNMP_ERR_WRONG_VALUE);
599 snmpd.txbuf = value->v.integer;
600 return (SNMP_ERR_NOERROR);
602 case LEAF_begemotSnmpdReceiveBuffer:
603 ctx->scratch->int1 = snmpd.rxbuf;
604 if (value->v.integer < 484 ||
605 value->v.integer > 65535)
606 return (SNMP_ERR_WRONG_VALUE);
607 snmpd.rxbuf = value->v.integer;
608 return (SNMP_ERR_NOERROR);
610 case LEAF_begemotSnmpdCommunityDisable:
611 ctx->scratch->int1 = snmpd.comm_dis;
612 if (!TRUTH_OK(value->v.integer))
613 return (SNMP_ERR_WRONG_VALUE);
614 if (TRUTH_GET(value->v.integer)) {
618 return (SNMP_ERR_WRONG_VALUE);
620 return (SNMP_ERR_NOERROR);
622 case LEAF_begemotSnmpdTrap1Addr:
623 return (ip_save(value, ctx, snmpd.trap1addr));
625 case LEAF_begemotSnmpdVersionEnable:
626 if (community != COMM_INITIALIZE)
627 return (SNMP_ERR_NOT_WRITEABLE);
628 ctx->scratch->int1 = snmpd.version_enable;
629 if (value->v.uint32 == 0 ||
630 (value->v.uint32 & ~VERS_ENABLE_ALL))
631 return (SNMP_ERR_WRONG_VALUE);
632 snmpd.version_enable = value->v.uint32;
633 return (SNMP_ERR_NOERROR);
637 case SNMP_OP_ROLLBACK:
640 case LEAF_begemotSnmpdTransmitBuffer:
641 snmpd.rxbuf = ctx->scratch->int1;
642 return (SNMP_ERR_NOERROR);
643 case LEAF_begemotSnmpdReceiveBuffer:
644 snmpd.txbuf = ctx->scratch->int1;
645 return (SNMP_ERR_NOERROR);
646 case LEAF_begemotSnmpdCommunityDisable:
647 snmpd.comm_dis = ctx->scratch->int1;
648 return (SNMP_ERR_NOERROR);
649 case LEAF_begemotSnmpdTrap1Addr:
650 ip_rollback(ctx, snmpd.trap1addr);
651 return (SNMP_ERR_NOERROR);
652 case LEAF_begemotSnmpdVersionEnable:
653 snmpd.version_enable = ctx->scratch->int1;
654 return (SNMP_ERR_NOERROR);
661 case LEAF_begemotSnmpdTransmitBuffer:
662 case LEAF_begemotSnmpdReceiveBuffer:
663 case LEAF_begemotSnmpdCommunityDisable:
664 return (SNMP_ERR_NOERROR);
665 case LEAF_begemotSnmpdTrap1Addr:
667 return (SNMP_ERR_NOERROR);
668 case LEAF_begemotSnmpdVersionEnable:
669 return (SNMP_ERR_NOERROR);
677 * The community table
680 op_community(struct snmp_context *ctx, struct snmp_value *value,
681 u_int sub, u_int iidx __unused, enum snmp_op op)
683 asn_subid_t which = value->var.subs[sub - 1];
688 case SNMP_OP_GETNEXT:
689 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
690 (c = NEXT_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
691 return (SNMP_ERR_NOSUCHNAME);
692 index_append(&value->var, sub, &c->index);
696 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
697 (c = FIND_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
698 return (SNMP_ERR_NOSUCHNAME);
702 if ((community != COMM_INITIALIZE && snmpd.comm_dis) ||
703 (c = FIND_OBJECT_OID(&community_list, &value->var, sub)) == NULL)
704 return (SNMP_ERR_NO_CREATION);
705 if (which != LEAF_begemotSnmpdCommunityString)
706 return (SNMP_ERR_NOT_WRITEABLE);
707 return (string_save(value, ctx, -1, &c->string));
709 case SNMP_OP_ROLLBACK:
710 if (which == LEAF_begemotSnmpdCommunityString) {
711 if ((c = FIND_OBJECT_OID(&community_list, &value->var,
715 string_rollback(ctx, &c->string);
716 return (SNMP_ERR_NOERROR);
721 if (which == LEAF_begemotSnmpdCommunityString) {
722 if ((c = FIND_OBJECT_OID(&community_list, &value->var,
727 return (SNMP_ERR_NOERROR);
737 case LEAF_begemotSnmpdCommunityString:
738 return (string_get(value, c->string, -1));
740 case LEAF_begemotSnmpdCommunityDescr:
741 return (string_get(value, c->descr, -1));
750 struct snmp_dependency dep;
751 u_char section[LM_SECTION_MAX + 1];
757 dep_modules(struct snmp_context *ctx, struct snmp_dependency *dep,
760 struct module_dep *mdep = (struct module_dep *)(void *)dep;
764 case SNMP_DEPOP_COMMIT:
765 if (mdep->path == NULL) {
766 /* unload - find the module */
767 TAILQ_FOREACH(mdep->m, &lmodules, link)
768 if (strcmp(mdep->m->section,
772 /* no such module - that's ok */
773 return (SNMP_ERR_NOERROR);
775 /* handle unloading in the finalizer */
776 return (SNMP_ERR_NOERROR);
779 if ((mdep->m = lm_load(mdep->path, mdep->section)) == NULL) {
781 return (SNMP_ERR_RES_UNAVAIL);
783 /* start in finalizer */
784 return (SNMP_ERR_NOERROR);
786 case SNMP_DEPOP_ROLLBACK:
787 if (mdep->path == NULL) {
788 /* rollback unload - the finalizer takes care */
789 return (SNMP_ERR_NOERROR);
793 return (SNMP_ERR_NOERROR);
795 case SNMP_DEPOP_FINISH:
796 if (mdep->path == NULL) {
797 if (mdep->m != NULL && ctx->code == SNMP_RET_OK)
800 if (mdep->m != NULL && ctx->code == SNMP_RET_OK &&
801 community != COMM_INITIALIZE)
805 return (SNMP_ERR_NOERROR);
811 op_modules(struct snmp_context *ctx, struct snmp_value *value,
812 u_int sub, u_int iidx, enum snmp_op op)
814 asn_subid_t which = value->var.subs[sub - 1];
816 u_char *section, *ptr;
818 struct module_dep *mdep;
823 case SNMP_OP_GETNEXT:
824 if ((m = NEXT_OBJECT_OID(&lmodules, &value->var, sub)) == NULL)
825 return (SNMP_ERR_NOSUCHNAME);
826 index_append(&value->var, sub, &m->index);
830 if ((m = FIND_OBJECT_OID(&lmodules, &value->var, sub)) == NULL)
831 return (SNMP_ERR_NOSUCHNAME);
835 m = FIND_OBJECT_OID(&lmodules, &value->var, sub);
836 if (which != LEAF_begemotSnmpdModulePath) {
838 return (SNMP_ERR_NO_CREATION);
839 return (SNMP_ERR_NOT_WRITEABLE);
842 /* the errors in the next few statements can only happen when
843 * m is NULL, hence the NO_CREATION error. */
844 if (index_decode(&value->var, sub, iidx,
846 return (SNMP_ERR_NO_CREATION);
848 /* check the section name */
849 if (seclen > LM_SECTION_MAX || seclen == 0) {
851 return (SNMP_ERR_NO_CREATION);
853 for (ptr = section; ptr < section + seclen; ptr++)
854 if (!isascii(*ptr) || !isalnum(*ptr)) {
856 return (SNMP_ERR_NO_CREATION);
858 if (!isalpha(section[0])) {
860 return (SNMP_ERR_NO_CREATION);
864 for (ptr = value->v.octetstring.octets;
865 ptr < value->v.octetstring.octets + value->v.octetstring.len;
869 return (SNMP_ERR_WRONG_VALUE);
874 if (value->v.octetstring.len == 0) {
876 return (SNMP_ERR_INCONS_VALUE);
879 if (value->v.octetstring.len != 0) {
881 return (SNMP_ERR_INCONS_VALUE);
885 asn_slice_oid(&idx, &value->var, sub, value->var.len);
887 /* so far, so good */
888 mdep = (struct module_dep *)(void *)snmp_dep_lookup(ctx,
889 &oid_begemotSnmpdModuleTable, &idx,
890 sizeof(*mdep), dep_modules);
893 return (SNMP_ERR_RES_UNAVAIL);
896 if (mdep->section[0] != '\0') {
897 /* two writes to the same entry - bad */
899 return (SNMP_ERR_INCONS_VALUE);
902 strncpy(mdep->section, section, seclen);
903 mdep->section[seclen] = '\0';
906 if (value->v.octetstring.len == 0)
909 if ((mdep->path = malloc(value->v.octetstring.len + 1)) == NULL)
910 return (SNMP_ERR_RES_UNAVAIL);
911 strncpy(mdep->path, value->v.octetstring.octets,
912 value->v.octetstring.len);
913 mdep->path[value->v.octetstring.len] = '\0';
915 ctx->scratch->ptr1 = mdep;
916 return (SNMP_ERR_NOERROR);
918 case SNMP_OP_ROLLBACK:
920 return (SNMP_ERR_NOERROR);
928 case LEAF_begemotSnmpdModulePath:
929 return (string_get(value, m->path, -1));
931 case LEAF_begemotSnmpdModuleComment:
932 return (string_get(value, m->config->comment, -1));
938 op_snmp_set(struct snmp_context *ctx __unused, struct snmp_value *value,
939 u_int sub, u_int iidx __unused, enum snmp_op op)
943 case SNMP_OP_GETNEXT:
947 switch (value->var.subs[sub - 1]) {
949 case LEAF_snmpSetSerialNo:
950 value->v.integer = snmp_serial_no;
956 return (SNMP_ERR_NOERROR);
959 switch (value->var.subs[sub - 1]) {
961 case LEAF_snmpSetSerialNo:
962 if (value->v.integer != snmp_serial_no)
963 return (SNMP_ERR_INCONS_VALUE);
969 return (SNMP_ERR_NOERROR);
971 case SNMP_OP_ROLLBACK:
972 return (SNMP_ERR_NOERROR);
975 if (snmp_serial_no++ == 2147483647)
977 return (SNMP_ERR_NOERROR);
986 op_transport_table(struct snmp_context *ctx __unused, struct snmp_value *value,
987 u_int sub, u_int iidx, enum snmp_op op)
989 asn_subid_t which = value->var.subs[sub - 1];
996 case SNMP_OP_GETNEXT:
997 if ((t = NEXT_OBJECT_OID(&transport_list, &value->var, sub))
999 return (SNMP_ERR_NOSUCHNAME);
1000 index_append(&value->var, sub, &t->index);
1004 if ((t = FIND_OBJECT_OID(&transport_list, &value->var, sub))
1006 return (SNMP_ERR_NOSUCHNAME);
1010 t = FIND_OBJECT_OID(&transport_list, &value->var, sub);
1011 if (which != LEAF_begemotSnmpdTransportStatus) {
1013 return (SNMP_ERR_NO_CREATION);
1014 return (SNMP_ERR_NOT_WRITEABLE);
1017 /* the errors in the next few statements can only happen when
1018 * t is NULL, hence the NO_CREATION error. */
1019 if (index_decode(&value->var, sub, iidx,
1021 return (SNMP_ERR_NO_CREATION);
1023 /* check the section name */
1024 if (tnamelen >= TRANS_NAMELEN || tnamelen == 0) {
1026 return (SNMP_ERR_NO_CREATION);
1028 for (ptr = tname; ptr < tname + tnamelen; ptr++) {
1029 if (!isascii(*ptr) || !isalnum(*ptr)) {
1031 return (SNMP_ERR_NO_CREATION);
1036 return (SNMP_ERR_NOT_WRITEABLE);
1038 case SNMP_OP_ROLLBACK:
1039 case SNMP_OP_COMMIT:
1040 return (SNMP_ERR_NOERROR);
1047 case LEAF_begemotSnmpdTransportStatus:
1048 value->v.integer = 1;
1051 case LEAF_begemotSnmpdTransportOid:
1052 memcpy(&value->v.oid, &t->vtab->id, sizeof(t->vtab->id));
1055 return (SNMP_ERR_NOERROR);