nat: pnat copy and clear byte instructions
[vpp.git] / src / plugins / nat / pnat / tests / pnat_test_stubs.h
similarity index 90%
rename from src/plugins/nat/pnat/pnat_test_stubs.h
rename to src/plugins/nat/pnat/tests/pnat_test_stubs.h
index 2801398..62aa050 100644 (file)
@@ -35,7 +35,8 @@ u8 *format_ip4_address(u8 *s, va_list *args) {
     return format(s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
 }
 
-u8 *format_pnat_5tuple(u8 *s, va_list *args) { return 0; }
+u8 *format_pnat_match_tuple(u8 *s, va_list *args) { return 0; }
+u8 *format_pnat_rewrite_tuple(u8 *s, va_list *args) { return 0; }
 
 vl_counter_t pnat_error_counters[10];
 
@@ -142,6 +143,28 @@ u8 *format_tcp_header(u8 *s, va_list *args) {
                clib_net_to_host_u16(tcp->checksum));
     return s;
 }
+/* Format UDP header. */
+u8 *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);
+    u32 indent;
+
+    /* Nothing to do. */
+    if (max_header_bytes < sizeof(udp[0]))
+        return format(s, "UDP header truncated");
+
+    indent = format_get_indent(s);
+    indent += 2;
+
+    s = format(s, "UDP: %d -> %d", clib_net_to_host_u16(udp->src_port),
+               clib_net_to_host_u16(udp->dst_port));
+
+    s = format(s, "\n%Ulength %d, checksum 0x%04x", format_white_space, indent,
+               clib_net_to_host_u16(udp->length),
+               clib_net_to_host_u16(udp->checksum));
+
+    return s;
+}
 
 /* Format an IP4 header. */
 u8 *format_ip4_header(u8 *s, va_list *args) {