Compare commits

...

5 Commits

Author SHA1 Message Date
qazmko1029
c87e27109d
Merge e46039adb9 into 1cc1536e6a 2024-04-19 16:52:02 +08:00
Erik Ekman
1cc1536e6a test/unit: fix inconsistent nullness check error
Inside a testcase, but still. Trying to address #160
2024-04-09 20:11:39 +02:00
qazmko1029
e46039adb9 snmp: forgot to change OID length 2023-12-30 23:30:06 +08:00
qazmko1029
5c8a07cd87 LwipMibCompiler: compile read-create object as read-write in generated C code 2023-12-30 23:19:59 +08:00
qazmko1029
53c3e8165a snmp: fix SNMPv2 generic trap ID and special varbinds OID to send according to rfc3584 2023-12-30 23:15:52 +08:00
3 changed files with 28 additions and 16 deletions

View File

@ -74,7 +74,7 @@ namespace LwipMibCompiler
string mibFileName = Path.GetFileNameWithoutExtension(mibFile).ToLowerInvariant(); string mibFileName = Path.GetFileNameWithoutExtension(mibFile).ToLowerInvariant();
destFile = Path.Combine(destFile, mibFileName + ".c"); destFile = Path.Combine(destFile, mibFileName + ".c");
} }
string destFileExt = Path.GetExtension(destFile); string destFileExt = Path.GetExtension(destFile);
if (!String.IsNullOrEmpty(destFileExt)) if (!String.IsNullOrEmpty(destFileExt))
{ {
@ -94,10 +94,10 @@ namespace LwipMibCompiler
} }
} }
// read and resolve MIB // read and resolve MIB
Console.WriteLine(" Reading MIB file..."); Console.WriteLine(" Reading MIB file...");
MibDocument md = new MibDocument(mibFile); MibDocument md = new MibDocument(mibFile);
MibTypesResolver.ResolveTypes(md.Modules[0]); MibTypesResolver.ResolveTypes(md.Modules[0]);
MibTree mt = new MibTree(md.Modules[0] as MibModule); MibTree mt = new MibTree(md.Modules[0] as MibModule);
@ -335,7 +335,7 @@ namespace LwipMibCompiler
{ {
Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}'!", mibType.Module, mibType.Name)); Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}'!", mibType.Module, mibType.Name));
} }
return null; return null;
} }
} }
@ -353,7 +353,7 @@ namespace LwipMibCompiler
} }
else if (ote.Access == MaxAccess.readCreate) else if (ote.Access == MaxAccess.readCreate)
{ {
result.AccessMode = SnmpAccessMode.ReadOnly; result.AccessMode = SnmpAccessMode.ReadWrite;
} }
else if (ignoreAccessibleFlag && (ote.Access == MaxAccess.notAccessible)) else if (ignoreAccessibleFlag && (ote.Access == MaxAccess.notAccessible))
{ {
@ -426,7 +426,7 @@ namespace LwipMibCompiler
} }
MibTreeNode rowNode = mibTreeNode.ChildNodes[0]; MibTreeNode rowNode = mibTreeNode.ChildNodes[0];
ObjectType rot = rowNode.Entity as ObjectType; ObjectType rot = rowNode.Entity as ObjectType;
if (rot != null) if (rot != null)
{ {

View File

@ -256,7 +256,7 @@ snmp_prepare_trap_oid(struct snmp_obj_id *dest_snmp_trap_oid, const struct snmp_
if (sizeof(dest_snmp_trap_oid->id) >= sizeof(snmpTrapOID)) { if (sizeof(dest_snmp_trap_oid->id) >= sizeof(snmpTrapOID)) {
MEMCPY(&dest_snmp_trap_oid->id, snmpTrapOID , sizeof(snmpTrapOID)); MEMCPY(&dest_snmp_trap_oid->id, snmpTrapOID , sizeof(snmpTrapOID));
dest_snmp_trap_oid->len = LWIP_ARRAYSIZE(snmpTrapOID); dest_snmp_trap_oid->len = LWIP_ARRAYSIZE(snmpTrapOID);
dest_snmp_trap_oid->id[dest_snmp_trap_oid->len++] = specific_trap + 1; dest_snmp_trap_oid->id[dest_snmp_trap_oid->len++] = generic_trap + 1;
} else { } else {
err = ERR_MEM; err = ERR_MEM;
} }
@ -359,8 +359,8 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
NULL, /* *next */ NULL, /* *next */
NULL, /* *prev */ NULL, /* *prev */
{ /* oid */ { /* oid */
8, /* oid len */ 9, /* oid len */
{1, 3, 6, 1, 2, 1, 1, 3} /* oid for sysUpTime */ {1, 3, 6, 1, 2, 1, 1, 3, 0} /* oid for sysUpTime.0 */
}, },
SNMP_ASN1_TYPE_TIMETICKS, /* type */ SNMP_ASN1_TYPE_TIMETICKS, /* type */
sizeof(u32_t), /* value_len */ sizeof(u32_t), /* value_len */
@ -371,8 +371,8 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
NULL, /* *next */ NULL, /* *next */
NULL, /* *prev */ NULL, /* *prev */
{ /* oid */ { /* oid */
10, /* oid len */ 11, /* oid len */
{1, 3, 6, 1, 6, 3, 1, 1, 4, 1} /* oid for snmpTrapOID */ {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0} /* oid for snmpTrapOID.0 */
}, },
SNMP_ASN1_TYPE_OBJECT_ID, /* type */ SNMP_ASN1_TYPE_OBJECT_ID, /* type */
0, /* value_len */ 0, /* value_len */

View File

@ -88,6 +88,7 @@ START_TEST(test_pbuf_copy_zero_pbuf)
fail_unless(p2->ref == 1); fail_unless(p2->ref == 1);
p3 = pbuf_alloc(PBUF_RAW, p1->tot_len, PBUF_POOL); p3 = pbuf_alloc(PBUF_RAW, p1->tot_len, PBUF_POOL);
fail_unless(p3 != NULL);
err = pbuf_copy(p3, p1); err = pbuf_copy(p3, p1);
fail_unless(err == ERR_VAL); fail_unless(err == ERR_VAL);
@ -161,8 +162,8 @@ START_TEST(test_pbuf_copy_partial_pbuf)
b->payload = packet; b->payload = packet;
pbuf_cat(a, b); pbuf_cat(a, b);
dest = pbuf_alloc(PBUF_RAW, 14, PBUF_RAM); dest = pbuf_alloc(PBUF_RAW, 14, PBUF_RAM);
memset(dest->payload, 0, dest->len);
fail_unless(dest != NULL); fail_unless(dest != NULL);
memset(dest->payload, 0, dest->len);
/* Don't copy if data will not fit */ /* Don't copy if data will not fit */
err = pbuf_copy_partial_pbuf(dest, a, a->tot_len, 4); err = pbuf_copy_partial_pbuf(dest, a, a->tot_len, 4);
@ -198,6 +199,7 @@ START_TEST(test_pbuf_split_64k_on_small_pbufs)
LWIP_UNUSED_ARG(_i); LWIP_UNUSED_ARG(_i);
p = pbuf_alloc(PBUF_RAW, 1, PBUF_POOL); p = pbuf_alloc(PBUF_RAW, 1, PBUF_POOL);
fail_unless(p != NULL);
pbuf_split_64k(p, &rest); pbuf_split_64k(p, &rest);
fail_unless(p->tot_len == 1); fail_unless(p->tot_len == 1);
pbuf_free(p); pbuf_free(p);
@ -267,9 +269,14 @@ START_TEST(test_pbuf_take_at_edge)
u8_t *out; u8_t *out;
int i; int i;
u8_t testdata[] = { 0x01, 0x08, 0x82, 0x02 }; u8_t testdata[] = { 0x01, 0x08, 0x82, 0x02 };
struct pbuf *p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL); struct pbuf *p;
struct pbuf *q = p->next; struct pbuf *q;
LWIP_UNUSED_ARG(_i); LWIP_UNUSED_ARG(_i);
p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL);
fail_unless(p != NULL);
q = p->next;
/* alloc big enough to get a chain of pbufs */ /* alloc big enough to get a chain of pbufs */
fail_if(p->tot_len == p->len); fail_if(p->tot_len == p->len);
memset(p->payload, 0, p->len); memset(p->payload, 0, p->len);
@ -319,9 +326,14 @@ START_TEST(test_pbuf_get_put_at_edge)
u8_t *out; u8_t *out;
u8_t testdata = 0x01; u8_t testdata = 0x01;
u8_t getdata; u8_t getdata;
struct pbuf *p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL); struct pbuf *p;
struct pbuf *q = p->next; struct pbuf *q;
LWIP_UNUSED_ARG(_i); LWIP_UNUSED_ARG(_i);
p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL);
fail_unless(p != NULL);
q = p->next;
/* alloc big enough to get a chain of pbufs */ /* alloc big enough to get a chain of pbufs */
fail_if(p->tot_len == p->len); fail_if(p->tot_len == p->len);
memset(p->payload, 0, p->len); memset(p->payload, 0, p->len);