get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/106174/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 106174,
    "url": "http://patches.dpdk.org/api/patches/106174/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220121103122.2926856-14-ronan.randles@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20220121103122.2926856-14-ronan.randles@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220121103122.2926856-14-ronan.randles@intel.com",
    "date": "2022-01-21T10:31:20",
    "name": "[v2,13/15] gen: add UDP support",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "ed596ed618e741d754bf4f07cf5dab02c4125cbc",
    "submitter": {
        "id": 2439,
        "url": "http://patches.dpdk.org/api/people/2439/?format=api",
        "name": "Ronan Randles",
        "email": "ronan.randles@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220121103122.2926856-14-ronan.randles@intel.com/mbox/",
    "series": [
        {
            "id": 21295,
            "url": "http://patches.dpdk.org/api/series/21295/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=21295",
            "date": "2022-01-21T10:31:07",
            "name": "add packet generator library and example app",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/21295/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/106174/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/106174/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C35BCA034E;\n\tFri, 21 Jan 2022 11:32:51 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 9243042790;\n\tFri, 21 Jan 2022 11:31:48 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by mails.dpdk.org (Postfix) with ESMTP id 4A5894276D\n for <dev@dpdk.org>; Fri, 21 Jan 2022 11:31:46 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 21 Jan 2022 02:31:45 -0800",
            "from silpixa00401120.ir.intel.com ([10.55.128.255])\n by orsmga008.jf.intel.com with ESMTP; 21 Jan 2022 02:31:44 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1642761106; x=1674297106;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=I9mkbkSBoHMIpIQwsuTaEYY/J5xcaK64aU5xNJNJb4w=;\n b=PE3vCpcAKvaIqdGOFGmo8uId9hawea8HVn/wad8b6iBYEfpTq/Y1b3ux\n PHjOqaV5cy4zrCKiDnKULH8eeJ+xASqhPfT1ZfpM60KSkWcYK7Q2kTFGO\n /g6vxWok3ONWrPFruxPgKsH1+ganxwvrFDsFRg0Cbn4C7m5di/nrk1htO\n 1qFRX6mmLm7B0tfABKozXfK5qrv92Ve6vo/fVI/9PBzqYEttkNhXiWQ89\n E/hjd3olVgI1Keb6hptcZGHaBt1Rp4B5Tkfj24VMUQjgpC7RuH6CifWad\n KJ55cWVnb5o3Q5aQw4zFEn1LDdV4r2HuDmnTMfoaKPGdNmtI/e8OJNq2a g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10233\"; a=\"270045145\"",
            "E=Sophos;i=\"5.88,304,1635231600\"; d=\"scan'208\";a=\"270045145\"",
            "E=Sophos;i=\"5.88,304,1635231600\"; d=\"scan'208\";a=\"533222789\""
        ],
        "X-ExtLoop1": "1",
        "From": "Ronan Randles <ronan.randles@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Ronan Randles <ronan.randles@intel.com>",
        "Subject": "[PATCH v2 13/15] gen: add UDP support",
        "Date": "Fri, 21 Jan 2022 10:31:20 +0000",
        "Message-Id": "<20220121103122.2926856-14-ronan.randles@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220121103122.2926856-1-ronan.randles@intel.com>",
        "References": "<20211214141242.3383831-1-ronan.randles@intel.com>\n <20220121103122.2926856-1-ronan.randles@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "This commit adds UDP parsing and logging. Unit tested by the adition of\n\"UDP()\" string to 'test_gen_packet_parse_string()'\n\nSigned-off-by: Ronan Randles <ronan.randles@intel.com>\n---\n app/test/test_gen.c |  1 +\n lib/gen/rte_gen.c   | 66 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 67 insertions(+)",
    "diff": "diff --git a/app/test/test_gen.c b/app/test/test_gen.c\nindex 7b67835c80..a0b00d6a6e 100644\n--- a/app/test/test_gen.c\n+++ b/app/test/test_gen.c\n@@ -137,6 +137,7 @@ test_gen_packet_parse_string(void)\n \t\t{ .str = \"Ether()/IP(sr=,dst=5.6.7.8)\", .expected_to_fail = 1},\n \t\t{ .str = \"Ether()/IP(src=1.2.3.fail,dst=5.6.7.8)\",\n \t\t\t\t\t.expected_to_fail = 1},\n+\t\t{ .str = \"Ether()/IP()/UDP()\"},\n \t};\n \n \tuint32_t i;\ndiff --git a/lib/gen/rte_gen.c b/lib/gen/rte_gen.c\nindex 4020150712..3a67ce8b6c 100644\n--- a/lib/gen/rte_gen.c\n+++ b/lib/gen/rte_gen.c\n@@ -11,6 +11,7 @@\n \n #include <rte_ether.h>\n #include <rte_ip.h>\n+#include <rte_udp.h>\n \n RTE_LOG_REGISTER(gen_logtype, lib.gen, NOTICE);\n \n@@ -138,6 +139,7 @@ enum GEN_PROTO {\n \tGEN_PROTO_INVALID,\n \tGEN_PROTO_ETHER,\n \tGEN_PROTO_IPV4,\n+\tGEN_PROTO_UDP,\n \n \t/* Must be last. */\n \tGEN_PROTO_COUNT,\n@@ -231,6 +233,9 @@ gen_log_ipv4(void *data, const char *indent)\n \tcase 0:\n \t\tproto_str = \"hopopt\";\n \t\tbreak;\n+\tcase IPPROTO_UDP:\n+\t\tproto_str = \"UDP\";\n+\t\tbreak;\n \tdefault:\n \t\tproto_str = \"unknown next proto\";\n \t\tbreak;\n@@ -351,6 +356,12 @@ gen_parse_ipv4(struct gen_parser *parser, char *protocol_str)\n \t}\n \n \tswitch (inner) {\n+\tcase GEN_PROTO_UDP:\n+\t\tip->next_proto_id = IPPROTO_UDP;\n+\t\tstruct rte_udp_hdr *udp = gen_parser_get_data_ptr(parser);\n+\t\tudp->dgram_cksum = 0;\n+\t\tbreak;\n+\n \tdefault:\n \t\t/* Default protocol is hopopt (0). */\n \t\tbreak;\n@@ -430,6 +441,55 @@ gen_parse_ether(struct gen_parser *parser, char *protocol_str)\n \treturn 0;\n }\n \n+static void\n+gen_log_udp(void *data, const char *indent)\n+{\n+\tstruct rte_udp_hdr *udp = data;\n+\n+\tGEN_LOG_PROTOCOL(DEBUG,\n+\t\t\"###[ UDP ]###\\n%ssport= %u\\n%sdport= %u\\n%s\"\n+\t\t\"len= %u\\n%schksum= %u\\n\",\n+\t\tindent, rte_be_to_cpu_16(udp->src_port),\n+\t\tindent,\trte_be_to_cpu_16(udp->dst_port),\n+\t\tindent,\trte_be_to_cpu_16(udp->dgram_len),\n+\t\tindent,\trte_be_to_cpu_16(udp->dgram_cksum));\n+\n+}\n+\n+static int32_t\n+gen_parse_udp(struct gen_parser *parser, char *protocol_str)\n+{\n+\tRTE_SET_USED(protocol_str);\n+\tstruct rte_udp_hdr *udp = gen_parser_get_data_ptr(parser);\n+\tuint32_t pre_udp_len = parser->buf_write_offset;\n+\tmemset(udp, 0, sizeof(*udp));\n+\n+\t/* Move up write pointer in packet. */\n+\tparser->buf_write_offset += sizeof(*udp);\n+\n+\t/* Recurse and handle inner protocol. */\n+\tenum GEN_PROTO inner;\n+\tint err = gen_parser_parse_next(parser, &inner);\n+\n+\tswitch (inner) {\n+\tdefault:\n+\t\t/* default to DNS like other packet generation tools */\n+\t\tudp->src_port = rte_cpu_to_be_16(53);\n+\t\tudp->dst_port = rte_cpu_to_be_16(53);\n+\t\tbreak;\n+\t};\n+\n+\t/* Minimum len is the UDP header itself (8 bytes) or more */\n+\tint32_t total_len = parser->mbuf->data_len;\n+\tint32_t dgram_len = total_len - pre_udp_len;\n+\tif (dgram_len < 8)\n+\t\tprintf(\"error parsing dgram len, %d\\n\", dgram_len);\n+\n+\tudp->dgram_len = rte_cpu_to_be_16(dgram_len);\n+\n+\treturn err;\n+}\n+\n /* (Name, Function-pointer) pairs for supported parse types */\n typedef int32_t (*gen_parse_func)(struct gen_parser *parser,\n \t\t\t\tchar *protocol_str);\n@@ -455,6 +515,12 @@ static struct gen_parse_func_t gen_protocols[] = {\n \t\t.parse_func = gen_parse_ipv4,\n \t\t.log_func = gen_log_ipv4,\n \t},\n+\t{\n+\t\t.name = \"UDP(\",\n+\t\t.proto = GEN_PROTO_UDP,\n+\t\t.parse_func = gen_parse_udp,\n+\t\t.log_func = gen_log_udp,\n+\t}\n \n };\n \n",
    "prefixes": [
        "v2",
        "13/15"
    ]
}