summaryrefslogtreecommitdiffstats
path: root/lib/src/base.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2022-09-21 17:11:22 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2022-09-30 09:17:13 +0200
commit3476dd9ddecc87d9212c3bf56a5be52079e27def (patch)
tree3c7ea2664e8f99fc4fd4588b9e4493f0dc9bbb93 /lib/src/base.c
parent29647f687c8dadc90e2ba4d3a772eee09a1a4f1b (diff)
feat: support for new packet format in hicn-light
Ref: HICN-792 Change-Id: I3204006bd2dd2be6504c33035c6578ec0292455a Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
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);
}