[Add basic opensync build support]

[Description]
Add basic opensync build support
1.Add basic opensync v2.0.5 build back
2.Add opensync v3.2.x build support(v3.2.7 test ok)
3.Default disable opensync build

[Release-log]
N/A

diff --git a/recipes-common/mesh-agent/files/enabling_dhcp_lease_resync.patch b/recipes-common/mesh-agent/files/enabling_dhcp_lease_resync.patch
new file mode 100644
index 0000000..b149b34
--- /dev/null
+++ b/recipes-common/mesh-agent/files/enabling_dhcp_lease_resync.patch
@@ -0,0 +1,54 @@
+From cc64f3a69d13feda1b9f07b8f572080436d7560b Mon Sep 17 00:00:00 2001
+From: "rajakumaran.a" <rajakumaran.a@lnttechservices.com>
+Date: Thu, 2 Apr 2020 10:09:05 +0000
+Subject: [PATCH] Mesh dns lease update
+
+Signed-off-by: rajakumaran.a <rajakumaran.a@lnttechservices.com>
+Change-Id: Ib098c6d444b75d15120b2224ff46869b0e436c2f
+---
+ source/MeshAgentSsp/cosa_mesh_apis.c | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/source/MeshAgentSsp/cosa_mesh_apis.c b/source/MeshAgentSsp/cosa_mesh_apis.c
+index 46ed117..566cc0d 100644
+--- a/source/MeshAgentSsp/cosa_mesh_apis.c
++++ b/source/MeshAgentSsp/cosa_mesh_apis.c
+@@ -2154,7 +2154,9 @@ static void *Mesh_sysevent_handler(void *data)
+     async_id_t mesh_enable_asyncid;
+     async_id_t mesh_url_asyncid;
+     async_id_t wifi_txRate_asyncid;
+-
++#ifdef _PLATFORM_TURRIS_
++    async_id_t lease_resync_asyncid;
++#endif
+     sysevent_set_options(sysevent_fd,     sysevent_token, meshSyncMsgArr[MESH_WIFI_RESET].sysStr,                     TUPLE_FLAG_EVENT);
+     sysevent_setnotification(sysevent_fd, sysevent_token, meshSyncMsgArr[MESH_WIFI_RESET].sysStr,                     &wifi_init_asyncid);
+     sysevent_set_options(sysevent_fd,     sysevent_token, meshSyncMsgArr[MESH_WIFI_SSID_NAME].sysStr,                 TUPLE_FLAG_EVENT);
+@@ -2195,6 +2197,10 @@ static void *Mesh_sysevent_handler(void *data)
+     sysevent_set_options(sysevent_fd,     sysevent_token, meshSyncMsgArr[MESH_WIFI_TXRATE].sysStr,                   TUPLE_FLAG_EVENT);
+     sysevent_setnotification(sysevent_fd, sysevent_token, meshSyncMsgArr[MESH_WIFI_TXRATE].sysStr,                   &wifi_txRate_asyncid);
+ 
++#ifdef _PLATFORM_TURRIS_
++    sysevent_set_options(sysevent_fd,     sysevent_token, meshSyncMsgArr[MESH_DHCP_RESYNC_LEASES].sysStr,                   TUPLE_FLAG_EVENT);
++    sysevent_setnotification(sysevent_fd, sysevent_token, meshSyncMsgArr[MESH_DHCP_RESYNC_LEASES].sysStr,                   &lease_resync_asyncid);
++#endif
+ 
+     for (;;)
+     {
+@@ -3198,6 +3204,13 @@ static void *Mesh_sysevent_handler(void *data)
+                     }
+                 }
+             }
++#ifdef _PLATFORM_TURRIS_
++            else if (strcmp(name, meshSyncMsgArr[MESH_DHCP_RESYNC_LEASES].sysStr)==0)
++            {
++                //This will handle sending lease information to plume for every new connection, without restarting the MeshAgent
++                Mesh_sendDhcpLeaseSync();
++            }
++#endif
+             else
+             {
+                 MeshWarning("undefined event %s \n",name);
+-- 
+2.24.0
+
diff --git a/recipes-common/mesh-agent/files/meshagent-enable-ovs-default.patch b/recipes-common/mesh-agent/files/meshagent-enable-ovs-default.patch
new file mode 100644
index 0000000..2fbdb31
--- /dev/null
+++ b/recipes-common/mesh-agent/files/meshagent-enable-ovs-default.patch
@@ -0,0 +1,13 @@
+diff --git a/source/MeshAgentSsp/cosa_mesh_apis.c b/source/MeshAgentSsp/cosa_mesh_apis.c
+index c100dfd..a33b37e 100644
+--- a/source/MeshAgentSsp/cosa_mesh_apis.c
++++ b/source/MeshAgentSsp/cosa_mesh_apis.c
+@@ -2497,7 +2497,7 @@ static void Mesh_SetDefaults(ANSC_HANDLE hThisObject)
+     if(Mesh_SysCfgGetStr("mesh_ovs_enable", out_val, sizeof(out_val)) != 0)
+     {
+         MeshInfo("Syscfg error, Setting OVS mode to default\n");
+-        Mesh_SetOVS(false,true,true);
++        Mesh_SetOVS(true,true,true);
+     }
+     else
+     {
diff --git a/recipes-common/mesh-agent/mesh-agent.bbappend b/recipes-common/mesh-agent/mesh-agent.bbappend
new file mode 100644
index 0000000..957517c
--- /dev/null
+++ b/recipes-common/mesh-agent/mesh-agent.bbappend
@@ -0,0 +1,36 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI += "\
+file://enabling_dhcp_lease_resync.patch;apply=no \
+file://meshagent-enable-ovs-default.patch;apply=no \
+"
+
+DEPENDS_append_dunfell = " safec trower-base64"
+RDEPENDS_${PN}_append_dunfell = " bash"
+
+# we need to patch to code for mesh-agent
+do_turris_meshagent_patches() {
+    cd ${S}
+    if [ ! -e patch_applied ]; then
+        bbnote "Patching enabling_dhcp_lease_resync.patch"
+        patch  -p1 < ${WORKDIR}/enabling_dhcp_lease_resync.patch ${S}/source/MeshAgentSsp/cosa_mesh_apis.c
+
+        bbnote "Patching meshagent-enable-ovs-default.patch"
+        patch  -p1 < ${WORKDIR}/meshagent-enable-ovs-default.patch ${S}/source/MeshAgentSsp/cosa_mesh_apis.c
+
+        touch patch_applied
+    fi
+}
+addtask turris_meshagent_patches after do_unpack before do_configure
+
+do_install_append () {
+       install -D -m 0644 ${S}/systemd_units/meshAgent.service ${D}${systemd_unitdir}/system/meshAgent.service
+}
+
+FILES_${PN}_append = "${systemd_unitdir}/system/meshAgent.service"
+
+CFLAGS_append = " -D_PLATFORM_TURRIS_"
+
+LDFLAGS_append_dunfell = " -lsyscfg -lsysevent -lbreakpadwrapper -lsafec-3.5.1"
+
+LDFLAGS_remove_dunfell = "-lsafec-3.5"