~ubuntu-branches/ubuntu/wily/net-snmp/wily-proposed

« back to all changes in this revision

Viewing changes to snmplib/snmp_api.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-28 14:59:36 UTC
  • mfrom: (1.2.3 upstream) (1.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100628145936-cbiallic69pn044g
Tags: 5.4.3~dfsg-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/snmpd.postinst: source debconf before doing work, LP: #589056
  - debian/snmp.preinst, debian/snmp.prerm: kill any/all processes owned by
    snmp user before install/uninstall, LP: #573391
  - Add apport hook (LP: #533603):
  - debian/{snmp,snmpd}.apport: Added.
  - debian/control: Build-depends on dh-apport.
  - debian/rules: 
    + Add --with apport.
    + override_dh_apport to install hook on snmpd package only.
 * Dropped patches:
   - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
    if (!retVal)
416
416
        retVal = 2;
417
417
    Reqid = retVal;
 
418
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
 
419
        retVal &= 0x7fff;       /* mask to 15 bits */
 
420
    else
 
421
        retVal &= 0x7fffffff;   /* mask to 31 bits */
 
422
 
 
423
    if (!retVal) {
 
424
        Reqid = retVal = 2;
 
425
    }
418
426
    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_REQUESTID);
419
 
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
420
 
        return (retVal & 0x7fff);       /* mask to 15 bits */
421
 
    else
422
 
        return (retVal & 0x7fffffff);   /* mask to 31 bits */
 
427
    return retVal;
423
428
}
424
429
 
425
430
long
431
436
    if (!retVal)
432
437
        retVal = 2;
433
438
    Msgid = retVal;
 
439
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
 
440
        retVal &= 0x7fff;       /* mask to 15 bits */
 
441
    else
 
442
        retVal &= 0x7fffffff;   /* mask to 31 bits */
 
443
 
 
444
    if (!retVal) {
 
445
        Msgid = retVal = 2;
 
446
    }
434
447
    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_MESSAGEID);
435
 
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
436
 
        return (retVal & 0x7fff);       /* mask to 15 bits */
437
 
    else
438
 
        return (retVal & 0x7fffffff);   /* mask to 31 bits */
 
448
    return retVal;
439
449
}
440
450
 
441
451
long
447
457
    if (!retVal)
448
458
        retVal = 2;
449
459
    Sessid = retVal;
 
460
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
 
461
        retVal &= 0x7fff;       /* mask to 15 bits */
 
462
    else
 
463
        retVal &= 0x7fffffff;   /* mask to 31 bits */
 
464
 
 
465
    if (!retVal) {
 
466
        Sessid = retVal = 2;
 
467
    }
450
468
    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
451
 
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
452
 
        return (retVal & 0x7fff);       /* mask to 15 bits */
453
 
    else
454
 
        return (retVal & 0x7fffffff);   /* mask to 31 bits */
 
469
    return retVal;
455
470
}
456
471
 
457
472
long
463
478
    if (!retVal)
464
479
        retVal = 2;
465
480
    Transid = retVal;
 
481
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
 
482
        retVal &= 0x7fff;       /* mask to 15 bits */
 
483
    else
 
484
        retVal &= 0x7fffffff;   /* mask to 31 bits */
 
485
 
 
486
    if (!retVal) {
 
487
        Transid = retVal = 2;
 
488
    }
466
489
    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
467
 
    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
468
 
        return (retVal & 0x7fff);       /* mask to 15 bits */
469
 
    else
470
 
        return (retVal & 0x7fffffff);   /* mask to 31 bits */
 
490
    return retVal;
471
491
}
472
492
 
473
493
void
614
634
 *
615
635
 * Warning: no debug messages here.
616
636
 */
 
637
static char _init_snmp_init_done = 0;
617
638
static void
618
639
_init_snmp(void)
619
640
{
620
 
    static char     have_done_init = 0;
621
641
 
622
642
    struct timeval  tv;
623
643
    long            tmpReqid, tmpMsgid;
624
644
 
625
 
    if (have_done_init)
 
645
    if (_init_snmp_init_done)
626
646
        return;
627
 
    have_done_init = 1;
 
647
    _init_snmp_init_done = 1;
628
648
    Reqid = 1;
629
649
 
630
650
    snmp_res_init();            /* initialize the mt locking structures */
752
772
    netsnmp_register_service_handlers();
753
773
}
754
774
 
 
775
static int init_snmp_init_done = 0; /* To prevent double init's. */
755
776
/**
756
777
 * Calls the functions to do config file loading and  mib module parsing
757
778
 * in the correct order.
765
786
void
766
787
init_snmp(const char *type)
767
788
{
768
 
    static int      done_init = 0;      /* To prevent double init's. */
769
 
 
770
 
    if (done_init) {
 
789
    if (init_snmp_init_done) {
771
790
        return;
772
791
    }
773
792
 
774
 
    done_init = 1;
 
793
    init_snmp_init_done = 1;
775
794
 
776
795
    /*
777
796
     * make the type available everywhere else 
852
871
    netsnmp_clear_default_target();
853
872
    netsnmp_clear_default_domain();
854
873
    free_etimelist();
 
874
 
 
875
    init_snmp_init_done  = 0;
 
876
    _init_snmp_init_done = 0;
855
877
}
856
878
 
857
879
 
6592
6614
 * may set these error types :
6593
6615
 * SNMPERR_RANGE - type, value, or length not found or out of range
6594
6616
 * SNMPERR_VALUE - value is not correct
 
6617
 * SNMPERR_VAR_TYPE - type is not correct
6595
6618
 * SNMPERR_BAD_NAME - name is not found
6596
6619
 *
6597
6620
 * returns 0 if success, error if failure.
6699
6722
            }
6700
6723
            if (!ep) {
6701
6724
#endif /* NETSNMP_DISABLE_MIB_LOADING */
6702
 
                result = SNMPERR_BAD_NAME;
 
6725
                result = SNMPERR_RANGE;   /* ?? or SNMPERR_VALUE; */
6703
6726
                snmp_set_detail(value);
6704
6727
                break;
6705
6728
#ifndef NETSNMP_DISABLE_MIB_LOADING
6925
6948
                    ltmp = ep->value;
6926
6949
                } else {
6927
6950
#endif /* NETSNMP_DISABLE_MIB_LOADING */
6928
 
                    result = SNMPERR_BAD_NAME;
 
6951
                    result = SNMPERR_RANGE;   /* ?? or SNMPERR_VALUE; */
6929
6952
                    snmp_set_detail(cp);
6930
6953
                    SNMP_FREE(buf);
6931
6954
                    SNMP_FREE(vp);