for (int i = 0; i < 4; i++)
if (o->ids[start + i] >= 256)
return 0; // false
-
- return 1; // true
+
+ return 1; // true
}
/**
return buf + snmp_str_size(str);
}
+byte *
+snmp_put_ip4(byte *buf, ip_addr addr)
+{
+ /* octet string has size 4 bytes */
+ STORE_PTR(buf, 4);
+
+ put_u32(buf+4, ipa_to_u32(addr));
+
+ return buf + 8;
+}
+
byte *
snmp_put_blank(byte *buf)
{
}
/** snmp_oid_compare - find the lexicographical order relation between @left and @right
+ * both @left and @right has to be non-blank.
* @left: left object id relation operant
* @right: right object id relation operant
*
- * function returns 0 if left == right -1 if left < right and 1 otherwise
+ * function returns 0 if left == right,
+ * -1 if left < right,
+ * and 1 otherwise
*/
int
snmp_oid_compare(struct oid *left, struct oid *right)
{
const u32 INTERNET_PREFIX[] = {1, 3, 6, 1};
+ /*
+ if (snmp_is_oid_empty(left) && snmp_is_oid_empty(right))
+ return 0;
+
+ if (snmp_is_oid_empty(right))
+ return -1;
+
+ if (snmp_is_oid_empty(left))
+ return 1;
+ */
+
if (left->prefix == 0 && right->prefix == 0)
goto test_ids;
if (right->prefix == 0)
- {
- struct oid *temp = left;
- left = right;
- right = temp;
- }
+ return (-1) * snmp_oid_compare(right, left);
if (left->prefix == 0)
{
byte *snmp_put_blank(byte *buf);
byte *snmp_put_oid(byte *buf, struct oid *oid);
+byte *snmp_put_ip4(byte *buf, ip_addr ip4);
+
byte *snmp_put_fbyte(byte *buf, u8 data);
void snmp_oid_ip4_index(struct oid *o, uint start, ip4_addr addr);