Treat BITS as just OCTET STRING. Example API's for processing bits from char* variable, Call this function by passing *val* from set_handler, /* * bits -- set val * pos -- which bit you want to read from set val */ int bit_get(const unsigned char *bits, int pos) { unsigned int mask; int i;
mask = 0x80; for (i=0; i < (pos % 8); i++) mask = mask >> 1; return (((mask & bits[(int)(pos / 8)]) == mask) ? 1 : 0); } Call this function by passing *ret_val* from get_handler, /* * bits -- ret value from get_handler from function * pos -- which bit you want to set */ void bit_set(unsigned char *bits, int pos) { unsigned char mask; int i; mask = 0x80; for (i = 0; i < (pos % 8); i++) mask = mask >> 1; bits[pos / 8] = bits[pos / 8] | mask; return; } Example snmpset command, Snmpset column.<index> x 28 OR snmpset column.<index> b proxyServer,registrarServer >> I suppose that numbering would be: >> 8 7 6 5 4 3 2 1 >> - - X - X - - - >> If these bits would be set then index 0 of the octet string should be >> equal to: 0x28. >> Is that correct? [JP] yes -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Abhishek Mishra Sent: Tuesday, June 26, 2007 11:51 AM To: net-snmp-users@lists.sourceforge.net Cc: Abhishek Mishra Subject: How to convert BITS data into OCTET String Hi, We have a column in the table that have datatype of BITS. After compilation of the MIB file, it is converted into a character array. I found some information in the RFC# 3416/3417 regarding the conversion but could not understand well how to convert BITS field into the octet string. Following is the BITS field we are using: SYNTAX BITS { other(0), userAgent(1), proxyServer(2), redirectServer(3), registrarServer(4) } Now, I have to set bit 2 (proxyServer) and 4 (registrarServer) into the octet string. Please guide me how the conversion would actually take place. I suppose that numbering would be: 8 7 6 5 4 3 2 1 - - X - X - - - If these bits would be set then index 0 of the octet string should be equal to: 0x28. Is that correct? Kind Regards, -Abhishek ------------------------------------------------------------------------ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users