diff options
Diffstat (limited to 'src/vnet/udp')
-rw-r--r-- | src/vnet/udp/udp.h | 1 | ||||
-rw-r--r-- | src/vnet/udp/udp_format.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h index 0cb085b1d72..95fbcd977ef 100644 --- a/src/vnet/udp/udp.h +++ b/src/vnet/udp/udp.h @@ -281,6 +281,7 @@ format_function_t format_udp_header; format_function_t format_udp_rx_trace; format_function_t format_udp_connection; unformat_function_t unformat_udp_header; +unformat_function_t unformat_udp_port; void udp_add_dst_port (udp_main_t * um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4); diff --git a/src/vnet/udp/udp_format.c b/src/vnet/udp/udp_format.c index 2277e18bcdb..93e7508711b 100644 --- a/src/vnet/udp/udp_format.c +++ b/src/vnet/udp/udp_format.c @@ -82,6 +82,23 @@ format_udp_header (u8 * s, va_list * args) return s; } +uword +unformat_udp_port (unformat_input_t * input, va_list * args) +{ + u16 *result = va_arg (*args, u16 *); + int port; + + /* Numeric type. */ + if (unformat (input, "0x%x", &port) || unformat (input, "%d", &port)) + { + if (port <= 0 || port >= (1 << 16)) + return 0; + *result = port; + return 1; + } + return 0; +} + /* * fd.io coding-style-patch-verification: ON * |