[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/lib/libnl/libnl-3.2.25/tests/test-create-bridge.c b/ap/lib/libnl/libnl-3.2.25/tests/test-create-bridge.c
new file mode 100644
index 0000000..7202cd7
--- /dev/null
+++ b/ap/lib/libnl/libnl-3.2.25/tests/test-create-bridge.c
@@ -0,0 +1,80 @@
+#include <netlink/netlink.h>
+#include <netlink/route/link.h>
+#include <netlink/route/link/bridge.h>
+
+#define TEST_BRIDGE_NAME "testbridge"
+#define TEST_INTERFACE_NAME "testtap1"
+
+int create_bridge(struct nl_sock *sk, struct nl_cache *link_cache, const char *name) {
+	struct rtnl_link *link;
+	int err;
+
+	link = rtnl_link_alloc();
+	if ((err = rtnl_link_set_type(link, "bridge")) < 0) {
+		rtnl_link_put(link);
+		return err;
+	}
+	rtnl_link_set_name(link, name);
+
+	if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) {
+		return err;
+	}
+	rtnl_link_put(link);
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	struct rtnl_link *link;
+	struct nl_cache *link_cache;
+	struct nl_sock *sk;
+	int err;
+
+	sk = nl_socket_alloc();
+	if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) {
+		nl_perror(err, "Unable to connect socket");
+		return err;
+	}
+
+	if ((err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache)) < 0) {
+		nl_perror(err, "Unable to allocate cache");
+		return err;
+	}
+
+	if ((err = create_bridge(sk, link_cache, TEST_BRIDGE_NAME)) < 0) {
+		nl_perror(err, "Unable to allocate testbridge");
+		return err;
+	}
+
+	nl_cache_refill(sk, link_cache);
+
+	link = rtnl_link_get_by_name(link_cache, TEST_BRIDGE_NAME);
+	struct rtnl_link *ltap = rtnl_link_get_by_name(link_cache, TEST_INTERFACE_NAME);
+	if (!ltap) {
+		fprintf(stderr, "You should create a tap interface before lunch this test (# tunctl -t %s)\n", TEST_INTERFACE_NAME);
+		return -1;
+	}
+
+	if ((err = rtnl_link_enslave(sk, link, ltap)) < 0) {
+		nl_perror(err, "Unable to enslave interface to his bridge\n");
+		return err;
+	}
+
+	if(rtnl_link_is_bridge(link) == 0) {
+		fprintf(stderr, "Link is not a bridge\n");
+		return -2;
+	}
+	if(rtnl_link_get_master(ltap) <= 0) {
+		fprintf(stderr, "Interface is not attached to a bridge\n");
+		return -3;
+	}
+
+	rtnl_link_put(ltap);
+	rtnl_link_put(link);
+
+	nl_cache_free(link_cache);
+	nl_socket_free(sk);
+
+	return 0;
+}