Signed-off-by: Rafał Miłecki <zaj...@gmail.com>
---
 package/network/config/swconfig/src/swlib.c | 38 +++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/package/network/config/swconfig/src/swlib.c 
b/package/network/config/swconfig/src/swlib.c
index 908e0fb..7bcd8d2 100644
--- a/package/network/config/swconfig/src/swlib.c
+++ b/package/network/config/swconfig/src/swlib.c
@@ -337,6 +337,40 @@ nla_put_failure:
 }
 
 static int
+send_attr_link(struct nl_msg *msg, struct switch_val *val)
+{
+       struct switch_port_link *link = val->value.link;
+       struct nlattr *n;
+
+       n = nla_nest_start(msg, SWITCH_ATTR_OP_VALUE_LINK);
+       if (!n)
+               goto nla_put_failure;
+
+       if (link->link)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_LINK);
+       if (link->duplex)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_DUPLEX);
+       if (link->aneg)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_ANEG);
+       if (link->tx_flow)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_TX_FLOW);
+       if (link->rx_flow)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_RX_FLOW);
+       NLA_PUT_U32(msg, SWITCH_LINK_SPEED, link->speed);
+       if (link->eee & SWLIB_LINK_FLAG_EEE_100BASET)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_EEE_100BASET);
+       if (link->eee & SWLIB_LINK_FLAG_EEE_1000BASET)
+               NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_EEE_1000BASET);
+
+       nla_nest_end(msg, n);
+
+       return 0;
+
+nla_put_failure:
+       return -1;
+}
+
+static int
 send_attr_val(struct nl_msg *msg, void *arg)
 {
        struct switch_val *val = arg;
@@ -360,6 +394,10 @@ send_attr_val(struct nl_msg *msg, void *arg)
                if (send_attr_ports(msg, val) < 0)
                        goto nla_put_failure;
                break;
+       case SWITCH_TYPE_LINK:
+               if (send_attr_link(msg, val))
+                       goto nla_put_failure;
+               break;
        default:
                goto nla_put_failure;
        }
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to