diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2013-04-23 09:39:59 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2013-10-09 15:22:27 -0400 |
commit | 17cf0ea455f1a4a7e8436ef96236999e9c452a93 (patch) | |
tree | 86b0a10dc27b3c32f27c13f15bc3e43291cacca9 /net/batman-adv/distributed-arp-table.c | |
parent | 414254e342a0d58144de40c3da777521ebaeeb07 (diff) |
batman-adv: tvlv - add distributed arp table container
Create DAT container to announce DAT capabilities (if enabled).
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv/distributed-arp-table.c')
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 06345d401588..f07ec320dc01 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -419,6 +419,10 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res, | |||
419 | bool ret = false; | 419 | bool ret = false; |
420 | int j; | 420 | int j; |
421 | 421 | ||
422 | /* check if orig node candidate is running DAT */ | ||
423 | if (!(candidate->capabilities & BATADV_ORIG_CAPA_HAS_DAT)) | ||
424 | goto out; | ||
425 | |||
422 | /* Check if this node has already been selected... */ | 426 | /* Check if this node has already been selected... */ |
423 | for (j = 0; j < select; j++) | 427 | for (j = 0; j < select; j++) |
424 | if (res[j].orig_node == candidate) | 428 | if (res[j].orig_node == candidate) |
@@ -626,6 +630,59 @@ out: | |||
626 | } | 630 | } |
627 | 631 | ||
628 | /** | 632 | /** |
633 | * batadv_dat_tvlv_container_update - update the dat tvlv container after dat | ||
634 | * setting change | ||
635 | * @bat_priv: the bat priv with all the soft interface information | ||
636 | */ | ||
637 | static void batadv_dat_tvlv_container_update(struct batadv_priv *bat_priv) | ||
638 | { | ||
639 | char dat_mode; | ||
640 | |||
641 | dat_mode = atomic_read(&bat_priv->distributed_arp_table); | ||
642 | |||
643 | switch (dat_mode) { | ||
644 | case 0: | ||
645 | batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1); | ||
646 | break; | ||
647 | case 1: | ||
648 | batadv_tvlv_container_register(bat_priv, BATADV_TVLV_DAT, 1, | ||
649 | NULL, 0); | ||
650 | break; | ||
651 | } | ||
652 | } | ||
653 | |||
654 | /** | ||
655 | * batadv_dat_status_update - update the dat tvlv container after dat | ||
656 | * setting change | ||
657 | * @net_dev: the soft interface net device | ||
658 | */ | ||
659 | void batadv_dat_status_update(struct net_device *net_dev) | ||
660 | { | ||
661 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | ||
662 | batadv_dat_tvlv_container_update(bat_priv); | ||
663 | } | ||
664 | |||
665 | /** | ||
666 | * batadv_gw_tvlv_ogm_handler_v1 - process incoming dat tvlv container | ||
667 | * @bat_priv: the bat priv with all the soft interface information | ||
668 | * @orig: the orig_node of the ogm | ||
669 | * @flags: flags indicating the tvlv state (see batadv_tvlv_handler_flags) | ||
670 | * @tvlv_value: tvlv buffer containing the gateway data | ||
671 | * @tvlv_value_len: tvlv buffer length | ||
672 | */ | ||
673 | static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, | ||
674 | struct batadv_orig_node *orig, | ||
675 | uint8_t flags, | ||
676 | void *tvlv_value, | ||
677 | uint16_t tvlv_value_len) | ||
678 | { | ||
679 | if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) | ||
680 | orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_DAT; | ||
681 | else | ||
682 | orig->capabilities |= BATADV_ORIG_CAPA_HAS_DAT; | ||
683 | } | ||
684 | |||
685 | /** | ||
629 | * batadv_dat_hash_free - free the local DAT hash table | 686 | * batadv_dat_hash_free - free the local DAT hash table |
630 | * @bat_priv: the bat priv with all the soft interface information | 687 | * @bat_priv: the bat priv with all the soft interface information |
631 | */ | 688 | */ |
@@ -657,6 +714,10 @@ int batadv_dat_init(struct batadv_priv *bat_priv) | |||
657 | 714 | ||
658 | batadv_dat_start_timer(bat_priv); | 715 | batadv_dat_start_timer(bat_priv); |
659 | 716 | ||
717 | batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1, | ||
718 | NULL, BATADV_TVLV_DAT, 1, | ||
719 | BATADV_TVLV_HANDLER_OGM_CIFNOTFND); | ||
720 | batadv_dat_tvlv_container_update(bat_priv); | ||
660 | return 0; | 721 | return 0; |
661 | } | 722 | } |
662 | 723 | ||
@@ -666,6 +727,9 @@ int batadv_dat_init(struct batadv_priv *bat_priv) | |||
666 | */ | 727 | */ |
667 | void batadv_dat_free(struct batadv_priv *bat_priv) | 728 | void batadv_dat_free(struct batadv_priv *bat_priv) |
668 | { | 729 | { |
730 | batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1); | ||
731 | batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_DAT, 1); | ||
732 | |||
669 | cancel_delayed_work_sync(&bat_priv->dat.work); | 733 | cancel_delayed_work_sync(&bat_priv->dat.work); |
670 | 734 | ||
671 | batadv_dat_hash_free(bat_priv); | 735 | batadv_dat_hash_free(bat_priv); |