get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45813,
    "url": "http://patches.dpdk.org/api/patches/45813/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181002084328.57127-8-david.hunt@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": "<20181002084328.57127-8-david.hunt@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181002084328.57127-8-david.hunt@intel.com",
    "date": "2018-10-02T08:43:25",
    "name": "[v6,07/10] examples/power: add json string handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "bbe7ed895a2665b58cda7a3436979fa722552c7e",
    "submitter": {
        "id": 342,
        "url": "http://patches.dpdk.org/api/people/342/?format=api",
        "name": "Hunt, David",
        "email": "david.hunt@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/20181002084328.57127-8-david.hunt@intel.com/mbox/",
    "series": [
        {
            "id": 1628,
            "url": "http://patches.dpdk.org/api/series/1628/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1628",
            "date": "2018-10-02T08:43:20",
            "name": "add json power policy interface for containers",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/1628/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45813/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/45813/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 244954F98;\n\tTue,  2 Oct 2018 10:43:55 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id 8C9152C5E\n\tfor <dev@dpdk.org>; Tue,  2 Oct 2018 10:43:43 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t02 Oct 2018 01:43:42 -0700",
            "from silpixa00399952.ir.intel.com (HELO\n\tsilpixa00399952.ger.corp.intel.com) ([10.237.223.64])\n\tby fmsmga006.fm.intel.com with ESMTP; 02 Oct 2018 01:43:41 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,331,1534834800\"; d=\"scan'208\";a=\"268705662\"",
        "From": "David Hunt <david.hunt@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "john.mcnamara@intel.com, stephen@networkplumber.org, lei.a.yao@intel.com,\n\tanatoly.burakov@intel.com, David Hunt <david.hunt@intel.com>",
        "Date": "Tue,  2 Oct 2018 09:43:25 +0100",
        "Message-Id": "<20181002084328.57127-8-david.hunt@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20181002084328.57127-1-david.hunt@intel.com>",
        "References": "<20180926163727.47337-1-david.hunt@intel.com>\n\t<20181002084328.57127-1-david.hunt@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v6 07/10] examples/power: add json string handling",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add JSON string handling to vm_power_manager for JSON strings received\nthrough the fifo. The format of the JSON strings are detailed in the\nnext patch, the vm_power_manager user guide documentation updates.\n\nThis patch introduces a new dependency on Jansson, a C library for\nencoding, decoding and manipulating JSON data. To compile the sample app\nyou now need to have installed libjansson4 and libjansson-dev (these may\nbe named slightly differently depending on your Operating System)\n\nSigned-off-by: David Hunt <david.hunt@intel.com>\nAcked-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n examples/vm_power_manager/Makefile          |   6 +\n examples/vm_power_manager/channel_monitor.c | 371 ++++++++++++++++++--\n 2 files changed, 352 insertions(+), 25 deletions(-)",
    "diff": "diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile\nindex 13a5205ba..50147c05d 100644\n--- a/examples/vm_power_manager/Makefile\n+++ b/examples/vm_power_manager/Makefile\n@@ -31,6 +31,12 @@ CFLAGS += $(WERROR_FLAGS)\n \n LDLIBS += -lvirt\n \n+JANSSON := $(shell pkg-config --exists jansson; echo $$?)\n+ifeq ($(JANSSON), 0)\n+LDLIBS += $(shell pkg-config --libs jansson)\n+CFLAGS += -DUSE_JANSSON\n+endif\n+\n ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)\n \n ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)\ndiff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c\nindex 53a4efe45..afb44a069 100644\n--- a/examples/vm_power_manager/channel_monitor.c\n+++ b/examples/vm_power_manager/channel_monitor.c\n@@ -9,11 +9,18 @@\n #include <signal.h>\n #include <errno.h>\n #include <string.h>\n+#include <fcntl.h>\n #include <sys/types.h>\n #include <sys/epoll.h>\n #include <sys/queue.h>\n #include <sys/time.h>\n-\n+#include <sys/socket.h>\n+#include <sys/select.h>\n+#ifdef USE_JANSSON\n+#include <jansson.h>\n+#else\n+#pragma message \"Jansson dev libs unavailable, not including JSON parsing\"\n+#endif\n #include <rte_log.h>\n #include <rte_memory.h>\n #include <rte_malloc.h>\n@@ -35,6 +42,8 @@\n \n uint64_t vsi_pkt_count_prev[384];\n uint64_t rdtsc_prev[384];\n+#define MAX_JSON_STRING_LEN 1024\n+char json_data[MAX_JSON_STRING_LEN];\n \n double time_period_ms = 1;\n static volatile unsigned run_loop = 1;\n@@ -43,6 +52,234 @@ static unsigned int policy_is_set;\n static struct epoll_event *global_events_list;\n static struct policy policies[MAX_CLIENTS];\n \n+#ifdef USE_JANSSON\n+\n+union PFID {\n+\tstruct ether_addr addr;\n+\tuint64_t pfid;\n+};\n+\n+static int\n+str_to_ether_addr(const char *a, struct ether_addr *ether_addr)\n+{\n+\tint i;\n+\tchar *end;\n+\tunsigned long o[ETHER_ADDR_LEN];\n+\n+\ti = 0;\n+\tdo {\n+\t\terrno = 0;\n+\t\to[i] = strtoul(a, &end, 16);\n+\t\tif (errno != 0 || end == a || (end[0] != ':' && end[0] != 0))\n+\t\t\treturn -1;\n+\t\ta = end + 1;\n+\t} while (++i != RTE_DIM(o) / sizeof(o[0]) && end[0] != 0);\n+\n+\t/* Junk at the end of line */\n+\tif (end[0] != 0)\n+\t\treturn -1;\n+\n+\t/* Support the format XX:XX:XX:XX:XX:XX */\n+\tif (i == ETHER_ADDR_LEN) {\n+\t\twhile (i-- != 0) {\n+\t\t\tif (o[i] > UINT8_MAX)\n+\t\t\t\treturn -1;\n+\t\t\tether_addr->addr_bytes[i] = (uint8_t)o[i];\n+\t\t}\n+\t/* Support the format XXXX:XXXX:XXXX */\n+\t} else if (i == ETHER_ADDR_LEN / 2) {\n+\t\twhile (i-- != 0) {\n+\t\t\tif (o[i] > UINT16_MAX)\n+\t\t\t\treturn -1;\n+\t\t\tether_addr->addr_bytes[i * 2] =\n+\t\t\t\t\t(uint8_t)(o[i] >> 8);\n+\t\t\tether_addr->addr_bytes[i * 2 + 1] =\n+\t\t\t\t\t(uint8_t)(o[i] & 0xff);\n+\t\t}\n+\t/* unknown format */\n+\t} else\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+set_policy_mac(struct channel_packet *pkt, int idx, char *mac)\n+{\n+\tunion PFID pfid;\n+\tint ret;\n+\n+\t/* Use port MAC address as the vfid */\n+\tret = str_to_ether_addr(mac, &pfid.addr);\n+\n+\tif (ret != 0) {\n+\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\"Invalid mac address received in JSON\\n\");\n+\t\tpkt->vfid[idx] = 0;\n+\t\treturn -1;\n+\t}\n+\n+\tprintf(\"Received MAC Address: %02\" PRIx8 \":%02\" PRIx8 \":%02\" PRIx8 \":\"\n+\t\t\t\"%02\" PRIx8 \":%02\" PRIx8 \":%02\" PRIx8 \"\\n\",\n+\t\t\tpfid.addr.addr_bytes[0], pfid.addr.addr_bytes[1],\n+\t\t\tpfid.addr.addr_bytes[2], pfid.addr.addr_bytes[3],\n+\t\t\tpfid.addr.addr_bytes[4], pfid.addr.addr_bytes[5]);\n+\n+\tpkt->vfid[idx] = pfid.pfid;\n+\treturn 0;\n+}\n+\n+\n+static int\n+parse_json_to_pkt(json_t *element, struct channel_packet *pkt)\n+{\n+\tconst char *key;\n+\tjson_t *value;\n+\tint ret;\n+\n+\tmemset(pkt, 0, sizeof(struct channel_packet));\n+\n+\tpkt->nb_mac_to_monitor = 0;\n+\tpkt->t_boost_status.tbEnabled = false;\n+\tpkt->workload = LOW;\n+\tpkt->policy_to_use = TIME;\n+\tpkt->command = PKT_POLICY;\n+\tpkt->core_type = CORE_TYPE_PHYSICAL;\n+\n+\tjson_object_foreach(element, key, value) {\n+\t\tif (!strcmp(key, \"policy\")) {\n+\t\t\t/* Recurse in to get the contents of profile */\n+\t\t\tret = parse_json_to_pkt(value, pkt);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t} else if (!strcmp(key, \"instruction\")) {\n+\t\t\t/* Recurse in to get the contents of instruction */\n+\t\t\tret = parse_json_to_pkt(value, pkt);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t} else if (!strcmp(key, \"name\")) {\n+\t\t\tstrcpy(pkt->vm_name, json_string_value(value));\n+\t\t} else if (!strcmp(key, \"command\")) {\n+\t\t\tchar command[32];\n+\t\t\tsnprintf(command, 32, \"%s\", json_string_value(value));\n+\t\t\tif (!strcmp(command, \"power\")) {\n+\t\t\t\tpkt->command = CPU_POWER;\n+\t\t\t} else if (!strcmp(command, \"create\")) {\n+\t\t\t\tpkt->command = PKT_POLICY;\n+\t\t\t} else if (!strcmp(command, \"destroy\")) {\n+\t\t\t\tpkt->command = PKT_POLICY_REMOVE;\n+\t\t\t} else {\n+\t\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"Invalid command received in JSON\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"policy_type\")) {\n+\t\t\tchar command[32];\n+\t\t\tsnprintf(command, 32, \"%s\", json_string_value(value));\n+\t\t\tif (!strcmp(command, \"TIME\")) {\n+\t\t\t\tpkt->policy_to_use = TIME;\n+\t\t\t} else if (!strcmp(command, \"TRAFFIC\")) {\n+\t\t\t\tpkt->policy_to_use = TRAFFIC;\n+\t\t\t} else if (!strcmp(command, \"WORKLOAD\")) {\n+\t\t\t\tpkt->policy_to_use = WORKLOAD;\n+\t\t\t} else if (!strcmp(command, \"BRANCH_RATIO\")) {\n+\t\t\t\tpkt->policy_to_use = BRANCH_RATIO;\n+\t\t\t} else {\n+\t\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"Wrong policy_type received in JSON\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"workload\")) {\n+\t\t\tchar command[32];\n+\t\t\tsnprintf(command, 32, \"%s\", json_string_value(value));\n+\t\t\tif (!strcmp(command, \"HIGH\")) {\n+\t\t\t\tpkt->workload = HIGH;\n+\t\t\t} else if (!strcmp(command, \"MEDIUM\")) {\n+\t\t\t\tpkt->workload = MEDIUM;\n+\t\t\t} else if (!strcmp(command, \"LOW\")) {\n+\t\t\t\tpkt->workload = LOW;\n+\t\t\t} else {\n+\t\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"Wrong workload received in JSON\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"busy_hours\")) {\n+\t\t\tunsigned int i;\n+\t\t\tsize_t size = json_array_size(value);\n+\n+\t\t\tfor (i = 0; i < size; i++) {\n+\t\t\t\tint hour = (int)json_integer_value(\n+\t\t\t\t\t\tjson_array_get(value, i));\n+\t\t\t\tpkt->timer_policy.busy_hours[i] = hour;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"quiet_hours\")) {\n+\t\t\tunsigned int i;\n+\t\t\tsize_t size = json_array_size(value);\n+\n+\t\t\tfor (i = 0; i < size; i++) {\n+\t\t\t\tint hour = (int)json_integer_value(\n+\t\t\t\t\t\tjson_array_get(value, i));\n+\t\t\t\tpkt->timer_policy.quiet_hours[i] = hour;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"core_list\")) {\n+\t\t\tunsigned int i;\n+\t\t\tsize_t size = json_array_size(value);\n+\n+\t\t\tfor (i = 0; i < size; i++) {\n+\t\t\t\tint core = (int)json_integer_value(\n+\t\t\t\t\t\tjson_array_get(value, i));\n+\t\t\t\tpkt->vcpu_to_control[i] = core;\n+\t\t\t}\n+\t\t\tpkt->num_vcpu = size;\n+\t\t} else if (!strcmp(key, \"mac_list\")) {\n+\t\t\tunsigned int i;\n+\t\t\tsize_t size = json_array_size(value);\n+\n+\t\t\tfor (i = 0; i < size; i++) {\n+\t\t\t\tchar mac[32];\n+\t\t\t\tsnprintf(mac, 32, \"%s\", json_string_value(\n+\t\t\t\t\t\tjson_array_get(value, i)));\n+\t\t\t\tset_policy_mac(pkt, i, mac);\n+\t\t\t}\n+\t\t\tpkt->nb_mac_to_monitor = size;\n+\t\t} else if (!strcmp(key, \"avg_packet_thresh\")) {\n+\t\t\tpkt->traffic_policy.avg_max_packet_thresh =\n+\t\t\t\t\t(uint32_t)json_integer_value(value);\n+\t\t} else if (!strcmp(key, \"max_packet_thresh\")) {\n+\t\t\tpkt->traffic_policy.max_max_packet_thresh =\n+\t\t\t\t\t(uint32_t)json_integer_value(value);\n+\t\t} else if (!strcmp(key, \"unit\")) {\n+\t\t\tchar unit[32];\n+\t\t\tsnprintf(unit, 32, \"%s\", json_string_value(value));\n+\t\t\tif (!strcmp(unit, \"SCALE_UP\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_SCALE_UP;\n+\t\t\t} else if (!strcmp(unit, \"SCALE_DOWN\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_SCALE_DOWN;\n+\t\t\t} else if (!strcmp(unit, \"SCALE_MAX\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_SCALE_MAX;\n+\t\t\t} else if (!strcmp(unit, \"SCALE_MIN\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_SCALE_MIN;\n+\t\t\t} else if (!strcmp(unit, \"ENABLE_TURBO\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_ENABLE_TURBO;\n+\t\t\t} else if (!strcmp(unit, \"DISABLE_TURBO\")) {\n+\t\t\t\tpkt->unit = CPU_POWER_DISABLE_TURBO;\n+\t\t\t} else {\n+\t\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"Invalid command received in JSON\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t} else if (!strcmp(key, \"resource_id\")) {\n+\t\t\tpkt->resource_id = (uint32_t)json_integer_value(value);\n+\t\t} else {\n+\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\"Unknown key received in JSON string: %s\\n\",\n+\t\t\t\tkey);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+#endif\n+\n void channel_monitor_exit(void)\n {\n \trun_loop = 0;\n@@ -555,6 +792,103 @@ channel_monitor_init(void)\n \treturn 0;\n }\n \n+static void\n+read_binary_packet(struct channel_info *chan_info)\n+{\n+\tstruct channel_packet pkt;\n+\tvoid *buffer = &pkt;\n+\tint buffer_len = sizeof(pkt);\n+\tint n_bytes, err = 0;\n+\n+\twhile (buffer_len > 0) {\n+\t\tn_bytes = read(chan_info->fd,\n+\t\t\t\tbuffer, buffer_len);\n+\t\tif (n_bytes == buffer_len)\n+\t\t\tbreak;\n+\t\tif (n_bytes == -1) {\n+\t\t\terr = errno;\n+\t\t\tRTE_LOG(DEBUG, CHANNEL_MONITOR,\n+\t\t\t\t\"Received error on \"\n+\t\t\t\t\"channel '%s' read: %s\\n\",\n+\t\t\t\tchan_info->channel_path,\n+\t\t\t\tstrerror(err));\n+\t\t\tremove_channel(&chan_info);\n+\t\t\tbreak;\n+\t\t}\n+\t\tbuffer = (char *)buffer + n_bytes;\n+\t\tbuffer_len -= n_bytes;\n+\t}\n+\tif (!err)\n+\t\tprocess_request(&pkt, chan_info);\n+}\n+\n+#ifdef USE_JANSSON\n+static void\n+read_json_packet(struct channel_info *chan_info)\n+{\n+\tstruct channel_packet pkt;\n+\tint n_bytes, ret;\n+\tjson_t *root;\n+\tjson_error_t error;\n+\n+\t/* read opening brace to closing brace */\n+\tdo {\n+\t\tint idx = 0;\n+\t\tint indent = 0;\n+\t\tdo {\n+\t\t\tn_bytes = read(chan_info->fd, &json_data[idx], 1);\n+\t\t\tif (n_bytes == 0)\n+\t\t\t\tbreak;\n+\t\t\tif (json_data[idx] == '{')\n+\t\t\t\tindent++;\n+\t\t\tif (json_data[idx] == '}')\n+\t\t\t\tindent--;\n+\t\t\tif ((indent > 0) || (idx > 0))\n+\t\t\t\tidx++;\n+\t\t\tif (indent == 0)\n+\t\t\t\tjson_data[idx] = 0;\n+\t\t\tif (idx >= MAX_JSON_STRING_LEN-1)\n+\t\t\t\tbreak;\n+\t\t} while (indent > 0);\n+\n+\t\tif (indent > 0)\n+\t\t\t/*\n+\t\t\t * We've broken out of the read loop without getting\n+\t\t\t * a closing brace, so throw away the data\n+\t\t\t */\n+\t\t\tjson_data[idx] = 0;\n+\n+\t\tif (strlen(json_data) == 0)\n+\t\t\tcontinue;\n+\n+\t\tprintf(\"got [%s]\\n\", json_data);\n+\n+\t\troot = json_loads(json_data, 0, &error);\n+\n+\t\tif (root) {\n+\t\t\t/*\n+\t\t\t * Because our data is now in the json\n+\t\t\t * object, we can overwrite the pkt\n+\t\t\t * with a channel_packet struct, using\n+\t\t\t * parse_json_to_pkt()\n+\t\t\t */\n+\t\t\tret = parse_json_to_pkt(root, &pkt);\n+\t\t\tjson_decref(root);\n+\t\t\tif (ret) {\n+\t\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"Error validating JSON profile data\\n\");\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tprocess_request(&pkt, chan_info);\n+\t\t} else {\n+\t\t\tRTE_LOG(ERR, CHANNEL_MONITOR,\n+\t\t\t\t\t\"JSON error on line %d: %s\\n\",\n+\t\t\t\t\terror.line, error.text);\n+\t\t}\n+\t} while (n_bytes > 0);\n+}\n+#endif\n+\n void\n run_channel_monitor(void)\n {\n@@ -578,31 +912,18 @@ run_channel_monitor(void)\n \t\t\t}\n \t\t\tif (global_events_list[i].events & EPOLLIN) {\n \n-\t\t\t\tint n_bytes, err = 0;\n-\t\t\t\tstruct channel_packet pkt;\n-\t\t\t\tvoid *buffer = &pkt;\n-\t\t\t\tint buffer_len = sizeof(pkt);\n-\n-\t\t\t\twhile (buffer_len > 0) {\n-\t\t\t\t\tn_bytes = read(chan_info->fd,\n-\t\t\t\t\t\t\tbuffer, buffer_len);\n-\t\t\t\t\tif (n_bytes == buffer_len)\n-\t\t\t\t\t\tbreak;\n-\t\t\t\t\tif (n_bytes == -1) {\n-\t\t\t\t\t\terr = errno;\n-\t\t\t\t\t\tRTE_LOG(DEBUG, CHANNEL_MONITOR,\n-\t\t\t\t\t\t\t\"Received error on \"\n-\t\t\t\t\t\t\t\"channel '%s' read: %s\\n\",\n-\t\t\t\t\t\t\tchan_info->channel_path,\n-\t\t\t\t\t\t\tstrerror(err));\n-\t\t\t\t\t\tremove_channel(&chan_info);\n-\t\t\t\t\t\tbreak;\n-\t\t\t\t\t}\n-\t\t\t\t\tbuffer = (char *)buffer + n_bytes;\n-\t\t\t\t\tbuffer_len -= n_bytes;\n+\t\t\t\tswitch (chan_info->type) {\n+\t\t\t\tcase CHANNEL_TYPE_BINARY:\n+\t\t\t\t\tread_binary_packet(chan_info);\n+\t\t\t\t\tbreak;\n+#ifdef USE_JANSSON\n+\t\t\t\tcase CHANNEL_TYPE_JSON:\n+\t\t\t\t\tread_json_packet(chan_info);\n+\t\t\t\t\tbreak;\n+#endif\n+\t\t\t\tdefault:\n+\t\t\t\t\tbreak;\n \t\t\t\t}\n-\t\t\t\tif (!err)\n-\t\t\t\t\tprocess_request(&pkt, chan_info);\n \t\t\t}\n \t\t}\n \t\trte_delay_us(time_period_ms*1000);\n",
    "prefixes": [
        "v6",
        "07/10"
    ]
}