aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/translation-table.c
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2011-07-07 09:35:36 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-08-22 09:16:20 -0400
commit59b699cdee039d75915c354da06937102d1f9a84 (patch)
tree33fabd9cac27cb7bc1d3fbc765f098b5b8e8575e /net/batman-adv/translation-table.c
parentbc2790808a7a3699a7c9f72f7ad225c8504824aa (diff)
batman-adv: implement AP-isolation on the receiver side
When a node receives a unicast packet it checks if the source and the destination client can communicate or not due to the AP isolation Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r--net/batman-adv/translation-table.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index d6305645e08d..d0ed931ad2e7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -781,6 +781,18 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
781 bat_priv->tt_global_hash = NULL; 781 bat_priv->tt_global_hash = NULL;
782} 782}
783 783
784static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
785 struct tt_global_entry *tt_global_entry)
786{
787 bool ret = false;
788
789 if (tt_local_entry->flags & TT_CLIENT_WIFI &&
790 tt_global_entry->flags & TT_CLIENT_WIFI)
791 ret = true;
792
793 return ret;
794}
795
784struct orig_node *transtable_search(struct bat_priv *bat_priv, 796struct orig_node *transtable_search(struct bat_priv *bat_priv,
785 const uint8_t *addr) 797 const uint8_t *addr)
786{ 798{
@@ -1729,3 +1741,33 @@ void tt_commit_changes(struct bat_priv *bat_priv)
1729 atomic_inc(&bat_priv->ttvn); 1741 atomic_inc(&bat_priv->ttvn);
1730 bat_priv->tt_poss_change = false; 1742 bat_priv->tt_poss_change = false;
1731} 1743}
1744
1745bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst)
1746{
1747 struct tt_local_entry *tt_local_entry = NULL;
1748 struct tt_global_entry *tt_global_entry = NULL;
1749 bool ret = true;
1750
1751 if (!atomic_read(&bat_priv->ap_isolation))
1752 return false;
1753
1754 tt_local_entry = tt_local_hash_find(bat_priv, dst);
1755 if (!tt_local_entry)
1756 goto out;
1757
1758 tt_global_entry = tt_global_hash_find(bat_priv, src);
1759 if (!tt_global_entry)
1760 goto out;
1761
1762 if (_is_ap_isolated(tt_local_entry, tt_global_entry))
1763 goto out;
1764
1765 ret = false;
1766
1767out:
1768 if (tt_global_entry)
1769 tt_global_entry_free_ref(tt_global_entry);
1770 if (tt_local_entry)
1771 tt_local_entry_free_ref(tt_local_entry);
1772 return ret;
1773}