Commit 7bd9e86f authored by Dafydd Harries's avatar Dafydd Harries

stun_attribute_dump: handle unknown attributes

darcs-hash:20061217202149-c9803-a5ce6fb838b9cf6f201a818a6ff8763a0f90ed9c.gz
parent 8fe09d64
......@@ -93,7 +93,7 @@ stun_attribute_dump(StunAttribute *attr)
(attr->address.ip & 0x000000ff) >> 0,
attr->address.port);
default:
return NULL;
return g_strdup_printf("UNKNOWN (%d)", attr->type);
}
}
......
......@@ -40,6 +40,22 @@ START_TEST (test_attribute_dump)
}
END_TEST
START_TEST (test_attribute_dump_unknown)
{
gchar *dump;
StunAttribute *attr = stun_attribute_unpack(4,
"\x00\xff" // type
"\x00\x00" // length
);
dump = stun_attribute_dump(attr);
fail_unless(0 == strcmp(dump, "UNKNOWN (255)"));
g_free(dump);
stun_attribute_free(attr);
}
END_TEST
START_TEST (test_attribute_unpack)
{
StunAttribute *attr = stun_attribute_unpack(12,
......@@ -152,6 +168,10 @@ stun_suite(void)
tcase_add_test(tcase, test_attribute_dump);
suite_add_tcase(suite, tcase);
tcase = tcase_create("attribute dump unknown");
tcase_add_test(tcase, test_attribute_dump_unknown);
suite_add_tcase(suite, tcase);
tcase = tcase_create("attribute unpack");
tcase_add_test(tcase, test_attribute_unpack);
suite_add_tcase(suite, tcase);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment