summaryrefslogtreecommitdiff
path: root/ipacm/src/IPACM_Config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ipacm/src/IPACM_Config.cpp')
-rw-r--r--ipacm/src/IPACM_Config.cpp51
1 files changed, 41 insertions, 10 deletions
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index babc847..ad0cdd3 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -467,7 +467,7 @@ int IPACM_Config::GetNatIfaces(int nIfaces, NatIfaces *pIfaces)
}
-int IPACM_Config::AddNatIfaces(char *dev_name)
+int IPACM_Config::AddNatIfaces(char *dev_name, ipa_ip_type ip_type)
{
int i;
/* Check if this iface already in NAT-iface*/
@@ -477,7 +477,15 @@ int IPACM_Config::AddNatIfaces(char *dev_name)
pNatIfaces[i].iface_name,
sizeof(pNatIfaces[i].iface_name)) == 0)
{
- IPACMDBG("Interface (%s) is add to nat iface already\n", dev_name);
+ IPACMDBG_H("Interface (%s) is add to nat iface already\n", dev_name);
+ if (ip_type == IPA_IP_v4) {
+ pNatIfaces[i].v4_up = true;
+ IPACMDBG_H("Change v4_up to (%d) \n", pNatIfaces[i].v4_up);
+ }
+ if (ip_type == IPA_IP_v6) {
+ pNatIfaces[i].v6_up = true;
+ IPACMDBG_H("Change v6_up to (%d) \n", pNatIfaces[i].v6_up);
+ }
return 0;
}
}
@@ -494,8 +502,15 @@ int IPACM_Config::AddNatIfaces(char *dev_name)
IPACMDBG_H("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n",
pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
ipa_nat_iface_entries);
+ if (ip_type == IPA_IP_v4) {
+ pNatIfaces[ipa_nat_iface_entries - 1].v4_up = true;
+ IPACMDBG_H("Change v4_up to (%d) \n", pNatIfaces[ipa_nat_iface_entries - 1].v4_up);
+ }
+ if (ip_type == IPA_IP_v6) {
+ pNatIfaces[ipa_nat_iface_entries - 1].v6_up = true;
+ IPACMDBG_H("Change v6_up to (%d) \n", pNatIfaces[ipa_nat_iface_entries - 1].v6_up);
+ }
}
-
return 0;
}
@@ -514,14 +529,20 @@ int IPACM_Config::DelNatIfaces(char *dev_name)
/* Reset the matched entry */
memset(pNatIfaces[i].iface_name, 0, IPA_IFACE_NAME_LEN);
+ pNatIfaces[i].v4_up = false;
+ pNatIfaces[i].v6_up = false;
for (; i < ipa_nat_iface_entries - 1; i++)
{
memcpy(pNatIfaces[i].iface_name,
pNatIfaces[i + 1].iface_name, IPA_IFACE_NAME_LEN);
+ pNatIfaces[i].v4_up = pNatIfaces[i + 1].v4_up;
+ pNatIfaces[i].v6_up = pNatIfaces[i + 1].v6_up;
/* Reset the copied entry */
memset(pNatIfaces[i + 1].iface_name, 0, IPA_IFACE_NAME_LEN);
+ pNatIfaces[i + 1].v4_up = false;
+ pNatIfaces[i + 1].v6_up = false;
}
ipa_nat_iface_entries--;
IPACMDBG_H("Update nat-ifaces number: %d\n", ipa_nat_iface_entries);
@@ -534,23 +555,33 @@ int IPACM_Config::DelNatIfaces(char *dev_name)
return 0;
}
-int IPACM_Config::CheckNatIfaces(const char *dev_name)
+int IPACM_Config::CheckNatIfaces(const char *dev_name, ipa_ip_type ip_type)
{
int i = 0;
- IPACMDBG_H("Check iface %s from NAT-ifaces, currently it has %d nat ifaces\n",
- dev_name, ipa_nat_iface_entries);
+ IPACMDBG_H("Check iface %s for ip-type %d from NAT-ifaces, currently it has %d nat ifaces\n",
+ dev_name, ip_type, ipa_nat_iface_entries);
for (i = 0; i < ipa_nat_iface_entries; i++)
{
if (strcmp(dev_name, pNatIfaces[i].iface_name) == 0)
{
- IPACMDBG_H("Find Nat IfaceName: %s ,previous nat-ifaces number: %d\n",
- pNatIfaces[i].iface_name, ipa_nat_iface_entries);
+ IPACMDBG_H("Find Nat IfaceName: %s ,previous nat-ifaces number: %d, v4_up %d, v6_up %d \n",
+ pNatIfaces[i].iface_name, ipa_nat_iface_entries, pNatIfaces[i].v4_up, pNatIfaces[i].v6_up);
+ if (ip_type == IPA_IP_v4 && pNatIfaces[i].v4_up == true)
+ {
+ IPACMDBG_H(" v4_up=%d\n", pNatIfaces[i].v4_up);
+ return 0;
+ }
+ if (ip_type == IPA_IP_v6 && pNatIfaces[i].v6_up == true)
+ {
+ IPACMDBG_H(" v6_up=%d\n", pNatIfaces[i].v6_up);
return 0;
}
+ return -1;
+ }
}
- IPACMDBG_H("Can't find Nat IfaceName: %s with total nat-ifaces number: %d\n",
- dev_name, ipa_nat_iface_entries);
+ IPACMDBG_H("Can't find Nat IfaceName: %s for ip_type %d up with total nat-ifaces number: %d\n",
+ dev_name, ip_type, ipa_nat_iface_entries);
return -1;
}