summaryrefslogtreecommitdiffstats
path: root/lib/src/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/base.c')
-rw-r--r--lib/src/base.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/src/base.c b/lib/src/base.c
index a15d55938..8c689da50 100644
--- a/lib/src/base.c
+++ b/lib/src/base.c
@@ -32,21 +32,20 @@ hicn_packet_format_snprintf (char *s, size_t size, hicn_packet_format_t format)
{
char *cur = s;
int rc;
- for (unsigned i = 0; i < 4; i++)
- {
- if (i > 0)
- {
- rc = snprintf (cur, size - (cur - s), " %s ", "/");
- if (rc < 0 || rc >= size - (cur - s))
- return rc;
- cur += rc;
- }
- rc = snprintf (cur, size - (cur - s), "%s",
- hicn_ops_vft[format.as_u8[i]]->name);
- if (rc < 0 || rc >= size - (cur - s))
- return rc;
- cur += rc;
- }
+ HICN_PACKET_FORMAT_ENUMERATE (format, i, protocol, {
+ if (i > 1)
+ {
+ rc = snprintf (cur, size - (cur - s), " %s ", "/");
+ if (rc < 0 || rc >= size - (cur - s))
+ return rc;
+ cur += rc;
+ }
+
+ rc = snprintf (cur, size - (cur - s), "%s", hicn_ops_vft[protocol]->name);
+ if (rc < 0 || rc >= size - (cur - s))
+ return rc;
+ cur += rc;
+ });
return (int) (cur - s);
}