~ubuntu-branches/debian/lenny/net-snmp/lenny

« back to all changes in this revision

Viewing changes to agent/mibgroup/snmp-usm-dh-objects-mib/usmDHUserKeyTable/usmDHUserKeyTable_interface.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Note: this file originally auto-generated by mib2c using
3
 
 *       version : 1.43 $ of : mfd-interface.m2c,v $ 
 
3
 *       version : 1.67 $ of : mfd-interface.m2c,v $ 
4
4
 *
5
 
 * $Id: usmDHUserKeyTable_interface.c,v 1.8.2.1 2005/01/27 22:56:27 rstory Exp $
 
5
 * $Id: usmDHUserKeyTable_interface.c,v 1.9 2005/12/01 21:31:52 rstory Exp $
6
6
 */
7
7
/*
8
8
 * *********************************************************************
39
39
#include "usmDHUserKeyTable.h"
40
40
 
41
41
 
 
42
#include <net-snmp/agent/table_container.h>
42
43
#include <net-snmp/library/container.h>
43
44
 
44
45
#include "usmDHUserKeyTable_interface.h"
45
46
 
 
47
#include <ctype.h>
 
48
 
46
49
/**********************************************************************
47
50
 **********************************************************************
48
51
 ***
51
54
 **********************************************************************
52
55
 **********************************************************************/
53
56
/*
54
 
 * usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
 
57
 * SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
55
58
 * Its status is Current.
56
59
 * OID: .1.3.6.1.3.101.1.1.2, length: 9
57
60
 */
58
61
typedef struct usmDHUserKeyTable_interface_ctx_s {
59
62
 
60
63
    netsnmp_container *container;
61
 
    netsnmp_cache  *cache;      /* optional cache */
 
64
    netsnmp_cache  *cache;
62
65
 
63
 
    usmDHUserKeyTable_registration_ptr user_ctx;
 
66
    usmDHUserKeyTable_registration *user_ctx;
64
67
 
65
68
    netsnmp_table_registration_info tbl_info;
66
69
 
67
70
    netsnmp_baby_steps_access_methods access_multiplexer;
68
71
 
 
72
    u_int           table_dirty;
 
73
 
69
74
} usmDHUserKeyTable_interface_ctx;
70
75
 
71
76
static usmDHUserKeyTable_interface_ctx usmDHUserKeyTable_if_ctx;
72
77
 
73
 
static void
74
 
                _usmDHUserKeyTable_container_init(usmDHUserKeyTable_interface_ctx *
75
 
                                                  if_ctx);
76
 
 
77
 
 
 
78
static void    
 
79
_usmDHUserKeyTable_container_init(usmDHUserKeyTable_interface_ctx *
 
80
                                  if_ctx);
 
81
static void    
 
82
_usmDHUserKeyTable_container_shutdown(usmDHUserKeyTable_interface_ctx *
 
83
                                      if_ctx);
 
84
 
 
85
 
 
86
netsnmp_container *
 
87
usmDHUserKeyTable_container_get(void)
 
88
{
 
89
    return usmDHUserKeyTable_if_ctx.container;
 
90
}
 
91
 
 
92
usmDHUserKeyTable_registration *
 
93
usmDHUserKeyTable_registration_get(void)
 
94
{
 
95
    return usmDHUserKeyTable_if_ctx.user_ctx;
 
96
}
 
97
 
 
98
usmDHUserKeyTable_registration *
 
99
usmDHUserKeyTable_registration_set(usmDHUserKeyTable_registration * newreg)
 
100
{
 
101
    usmDHUserKeyTable_registration *old =
 
102
        usmDHUserKeyTable_if_ctx.user_ctx;
 
103
    usmDHUserKeyTable_if_ctx.user_ctx = newreg;
 
104
    return old;
 
105
}
 
106
 
 
107
int
 
108
usmDHUserKeyTable_container_size(void)
 
109
{
 
110
    return CONTAINER_SIZE(usmDHUserKeyTable_if_ctx.container);
 
111
}
 
112
 
 
113
u_int
 
114
usmDHUserKeyTable_dirty_get(void)
 
115
{
 
116
    return usmDHUserKeyTable_if_ctx.table_dirty;
 
117
}
 
118
 
 
119
void
 
120
usmDHUserKeyTable_dirty_set(u_int status)
 
121
{
 
122
    DEBUGMSGTL(("usmDHUserKeyTable:usmDHUserKeyTable_dirty_set",
 
123
                "called. was %d, now %d\n",
 
124
                usmDHUserKeyTable_if_ctx.table_dirty, status));
 
125
    usmDHUserKeyTable_if_ctx.table_dirty = status;
 
126
}
 
127
 
 
128
/*
 
129
 * mfd multiplexer modes
 
130
 */
78
131
static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_pre_request;
79
132
static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_post_request;
80
133
static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_object_lookup;
90
143
static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_check_dependencies;
91
144
 
92
145
NETSNMP_STATIC_INLINE int
93
 
                _usmDHUserKeyTable_undo_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
 
146
_usmDHUserKeyTable_undo_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
94
147
                                               netsnmp_variable_list * var,
95
148
                                               int column);
96
149
 
100
153
 *    (Define its contents and how it's structured)
101
154
 */
102
155
void
103
 
_usmDHUserKeyTable_initialize_interface(usmDHUserKeyTable_registration_ptr
 
156
_usmDHUserKeyTable_initialize_interface(usmDHUserKeyTable_registration *
104
157
                                        reg_ptr, u_long flags)
105
158
{
106
159
    netsnmp_baby_steps_access_methods *access_multiplexer =
281
334
     * register table
282
335
     */
283
336
    netsnmp_register_table(reginfo, tbl_info);
 
337
 
284
338
}                               /* _usmDHUserKeyTable_initialize_interface */
285
339
 
 
340
/**
 
341
 * @internal
 
342
 * Shutdown the table usmDHUserKeyTable
 
343
 */
 
344
void
 
345
_usmDHUserKeyTable_shutdown_interface(usmDHUserKeyTable_registration *
 
346
                                      reg_ptr)
 
347
{
 
348
    /*
 
349
     * shutdown the container
 
350
     */
 
351
    _usmDHUserKeyTable_container_shutdown(&usmDHUserKeyTable_if_ctx);
 
352
}
 
353
 
286
354
void
287
355
usmDHUserKeyTable_valid_columns_set(netsnmp_column_info *vc)
288
356
{
348
416
    err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
349
417
                            NULL, 0, &var_usmUserEngineID);
350
418
    if (err)
351
 
        snmp_log(LOG_ERR, "error %d converting index to oid\n");
 
419
        snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
352
420
 
353
421
    /*
354
422
     * parsing may have allocated memory. free it.
451
519
 * allocate resources for a usmDHUserKeyTable_rowreq_ctx
452
520
 */
453
521
usmDHUserKeyTable_rowreq_ctx *
454
 
usmDHUserKeyTable_allocate_rowreq_ctx(usmDHUserKeyTable_data * data)
 
522
usmDHUserKeyTable_allocate_rowreq_ctx(usmDHUserKeyTable_data * data,
 
523
                                      void *user_init_ctx)
455
524
{
456
525
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
457
526
        SNMP_MALLOC_TYPEDEF(usmDHUserKeyTable_rowreq_ctx);
464
533
    } else {
465
534
        if (NULL != data) {
466
535
            /*
467
 
             * for non-transient data, track when we got data from user
 
536
             * track if we got data from user
468
537
             */
469
538
            rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
470
539
            rowreq_ctx->data = data;
483
552
    rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
484
553
 
485
554
    rowreq_ctx->usmDHUserKeyTable_data_list = NULL;
486
 
    rowreq_ctx->usmDHUserKeyTable_reg = usmDHUserKeyTable_if_ctx.user_ctx;
487
555
 
 
556
    /*
 
557
     * if we allocated data, call init routine
 
558
     */
 
559
    if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
 
560
        if (SNMPERR_SUCCESS !=
 
561
            usmDHUserKeyTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
 
562
            usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
 
563
            rowreq_ctx = NULL;
 
564
        }
 
565
    }
488
566
 
489
567
    return rowreq_ctx;
490
568
}                               /* usmDHUserKeyTable_allocate_rowreq_ctx */
501
579
 
502
580
    netsnmp_assert(NULL != rowreq_ctx);
503
581
 
 
582
    usmDHUserKeyTable_rowreq_ctx_cleanup(rowreq_ctx);
504
583
 
505
584
    /*
506
585
     * for non-transient data, don't free data we got from the user
533
612
                                   netsnmp_agent_request_info *agtreq_info,
534
613
                                   netsnmp_request_info *requests)
535
614
{
536
 
    int             rc =
537
 
        usmDHUserKeyTable_pre_request(usmDHUserKeyTable_if_ctx.user_ctx);
 
615
    int             rc;
 
616
 
 
617
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_pre_request", "called\n"));
 
618
 
 
619
    if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
 
620
        DEBUGMSGTL(("internal:usmDHUserKeyTable",
 
621
                    "skipping additional pre_request\n"));
 
622
        return SNMP_ERR_NOERROR;
 
623
    }
 
624
 
 
625
    rc = usmDHUserKeyTable_pre_request(usmDHUserKeyTable_if_ctx.user_ctx);
538
626
    if (MFD_SUCCESS != rc) {
539
627
        /*
540
628
         * nothing we can do about it but log it
541
629
         */
542
 
        DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from "
 
630
        DEBUGMSGTL(("usmDHUserKeyTable", "error %d from "
543
631
                    "usmDHUserKeyTable_pre_request\n", rc));
544
632
        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
545
633
    }
558
646
                                    *agtreq_info,
559
647
                                    netsnmp_request_info *requests)
560
648
{
561
 
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx;
562
 
    int             rc =
563
 
        usmDHUserKeyTable_post_request(usmDHUserKeyTable_if_ctx.user_ctx);
 
649
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
 
650
        netsnmp_container_table_row_extract(requests);
 
651
    int             rc, packet_rc;
 
652
 
 
653
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_post_request", "called\n"));
 
654
 
 
655
    /*
 
656
     * release row context, if deleted
 
657
     */
 
658
    if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
 
659
        usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
 
660
 
 
661
    /*
 
662
     * wait for last call before calling user
 
663
     */
 
664
    if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
 
665
        DEBUGMSGTL(("internal:usmDHUserKeyTable",
 
666
                    "waiting for last post_request\n"));
 
667
        return SNMP_ERR_NOERROR;
 
668
    }
 
669
 
 
670
    packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
 
671
    if ((MFD_SUCCESS != packet_rc) && usmDHUserKeyTable_dirty_get()) {
 
672
        /*
 
673
         * we shouldn't get here. the undo steps should also clear
 
674
         * the dirty flags.
 
675
         */
 
676
        snmp_log(LOG_WARNING,
 
677
                 "usmDHUserKeyTable dirty flag set in post_request "
 
678
                 "but status != SUCCESS.\n");
 
679
    }
 
680
 
 
681
    rc = usmDHUserKeyTable_post_request(usmDHUserKeyTable_if_ctx.user_ctx,
 
682
                                        packet_rc);
564
683
    if (MFD_SUCCESS != rc) {
565
684
        /*
566
685
         * nothing we can do about it but log it
567
686
         */
568
 
        DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from "
 
687
        DEBUGMSGTL(("usmDHUserKeyTable", "error %d from "
569
688
                    "usmDHUserKeyTable_post_request\n", rc));
570
689
    }
571
690
 
572
 
    /*
573
 
     * if there are no errors, check for and handle row creation/deletion
574
 
     */
575
 
    rc = netsnmp_check_requests_error(requests);
576
 
    if ((SNMP_ERR_NOERROR == rc) &&
577
 
        (NULL !=
578
 
         (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) {
579
 
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
580
 
        rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
581
 
            CONTAINER_INSERT(usmDHUserKeyTable_if_ctx.container,
582
 
                             rowreq_ctx);
583
 
        } else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {
584
 
            CONTAINER_REMOVE(usmDHUserKeyTable_if_ctx.container,
585
 
                             rowreq_ctx);
586
 
            usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
587
 
        }
588
 
    }
589
 
 
590
691
    return SNMP_ERR_NOERROR;
591
692
}                               /* _mfd_usmDHUserKeyTable_post_request */
592
693
 
601
702
                                     *agtreq_info,
602
703
                                     netsnmp_request_info *requests)
603
704
{
 
705
    int             rc = SNMP_ERR_NOERROR;
604
706
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
605
707
        netsnmp_container_table_row_extract(requests);
606
708
 
613
715
     */
614
716
 
615
717
    if (NULL == rowreq_ctx) {
616
 
        netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION);
617
 
    } else {
 
718
        rc = SNMP_ERR_NOCREATION;
 
719
    }
 
720
 
 
721
    if (MFD_SUCCESS != rc)
 
722
        netsnmp_request_set_error_all(requests, rc);
 
723
    else
618
724
        usmDHUserKeyTable_row_prep(rowreq_ctx);
619
 
    }
620
725
 
621
 
    return SNMP_ERR_NOERROR;
 
726
    return SNMP_VALIDATE_ERR(rc);
622
727
}                               /* _mfd_usmDHUserKeyTable_object_lookup */
623
728
 
624
729
/***********************************************************************
636
741
{
637
742
    int             rc = SNMPERR_SUCCESS;
638
743
 
639
 
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_column", "called\n"));
 
744
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_column", "called for %d\n", column));
640
745
 
641
746
 
642
747
    netsnmp_assert(NULL != rowreq_ctx);
739
844
                                           tri->colnum);
740
845
        if (rc) {
741
846
            if (MFD_SKIP == rc) {
742
 
                requests->requestvb->type = ASN_PRIV_RETRY;
 
847
                requests->requestvb->type = SNMP_NOSUCHINSTANCE;
743
848
                rc = SNMP_ERR_NOERROR;
744
849
            }
745
850
        } else if (NULL == requests->requestvb->val.string) {
766
871
    return SNMP_ERR_NOERROR;
767
872
}                               /* _mfd_usmDHUserKeyTable_get_values */
768
873
 
 
874
 
769
875
/***********************************************************************
770
876
 *
771
877
 * SET processing
787
893
{
788
894
    int             rc = SNMPERR_SUCCESS;
789
895
 
790
 
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_check_column", "called\n"));
 
896
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_check_column", "called for %d\n", column));
791
897
 
792
898
    netsnmp_assert(NULL != rowreq_ctx);
793
899
 
798
904
         */
799
905
    case COLUMN_USMDHUSERAUTHKEYCHANGE:
800
906
        rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
801
 
        /*
802
 
         * yyy-rks: anything else we can do here? 
803
 
         */
804
 
        if (SNMPERR_SUCCESS == rc) {
 
907
        if (SNMPERR_SUCCESS != rc) {
 
908
            DEBUGMSGTL(("usmDHUserKeyTable:_usmDHUserKeyTable_check_column:usmDHUserAuthKeyChange", "varbind validation failed (eg bad type or size)\n"));
 
909
        } else {
805
910
            rc = usmDHUserAuthKeyChange_check_value(rowreq_ctx,
806
911
                                                    (char *) var->val.
807
912
                                                    string, var->val_len);
820
925
         */
821
926
    case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
822
927
        rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
823
 
        /*
824
 
         * yyy-rks: anything else we can do here? 
825
 
         */
826
 
        if (SNMPERR_SUCCESS == rc) {
 
928
        if (SNMPERR_SUCCESS != rc) {
 
929
            DEBUGMSGTL(("usmDHUserKeyTable:_usmDHUserKeyTable_check_column:usmDHUserOwnAuthKeyChange", "varbind validation failed (eg bad type or size)\n"));
 
930
        } else {
827
931
            rc = usmDHUserOwnAuthKeyChange_check_value(rowreq_ctx,
828
932
                                                       (char *) var->val.
829
933
                                                       string,
843
947
         */
844
948
    case COLUMN_USMDHUSERPRIVKEYCHANGE:
845
949
        rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
846
 
        /*
847
 
         * yyy-rks: anything else we can do here? 
848
 
         */
849
 
        if (SNMPERR_SUCCESS == rc) {
 
950
        if (SNMPERR_SUCCESS != rc) {
 
951
            DEBUGMSGTL(("usmDHUserKeyTable:_usmDHUserKeyTable_check_column:usmDHUserPrivKeyChange", "varbind validation failed (eg bad type or size)\n"));
 
952
        } else {
850
953
            rc = usmDHUserPrivKeyChange_check_value(rowreq_ctx,
851
954
                                                    (char *) var->val.
852
955
                                                    string, var->val_len);
865
968
         */
866
969
    case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
867
970
        rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
868
 
        /*
869
 
         * yyy-rks: anything else we can do here? 
870
 
         */
871
 
        if (SNMPERR_SUCCESS == rc) {
 
971
        if (SNMPERR_SUCCESS != rc) {
 
972
            DEBUGMSGTL(("usmDHUserKeyTable:_usmDHUserKeyTable_check_column:usmDHUserOwnPrivKeyChange", "varbind validation failed (eg bad type or size)\n"));
 
973
        } else {
872
974
            rc = usmDHUserOwnPrivKeyChange_check_value(rowreq_ctx,
873
975
                                                       (char *) var->val.
874
976
                                                       string,
883
985
        }
884
986
        break;
885
987
 
886
 
    default:   /** We shouldn't get here */
 
988
    default:    /** We shouldn't get here */
887
989
        rc = SNMP_ERR_GENERR;
888
990
        snmp_log(LOG_ERR,
889
991
                 "unknown column %d in _usmDHUserKeyTable_check_column\n",
932
1034
}                               /* _mfd_usmDHUserKeyTable_check_objects */
933
1035
 
934
1036
 
935
 
 
936
1037
/*----------------------------------------------------------------------
937
1038
 *
938
1039
 * SET: check dependencies
957
1058
 
958
1059
    rc = usmDHUserKeyTable_check_dependencies(rowreq_ctx);
959
1060
    if (rc) {
960
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1061
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
961
1062
                    "usmDHUserKeyTable_check_dependencies\n", rc));
962
1063
        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
963
1064
    }
980
1081
{
981
1082
    int             rc = SNMPERR_SUCCESS;
982
1083
 
983
 
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_setup_column", "called\n"));
 
1084
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_setup_column", "called for %d\n", column));
984
1085
 
985
1086
    netsnmp_assert(NULL != rowreq_ctx);
986
1087
 
990
1091
         * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
991
1092
         */
992
1093
    case COLUMN_USMDHUSERAUTHKEYCHANGE:
993
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSERAUTHKEYCHANGE;
 
1094
        rowreq_ctx->column_set_flags |= COLUMN_USMDHUSERAUTHKEYCHANGE_FLAG;
994
1095
        rc = usmDHUserAuthKeyChange_undo_setup(rowreq_ctx);
995
1096
        break;
996
1097
 
998
1099
         * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
999
1100
         */
1000
1101
    case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
1001
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNAUTHKEYCHANGE;
 
1102
        rowreq_ctx->column_set_flags |=
 
1103
            COLUMN_USMDHUSEROWNAUTHKEYCHANGE_FLAG;
1002
1104
        rc = usmDHUserOwnAuthKeyChange_undo_setup(rowreq_ctx);
1003
1105
        break;
1004
1106
 
1006
1108
         * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1007
1109
         */
1008
1110
    case COLUMN_USMDHUSERPRIVKEYCHANGE:
1009
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSERPRIVKEYCHANGE;
 
1111
        rowreq_ctx->column_set_flags |= COLUMN_USMDHUSERPRIVKEYCHANGE_FLAG;
1010
1112
        rc = usmDHUserPrivKeyChange_undo_setup(rowreq_ctx);
1011
1113
        break;
1012
1114
 
1014
1116
         * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1015
1117
         */
1016
1118
    case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
1017
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNPRIVKEYCHANGE;
 
1119
        rowreq_ctx->column_set_flags |=
 
1120
            COLUMN_USMDHUSEROWNPRIVKEYCHANGE_FLAG;
1018
1121
        rc = usmDHUserOwnPrivKeyChange_undo_setup(rowreq_ctx);
1019
1122
        break;
1020
1123
 
1064
1167
    rowreq_ctx->column_set_flags = 0;
1065
1168
    rc = usmDHUserKeyTable_undo_setup(rowreq_ctx);
1066
1169
    if (MFD_SUCCESS != rc) {
1067
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1170
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1068
1171
                    "usmDHUserKeyTable_undo_setup\n", rc));
1069
1172
        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
1070
1173
    } else {
1083
1186
            rc = _usmDHUserKeyTable_undo_setup_column(rowreq_ctx,
1084
1187
                                                      tri->colnum);
1085
1188
            if (MFD_SUCCESS != rc) {
1086
 
                DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd",
1087
 
                            "error %d from "
 
1189
                DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1088
1190
                            "usmDHUserKeyTable_undo_setup_column\n", rc));
1089
1191
                netsnmp_set_request_error(agtreq_info, requests,
1090
1192
                                          SNMP_VALIDATE_ERR(rc));
1126
1228
        /*
1127
1229
         * nothing we can do about it but log it
1128
1230
         */
1129
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1231
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1130
1232
                    "usmDHUserKeyTable_undo_cleanup\n", rc));
1131
1233
    }
1132
1234
 
1138
1240
        rowreq_ctx->undo = NULL;
1139
1241
    }
1140
1242
 
1141
 
    /*
1142
 
     * clear set flags
1143
 
     */
1144
 
    rowreq_ctx->column_set_flags = 0;
1145
1243
 
1146
1244
    return SNMP_ERR_NOERROR;
1147
1245
}                               /* _mfd_usmDHUserKeyTable_undo_cleanup */
1162
1260
    int             rc = SNMPERR_SUCCESS;
1163
1261
 
1164
1262
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_set_column",
1165
 
                "called\n"));
 
1263
                "called for %d\n", column));
1166
1264
 
1167
1265
    netsnmp_assert(NULL != rowreq_ctx);
1168
1266
 
1172
1270
         * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1173
1271
         */
1174
1272
    case COLUMN_USMDHUSERAUTHKEYCHANGE:
1175
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSERAUTHKEYCHANGE;
 
1273
        rowreq_ctx->column_set_flags |= COLUMN_USMDHUSERAUTHKEYCHANGE_FLAG;
1176
1274
        rc = usmDHUserAuthKeyChange_set(rowreq_ctx,
1177
1275
                                        (char *) var->val.string,
1178
1276
                                        var->val_len);
1182
1280
         * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1183
1281
         */
1184
1282
    case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
1185
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNAUTHKEYCHANGE;
 
1283
        rowreq_ctx->column_set_flags |=
 
1284
            COLUMN_USMDHUSEROWNAUTHKEYCHANGE_FLAG;
1186
1285
        rc = usmDHUserOwnAuthKeyChange_set(rowreq_ctx,
1187
1286
                                           (char *) var->val.string,
1188
1287
                                           var->val_len);
1192
1291
         * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1193
1292
         */
1194
1293
    case COLUMN_USMDHUSERPRIVKEYCHANGE:
1195
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSERPRIVKEYCHANGE;
 
1294
        rowreq_ctx->column_set_flags |= COLUMN_USMDHUSERPRIVKEYCHANGE_FLAG;
1196
1295
        rc = usmDHUserPrivKeyChange_set(rowreq_ctx,
1197
1296
                                        (char *) var->val.string,
1198
1297
                                        var->val_len);
1202
1301
         * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
1203
1302
         */
1204
1303
    case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
1205
 
        rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNPRIVKEYCHANGE;
 
1304
        rowreq_ctx->column_set_flags |=
 
1305
            COLUMN_USMDHUSEROWNPRIVKEYCHANGE_FLAG;
1206
1306
        rc = usmDHUserOwnPrivKeyChange_set(rowreq_ctx,
1207
1307
                                           (char *) var->val.string,
1208
1308
                                           var->val_len);
1212
1312
        snmp_log(LOG_ERR,
1213
1313
                 "unknown column %d in _usmDHUserKeyTable_set_column\n",
1214
1314
                 column);
 
1315
        rc = SNMP_ERR_GENERR;
1215
1316
        break;
1216
1317
    }
1217
1318
 
1246
1347
                                           requests->requestvb,
1247
1348
                                           tri->colnum);
1248
1349
        if (MFD_SUCCESS != rc) {
1249
 
            DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1350
            DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1250
1351
                        "usmDHUserKeyTable_set_column\n", rc));
1251
1352
            netsnmp_set_request_error(agtreq_info, requests,
1252
1353
                                      SNMP_VALIDATE_ERR(rc));
1282
1383
 
1283
1384
    rc = usmDHUserKeyTable_commit(rowreq_ctx);
1284
1385
    if (MFD_SUCCESS != rc) {
1285
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1386
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1286
1387
                    "usmDHUserKeyTable_commit\n", rc));
1287
1388
        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
1288
1389
    }
1289
1390
 
 
1391
    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
 
1392
        /*
 
1393
         * if we successfully commited this row, set the dirty flag. Use the
 
1394
         * current value + 1 (i.e. dirty = # rows changed).
 
1395
         * this is checked in post_request...
 
1396
         */
 
1397
        usmDHUserKeyTable_dirty_set(usmDHUserKeyTable_dirty_get() + 1); /* set table dirty flag */
 
1398
    }
 
1399
 
1290
1400
    return SNMP_ERR_NOERROR;
1291
1401
}
1292
1402
 
1304
1414
 
1305
1415
    netsnmp_assert(NULL != rowreq_ctx);
1306
1416
 
 
1417
    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
 
1418
        u_int           d = usmDHUserKeyTable_dirty_get();
 
1419
 
 
1420
        netsnmp_assert(d != 0);
 
1421
        if (d)
 
1422
            usmDHUserKeyTable_dirty_set(d - 1);
 
1423
    }
 
1424
 
1307
1425
    rc = usmDHUserKeyTable_undo_commit(rowreq_ctx);
1308
1426
    if (MFD_SUCCESS != rc) {
1309
1427
        /*
1310
1428
         * nothing we can do about it but log it
1311
1429
         */
1312
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1430
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1313
1431
                    "usmDHUserKeyTable_undo_commit\n", rc));
1314
1432
    }
1315
1433
 
 
1434
    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
 
1435
        snmp_log(LOG_WARNING,
 
1436
                 "usmDHUserKeyTable row dirty flag still set after undo_commit\n");
 
1437
        rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;
 
1438
    }
 
1439
 
1316
1440
    return SNMP_ERR_NOERROR;
1317
1441
}                               /* _mfd_usmDHUserKeyTable_commit */
1318
1442
 
1332
1456
{
1333
1457
    int             rc = SNMPERR_SUCCESS;
1334
1458
 
1335
 
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_column", "called\n"));
 
1459
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_column", "called for %d\n", column));
1336
1460
 
1337
1461
    netsnmp_assert(NULL != rowreq_ctx);
1338
1462
 
1391
1515
 
1392
1516
    netsnmp_assert(NULL != rowreq_ctx);
1393
1517
 
 
1518
    rc = usmDHUserKeyTable_undo(rowreq_ctx);
 
1519
    if (MFD_SUCCESS != rc) {
 
1520
        /*
 
1521
         * nothing we can do about it but log it
 
1522
         */
 
1523
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
 
1524
                    "usmDHUserKeyTable_undo\n", rc));
 
1525
    }
 
1526
 
1394
1527
    for (; requests; requests = requests->next) {
1395
1528
        /*
1396
1529
         * set column data
1406
1539
            /*
1407
1540
             * nothing we can do about it but log it
1408
1541
             */
1409
 
            DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1542
            DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1410
1543
                        "usmDHUserKeyTable_undo_column\n", rc));
1411
1544
        }
1412
1545
    }                           /* for results */
1440
1573
    rc = usmDHUserKeyTable_irreversible_commit(rowreq_ctx);
1441
1574
    if (MFD_SUCCESS != rc) {
1442
1575
        netsnmp_request_set_error_all(requests, SNMP_ERR_COMMITFAILED);
1443
 
        DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
 
1576
        DEBUGMSGTL(("usmDHUserKeyTable:mfd", "error %d from "
1444
1577
                    "usmDHUserKeyTable_irreversible_commit\n", rc));
1445
1578
    }
1446
1579
 
 
1580
    /*
 
1581
     * check for and handle row creation/deletion
 
1582
     * and update column exist flags...
 
1583
     */
 
1584
    if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {
 
1585
        CONTAINER_REMOVE(usmDHUserKeyTable_if_ctx.container, rowreq_ctx);
 
1586
    } else {
 
1587
        if (rowreq_ctx->column_set_flags) {
 
1588
            rowreq_ctx->column_set_flags = 0;
 
1589
        }
 
1590
    }
 
1591
 
1447
1592
    return SNMP_ERR_NOERROR;
1448
1593
}                               /* _mfd_usmDHUserKeyTable_irreversible_commit */
1449
1594
 
1452
1597
 * DATA ACCESS
1453
1598
 *
1454
1599
 ***********************************************************************/
 
1600
static void     _container_free(netsnmp_container * container);
 
1601
 
1455
1602
/**
1456
1603
 * @internal
1457
1604
 */
1472
1619
    /*
1473
1620
     * call user code
1474
1621
     */
1475
 
    return usmDHUserKeyTable_cache_load((netsnmp_container *) cache->
1476
 
                                        magic);
 
1622
    return usmDHUserKeyTable_container_load((netsnmp_container *) cache->
 
1623
                                            magic);
1477
1624
}                               /* _cache_load */
1478
1625
 
1479
1626
/**
1480
1627
 * @internal
1481
1628
 */
1482
1629
static void
1483
 
_cache_item_free(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, void *context)
1484
 
{
1485
 
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_cache_item_free",
1486
 
                "called\n"));
1487
 
 
1488
 
    if (NULL == rowreq_ctx)
1489
 
        return;
1490
 
 
1491
 
    usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
1492
 
}                               /* _cache_item_free */
1493
 
 
1494
 
/**
1495
 
 * @internal
1496
 
 */
1497
 
static void
1498
1630
_cache_free(netsnmp_cache * cache, void *magic)
1499
1631
{
1500
1632
    netsnmp_container *container;
1509
1641
 
1510
1642
    container = (netsnmp_container *) cache->magic;
1511
1643
 
 
1644
    _container_free(container);
 
1645
}                               /* _cache_free */
 
1646
 
 
1647
/**
 
1648
 * @internal
 
1649
 */
 
1650
static void
 
1651
_container_item_free(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
 
1652
                     void *context)
 
1653
{
 
1654
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_container_item_free",
 
1655
                "called\n"));
 
1656
 
 
1657
    if (NULL == rowreq_ctx)
 
1658
        return;
 
1659
 
 
1660
    usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
 
1661
}                               /* _container_item_free */
 
1662
 
 
1663
/**
 
1664
 * @internal
 
1665
 */
 
1666
static void
 
1667
_container_free(netsnmp_container * container)
 
1668
{
 
1669
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_container_free", "called\n"));
 
1670
 
 
1671
    if (NULL == container) {
 
1672
        snmp_log(LOG_ERR,
 
1673
                 "invalid container in usmDHUserKeyTable_container_free\n");
 
1674
        return;
 
1675
    }
 
1676
 
1512
1677
    /*
1513
1678
     * call user code
1514
1679
     */
1515
 
    usmDHUserKeyTable_cache_free(container);
 
1680
    usmDHUserKeyTable_container_free(container);
1516
1681
 
1517
1682
    /*
1518
1683
     * free all items. inefficient, but easy.
1519
1684
     */
1520
1685
    CONTAINER_CLEAR(container,
1521
 
                    (netsnmp_container_obj_func *) _cache_item_free, NULL);
1522
 
}                               /* _cache_free */
 
1686
                    (netsnmp_container_obj_func *) _container_item_free,
 
1687
                    NULL);
 
1688
}                               /* _container_free */
1523
1689
 
1524
1690
/**
1525
1691
 * @internal
1526
 
 * initialize the iterator container with functions or wrappers
 
1692
 * initialize the container with functions or wrappers
1527
1693
 */
1528
1694
void
1529
1695
_usmDHUserKeyTable_container_init(usmDHUserKeyTable_interface_ctx * if_ctx)
1531
1697
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_container_init", "called\n"));
1532
1698
 
1533
1699
    /*
1534
 
     * set up the cache
 
1700
     * cache init
1535
1701
     */
1536
1702
    if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */
1537
1703
                                         _cache_load, _cache_free,
1554
1720
                 "usmDHUserKeyTable_container_init\n");
1555
1721
        return;
1556
1722
    }
1557
 
    if_ctx->cache->magic = (void *) if_ctx->container;
 
1723
 
 
1724
    if (NULL != if_ctx->cache)
 
1725
        if_ctx->cache->magic = (void *) if_ctx->container;
1558
1726
}                               /* _usmDHUserKeyTable_container_init */
 
1727
 
 
1728
/**
 
1729
 * @internal
 
1730
 * shutdown the container with functions or wrappers
 
1731
 */
 
1732
void
 
1733
_usmDHUserKeyTable_container_shutdown(usmDHUserKeyTable_interface_ctx *
 
1734
                                      if_ctx)
 
1735
{
 
1736
    DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_container_shutdown", "called\n"));
 
1737
 
 
1738
    usmDHUserKeyTable_container_shutdown(if_ctx->container);
 
1739
 
 
1740
    _container_free(if_ctx->container);
 
1741
 
 
1742
}                               /* _usmDHUserKeyTable_container_shutdown */
 
1743
 
 
1744
 
 
1745
usmDHUserKeyTable_rowreq_ctx *
 
1746
usmDHUserKeyTable_row_find_by_mib_index(usmDHUserKeyTable_mib_index *
 
1747
                                        mib_idx)
 
1748
{
 
1749
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx;
 
1750
    oid             oid_tmp[MAX_OID_LEN];
 
1751
    netsnmp_index   oid_idx;
 
1752
    int             rc;
 
1753
 
 
1754
    /*
 
1755
     * set up storage for OID
 
1756
     */
 
1757
    oid_idx.oids = oid_tmp;
 
1758
    oid_idx.len = sizeof(oid_tmp) / sizeof(oid);
 
1759
 
 
1760
    /*
 
1761
     * convert
 
1762
     */
 
1763
    rc = usmDHUserKeyTable_index_to_oid(&oid_idx, mib_idx);
 
1764
    if (MFD_SUCCESS != rc)
 
1765
        return NULL;
 
1766
 
 
1767
    rowreq_ctx =
 
1768
        CONTAINER_FIND(usmDHUserKeyTable_if_ctx.container, &oid_idx);
 
1769
 
 
1770
    return rowreq_ctx;
 
1771
}