batman-adv: Multicast Listener Announcements via Translation Table
[firefly-linux-kernel-4.4.55.git] / net / batman-adv / types.h
index 8435d7c83a14f717fad28b3fa84834dfc19ec8f5..d553264135d34cd4c1eb7487cf80f8f45b64b313 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
+/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
  *
@@ -84,6 +84,7 @@ struct batadv_hard_iface_bat_iv {
  * @rcu: struct used for freeing in an RCU-safe manner
  * @bat_iv: BATMAN IV specific per hard interface data
  * @cleanup_work: work queue callback item for hard interface deinit
+ * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
  */
 struct batadv_hard_iface {
        struct list_head list;
@@ -98,6 +99,29 @@ struct batadv_hard_iface {
        struct rcu_head rcu;
        struct batadv_hard_iface_bat_iv bat_iv;
        struct work_struct cleanup_work;
+       struct dentry *debug_dir;
+};
+
+/**
+ * struct batadv_orig_ifinfo - originator info per outgoing interface
+ * @list: list node for orig_node::ifinfo_list
+ * @if_outgoing: pointer to outgoing hard interface
+ * @router: router that should be used to reach this originator
+ * @last_real_seqno: last and best known sequence number
+ * @last_ttl: ttl of last received packet
+ * @batman_seqno_reset: time when the batman seqno window was reset
+ * @refcount: number of contexts the object is used
+ * @rcu: struct used for freeing in an RCU-safe manner
+ */
+struct batadv_orig_ifinfo {
+       struct hlist_node list;
+       struct batadv_hard_iface *if_outgoing;
+       struct batadv_neigh_node __rcu *router; /* rcu protected pointer */
+       uint32_t last_real_seqno;
+       uint8_t last_ttl;
+       unsigned long batman_seqno_reset;
+       atomic_t refcount;
+       struct rcu_head rcu;
 };
 
 /**
@@ -139,7 +163,7 @@ struct batadv_vlan_tt {
 };
 
 /**
- * batadv_orig_node_vlan - VLAN specific data per orig_node
+ * struct batadv_orig_node_vlan - VLAN specific data per orig_node
  * @vid: the VLAN identifier
  * @tt: VLAN specific TT attributes
  * @list: list node for orig_node::vlan_list
@@ -175,11 +199,11 @@ struct batadv_orig_bat_iv {
  * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
  * @orig: originator ethernet address
  * @primary_addr: hosts primary interface address
- * @router: router that should be used to reach this originator
+ * @ifinfo_list: list for routers per outgoing interface
+ * @last_bonding_candidate: pointer to last ifinfo of last used router
  * @batadv_dat_addr_t:  address of the orig node in the distributed hash
  * @last_seen: time when last packet from this node was received
  * @bcast_seqno_reset: time when the broadcast seqno window was reset
- * @batman_seqno_reset: time when the batman seqno window was reset
  * @capabilities: announced capabilities of this originator
  * @last_ttvn: last seen translation table version number
  * @tt_buff: last tt changeset this node received from the orig node
@@ -192,8 +216,6 @@ struct batadv_orig_bat_iv {
  *  made up by two operations (data structure update and metdata -CRC/TTVN-
  *  recalculation) and they have to be executed atomically in order to avoid
  *  another thread to read the table/metadata between those.
- * @last_real_seqno: last and best known sequence number
- * @last_ttl: ttl of last received packet
  * @bcast_bits: bitfield containing the info which payload broadcast originated
  *  from this orig node this host already has seen (relative to
  *  last_bcast_seqno)
@@ -218,13 +240,13 @@ struct batadv_orig_bat_iv {
 struct batadv_orig_node {
        uint8_t orig[ETH_ALEN];
        uint8_t primary_addr[ETH_ALEN];
-       struct batadv_neigh_node __rcu *router; /* rcu protected pointer */
+       struct hlist_head ifinfo_list;
+       struct batadv_orig_ifinfo *last_bonding_candidate;
 #ifdef CONFIG_BATMAN_ADV_DAT
        batadv_dat_addr_t dat_addr;
 #endif
        unsigned long last_seen;
        unsigned long bcast_seqno_reset;
-       unsigned long batman_seqno_reset;
        uint8_t capabilities;
        atomic_t last_ttvn;
        unsigned char *tt_buff;
@@ -233,8 +255,6 @@ struct batadv_orig_node {
        bool tt_initialised;
        /* prevents from changing the table while reading it */
        spinlock_t tt_lock;
-       uint32_t last_real_seqno;
-       uint8_t last_ttl;
        DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
        uint32_t last_bcast_seqno;
        struct hlist_head neigh_list;
@@ -313,7 +333,8 @@ struct batadv_neigh_node {
        struct rcu_head rcu;
 };
 
-/* struct batadv_neigh_node_bat_iv - neighbor information per outgoing
+/**
+ * struct batadv_neigh_ifinfo_bat_iv - neighbor information per outgoing
  *  interface for BATMAN IV
  * @tq_recv: ring buffer of received TQ values from this neigh node
  * @tq_index: ring buffer index
@@ -330,7 +351,8 @@ struct batadv_neigh_ifinfo_bat_iv {
        uint8_t real_packet_count;
 };
 
-/* struct batadv_neigh_ifinfo - neighbor information per outgoing interface
+/**
+ * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
  * @list: list node for batadv_neigh_node::ifinfo_list
  * @if_outgoing: pointer to outgoing hard interface
  * @bat_iv: B.A.T.M.A.N. IV private structure
@@ -522,7 +544,7 @@ struct batadv_priv_bla {
 #endif
 
 /**
- * struct batadv_debug_log - debug logging data
+ * struct batadv_priv_debug_log - debug logging data
  * @log_buff: buffer holding the logs (ring bufer)
  * @log_start: index of next character to read
  * @log_end: index of next character to write
@@ -585,6 +607,16 @@ struct batadv_priv_dat {
 };
 #endif
 
+#ifdef CONFIG_BATMAN_ADV_MCAST
+/**
+ * struct batadv_priv_mcast - per mesh interface mcast data
+ * @mla_list: list of multicast addresses we are currently announcing via TT
+ */
+struct batadv_priv_mcast {
+       struct hlist_head mla_list;
+};
+#endif
+
 /**
  * struct batadv_priv_nc - per mesh interface network coding private data
  * @work: work queue callback item for cleanup
@@ -680,6 +712,7 @@ struct batadv_softif_vlan {
  * @tt: translation table data
  * @tvlv: type-version-length-value data
  * @dat: distributed arp table data
+ * @mcast: multicast data
  * @network_coding: bool indicating whether network coding is enabled
  * @batadv_priv_nc: network coding data
  */
@@ -737,6 +770,9 @@ struct batadv_priv {
 #ifdef CONFIG_BATMAN_ADV_DAT
        struct batadv_priv_dat dat;
 #endif
+#ifdef CONFIG_BATMAN_ADV_MCAST
+       struct batadv_priv_mcast mcast;
+#endif
 #ifdef CONFIG_BATMAN_ADV_NC
        atomic_t network_coding;
        struct batadv_priv_nc nc;
@@ -982,8 +1018,8 @@ struct batadv_nc_packet {
 };
 
 /**
- * batadv_skb_cb - control buffer structure used to store private data relevant
- *  to batman-adv in the skb->cb buffer in skbs.
+ * struct batadv_skb_cb - control buffer structure used to store private data
+ *  relevant to batman-adv in the skb->cb buffer in skbs.
  * @decoded: Marks a skb as decoded, which is checked when searching for coding
  *  opportunities in network-coding.c
  */
@@ -1002,8 +1038,10 @@ struct batadv_skb_cb {
  * @direct_link_flags: direct link flags for aggregated OGM packets
  * @num_packets: counter for bcast packet retransmission
  * @delayed_work: work queue callback item for packet sending
- * @if_incoming: pointer incoming hard-iface or primary iface if locally
- *  generated packet
+ * @if_incoming: pointer to incoming hard-iface or primary iface if
+ *  locally generated packet
+ * @if_outgoing: packet where the packet should be sent to, or NULL if
+ *  unspecified
  */
 struct batadv_forw_packet {
        struct hlist_node list;
@@ -1015,6 +1053,7 @@ struct batadv_forw_packet {
        uint8_t num_packets;
        struct delayed_work delayed_work;
        struct batadv_hard_iface *if_incoming;
+       struct batadv_hard_iface *if_outgoing;
 };
 
 /**
@@ -1060,7 +1099,8 @@ struct batadv_algo_ops {
                 struct batadv_neigh_node *neigh2,
                 struct batadv_hard_iface *if_outgoing2);
        /* orig_node handling API */
-       void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq);
+       void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq,
+                              struct batadv_hard_iface *hard_iface);
        void (*bat_orig_free)(struct batadv_orig_node *orig_node);
        int (*bat_orig_add_if)(struct batadv_orig_node *orig_node,
                               int max_if_num);
@@ -1089,6 +1129,16 @@ struct batadv_dat_entry {
        struct rcu_head rcu;
 };
 
+/**
+ * struct batadv_hw_addr - a list entry for a MAC address
+ * @list: list node for the linking of entries
+ * @addr: the MAC address of this list entry
+ */
+struct batadv_hw_addr {
+       struct hlist_node list;
+       unsigned char addr[ETH_ALEN];
+};
+
 /**
  * struct batadv_dat_candidate - candidate destination for DAT operations
  * @type: the type of the selected candidate. It can one of the following: