- if (unformat (input, "tcp"))
- *proto = TRANSPORT_PROTO_TCP;
- else if (unformat (input, "TCP"))
- *proto = TRANSPORT_PROTO_TCP;
- else if (unformat (input, "udpc"))
- *proto = TRANSPORT_PROTO_UDPC;
- else if (unformat (input, "UDPC"))
- *proto = TRANSPORT_PROTO_UDPC;
- else if (unformat (input, "udp"))
- *proto = TRANSPORT_PROTO_UDP;
- else if (unformat (input, "UDP"))
- *proto = TRANSPORT_PROTO_UDP;
- else if (unformat (input, "sctp"))
- *proto = TRANSPORT_PROTO_SCTP;
- else if (unformat (input, "SCTP"))
- *proto = TRANSPORT_PROTO_SCTP;
- else if (unformat (input, "tls"))
- *proto = TRANSPORT_PROTO_TLS;
- else if (unformat (input, "TLS"))
- *proto = TRANSPORT_PROTO_TLS;
- else if (unformat (input, "quic"))
- *proto = TRANSPORT_PROTO_QUIC;
- else if (unformat (input, "QUIC"))
- *proto = TRANSPORT_PROTO_QUIC;
- else
- return 0;
- return 1;
+ u8 longest_match = 0, match;
+ char *str_match = 0;
+
+#define _(sym, str, sstr) \
+ if (unformat_transport_str_match (input, str)) \
+ { \
+ match = strlen (str); \
+ if (match > longest_match) \
+ { \
+ *proto = TRANSPORT_PROTO_ ## sym; \
+ longest_match = match; \
+ str_match = str; \
+ } \
+ }
+ foreach_transport_proto
+#undef _
+ if (longest_match)
+ {
+ unformat (input, str_match);
+ return 1;
+ }
+
+ return 0;