X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fudp%2Fudp_format.c;h=93e7508711beb339a9ebf0e08a2fcb7e3035a12f;hb=2ca88ff97884ec9ed20a853b13cee6d86f9c9d0f;hp=abdf561e8c90cd50c854773ab300ce5bb9c6dd20;hpb=68b0fb0c620c7451ef1a6380c43c39de6614db51;p=vpp.git diff --git a/src/vnet/udp/udp_format.c b/src/vnet/udp/udp_format.c index abdf561e8c9..93e7508711b 100644 --- a/src/vnet/udp/udp_format.c +++ b/src/vnet/udp/udp_format.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco and/or its affiliates. + * Copyright (c) 2015-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -45,7 +45,7 @@ format_udp_header (u8 * s, va_list * args) { udp_header_t *udp = va_arg (*args, udp_header_t *); u32 max_header_bytes = va_arg (*args, u32); - uword indent; + u32 indent; u32 header_bytes = sizeof (udp[0]); /* Nothing to do. */ @@ -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 *