~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to perl/agent/agent.xs

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2010-06-10 18:02:54 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100610180254-6ezvupl2clicwdqf
ImportĀ upstreamĀ versionĀ 5.4.3~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#define sv_undef PL_sv_undef
14
14
#endif
15
15
 
 
16
typedef netsnmp_handler_registration *NetSNMP__agent__netsnmp_handler_registration;
 
17
 
16
18
typedef struct handler_cb_data_s {
17
19
   SV *perl_cb;
18
20
} handler_cb_data;
397
399
        sv_setiv(arg, (IV) handler);
398
400
        XPUSHs(sv_2mortal(rarg));
399
401
        rarg = newSViv(0);
400
 
        arg = newSVrv(rarg, "NetSNMP::agent::reginfo");
 
402
        arg = newSVrv(rarg, "NetSNMP::agent::netsnmp_handler_registrationPtr");
401
403
        sv_setiv(arg, (IV) reginfo);
402
404
        XPUSHs(sv_2mortal(rarg));
403
405
        rarg = newSViv(0);
494
496
 
495
497
MODULE = NetSNMP::agent  PACKAGE = NetSNMP::agent::netsnmp_handler_registration  PREFIX = nsahr_
496
498
 
497
 
netsnmp_handler_registration *
 
499
NetSNMP::agent::netsnmp_handler_registration
498
500
nsahr_new(name, regoid, perlcallback)
499
501
        char *name;
500
502
        char *regoid;
524
526
    OUTPUT:
525
527
        RETVAL
526
528
 
527
 
MODULE = NetSNMP::agent  PACKAGE = netsnmp_handler_registrationPtr  PREFIX = nsahr_
528
 
 
529
529
void
530
530
nsahr_DESTROY(reginfo)
531
531
        netsnmp_handler_registration *reginfo
549
549
    OUTPUT:
550
550
        RETVAL
551
551
 
 
552
 
 
553
MODULE = NetSNMP::agent PACKAGE = NetSNMP::agent::netsnmp_handler_registrationPtr PREFIX = nsahr_
 
554
 
552
555
void
553
556
nsahr_getRootOID(me)
554
557
    SV *me;
773
776
        netsnmp_request_info *request;
774
777
        u_long utmp;
775
778
        long ltmp;
 
779
        uint64_t ulltmp;
 
780
        struct counter64 c64;
776
781
        oid myoid[MAX_OID_LEN];
777
782
        size_t myoid_len;
778
783
        STRLEN stringlen;
828
833
 
829
834
          case ASN_UNSIGNED:
830
835
          case ASN_COUNTER:
831
 
          case ASN_COUNTER64:
832
836
          case ASN_TIMETICKS:
833
837
              /* We want an integer here */
834
838
              if ((SvTYPE(value) == SVt_IV) || (SvTYPE(value) == SVt_PVMG) ||
862
866
                break;
863
867
              }
864
868
 
 
869
          case ASN_COUNTER64:
 
870
              /* We want an integer here */
 
871
              if ((SvTYPE(value) == SVt_IV) || (SvTYPE(value) == SVt_PVMG)) {
 
872
                  /* Good - got a real one (or a blessed scalar which we have to hope will turn out OK) */
 
873
                  ulltmp = SvIV(value);
 
874
                  c64.high = (uint32_t)(ulltmp >> 32);
 
875
                  c64.low  = (uint32_t)ulltmp;
 
876
                  snmp_set_var_typed_value(request->requestvb, (u_char)type,
 
877
                                       (u_char *) &c64, sizeof(struct counter64));
 
878
                  RETVAL = 1;
 
879
                  break;
 
880
              }
 
881
              else if (SvPOKp(value)) {
 
882
                  /* Might be OK - got a string, so try to convert it, allowing base 10, octal, and hex forms */
 
883
                  stringptr = SvPV(value, stringlen);
 
884
#if defined(WIN32)
 
885
                  ulltmp = strtoul(  stringptr, NULL, 0 );
 
886
#else
 
887
                  ulltmp = strtoull( stringptr, NULL, 0 );
 
888
#endif
 
889
                  if (errno == EINVAL) {
 
890
                        snmp_log(LOG_ERR, "Could not convert string to number in setValue: '%s'", stringptr);
 
891
                        RETVAL = 0;
 
892
                        break;
 
893
                  }
 
894
 
 
895
                  c64.high = (uint32_t)(ulltmp >> 32);
 
896
                  c64.low  = (uint32_t)ulltmp;
 
897
                  snmp_set_var_typed_value(request->requestvb, (u_char)type,
 
898
                                       (u_char *) &c64, sizeof(struct counter64));
 
899
                  RETVAL = 1;
 
900
                  break;
 
901
              }
 
902
              else {
 
903
                snmp_log(LOG_ERR, "Non-unsigned-integer value passed to setValue with ASN_COUNTER64: type was %d\n",
 
904
                        SvTYPE(value));
 
905
                RETVAL = 0;
 
906
                break;
 
907
              }
 
908
 
865
909
          case ASN_OCTET_STR:
866
910
          case ASN_BIT_STR:
867
911
              /* Check that we have been passed something with a string value (or a blessed scalar) */