From: Vincent Bernat Date: Sun, 15 Oct 2023 17:41:38 +0000 (+0200) Subject: daemon/lldp: remove support for 802.3bt X-Git-Tag: 1.0.18~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f01183f986bd31e4306a363280e0a1154955cf9d;p=thirdparty%2Flldpd.git daemon/lldp: remove support for 802.3bt It was broken and despite a tentative to fix it, it is unknown if this is correct. This looks different from the code in Wireshark. Maybe it was done on an earlier version of 802.3bt? As the standard is not freely available, I cannot reasonably fix it. --- diff --git a/NEWS b/NEWS index ceb9bee5..f0e0fb19 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ lldpd (1.0.18) - * Changes: - + Add support for 802.3bt in lldpcli. + * Changes (breaking): + + Remove support for 802.3bt (broken). * Fix: + Fix memory leaks in EDP/FDP decoding when receiving some TLVs twice. diff --git a/src/client/conf-power.c b/src/client/conf-power.c index a1ca816c..38f25361 100644 --- a/src/client/conf-power.c +++ b/src/client/conf-power.c @@ -21,10 +21,6 @@ #include "client.h" #include "../log.h" -static int cmd_check_ext_type(struct cmd_env *env, const char *type); -static int cmd_check_ext_pse_but_no(struct cmd_env *env, void *arg); -static int cmd_check_ext_pd_but_no(struct cmd_env *env, void *arg); - static int cmd_medpower(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env, void *arg) @@ -93,132 +89,6 @@ cmd_store_prio_env_value_and_pop2(struct lldpctl_conn_t *conn, struct writer *w, return cmd_store_something_env_value_and_pop2("priority", env, value); } -static int -cmd_dot3power_conf_at(struct lldpctl_conn_t *conn, struct writer *w, - struct cmd_env *env, lldpctl_atom_t *dot3_power, const char *name) -{ - const char *what = NULL; - int typeat = cmdenv_get(env, "typeat")[0] - '0'; - const char *source = cmdenv_get(env, "source"); - if ((what = "802.3at type", - lldpctl_atom_set_int(dot3_power, lldpctl_k_dot3_power_type, typeat)) == - NULL || - (what = "source", - lldpctl_atom_set_int(dot3_power, lldpctl_k_dot3_power_source, - (!strcmp(source, "primary")) ? LLDP_DOT3_POWER_SOURCE_PRIMARY : - (!strcmp(source, "backup")) ? LLDP_DOT3_POWER_SOURCE_BACKUP : - (!strcmp(source, "pse")) ? LLDP_DOT3_POWER_SOURCE_PSE : - (!strcmp(source, "local")) ? LLDP_DOT3_POWER_SOURCE_LOCAL : - (!strcmp(source, "both")) ? LLDP_DOT3_POWER_SOURCE_BOTH : - LLDP_DOT3_POWER_SOURCE_UNKNOWN)) == - NULL || - (what = "priority", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_priority, - cmdenv_get(env, "priority"))) == NULL || - (what = "requested power", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_requested, - cmdenv_get(env, "requested"))) == NULL || - (what = "allocated power", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_allocated, - cmdenv_get(env, "allocated"))) == NULL) { - log_warnx("lldpctl", - "unable to set LLDP Dot3 power value for %s on %s. %s.", what, name, - lldpctl_last_strerror(conn)); - return 1; - } - return 0; -} - -static int -cmd_dot3power_conf_bt(struct lldpctl_conn_t *conn, struct writer *w, - struct cmd_env *env, lldpctl_atom_t *dot3_power, const char *name) -{ - const char *what = NULL; - int typebt = cmdenv_get(env, "type-ext")[0] - '0'; - if (typebt != LLDP_DOT3_POWER_8023BT_OFF) { - if ((what = "802.3bt class-a", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_class_a, - cmdenv_get(env, "class-a"))) == NULL || - (what = "802.3bt class-b", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_class_b, - cmdenv_get(env, "class-b"))) == NULL || - (what = "802.3bt class-ext", - lldpctl_atom_set_str(dot3_power, lldpctl_k_dot3_power_class_ext, - cmdenv_get(env, "class-ext"))) == NULL) { - log_warnx("lldpctl", - "unable to set LLDP Dot3 power value for %s on %s. %s.", - what, name, lldpctl_last_strerror(conn)); - return 1; - } - - if ((what = "802.3bt type", - lldpctl_atom_set_int(dot3_power, lldpctl_k_dot3_power_type_ext, - typebt)) == NULL || - (what = "requested power A", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_requested_a, - cmdenv_get(env, "requested-a"))) == NULL || - (what = "allocated power A", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_allocated_a, - cmdenv_get(env, "allocated-a"))) == NULL || - (what = "requested power B", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_requested_b, - cmdenv_get(env, "requested-b"))) == NULL || - (what = "allocated power B", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_allocated_b, - cmdenv_get(env, "allocated-b"))) == NULL) { - log_warnx("lldpctl", - "unable to set LLDP Dot3 power value for %s on %s. %s.", - what, name, lldpctl_last_strerror(conn)); - return 1; - } - - if (cmd_check_ext_pse_but_no(env, NULL)) { - if ((what = "PSE status", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pse_status, - cmdenv_get(env, "pse-status"))) == NULL || - (what = "PSE pairs", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pse_pairs_ext, - cmdenv_get(env, "pse-pairs-ext"))) == NULL || - (what = "PSE max", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pse_max, - cmdenv_get(env, "pse-max"))) == NULL) { - log_warnx("lldpctl", - "unable to set LLDP Dot3 power value for %s on %s. %s.", - what, name, lldpctl_last_strerror(conn)); - return 1; - } - } - - if (cmd_check_ext_pd_but_no(env, NULL)) { - if ((what = "PD status", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pd_status, - cmdenv_get(env, "pd-status"))) == NULL || - (what = "PD 4pid", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pd_4pid, - cmdenv_get(env, "pd-4pid"))) == NULL || - (what = "PD load", - lldpctl_atom_set_str(dot3_power, - lldpctl_k_dot3_power_pd_load, - cmdenv_get(env, "pd-load"))) == NULL) { - log_warnx("lldpctl", - "unable to set LLDP Dot3 power value for %s on %s. %s.", - what, name, lldpctl_last_strerror(conn)); - return 1; - } - } - } - return 0; -} - static int cmd_dot3power(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env, void *arg) @@ -271,16 +141,42 @@ cmd_dot3power(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env "unable to set LLDP Dot3 power value for %s on %s. %s.", what, name, lldpctl_last_strerror(conn)); ok = 0; - } else { - if (cmdenv_get(env, "typeat")) { - if (cmd_dot3power_conf_at(conn, w, env, dot3_power, - name)) - ok = 0; - } - if (cmdenv_get(env, "type-ext")) { - if (cmd_dot3power_conf_bt(conn, w, env, dot3_power, - name)) - ok = 0; + } else if (cmdenv_get(env, "typeat")) { + int typeat = cmdenv_get(env, "typeat")[0] - '0'; + const char *source = cmdenv_get(env, "source"); + if ((what = "802.3at type", + lldpctl_atom_set_int(dot3_power, + lldpctl_k_dot3_power_type, typeat)) == NULL || + (what = "source", + lldpctl_atom_set_int(dot3_power, + lldpctl_k_dot3_power_source, + (!strcmp(source, "primary")) ? + LLDP_DOT3_POWER_SOURCE_PRIMARY : + (!strcmp(source, "backup")) ? + LLDP_DOT3_POWER_SOURCE_BACKUP : + (!strcmp(source, "pse")) ? + LLDP_DOT3_POWER_SOURCE_PSE : + (!strcmp(source, "local")) ? + LLDP_DOT3_POWER_SOURCE_LOCAL : + (!strcmp(source, "both")) ? + LLDP_DOT3_POWER_SOURCE_BOTH : + LLDP_DOT3_POWER_SOURCE_UNKNOWN)) == NULL || + (what = "priority", + lldpctl_atom_set_str(dot3_power, + lldpctl_k_dot3_power_priority, + cmdenv_get(env, "priority"))) == NULL || + (what = "requested power", + lldpctl_atom_set_str(dot3_power, + lldpctl_k_dot3_power_requested, + cmdenv_get(env, "requested"))) == NULL || + (what = "allocated power", + lldpctl_atom_set_str(dot3_power, + lldpctl_k_dot3_power_allocated, + cmdenv_get(env, "allocated"))) == NULL) { + log_warnx("lldpctl", + "unable to set LLDP Dot3 power value for %s on %s. %s.", + what, name, lldpctl_last_strerror(conn)); + ok = 0; } } if (ok) { @@ -316,14 +212,6 @@ cmd_check_typeat_but_no(struct cmd_env *env, void *arg) return 1; } static int -cmd_check_typeext_but_no(struct cmd_env *env, void *arg) -{ - const char *what = arg; - if (!cmdenv_get(env, "type-ext")) return 0; - if (cmdenv_get(env, what)) return 0; - return 1; -} -static int cmd_check_type(struct cmd_env *env, const char *type) { const char *etype = cmdenv_get(env, "device-type"); @@ -340,33 +228,6 @@ cmd_check_pd(struct cmd_env *env, void *arg) { return cmd_check_type(env, "pd"); } -static int -cmd_check_ext_type(struct cmd_env *env, const char *type) -{ - const char *etype = cmdenv_get(env, "type-ext"); - if (!etype) return 0; - return (!strcmp(type, etype)); -} -static int -cmd_check_ext_pse_but_no(struct cmd_env *env, void *arg) -{ - const char *what = arg; - if (what) - if (cmdenv_get(env, what)) return 0; - - return !!(cmd_check_ext_type(env, "1") || cmd_check_ext_type(env, "2")); -} -static int -cmd_check_ext_pd_but_no(struct cmd_env *env, void *arg) -{ - const char *what = arg; - - if (what) - if (cmdenv_get(env, what)) return 0; - - return !!(cmd_check_ext_type(env, "3") || cmd_check_ext_type(env, "4") || - cmd_check_ext_type(env, "5") || cmd_check_ext_type(env, "6")); -} static void register_commands_pow_source(struct cmd_node *source) @@ -435,33 +296,15 @@ register_commands_medpow(struct cmd_node *configure_med) static int cmd_check_env_power(struct cmd_env *env, void *nothing) { - int ret = 1; - /* We need type and powerpair but if we have typeat, we also request * source, priority, requested and allocated. */ if (!cmdenv_get(env, "device-type")) return 0; if (!cmdenv_get(env, "powerpairs")) return 0; - if (cmdenv_get(env, "typeat")) { - ret &= (!!cmdenv_get(env, "source") && !!cmdenv_get(env, "priority") && + return (!!cmdenv_get(env, "source") && !!cmdenv_get(env, "priority") && !!cmdenv_get(env, "requested") && !!cmdenv_get(env, "allocated")); } - - if (cmdenv_get(env, "type-ext")) { - int mandatories = (!!cmdenv_get(env, "class-a") && - !!cmdenv_get(env, "class-b") && !!cmdenv_get(env, "class-ext")); - - if (cmd_check_ext_pd_but_no(env, NULL)) { - ret &= (!!cmdenv_get(env, "pd-status") && - !!cmdenv_get(env, "pd-4pid") && mandatories); - } else if (cmd_check_ext_pse_but_no(env, NULL)) { - ret &= (!!cmdenv_get(env, "pse-status") && - !!cmdenv_get(env, "pse-pairs-ext") && - !!cmdenv_get(env, "pse-max") && mandatories); - } - } - - return ret; + return 1; } /** @@ -512,114 +355,6 @@ register_commands_dot3pow(struct cmd_node *configure_dot3) cmd_store_class_env_value_and_pop2, class_map->string); } - struct cmd_node *class_a = commands_new(configure_dot3power, "class-a", - "802.3bt power class a (mandatory)", cmd_check_typeext_but_no, NULL, - "class-a"); - commands_new(class_a, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "1", "Class 1", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "2", "Class 2", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "3", "Class 3", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "4", "Class 4", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "5", "Class 5", NULL, cmd_store_env_value_and_pop2, - "class-a"); - commands_new(class_a, "7", "Single-signature PD or 2-pair only PSE", NULL, - cmd_store_env_value_and_pop2, "class-a"); - - struct cmd_node *class_b = commands_new(configure_dot3power, "class-b", - "802.3bt power class b (mandatory)", cmd_check_typeext_but_no, NULL, - "class-b"); - commands_new(class_b, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "1", "Class 1", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "2", "Class 2", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "3", "Class 3", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "4", "Class 4", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "5", "Class 5", NULL, cmd_store_env_value_and_pop2, - "class-b"); - commands_new(class_b, "7", "Single-signature PD or 2-pair only PSE", NULL, - cmd_store_env_value_and_pop2, "class-b"); - - struct cmd_node *class_ext = commands_new(configure_dot3power, "class-ext", - "802.3bt power class ext (mandatory)", cmd_check_typeext_but_no, NULL, - "class-ext"); - commands_new(class_ext, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "1", "Class 1", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "2", "Class 2", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "3", "Class 3", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "4", "Class 4", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "5", "Class 5", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "6", "Class 6", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "7", "Class 7", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "8", "Class 8", NULL, cmd_store_env_value_and_pop2, - "class-ext"); - commands_new(class_ext, "15", "Dual-signature PD", NULL, - cmd_store_env_value_and_pop2, "class-ext"); - - /* PD status */ - struct cmd_node *pd_status = commands_new(configure_dot3power, "pd-status", - "802.3bt PD status (mandatory)", cmd_check_ext_pd_but_no, NULL, - "pd-status"); - commands_new(pd_status, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "pd-status"); - commands_new(pd_status, "1", "2-pair powered PD", NULL, - cmd_store_env_value_and_pop2, "pd-status"); - commands_new(pd_status, "2", "4-pair powered dual-signature PD", NULL, - cmd_store_env_value_and_pop2, "pd-status"); - commands_new(pd_status, "3", "4-pair powered single-signature PD", NULL, - cmd_store_env_value_and_pop2, "pd-status"); - - /* PD 4pid */ - struct cmd_node *pd_4pid = commands_new(configure_dot3power, "pd-4pid", - "802.3bt PD 4pid config (mandatory)", cmd_check_ext_pd_but_no, NULL, - "pd-4pid"); - commands_new(pd_4pid, "0", "PD does not support powering both modes", NULL, - cmd_store_env_value_and_pop2, "pd-4pid"); - commands_new(pd_4pid, "1", "PD supports powering both modes", NULL, - cmd_store_env_value_and_pop2, "pd-4pid"); - - /* PSE status */ - struct cmd_node *pse_status = commands_new(configure_dot3power, "pse-status", - "802.3bt PSE status (mandatory)", cmd_check_ext_pse_but_no, NULL, - "pse-status"); - commands_new(pse_status, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "pse-status"); - commands_new(pse_status, "1", "2-pair powering PSE", NULL, - cmd_store_env_value_and_pop2, "pse-status"); - commands_new(pse_status, "2", "4-pair powering dual-signature PSE", NULL, - cmd_store_env_value_and_pop2, "pse-status"); - commands_new(pse_status, "3", "4-pair powering single-signature PSE", NULL, - cmd_store_env_value_and_pop2, "pse-status"); - - /* PSE pairs */ - struct cmd_node *pse_pairs = commands_new(configure_dot3power, "pse-pairs-ext", - "802.3bt PD pairs (mandatory)", cmd_check_ext_pse_but_no, NULL, - "pse-pairs-ext"); - commands_new(pse_pairs, "0", "Unknown", NULL, cmd_store_env_value_and_pop2, - "pse-pairs-ext"); - commands_new(pse_pairs, "1", "Alternative A", NULL, - cmd_store_env_value_and_pop2, "pse-pairs-ext"); - commands_new(pse_pairs, "2", "Alternative B", NULL, - cmd_store_env_value_and_pop2, "pse-pairs-ext"); - commands_new(pse_pairs, "3", "Both alternatives", NULL, - cmd_store_env_value_and_pop2, "pse-pairs-ext"); - /* 802.3at type */ struct cmd_node *typeat = commands_new(configure_dot3power, "type", "802.3at device type", cmd_check_type_but_no, NULL, "typeat"); @@ -628,24 +363,6 @@ register_commands_dot3pow(struct cmd_node *configure_dot3) commands_new(typeat, "2", "802.3at type 2", NULL, cmd_store_env_value_and_pop2, "typeat"); - /* 802.3bt type */ - struct cmd_node *typeext = commands_new(configure_dot3power, "type-ext", - "802.3bt device type", cmd_check_type_but_no, NULL, "type-ext"); - commands_new(typeext, "0", "802.3bt off", NULL, cmd_store_env_value_and_pop2, - "type-ext"); - commands_new(typeext, "1", "802.3bt type 3 PSE", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - commands_new(typeext, "2", "802.3bt type 4 PSE", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - commands_new(typeext, "3", "802.3bt type 3 single-signature PD", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - commands_new(typeext, "4", "802.3bt type 3 dual-signature PD", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - commands_new(typeext, "5", "802.3bt type 4 single-signature PD", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - commands_new(typeext, "6", "802.3bt type 4 dual-signature PD", NULL, - cmd_store_env_value_and_pop2, "type-ext"); - /* Source */ struct cmd_node *source = commands_new(configure_dot3power, "source", "802.3at dot3 power source (mandatory)", cmd_check_typeat_but_no, NULL, @@ -669,34 +386,4 @@ register_commands_dot3pow(struct cmd_node *configure_dot3) cmd_check_typeat_but_no, NULL, "allocated"), NULL, "802.3at power value allocated in milliwatts", NULL, cmd_store_env_value_and_pop2, "allocated"); - commands_new(commands_new(configure_dot3power, "requested-a", - "802.3bt dot3 class a power value requested (mandatory)", - cmd_check_typeext_but_no, NULL, "requested-a"), - NULL, "802.3bt power value requested in milliwatts", NULL, - cmd_store_env_value_and_pop2, "requested-a"); - commands_new(commands_new(configure_dot3power, "allocated-a", - "802.3bt dot3 class a power value allocated (mandatory)", - cmd_check_typeext_but_no, NULL, "allocated-a"), - NULL, "802.3bt power value allocated in milliwatts", NULL, - cmd_store_env_value_and_pop2, "allocated-a"); - commands_new(commands_new(configure_dot3power, "requested-b", - "802.3bt dot3 class b power value requested (mandatory)", - cmd_check_typeext_but_no, NULL, "requested-b"), - NULL, "802.3bt power value requested in milliwatts", NULL, - cmd_store_env_value_and_pop2, "requested-b"); - commands_new(commands_new(configure_dot3power, "allocated-b", - "802.3bt dot3 class b power value allocated (mandatory)", - cmd_check_typeext_but_no, NULL, "allocated-b"), - NULL, "802.3bt power value allocated in milliwatts", NULL, - cmd_store_env_value_and_pop2, "allocated-b"); - commands_new(commands_new(configure_dot3power, "pd-load", - "802.3bt dot3 pd power load", cmd_check_ext_pd_but_no, NULL, - "pd-load"), - NULL, "802.3bt pd power load value allocated in milliwatts", NULL, - cmd_store_env_value_and_pop2, "pd-load"); - commands_new(commands_new(configure_dot3power, "pse-max", - "802.3bt dot3 pse max power load (mandatory)", - cmd_check_ext_pse_but_no, NULL, "pse-max"), - NULL, "802.3bt pse max power value allocated in milliwatts", NULL, - cmd_store_env_value_and_pop2, "pse-max"); } diff --git a/src/client/display.c b/src/client/display.c index a050432d..d6338d0d 100644 --- a/src/client/display.c +++ b/src/client/display.c @@ -493,80 +493,6 @@ display_port(struct writer *w, lldpctl_atom_t *port, int details) tag_end(w); } - /* 802.3bt */ - if (lldpctl_atom_get_int(dot3_power, - lldpctl_k_dot3_power_type_ext) > - LLDP_DOT3_POWER_8023BT_OFF) { - tag_start(w, "requested-a", "Requested mode A"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_requested_a)); - tag_end(w); - tag_start(w, "requested-b", "Requested mode B"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_requested_b)); - tag_end(w); - tag_start(w, "allocated-a", "Allocated alternative A"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_allocated_a)); - tag_end(w); - tag_start(w, "allocated-b", "Allocated alternative B"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_allocated_b)); - tag_end(w); - tag_start(w, "pse-powering-status", - "PSE powering status"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_pse_status)); - tag_end(w); - tag_start(w, "pd-powering-status", - "PD powering status"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_pd_status)); - tag_end(w); - tag_start(w, "power-pairs-ext", "Power pairs extra"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_pse_pairs_ext)); - tag_end(w); - tag_start(w, "power-class-ext-a", "Class extra A"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_class_a)); - tag_end(w); - tag_start(w, "power-class-ext-b", "Class extra B"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_class_b)); - tag_end(w); - tag_start(w, "power-class-ext", "Class extra"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_class_ext)); - tag_end(w); - tag_start(w, "power-type-ext", "Power type extra"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_type_ext)); - tag_end(w); - tag_start(w, "pd-load", "PD load"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_pd_load)); - tag_end(w); - tag_start(w, "max-power", - "PSE maximum available power"); - tag_data(w, - lldpctl_atom_get_str(dot3_power, - lldpctl_k_dot3_power_pse_max)); - tag_end(w); - } - tag_end(w); } lldpctl_atom_dec_ref(dot3_power); diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 83dc3fce..fee44d23 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1007,10 +1007,6 @@ lldpd_dot3_power_pd_pse(struct lldpd_hardware *hardware) hardware->h_ifname, selected_port->p_power.allocated, hardware->h_lport.p_power.allocated); hardware->h_lport.p_power.allocated = selected_port->p_power.allocated; - hardware->h_lport.p_power.allocated_a = - selected_port->p_power.allocated_a; - hardware->h_lport.p_power.allocated_b = - selected_port->p_power.allocated_b; levent_schedule_pdu(hardware); } diff --git a/src/daemon/protocols/lldp.c b/src/daemon/protocols/lldp.c index 3a93b96d..03b6b680 100644 --- a/src/daemon/protocols/lldp.c +++ b/src/daemon/protocols/lldp.c @@ -289,8 +289,7 @@ _lldp_send(struct lldpd *global, struct lldpd_hardware *hardware, u_int8_t c_id_ POKE_UINT8(port->p_power.class))) goto toobig; /* 802.3at */ - if (port->p_power.powertype != LLDP_DOT3_POWER_8023AT_OFF || - port->p_power.type_ext != LLDP_DOT3_POWER_8023BT_OFF) { + if (port->p_power.powertype != LLDP_DOT3_POWER_8023AT_OFF) { if (!(POKE_UINT8(((((port->p_power.powertype == LLDP_DOT3_POWER_8023AT_TYPE1) ? 1 : @@ -301,34 +300,11 @@ _lldp_send(struct lldpd *global, struct lldpd_hardware *hardware, u_int8_t c_id_ 1) << 6) | ((port->p_power.source % (1 << 2)) << 4) | - ((port->p_power.pd_4pid % (1 << 1)) << 2) | ((port->p_power.priority % (1 << 2)) << 0))) && POKE_UINT16(port->p_power.requested) && POKE_UINT16(port->p_power.allocated))) goto toobig; } - /* 802.3bt */ - if (port->p_power.type_ext != LLDP_DOT3_POWER_8023BT_OFF) { - if (!(POKE_UINT16(port->p_power.requested_a) && - POKE_UINT16(port->p_power.requested_b) && - POKE_UINT16(port->p_power.allocated_a) && - POKE_UINT16(port->p_power.allocated_b) && - POKE_UINT16(((port->p_power.pse_status << 14) | - (port->p_power.pd_status << 12) | - (port->p_power.pse_pairs_ext << 10) | - (port->p_power.class_a << 7) | - (port->p_power.class_b << 4) | - (port->p_power.class_ext << 0))) && - POKE_UINT8( - /* Adjust by -1 to enable 0 to mean no 802.3bt - support */ - ((port->p_power.type_ext - 1) << 1) | - (port->p_power.pd_load << 0)) && - POKE_UINT16(port->p_power.pse_max) && - /* Send 0 for autoclass and power down requests */ - POKE_UINT8(0) && POKE_UINT16(0) && POKE_UINT8(0))) - goto toobig; - } if (!(POKE_END_LLDP_TLV)) goto toobig; } #endif @@ -1018,47 +994,6 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardwa } else port->p_power.powertype = LLDP_DOT3_POWER_8023AT_OFF; - /* 802.3bt? */ - if (tlv_size >= 29) { - port->p_power.requested_a = PEEK_UINT16; - port->p_power.requested_b = PEEK_UINT16; - port->p_power.allocated_a = PEEK_UINT16; - port->p_power.allocated_b = PEEK_UINT16; - port->p_power.pse_status = PEEK_UINT16; - port->p_power.pd_status = - (port->p_power.pse_status & - (1 << 13 | 1 << 12)) >> - 12; - port->p_power.pse_pairs_ext = - (port->p_power.pse_status & - (1 << 11 | 1 << 10)) >> - 10; - port->p_power.class_a = - (port->p_power.pse_status & - (1 << 9 | 1 << 8 | 1 << 7)) >> - 7; - port->p_power.class_b = - (port->p_power.pse_status & - (1 << 6 | 1 << 5 | 1 << 4)) >> - 4; - port->p_power.class_ext = - (port->p_power.pse_status & 0xf); - port->p_power.pse_status = - (port->p_power.pse_status & - (1 << 15 | 1 << 14)) >> - 14; - port->p_power.type_ext = PEEK_UINT8; - port->p_power.pd_load = - (port->p_power.type_ext & 0x1); - port->p_power.type_ext = - ((port->p_power.type_ext & - (1 << 3 | 1 << 2 | 1 << 1)) + - 1); - port->p_power.pse_max = PEEK_UINT16; - } else { - port->p_power.type_ext = - LLDP_DOT3_POWER_8023BT_OFF; - } break; default: /* Unknown Dot3 TLV, ignore it */ diff --git a/src/lib/atoms/dot3.c b/src/lib/atoms/dot3.c index ffe497dd..202ac9b6 100644 --- a/src/lib/atoms/dot3.c +++ b/src/lib/atoms/dot3.c @@ -63,128 +63,6 @@ static struct atom_map port_dot3_power_priority_map = { }, }; -static struct atom_map port_dot3_power_pd_4pid_map = { - .key = lldpctl_k_dot3_power_pd_4pid, - .map = { - { 0, "PD does not support powering both modes" }, - { 1, "PD supports powering both modes" }, - { 0, NULL}, - }, -}; - -static struct atom_map port_dot3_power_pse_status_map = { - .key = lldpctl_k_dot3_power_pse_status, - .map = { - { 0, "unknown" }, - { 1, "2-pair powering" }, - { 2, "4-pair powering dual-signature PD" }, - { 3, "4-pair powering single-signature PD" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_pd_status_map = { - .key = lldpctl_k_dot3_power_pd_status, - .map = { - { 0, "unknown" }, - { 1, "2-pair powered PD" }, - { 2, "4-pair powered dual-signature PD" }, - { 3, "4-pair powered single-signature PD" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_pse_pairs_ext_map = { - .key = lldpctl_k_dot3_power_pse_pairs_ext, - .map = { - { 0, "unknown" }, - { 1, "alternative A" }, - { 2, "alternative B" }, - { 3, "both alternatives" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_class_a_map = { - .key = lldpctl_k_dot3_power_class_a, - .map = { - { 0, "unknown" }, - { 1, "class 1" }, - { 2, "class 2" }, - { 3, "class 3" }, - { 4, "class 4" }, - { 5, "class 5" }, - { 6, "unknown" }, - { 7, "single-signature PD or 2-pair only PSE" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_class_b_map = { - .key = lldpctl_k_dot3_power_class_b, - .map = { - { 0, "unknown" }, - { 1, "class 1" }, - { 2, "class 2" }, - { 3, "class 3" }, - { 4, "class 4" }, - { 5, "class 5" }, - { 6, "unknown" }, - { 7, "single-signature PD or 2-pair only PSE" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_class_ext_map = { - .key = lldpctl_k_dot3_power_class_ext, - .map = { - { 0, "unknown" }, - { 1, "class 1" }, - { 2, "class 2" }, - { 3, "class 3" }, - { 4, "class 4" }, - { 5, "class 5" }, - { 6, "class 6" }, - { 7, "class 7" }, - { 8, "class 8" }, - { 9, "unknown" }, - { 10, "unknown" }, - { 11, "unknown" }, - { 12, "unknown" }, - { 13, "unknown" }, - { 14, "unknown" }, - { 15, "dual-signature PD" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_type_ext_map = { - .key = lldpctl_k_dot3_power_type_ext, - .map = { - { LLDP_DOT3_POWER_8023BT_OFF, "802.3bt off" }, - { 1, "type 3 PSE" }, - { 2, "type 4 PSE" }, - { 3, "type 3 single-signature PD" }, - { 4, "type 3 dual-signature PD" }, - { 5, "type 4 single-signature PD" }, - { 6, "type 4 dual-signature PD" }, - { 7, "unknown" }, - { 8, "unknown" }, - { 0, NULL }, - }, -}; - -static struct atom_map port_dot3_power_pd_load_map = { - .key = lldpctl_k_dot3_power_pd_load, - .map = { - { 0, "PD is single- or dual-signature and power is not " - "electrically isolated" }, - { 1, "PD is dual-signature and power is electrically " - "isolated" }, - { 0, NULL }, - }, -}; - ATOM_MAP_REGISTER(port_dot3_power_pairs_map, 4); ATOM_MAP_REGISTER(port_dot3_power_class_map, 5); ATOM_MAP_REGISTER(port_dot3_power_priority_map, 6); @@ -231,33 +109,6 @@ _lldpctl_atom_get_str_dot3_power(lldpctl_atom_t *atom, lldpctl_key_t key) case lldpctl_k_dot3_power_priority: return map_lookup(port_dot3_power_priority_map.map, port->p_power.priority); - case lldpctl_k_dot3_power_pd_4pid: - return map_lookup(port_dot3_power_pd_4pid_map.map, - port->p_power.pd_4pid); - case lldpctl_k_dot3_power_pse_status: - return map_lookup(port_dot3_power_pse_status_map.map, - port->p_power.pse_status); - case lldpctl_k_dot3_power_pd_status: - return map_lookup(port_dot3_power_pd_status_map.map, - port->p_power.pd_status); - case lldpctl_k_dot3_power_pse_pairs_ext: - return map_lookup(port_dot3_power_pse_pairs_ext_map.map, - port->p_power.pse_pairs_ext); - case lldpctl_k_dot3_power_class_a: - return map_lookup(port_dot3_power_class_a_map.map, - port->p_power.class_a); - case lldpctl_k_dot3_power_class_b: - return map_lookup(port_dot3_power_class_b_map.map, - port->p_power.class_b); - case lldpctl_k_dot3_power_class_ext: - return map_lookup(port_dot3_power_class_ext_map.map, - port->p_power.class_ext); - case lldpctl_k_dot3_power_type_ext: - return map_lookup(port_dot3_power_type_ext_map.map, - port->p_power.type_ext); - case lldpctl_k_dot3_power_pd_load: - return map_lookup(port_dot3_power_pd_load_map.map, - port->p_power.pd_load); default: SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); return NULL; @@ -295,35 +146,6 @@ _lldpctl_atom_get_int_dot3_power(lldpctl_atom_t *atom, lldpctl_key_t key) return port->p_power.requested * 100; case lldpctl_k_dot3_power_allocated: return port->p_power.allocated * 100; - /* 802.3bt additions */ - case lldpctl_k_dot3_power_pd_4pid: - return port->p_power.pd_4pid; - case lldpctl_k_dot3_power_requested_a: - return port->p_power.requested_a * 100; - case lldpctl_k_dot3_power_requested_b: - return port->p_power.requested_b * 100; - case lldpctl_k_dot3_power_allocated_a: - return port->p_power.allocated_a * 100; - case lldpctl_k_dot3_power_allocated_b: - return port->p_power.allocated_b * 100; - case lldpctl_k_dot3_power_pse_status: - return port->p_power.pse_status; - case lldpctl_k_dot3_power_pd_status: - return port->p_power.pd_status; - case lldpctl_k_dot3_power_pse_pairs_ext: - return port->p_power.pse_pairs_ext; - case lldpctl_k_dot3_power_class_a: - return port->p_power.class_a; - case lldpctl_k_dot3_power_class_b: - return port->p_power.class_b; - case lldpctl_k_dot3_power_class_ext: - return port->p_power.class_ext; - case lldpctl_k_dot3_power_type_ext: - return port->p_power.type_ext; - case lldpctl_k_dot3_power_pd_load: - return port->p_power.pd_load; - case lldpctl_k_dot3_power_pse_max: - return port->p_power.pse_max * 100; default: return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); } @@ -427,49 +249,6 @@ _lldpctl_atom_set_int_dot3_power(lldpctl_atom_t *atom, lldpctl_key_t key, if (value < 0) goto bad; port->p_power.requested = value / 100; return atom; - /* 802.3bt additions */ - case lldpctl_k_dot3_power_pd_4pid: - port->p_power.pd_4pid = value; - return atom; - case lldpctl_k_dot3_power_requested_a: - port->p_power.requested_a = value / 100; - return atom; - case lldpctl_k_dot3_power_requested_b: - port->p_power.requested_b = value / 100; - return atom; - case lldpctl_k_dot3_power_allocated_a: - port->p_power.allocated_a = value / 100; - return atom; - case lldpctl_k_dot3_power_allocated_b: - port->p_power.allocated_b = value / 100; - return atom; - case lldpctl_k_dot3_power_pse_status: - port->p_power.pse_status = value; - return atom; - case lldpctl_k_dot3_power_pd_status: - port->p_power.pd_status = value; - return atom; - case lldpctl_k_dot3_power_pse_pairs_ext: - port->p_power.pse_pairs_ext = value; - return atom; - case lldpctl_k_dot3_power_class_a: - port->p_power.class_a = value; - return atom; - case lldpctl_k_dot3_power_class_b: - port->p_power.class_b = value; - return atom; - case lldpctl_k_dot3_power_class_ext: - port->p_power.class_ext = value; - return atom; - case lldpctl_k_dot3_power_type_ext: - port->p_power.type_ext = value; - return atom; - case lldpctl_k_dot3_power_pd_load: - port->p_power.pd_load = value; - return atom; - case lldpctl_k_dot3_power_pse_max: - port->p_power.pse_max = value / 100; - return atom; default: SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); return NULL; diff --git a/src/lib/lldpctl.h b/src/lib/lldpctl.h index f1cb1d04..cc6e12a2 100644 --- a/src/lib/lldpctl.h +++ b/src/lib/lldpctl.h @@ -773,26 +773,6 @@ typedef enum { lldpctl_k_dot3_power_allocated, /**< `(I,W)` 802.3AT power allocated */ lldpctl_k_dot3_power_requested, /**< `(I,W)` 802.3AT power requested */ - /* 802.3bt additions */ - lldpctl_k_dot3_power_pd_4pid, /**< `(IS,W)` 802.3BT both modes supported? */ - lldpctl_k_dot3_power_requested_a, /**< `(I,W)` 802.3BT power value requested for - A */ - lldpctl_k_dot3_power_requested_b, /**< `(I,W)` 802.3BT power value requested for - B */ - lldpctl_k_dot3_power_allocated_a, /**< `(I,W)` 802.3BT power value allocated for - A */ - lldpctl_k_dot3_power_allocated_b, /**< `(I,W)` 802.3BT power value allocated for - B */ - lldpctl_k_dot3_power_pse_status, /**< `(IS,W)` 802.3BT PSE powering status */ - lldpctl_k_dot3_power_pd_status, /**< `(IS,W)` 802.3BT PD powering status */ - lldpctl_k_dot3_power_pse_pairs_ext, /**< `(IS,W)` 802.3BT PSE power pairs */ - lldpctl_k_dot3_power_class_a, /**< `(IS,W)` 802.3BT power class for A */ - lldpctl_k_dot3_power_class_b, /**< `(IS,W)` 802.3BT power class for B */ - lldpctl_k_dot3_power_class_ext, /**< `(IS,W)` 802.3BT power class */ - lldpctl_k_dot3_power_type_ext, /**< `(IS,W)` 802.3BT power type */ - lldpctl_k_dot3_power_pd_load, /**< `(IS,W)` 802.3BT dualsig isolated? */ - lldpctl_k_dot3_power_pse_max, /**< `(I,W)` 802.3BT maximum available power */ - lldpctl_k_port_vlan_pvid = 1500, /**< `(I)` Primary VLAN ID */ lldpctl_k_port_vlans, /**< `(AL)` List of VLAN */ lldpctl_k_vlan_id, /**< `(I)` VLAN ID */ diff --git a/src/lldp-const.h b/src/lldp-const.h index 454424d0..c3fc40e4 100644 --- a/src/lldp-const.h +++ b/src/lldp-const.h @@ -207,11 +207,6 @@ #define LLDP_DOT3_POWER_8023AT_TYPE1 1 #define LLDP_DOT3_POWER_8023AT_TYPE2 2 -/* 802.3bt additions */ -#define LLDP_DOT3_POWER_8023BT_OFF 0 -#define LLDP_DOT3_POWER_8023BT_TYPE3 1 -#define LLDP_DOT3_POWER_8023BT_TYPE4 2 - /* Dot3 power source */ #define LLDP_DOT3_POWER_SOURCE_UNKNOWN 0 #define LLDP_DOT3_POWER_SOURCE_PRIMARY 1 diff --git a/src/lldpd-structs.h b/src/lldpd-structs.h index 5647c83f..10fcdf65 100644 --- a/src/lldpd-structs.h +++ b/src/lldpd-structs.h @@ -125,22 +125,6 @@ struct lldpd_dot3_power { u_int8_t priority; u_int16_t requested; u_int16_t allocated; - - /* For 802.3BT */ - u_int8_t pd_4pid; - u_int16_t requested_a; - u_int16_t requested_b; - u_int16_t allocated_a; - u_int16_t allocated_b; - u_int16_t pse_status; - u_int8_t pd_status; - u_int8_t pse_pairs_ext; - u_int8_t class_a; - u_int8_t class_b; - u_int8_t class_ext; - u_int8_t type_ext; - u_int8_t pd_load; - u_int16_t pse_max; }; MARSHAL(lldpd_dot3_power); #endif diff --git a/tests/integration/test_dot3.py b/tests/integration/test_dot3.py index 35d036e7..abeb86ef 100644 --- a/tests/integration/test_dot3.py +++ b/tests/integration/test_dot3.py @@ -49,41 +49,6 @@ class TestLldpDot3(object): "allocated": "15000", }, ), - ( - "pd type-ext 4 powerpairs signal class-a 4 class-b 3 class-ext 5 " - "pd-status 2 pd-4pid 0 " - "requested-a 1000 allocated-a 900 " - "requested-b 2000 allocated-b 500 " - "pd-load 400", - { - "supported": "no", - "enabled": "no", - "paircontrol": "no", - "device-type": "PD", - "pairs": "signal", - "power-type": "2", - # 802.3at is not configured - "class": "unknown", - "source": "unknown", - "priority": "unknown", - "requested": "0", - "allocated": "0", - # 802.3bt is configured - "requested-a": "1000", - "allocated-a": "900", - "requested-b": "2000", - "allocated-b": "500", - "power-pairs-ext": "unknown", - "pse-power-status": "unknown", - "pd-power-status": "4-pair powered dual-signature PD", - "power-class-ext-a": "class 4", - "power-class-ext-b": "class 3", - "power-class-ext": "class 5", - "power-type-ext": "unknown", - "pd-load": "???", - "max-power": "0", - }, - ), ], ) def test_power(self, lldpd1, lldpd, lldpcli, namespaces, command, expected):