summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKingwel Xie <kingwel.xie@ericsson.com>2018-10-26 23:42:15 -0400
committerDamjan Marion <dmarion@me.com>2018-10-27 09:14:00 +0000
commit4af47092eec97ce88f66174570cfc6a7baad4c6c (patch)
treeaba1f35887db4a14a5f7c91440aa84acc7ed9dc7 /src
parent6e43e0680fc21c6a986289cec4406c3624d3bbe6 (diff)
pg: allow creating pg for udp based protocols
f.g., gtpu4/6 Change-Id: I8bb1dc5fd2fba89ff17ec069a9816bafb9684190 Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/udp/udp.h3
-rw-r--r--src/vnet/udp/udp_pg.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h
index 91d063a2f0c..3b6de6ca271 100644
--- a/src/vnet/udp/udp.h
+++ b/src/vnet/udp/udp.h
@@ -107,6 +107,9 @@ typedef struct
/* Next index for this type. */
u32 next_index;
+
+ /* Parser for packet generator edits for this protocol */
+ unformat_function_t *unformat_pg_edit;
} udp_dst_port_info_t;
typedef enum
diff --git a/src/vnet/udp/udp_pg.c b/src/vnet/udp/udp_pg.c
index a81a9d2ed40..0f633eb6c9f 100644
--- a/src/vnet/udp/udp_pg.c
+++ b/src/vnet/udp/udp_pg.c
@@ -39,6 +39,7 @@
#include <vnet/pg/pg.h>
#include <vnet/ip/ip.h> /* for unformat_udp_udp_port */
+#include <vnet/udp/udp.h>
#define UDP_PG_EDIT_LENGTH (1 << 0)
#define UDP_PG_EDIT_CHECKSUM (1 << 1)
@@ -191,17 +192,25 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args)
u16 dst_port;
tcp_udp_port_info_t *pi;
+ /* For the pg format of applications over UDP local */
+ udp_dst_port_info_t *pi2 = NULL;
+
pi = 0;
if (p->dst_port.type == PG_EDIT_FIXED)
{
dst_port = pg_edit_get_value (&p->dst_port, PG_EDIT_LO);
pi = ip_get_tcp_udp_port_info (im, dst_port);
+ pi2 = udp_get_dst_port_info (&udp_main, dst_port, UDP_IP4);
+ if (!pi2)
+ pi2 = udp_get_dst_port_info (&udp_main, dst_port, UDP_IP6);
}
if (pi && pi->unformat_pg_edit
&& unformat_user (input, pi->unformat_pg_edit, s))
;
-
+ else if (pi2 && pi2->unformat_pg_edit
+ && unformat_user (input, pi2->unformat_pg_edit, s))
+ ;
else if (!unformat_user (input, unformat_pg_payload, s))
goto error;