summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/ip/udp_pg.c
diff options
context:
space:
mode:
Diffstat (limited to 'vnet/vnet/ip/udp_pg.c')
-rw-r--r--vnet/vnet/ip/udp_pg.c82
1 files changed, 43 insertions, 39 deletions
diff --git a/vnet/vnet/ip/udp_pg.c b/vnet/vnet/ip/udp_pg.c
index 76383a9a9c2..c9d8d38ca4a 100644
--- a/vnet/vnet/ip/udp_pg.c
+++ b/vnet/vnet/ip/udp_pg.c
@@ -38,7 +38,7 @@
*/
#include <vnet/pg/pg.h>
-#include <vnet/ip/ip.h> /* for unformat_udp_udp_port */
+#include <vnet/ip/ip.h> /* for unformat_udp_udp_port */
#define UDP_PG_EDIT_LENGTH (1 << 0)
#define UDP_PG_EDIT_CHECKSUM (1 << 1)
@@ -47,21 +47,19 @@ always_inline void
udp_pg_edit_function_inline (pg_main_t * pg,
pg_stream_t * s,
pg_edit_group_t * g,
- u32 * packets,
- u32 n_packets,
- u32 flags)
+ u32 * packets, u32 n_packets, u32 flags)
{
- vlib_main_t * vm = vlib_get_main();
+ vlib_main_t *vm = vlib_get_main ();
u32 ip_offset, udp_offset;
udp_offset = g->start_byte_offset;
- ip_offset = (g-1)->start_byte_offset;
+ ip_offset = (g - 1)->start_byte_offset;
while (n_packets >= 1)
{
- vlib_buffer_t * p0;
- ip4_header_t * ip0;
- udp_header_t * udp0;
+ vlib_buffer_t *p0;
+ ip4_header_t *ip0;
+ udp_header_t *udp0;
u32 udp_len0;
p0 = vlib_get_buffer (vm, packets[0]);
@@ -73,9 +71,9 @@ udp_pg_edit_function_inline (pg_main_t * pg,
udp_len0 = clib_net_to_host_u16 (ip0->length) - sizeof (ip0[0]);
if (flags & UDP_PG_EDIT_LENGTH)
- udp0->length =
- clib_net_to_host_u16 (vlib_buffer_length_in_chain (vm, p0)
- - ip_offset);
+ udp0->length =
+ clib_net_to_host_u16 (vlib_buffer_length_in_chain (vm, p0)
+ - ip_offset);
/* Initialize checksum with header. */
if (flags & UDP_PG_EDIT_CHECKSUM)
@@ -90,9 +88,11 @@ udp_pg_edit_function_inline (pg_main_t * pg,
/* Invalidate possibly old checksum. */
udp0->checksum = 0;
- sum0 = ip_incremental_checksum_buffer (vm, p0, udp_offset, udp_len0, sum0);
+ sum0 =
+ ip_incremental_checksum_buffer (vm, p0, udp_offset, udp_len0,
+ sum0);
- sum0 = ~ ip_csum_fold (sum0);
+ sum0 = ~ip_csum_fold (sum0);
/* Zero checksum means checksumming disabled. */
sum0 = sum0 != 0 ? sum0 : 0xffff;
@@ -105,9 +105,7 @@ udp_pg_edit_function_inline (pg_main_t * pg,
static void
udp_pg_edit_function (pg_main_t * pg,
pg_stream_t * s,
- pg_edit_group_t * g,
- u32 * packets,
- u32 n_packets)
+ pg_edit_group_t * g, u32 * packets, u32 n_packets)
{
switch (g->edit_function_opaque)
{
@@ -132,7 +130,8 @@ udp_pg_edit_function (pg_main_t * pg,
}
}
-typedef struct {
+typedef struct
+{
pg_edit_t src_port, dst_port;
pg_edit_t length;
pg_edit_t checksum;
@@ -143,20 +142,20 @@ pg_udp_header_init (pg_udp_header_t * p)
{
/* Initialize fields that are not bit fields in the IP header. */
#define _(f) pg_edit_init (&p->f, udp_header_t, f);
- _ (src_port);
- _ (dst_port);
- _ (length);
- _ (checksum);
+ _(src_port);
+ _(dst_port);
+ _(length);
+ _(checksum);
#undef _
}
uword
unformat_pg_udp_header (unformat_input_t * input, va_list * args)
{
- pg_stream_t * s = va_arg (*args, pg_stream_t *);
- pg_udp_header_t * p;
+ pg_stream_t *s = va_arg (*args, pg_stream_t *);
+ pg_udp_header_t *p;
u32 group_index;
-
+
p = pg_create_edit_group (s, sizeof (p[0]), sizeof (udp_header_t),
&group_index);
pg_udp_header_init (p);
@@ -165,24 +164,21 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args)
p->checksum.type = PG_EDIT_UNSPECIFIED;
p->length.type = PG_EDIT_UNSPECIFIED;
- if (! unformat (input, "UDP: %U -> %U",
- unformat_pg_edit,
- unformat_tcp_udp_port, &p->src_port,
- unformat_pg_edit,
- unformat_tcp_udp_port, &p->dst_port))
+ if (!unformat (input, "UDP: %U -> %U",
+ unformat_pg_edit,
+ unformat_tcp_udp_port, &p->src_port,
+ unformat_pg_edit, unformat_tcp_udp_port, &p->dst_port))
goto error;
/* Parse options. */
while (1)
{
if (unformat (input, "length %U",
- unformat_pg_edit,
- unformat_pg_number, &p->length))
+ unformat_pg_edit, unformat_pg_number, &p->length))
;
else if (unformat (input, "checksum %U",
- unformat_pg_edit,
- unformat_pg_number, &p->checksum))
+ unformat_pg_edit, unformat_pg_number, &p->checksum))
;
/* Can't parse input: try next protocol level. */
@@ -191,9 +187,9 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args)
}
{
- ip_main_t * im = &ip_main;
+ ip_main_t *im = &ip_main;
u16 dst_port;
- tcp_udp_port_info_t * pi;
+ tcp_udp_port_info_t *pi;
pi = 0;
if (p->dst_port.type == PG_EDIT_FIXED)
@@ -206,14 +202,14 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args)
&& unformat_user (input, pi->unformat_pg_edit, s))
;
- else if (! unformat_user (input, unformat_pg_payload, s))
+ else if (!unformat_user (input, unformat_pg_payload, s))
goto error;
p = pg_get_edit_group (s, group_index);
if (p->checksum.type == PG_EDIT_UNSPECIFIED
|| p->length.type == PG_EDIT_UNSPECIFIED)
{
- pg_edit_group_t * g = pg_stream_get_group (s, group_index);
+ pg_edit_group_t *g = pg_stream_get_group (s, group_index);
g->edit_function = udp_pg_edit_function;
g->edit_function_opaque = 0;
if (p->checksum.type == PG_EDIT_UNSPECIFIED)
@@ -225,9 +221,17 @@ unformat_pg_udp_header (unformat_input_t * input, va_list * args)
return 1;
}
- error:
+error:
/* Free up any edits we may have added. */
pg_free_edit_group (s);
return 0;
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */