Find the answer to your Linux question:
Results 1 to 6 of 6
Hi I have endian issues in net-snmp. when requesting for a value, instead of presenting 1 I get 16777216 (which is 1000...0000) I tried adding the flag "--with-endianness" in configure ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    9

    endian problems Net-SNMP


    Hi

    I have endian issues in net-snmp.
    when requesting for a value, instead of presenting 1 I get 16777216 (which is 1000...0000)
    I tried adding the flag "--with-endianness" in configure with both big and little values - and none worked

    What to do?

    here are configure commands (in a file that I execute):
    ------------------------------------------------------------------------------
    CC=mips64-octeon-linux-gnu-gcc\
    LD=/home/naamab/projects/eclipse/env/cavium-sdk/tools-gcc-4.3/mips64-octeon-linux-gnu/bin/ld\
    ./configure --target=mips64-octeon-linux-gnu\
    --build=mips64-octeon-linux-gnu\
    --host=i686-pc-linux-gnu\
    --prefix=$PWD/usr\
    --exec-prefix=$PWD/../../../bin\
    --with-build-cc=gc\
    --with-endianness=big\
    --enable-shared\
    --enable-embedded-perl\
    --with-mib-modules="ucd_snmp"\
    --with-default-snmp-version=3\
    --with-sys-location=\
    --with-logfile=/data/net/naamab/snmp/log/snmpd.log\
    --with-persistent-directory=/data/net/naamab/snmp/snmp_persist/

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    In any case, you need to use the host-to-network and network-to-host conversion functions. Which, depends upon the type/size of value you are converting, such as htonl/ntohl (32bit values), htons/ntohs (16bit values). The sending side needs to encode the values using htonl/htons and the receiving side needs to decode the values using ntohl/ntohs functions/macros.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    9
    I'm not sure where I need to use these functuins.
    I created my MIBs source/header files using mib2c tool and filled in the necessary data.

    - on the GET case, after getting the proper value from my external code I use the function "snmp_set_var_typed_value" (Net-SNMP/mib2c function)

    - on the SET action I get the value from the request using :
    req_value = *(requests->requestvb->val.integer);
    and than set the new value on my external code
    (requests is a pointer to the Net-SNMP structure "netsnmp_request_info" and it is one of the paraneters the handler receive)

    Thank you,
    nbm

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2010
    Posts
    9
    Quote Originally Posted by Rubberman View Post
    In any case, you need to use the host-to-network and network-to-host conversion functions. Which, depends upon the type/size of value you are converting, such as htonl/ntohl (32bit values), htons/ntohs (16bit values). The sending side needs to encode the values using htonl/htons and the receiving side needs to decode the values using ntohl/ntohs functions/macros.
    Isn't there a way to tell SNMP to always swap the wndian of the fields instead of using these functions?

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    Quote Originally Posted by nbm2 View Post
    Isn't there a way to tell SNMP to always swap the wndian of the fields instead of using these functions?
    Don't know. I haven't done much SNMP programming and MIB development so I'm not the best person to ask that. However, if the functions don't have a flag to allow that, I would doubt it.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #6
    Just Joined!
    Join Date
    Aug 2010
    Posts
    9
    Thanks a lot for your help.
    I found the problem, and it had nothing to do with SNMP, but with a bug in my code

    Have a great day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •