From ed6c4daec95185dc0d105eab2c93b97468deac07 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jul 2019 15:48:16 +0200 Subject: [PATCH] ++code move for function --- p4src/actions_delta_checksum.p4 | 12 ++---------- p4src/headers.p4 | 13 +++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/p4src/actions_delta_checksum.p4 b/p4src/actions_delta_checksum.p4 index 3721b74..9b48e03 100644 --- a/p4src/actions_delta_checksum.p4 +++ b/p4src/actions_delta_checksum.p4 @@ -1,17 +1,9 @@ #ifndef NICO_DELTA_CHECKSUM #define NICO_DELTA_CHECKSUM -/* copied from -https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation -*/ -bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) { - bit<17> ret = (bit<17>) x + (bit<17>) y; - if (ret[16:16] == 1) { - ret = ret + 1; - } - return ret[15:0]; -} + +#include "headers.p4" action v4sum() { bit<16> tmp = 0; diff --git a/p4src/headers.p4 b/p4src/headers.p4 index 28d6651..3643502 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -239,4 +239,17 @@ struct metadata { table_t table_id; } +/* copied from +https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation +*/ + +bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) { + bit<17> ret = (bit<17>) x + (bit<17>) y; + if (ret[16:16] == 1) { + ret = ret + 1; + } + return ret[15:0]; +} + + #endif \ No newline at end of file