fork allowing use of the latest official mbed networking library
Fork of Agentbed by
Diff: Agentbed.h
- Revision:
- 1:b2db0ea96703
- Parent:
- 0:bb21da73024a
- Child:
- 3:81f25e337afc
--- a/Agentbed.h Tue Dec 28 13:40:49 2010 +0000 +++ b/Agentbed.h Wed Jan 12 11:17:18 2011 +0000 @@ -78,6 +78,11 @@ // byte data[2]; //}; +typedef union float_u{ + float float_t; + byte data[4]; +} float_u; + enum ASN_BER_BASE_TYPES { // ASN/BER base types ASN_BER_BASE_UNIVERSAL = 0x0, @@ -163,6 +168,7 @@ SNMP_SYNTAX_NSAPADDR = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 5, SNMP_SYNTAX_COUNTER64 = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 6, SNMP_SYNTAX_UINT32 = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 7, + SNMP_SYNTAX_OPAQUE_FLOAT = 0x78, }; typedef struct SNMP_OID { @@ -496,6 +502,25 @@ } } // + // encode's an int32 to int32, opaque syntax + SNMP_ERR_CODES encode(SNMP_SYNTAXES syn, const float value) { + memset(data, 0, SNMP_MAX_VALUE_LEN); + if ( syn == SNMP_SYNTAX_OPAQUE_FLOAT ) { + float_u tmp; + size = 4; + syntax = syn; + tmp.float_t = value; + data[0] = tmp.data[3]; + data[1] = tmp.data[2]; + data[2] = tmp.data[1]; + data[3] = tmp.data[0]; + return SNMP_ERR_NO_ERROR; + } else { + clear(); + return SNMP_ERR_WRONG_TYPE; + } + } + // // encode's a null to null, opaque syntax SNMP_ERR_CODES encode(SNMP_SYNTAXES syn) { clear();