swconfig: Bugfix switch_port uci option parsing
[openwrt/openwrt.git] / package / network / config / swconfig / src / swlib.h
index ff73969c8718cc0edcc1c7010669b44f24da0b14..3826a5e3402890854672953478c72e3870432247 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * swlib.h: Switch configuration API (user space part)
  *
- * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008-2009 Felix Fietkau <nbd@nbd.name>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -105,24 +105,31 @@ enum swlib_port_flags {
        SWLIB_PORT_FLAG_TAGGED = (1 << 0),
 };
 
+enum swlib_link_flags {
+       SWLIB_LINK_FLAG_EEE_100BASET = (1 << 0),
+       SWLIB_LINK_FLAG_EEE_1000BASET = (1 << 1),
+};
 
 struct switch_dev;
 struct switch_attr;
 struct switch_port;
+struct switch_port_map;
+struct switch_port_link;
 struct switch_val;
 struct uci_package;
 
 struct switch_dev {
        int id;
        char dev_name[IFNAMSIZ];
-       const char *name;
-       const char *alias;
+       char *name;
+       char *alias;
        int ports;
        int vlans;
        int cpu_port;
        struct switch_attr *ops;
        struct switch_attr *port_ops;
        struct switch_attr *vlan_ops;
+       struct switch_portmap *maps;
        struct switch_dev *next;
        void *priv;
 };
@@ -133,9 +140,10 @@ struct switch_val {
        int err;
        int port_vlan;
        union {
-               const char *s;
+               char *s;
                int i;
                struct switch_port *ports;
+               struct switch_port_link *link;
        } value;
 };
 
@@ -144,8 +152,8 @@ struct switch_attr {
        int atype;
        int id;
        int type;
-       const char *name;
-       const char *description;
+       char *name;
+       char *description;
        struct switch_attr *next;
 };
 
@@ -154,6 +162,33 @@ struct switch_port {
        unsigned int flags;
 };
 
+struct switch_portmap {
+       unsigned int virt;
+       char *segment;
+};
+
+struct switch_port_link {
+       int link:1;
+       int duplex:1;
+       int aneg:1;
+       int tx_flow:1;
+       int rx_flow:1;
+       int speed;
+       /* in ethtool adv_t format */
+       uint32_t eee;
+};
+
+/**
+ * swlib_list: list all switches
+ */
+void swlib_list(void);
+
+/**
+ * swlib_print_portmap: get portmap
+ * @dev: switch device struct
+ */
+void swlib_print_portmap(struct switch_dev *dev, char *segment);
+
 /**
  * swlib_connect: connect to the switch through netlink
  * @name: name of the ethernet interface,