Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 2 | * |
| 3 | * Marek Lindner, Simon Wunderlich |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of version 2 of the GNU General Public |
| 7 | * License as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 | * 02110-1301, USA |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 20 | #ifndef _NET_BATMAN_ADV_TYPES_H_ |
| 21 | #define _NET_BATMAN_ADV_TYPES_H_ |
| 22 | |
| 23 | #include "packet.h" |
| 24 | #include "bitarray.h" |
Sven Eckelmann | c11fdfa | 2012-06-03 22:19:14 +0200 | [diff] [blame] | 25 | #include <linux/kernel.h> |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 26 | |
Sven Eckelmann | c11fdfa | 2012-06-03 22:19:14 +0200 | [diff] [blame] | 27 | #define BATADV_HEADER_LEN \ |
Sven Eckelmann | 9641269 | 2012-06-05 22:31:30 +0200 | [diff] [blame] | 28 | (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \ |
| 29 | sizeof(struct batadv_bcast_packet))) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 30 | |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 31 | #ifdef CONFIG_BATMAN_ADV_DAT |
| 32 | |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 33 | /* batadv_dat_addr_t is the type used for all DHT addresses. If it is changed, |
| 34 | * BATADV_DAT_ADDR_MAX is changed as well. |
| 35 | * |
| 36 | * *Please be careful: batadv_dat_addr_t must be UNSIGNED* |
| 37 | */ |
| 38 | #define batadv_dat_addr_t uint16_t |
| 39 | |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 40 | #endif /* CONFIG_BATMAN_ADV_DAT */ |
| 41 | |
Marek Lindner | 1451151 | 2012-08-02 17:20:26 +0200 | [diff] [blame] | 42 | /** |
| 43 | * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data |
| 44 | * @ogm_buff: buffer holding the OGM packet |
| 45 | * @ogm_buff_len: length of the OGM packet buffer |
| 46 | * @ogm_seqno: OGM sequence number - used to identify each OGM |
| 47 | */ |
| 48 | struct batadv_hard_iface_bat_iv { |
| 49 | unsigned char *ogm_buff; |
| 50 | int ogm_buff_len; |
| 51 | atomic_t ogm_seqno; |
| 52 | }; |
| 53 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 54 | struct batadv_hard_iface { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 55 | struct list_head list; |
| 56 | int16_t if_num; |
| 57 | char if_status; |
| 58 | struct net_device *net_dev; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 59 | atomic_t frag_seqno; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 60 | struct kobject *hardif_obj; |
Marek Lindner | ed75ccb | 2011-02-10 14:33:51 +0000 | [diff] [blame] | 61 | atomic_t refcount; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 62 | struct packet_type batman_adv_ptype; |
| 63 | struct net_device *soft_iface; |
| 64 | struct rcu_head rcu; |
Marek Lindner | 1451151 | 2012-08-02 17:20:26 +0200 | [diff] [blame] | 65 | struct batadv_hard_iface_bat_iv bat_iv; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
Ben Hutchings | 2c53040 | 2012-07-10 10:55:09 +0000 | [diff] [blame] | 68 | /** |
| 69 | * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 70 | * @primary_addr: hosts primary interface address |
Marek Lindner | d7b2a97 | 2012-03-01 15:35:19 +0800 | [diff] [blame] | 71 | * @last_seen: when last packet from this node was received |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 72 | * @bcast_seqno_reset: time when the broadcast seqno window was reset |
| 73 | * @batman_seqno_reset: time when the batman seqno window was reset |
| 74 | * @gw_flags: flags related to gateway class |
| 75 | * @flags: for now only VIS_SERVER flag |
Antonio Quartulli | 015758d | 2011-07-09 17:52:13 +0200 | [diff] [blame] | 76 | * @last_real_seqno: last and best known sequence number |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 77 | * @last_ttl: ttl of last received packet |
| 78 | * @last_bcast_seqno: last broadcast sequence number received by this host |
| 79 | * |
| 80 | * @candidates: how many candidates are available |
| 81 | * @selected: next bonding candidate |
| 82 | */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 83 | struct batadv_orig_node { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 84 | uint8_t orig[ETH_ALEN]; |
| 85 | uint8_t primary_addr[ETH_ALEN]; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 86 | struct batadv_neigh_node __rcu *router; /* rcu protected pointer */ |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 87 | #ifdef CONFIG_BATMAN_ADV_DAT |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 88 | batadv_dat_addr_t dat_addr; |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 89 | #endif |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 90 | unsigned long *bcast_own; |
| 91 | uint8_t *bcast_own_sum; |
Marek Lindner | d7b2a97 | 2012-03-01 15:35:19 +0800 | [diff] [blame] | 92 | unsigned long last_seen; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 93 | unsigned long bcast_seqno_reset; |
| 94 | unsigned long batman_seqno_reset; |
| 95 | uint8_t gw_flags; |
| 96 | uint8_t flags; |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 97 | atomic_t last_ttvn; /* last seen translation table version number */ |
| 98 | uint16_t tt_crc; |
Antonio Quartulli | 2dafb49 | 2011-05-05 08:42:45 +0200 | [diff] [blame] | 99 | unsigned char *tt_buff; |
| 100 | int16_t tt_buff_len; |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 101 | spinlock_t tt_buff_lock; /* protects tt_buff */ |
| 102 | atomic_t tt_size; |
Antonio Quartulli | 1707157 | 2011-11-07 16:36:40 +0100 | [diff] [blame] | 103 | bool tt_initialised; |
Antonio Quartulli | cc47f66 | 2011-04-27 14:27:57 +0200 | [diff] [blame] | 104 | /* The tt_poss_change flag is used to detect an ongoing roaming phase. |
| 105 | * If true, then I sent a Roaming_adv to this orig_node and I have to |
| 106 | * inspect every packet directed to it to check whether it is still |
| 107 | * the true destination or not. This flag will be reset to false as |
Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 108 | * soon as I receive a new TTVN from this orig_node |
| 109 | */ |
Antonio Quartulli | cc47f66 | 2011-04-27 14:27:57 +0200 | [diff] [blame] | 110 | bool tt_poss_change; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 111 | uint32_t last_real_seqno; |
| 112 | uint8_t last_ttl; |
Sven Eckelmann | 42d0b04 | 2012-06-03 22:19:17 +0200 | [diff] [blame] | 113 | DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 114 | uint32_t last_bcast_seqno; |
Marek Lindner | 9591a79 | 2010-12-12 21:57:11 +0000 | [diff] [blame] | 115 | struct hlist_head neigh_list; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 116 | struct list_head frag_list; |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 117 | spinlock_t neigh_list_lock; /* protects neigh_list and router */ |
Marek Lindner | 7b36e8e | 2011-02-18 12:28:10 +0000 | [diff] [blame] | 118 | atomic_t refcount; |
| 119 | struct rcu_head rcu; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 120 | struct hlist_node hash_entry; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 121 | struct batadv_priv *bat_priv; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 122 | unsigned long last_frag_packet; |
Sven Eckelmann | 6e215fd | 2011-05-08 12:45:45 +0200 | [diff] [blame] | 123 | /* ogm_cnt_lock protects: bcast_own, bcast_own_sum, |
Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 124 | * neigh_node->real_bits, neigh_node->real_packet_count |
| 125 | */ |
Sven Eckelmann | 6e215fd | 2011-05-08 12:45:45 +0200 | [diff] [blame] | 126 | spinlock_t ogm_cnt_lock; |
| 127 | /* bcast_seqno_lock protects bcast_bits, last_bcast_seqno */ |
| 128 | spinlock_t bcast_seqno_lock; |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 129 | spinlock_t tt_list_lock; /* protects tt_list */ |
Simon Wunderlich | a4c135c | 2011-01-19 20:01:43 +0000 | [diff] [blame] | 130 | atomic_t bond_candidates; |
| 131 | struct list_head bond_list; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 134 | struct batadv_gw_node { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 135 | struct hlist_node list; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 136 | struct batadv_orig_node *orig_node; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 137 | unsigned long deleted; |
Marek Lindner | 25b6d3c | 2011-02-10 14:33:49 +0000 | [diff] [blame] | 138 | atomic_t refcount; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 139 | struct rcu_head rcu; |
| 140 | }; |
| 141 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 142 | /* batadv_neigh_node |
Marek Lindner | d7b2a97 | 2012-03-01 15:35:19 +0800 | [diff] [blame] | 143 | * @last_seen: when last packet via this neighbor was received |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 144 | */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 145 | struct batadv_neigh_node { |
Marek Lindner | 9591a79 | 2010-12-12 21:57:11 +0000 | [diff] [blame] | 146 | struct hlist_node list; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 147 | uint8_t addr[ETH_ALEN]; |
| 148 | uint8_t real_packet_count; |
Sven Eckelmann | 42d0b04 | 2012-06-03 22:19:17 +0200 | [diff] [blame] | 149 | uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE]; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 150 | uint8_t tq_index; |
| 151 | uint8_t tq_avg; |
| 152 | uint8_t last_ttl; |
Simon Wunderlich | a4c135c | 2011-01-19 20:01:43 +0000 | [diff] [blame] | 153 | struct list_head bonding_list; |
Marek Lindner | d7b2a97 | 2012-03-01 15:35:19 +0800 | [diff] [blame] | 154 | unsigned long last_seen; |
Sven Eckelmann | 42d0b04 | 2012-06-03 22:19:17 +0200 | [diff] [blame] | 155 | DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); |
Marek Lindner | 44524fc | 2011-02-10 14:33:53 +0000 | [diff] [blame] | 156 | atomic_t refcount; |
Marek Lindner | f987ed6 | 2010-12-12 21:57:12 +0000 | [diff] [blame] | 157 | struct rcu_head rcu; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 158 | struct batadv_orig_node *orig_node; |
| 159 | struct batadv_hard_iface *if_incoming; |
Marek Lindner | e3b0d0d | 2012-03-17 15:28:32 +0800 | [diff] [blame] | 160 | spinlock_t lq_update_lock; /* protects: tq_recv, tq_index */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 163 | #ifdef CONFIG_BATMAN_ADV_BLA |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 164 | struct batadv_bcast_duplist_entry { |
Simon Wunderlich | fe2da6f | 2012-01-22 20:00:24 +0100 | [diff] [blame] | 165 | uint8_t orig[ETH_ALEN]; |
| 166 | uint16_t crc; |
| 167 | unsigned long entrytime; |
| 168 | }; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 169 | #endif |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 170 | |
Sven Eckelmann | d69909d | 2012-06-03 22:19:20 +0200 | [diff] [blame] | 171 | enum batadv_counters { |
Marek Lindner | 1c9b055 | 2012-06-23 11:47:53 +0200 | [diff] [blame] | 172 | BATADV_CNT_TX, |
| 173 | BATADV_CNT_TX_BYTES, |
| 174 | BATADV_CNT_TX_DROPPED, |
| 175 | BATADV_CNT_RX, |
| 176 | BATADV_CNT_RX_BYTES, |
Sven Eckelmann | d69909d | 2012-06-03 22:19:20 +0200 | [diff] [blame] | 177 | BATADV_CNT_FORWARD, |
| 178 | BATADV_CNT_FORWARD_BYTES, |
| 179 | BATADV_CNT_MGMT_TX, |
| 180 | BATADV_CNT_MGMT_TX_BYTES, |
| 181 | BATADV_CNT_MGMT_RX, |
| 182 | BATADV_CNT_MGMT_RX_BYTES, |
| 183 | BATADV_CNT_TT_REQUEST_TX, |
| 184 | BATADV_CNT_TT_REQUEST_RX, |
| 185 | BATADV_CNT_TT_RESPONSE_TX, |
| 186 | BATADV_CNT_TT_RESPONSE_RX, |
| 187 | BATADV_CNT_TT_ROAM_ADV_TX, |
| 188 | BATADV_CNT_TT_ROAM_ADV_RX, |
| 189 | BATADV_CNT_NUM, |
Martin Hundebøll | f821486 | 2012-04-20 17:02:45 +0200 | [diff] [blame] | 190 | }; |
| 191 | |
Sven Eckelmann | 807736f | 2012-07-15 22:26:51 +0200 | [diff] [blame] | 192 | /** |
| 193 | * struct batadv_priv_tt - per mesh interface translation table data |
| 194 | * @vn: translation table version number |
| 195 | * @local_changes: changes registered in an originator interval |
| 196 | * @poss_change: Detect an ongoing roaming phase. If true, then this node |
| 197 | * received a roaming_adv and has to inspect every packet directed to it to |
| 198 | * check whether it still is the true destination or not. This flag will be |
| 199 | * reset to false as soon as the this node's ttvn is increased |
| 200 | * @changes_list: tracks tt local changes within an originator interval |
| 201 | * @req_list: list of pending tt_requests |
| 202 | * @local_crc: Checksum of the local table, recomputed before sending a new OGM |
| 203 | */ |
| 204 | struct batadv_priv_tt { |
| 205 | atomic_t vn; |
| 206 | atomic_t ogm_append_cnt; |
| 207 | atomic_t local_changes; |
| 208 | bool poss_change; |
| 209 | struct list_head changes_list; |
| 210 | struct batadv_hashtable *local_hash; |
| 211 | struct batadv_hashtable *global_hash; |
| 212 | struct list_head req_list; |
| 213 | struct list_head roam_list; |
| 214 | spinlock_t changes_list_lock; /* protects changes */ |
| 215 | spinlock_t req_list_lock; /* protects req_list */ |
| 216 | spinlock_t roam_list_lock; /* protects roam_list */ |
| 217 | atomic_t local_entry_num; |
| 218 | uint16_t local_crc; |
| 219 | unsigned char *last_changeset; |
| 220 | int16_t last_changeset_len; |
| 221 | spinlock_t last_changeset_lock; /* protects last_changeset */ |
| 222 | struct delayed_work work; |
| 223 | }; |
| 224 | |
| 225 | #ifdef CONFIG_BATMAN_ADV_BLA |
| 226 | struct batadv_priv_bla { |
| 227 | atomic_t num_requests; /* number of bla requests in flight */ |
| 228 | struct batadv_hashtable *claim_hash; |
| 229 | struct batadv_hashtable *backbone_hash; |
| 230 | struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; |
| 231 | int bcast_duplist_curr; |
Linus Lüssing | 7dac7b7 | 2012-10-17 14:53:05 +0200 | [diff] [blame] | 232 | /* protects bcast_duplist and bcast_duplist_curr */ |
| 233 | spinlock_t bcast_duplist_lock; |
Sven Eckelmann | 807736f | 2012-07-15 22:26:51 +0200 | [diff] [blame] | 234 | struct batadv_bla_claim_dst claim_dest; |
| 235 | struct delayed_work work; |
| 236 | }; |
| 237 | #endif |
| 238 | |
| 239 | struct batadv_priv_gw { |
| 240 | struct hlist_head list; |
| 241 | spinlock_t list_lock; /* protects gw_list and curr_gw */ |
| 242 | struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */ |
| 243 | atomic_t reselect; |
| 244 | }; |
| 245 | |
| 246 | struct batadv_priv_vis { |
| 247 | struct list_head send_list; |
| 248 | struct batadv_hashtable *hash; |
| 249 | spinlock_t hash_lock; /* protects hash */ |
| 250 | spinlock_t list_lock; /* protects info::recv_list */ |
| 251 | struct delayed_work work; |
| 252 | struct batadv_vis_info *my_info; |
| 253 | }; |
| 254 | |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 255 | /** |
| 256 | * struct batadv_priv_dat - per mesh interface DAT private data |
| 257 | * @addr: node DAT address |
Antonio Quartulli | 2f1dfbe | 2012-06-30 20:01:19 +0200 | [diff] [blame] | 258 | * @hash: hashtable representing the local ARP cache |
| 259 | * @work: work queue callback item for cache purging |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 260 | */ |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 261 | #ifdef CONFIG_BATMAN_ADV_DAT |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 262 | struct batadv_priv_dat { |
| 263 | batadv_dat_addr_t addr; |
Antonio Quartulli | 2f1dfbe | 2012-06-30 20:01:19 +0200 | [diff] [blame] | 264 | struct batadv_hashtable *hash; |
| 265 | struct delayed_work work; |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 266 | }; |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 267 | #endif |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 268 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 269 | struct batadv_priv { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 270 | atomic_t mesh_state; |
| 271 | struct net_device_stats stats; |
Martin Hundebøll | f821486 | 2012-04-20 17:02:45 +0200 | [diff] [blame] | 272 | uint64_t __percpu *bat_counters; /* Per cpu counters */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 273 | atomic_t aggregated_ogms; /* boolean */ |
| 274 | atomic_t bonding; /* boolean */ |
| 275 | atomic_t fragmentation; /* boolean */ |
Antonio Quartulli | 59b699c | 2011-07-07 15:35:36 +0200 | [diff] [blame] | 276 | atomic_t ap_isolation; /* boolean */ |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 277 | atomic_t bridge_loop_avoidance; /* boolean */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 278 | atomic_t vis_mode; /* VIS_TYPE_* */ |
| 279 | atomic_t gw_mode; /* GW_MODE_* */ |
| 280 | atomic_t gw_sel_class; /* uint */ |
| 281 | atomic_t gw_bandwidth; /* gw bandwidth */ |
| 282 | atomic_t orig_interval; /* uint */ |
| 283 | atomic_t hop_penalty; /* uint */ |
| 284 | atomic_t log_level; /* uint */ |
| 285 | atomic_t bcast_seqno; |
| 286 | atomic_t bcast_queue_left; |
| 287 | atomic_t batman_queue_left; |
| 288 | char num_ifaces; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 289 | struct batadv_debug_log *debug_log; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 290 | struct kobject *mesh_obj; |
| 291 | struct dentry *debug_dir; |
| 292 | struct hlist_head forw_bat_list; |
| 293 | struct hlist_head forw_bcast_list; |
Sven Eckelmann | 5bf74e9 | 2012-06-05 22:31:28 +0200 | [diff] [blame] | 294 | struct batadv_hashtable *orig_hash; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 295 | spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ |
| 296 | spinlock_t forw_bcast_list_lock; /* protects */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 297 | struct delayed_work orig_work; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 298 | struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 299 | struct batadv_algo_ops *bat_algo_ops; |
Sven Eckelmann | 807736f | 2012-07-15 22:26:51 +0200 | [diff] [blame] | 300 | #ifdef CONFIG_BATMAN_ADV_BLA |
| 301 | struct batadv_priv_bla bla; |
| 302 | #endif |
| 303 | struct batadv_priv_gw gw; |
| 304 | struct batadv_priv_tt tt; |
| 305 | struct batadv_priv_vis vis; |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 306 | #ifdef CONFIG_BATMAN_ADV_DAT |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 307 | struct batadv_priv_dat dat; |
Antonio Quartulli | 1722447 | 2011-11-06 12:23:55 +0100 | [diff] [blame^] | 308 | #endif |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 309 | }; |
| 310 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 311 | struct batadv_socket_client { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 312 | struct list_head queue_list; |
| 313 | unsigned int queue_len; |
| 314 | unsigned char index; |
| 315 | spinlock_t lock; /* protects queue_list, queue_len, index */ |
| 316 | wait_queue_head_t queue_wait; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 317 | struct batadv_priv *bat_priv; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 320 | struct batadv_socket_packet { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 321 | struct list_head list; |
| 322 | size_t icmp_len; |
Sven Eckelmann | 9641269 | 2012-06-05 22:31:30 +0200 | [diff] [blame] | 323 | struct batadv_icmp_packet_rr icmp_packet; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 324 | }; |
| 325 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 326 | struct batadv_tt_common_entry { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 327 | uint8_t addr[ETH_ALEN]; |
Antonio Quartulli | 93840ac | 2011-10-22 00:55:39 +0200 | [diff] [blame] | 328 | struct hlist_node hash_entry; |
Antonio Quartulli | 5fbc159 | 2011-06-17 16:11:27 +0200 | [diff] [blame] | 329 | uint16_t flags; |
Antonio Quartulli | 30cfd02 | 2012-07-05 23:38:29 +0200 | [diff] [blame] | 330 | unsigned long added_at; |
Antonio Quartulli | 7683fdc | 2011-04-27 14:28:07 +0200 | [diff] [blame] | 331 | atomic_t refcount; |
| 332 | struct rcu_head rcu; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 333 | }; |
| 334 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 335 | struct batadv_tt_local_entry { |
| 336 | struct batadv_tt_common_entry common; |
Antonio Quartulli | 48100ba | 2011-10-30 12:17:33 +0100 | [diff] [blame] | 337 | unsigned long last_seen; |
| 338 | }; |
| 339 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 340 | struct batadv_tt_global_entry { |
| 341 | struct batadv_tt_common_entry common; |
Simon Wunderlich | db08e6e | 2011-10-22 20:12:51 +0200 | [diff] [blame] | 342 | struct hlist_head orig_list; |
| 343 | spinlock_t list_lock; /* protects the list */ |
| 344 | unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ |
| 345 | }; |
| 346 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 347 | struct batadv_tt_orig_list_entry { |
| 348 | struct batadv_orig_node *orig_node; |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 349 | uint8_t ttvn; |
Antonio Quartulli | d657e62 | 2012-07-01 14:09:12 +0200 | [diff] [blame] | 350 | atomic_t refcount; |
Simon Wunderlich | db08e6e | 2011-10-22 20:12:51 +0200 | [diff] [blame] | 351 | struct rcu_head rcu; |
| 352 | struct hlist_node list; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 355 | #ifdef CONFIG_BATMAN_ADV_BLA |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 356 | struct batadv_backbone_gw { |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 357 | uint8_t orig[ETH_ALEN]; |
| 358 | short vid; /* used VLAN ID */ |
| 359 | struct hlist_node hash_entry; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 360 | struct batadv_priv *bat_priv; |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 361 | unsigned long lasttime; /* last time we heard of this backbone gw */ |
| 362 | atomic_t request_sent; |
| 363 | atomic_t refcount; |
| 364 | struct rcu_head rcu; |
| 365 | uint16_t crc; /* crc checksum over all claims */ |
| 366 | }; |
| 367 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 368 | struct batadv_claim { |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 369 | uint8_t addr[ETH_ALEN]; |
| 370 | short vid; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 371 | struct batadv_backbone_gw *backbone_gw; |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 372 | unsigned long lasttime; /* last time we heard of claim (locals only) */ |
| 373 | struct rcu_head rcu; |
| 374 | atomic_t refcount; |
| 375 | struct hlist_node hash_entry; |
| 376 | }; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 377 | #endif |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 378 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 379 | struct batadv_tt_change_node { |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 380 | struct list_head list; |
Sven Eckelmann | 9641269 | 2012-06-05 22:31:30 +0200 | [diff] [blame] | 381 | struct batadv_tt_change change; |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 384 | struct batadv_tt_req_node { |
Antonio Quartulli | a73105b | 2011-04-27 14:27:44 +0200 | [diff] [blame] | 385 | uint8_t addr[ETH_ALEN]; |
| 386 | unsigned long issued_at; |
| 387 | struct list_head list; |
| 388 | }; |
| 389 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 390 | struct batadv_tt_roam_node { |
Antonio Quartulli | cc47f66 | 2011-04-27 14:27:57 +0200 | [diff] [blame] | 391 | uint8_t addr[ETH_ALEN]; |
| 392 | atomic_t counter; |
| 393 | unsigned long first_time; |
| 394 | struct list_head list; |
| 395 | }; |
| 396 | |
Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 397 | /* forw_packet - structure for forw_list maintaining packets to be |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 398 | * send/forwarded |
| 399 | */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 400 | struct batadv_forw_packet { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 401 | struct hlist_node list; |
| 402 | unsigned long send_time; |
| 403 | uint8_t own; |
| 404 | struct sk_buff *skb; |
| 405 | uint16_t packet_len; |
| 406 | uint32_t direct_link_flags; |
| 407 | uint8_t num_packets; |
| 408 | struct delayed_work delayed_work; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 409 | struct batadv_hard_iface *if_incoming; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 410 | }; |
| 411 | |
| 412 | /* While scanning for vis-entries of a particular vis-originator |
| 413 | * this list collects its interfaces to create a subgraph/cluster |
| 414 | * out of them later |
| 415 | */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 416 | struct batadv_if_list_entry { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 417 | uint8_t addr[ETH_ALEN]; |
| 418 | bool primary; |
| 419 | struct hlist_node list; |
| 420 | }; |
| 421 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 422 | struct batadv_debug_log { |
Sven Eckelmann | 42d0b04 | 2012-06-03 22:19:17 +0200 | [diff] [blame] | 423 | char log_buff[BATADV_LOG_BUF_LEN]; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 424 | unsigned long log_start; |
| 425 | unsigned long log_end; |
| 426 | spinlock_t lock; /* protects log_buff, log_start and log_end */ |
| 427 | wait_queue_head_t queue_wait; |
| 428 | }; |
| 429 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 430 | struct batadv_frag_packet_list_entry { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 431 | struct list_head list; |
| 432 | uint16_t seqno; |
| 433 | struct sk_buff *skb; |
| 434 | }; |
| 435 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 436 | struct batadv_vis_info { |
Antonio Quartulli | 4021967 | 2011-05-18 16:47:23 +0200 | [diff] [blame] | 437 | unsigned long first_seen; |
| 438 | /* list of server-neighbors we received a vis-packet |
Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 439 | * from. we should not reply to them. |
| 440 | */ |
Antonio Quartulli | 4021967 | 2011-05-18 16:47:23 +0200 | [diff] [blame] | 441 | struct list_head recv_list; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 442 | struct list_head send_list; |
| 443 | struct kref refcount; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 444 | struct hlist_node hash_entry; |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 445 | struct batadv_priv *bat_priv; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 446 | /* this packet might be part of the vis send queue. */ |
| 447 | struct sk_buff *skb_packet; |
Sven Eckelmann | 9cfc7bd | 2012-05-12 02:09:43 +0200 | [diff] [blame] | 448 | /* vis_info may follow here */ |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 449 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 450 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 451 | struct batadv_vis_info_entry { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 452 | uint8_t src[ETH_ALEN]; |
| 453 | uint8_t dest[ETH_ALEN]; |
Antonio Quartulli | 2dafb49 | 2011-05-05 08:42:45 +0200 | [diff] [blame] | 454 | uint8_t quality; /* quality = 0 client */ |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 455 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 456 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 457 | struct batadv_recvlist_node { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 458 | struct list_head list; |
| 459 | uint8_t mac[ETH_ALEN]; |
| 460 | }; |
| 461 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 462 | struct batadv_algo_ops { |
Marek Lindner | 1c28047 | 2011-11-28 17:40:17 +0800 | [diff] [blame] | 463 | struct hlist_node list; |
| 464 | char *name; |
Marek Lindner | c2aca02 | 2012-02-07 17:20:45 +0800 | [diff] [blame] | 465 | /* init routing info when hard-interface is enabled */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 466 | int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface); |
Marek Lindner | 00a5007 | 2012-02-07 17:20:47 +0800 | [diff] [blame] | 467 | /* de-init routing info when hard-interface is disabled */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 468 | void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface); |
Marek Lindner | c322939 | 2012-03-11 06:17:50 +0800 | [diff] [blame] | 469 | /* (re-)init mac addresses of the protocol information |
| 470 | * belonging to this hard-interface |
| 471 | */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 472 | void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface); |
Marek Lindner | cd8b78e | 2012-02-07 17:20:49 +0800 | [diff] [blame] | 473 | /* called when primary interface is selected / changed */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 474 | void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface); |
Marek Lindner | 01c4224 | 2011-11-28 21:31:55 +0800 | [diff] [blame] | 475 | /* prepare a new outgoing OGM for the send queue */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 476 | void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface); |
Marek Lindner | 01c4224 | 2011-11-28 21:31:55 +0800 | [diff] [blame] | 477 | /* send scheduled OGM */ |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 478 | void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); |
Marek Lindner | 1c28047 | 2011-11-28 17:40:17 +0800 | [diff] [blame] | 479 | }; |
| 480 | |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 481 | /** |
Antonio Quartulli | 2f1dfbe | 2012-06-30 20:01:19 +0200 | [diff] [blame] | 482 | * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It |
| 483 | * is used to stored ARP entries needed for the global DAT cache |
| 484 | * @ip: the IPv4 corresponding to this DAT/ARP entry |
| 485 | * @mac_addr: the MAC address associated to the stored IPv4 |
| 486 | * @last_update: time in jiffies when this entry was refreshed last time |
| 487 | * @hash_entry: hlist node for batadv_priv_dat::hash |
| 488 | * @refcount: number of contexts the object is used |
| 489 | * @rcu: struct used for freeing in an RCU-safe manner |
| 490 | */ |
| 491 | struct batadv_dat_entry { |
| 492 | __be32 ip; |
| 493 | uint8_t mac_addr[ETH_ALEN]; |
| 494 | unsigned long last_update; |
| 495 | struct hlist_node hash_entry; |
| 496 | atomic_t refcount; |
| 497 | struct rcu_head rcu; |
| 498 | }; |
| 499 | |
| 500 | /** |
Antonio Quartulli | 785ea11 | 2011-11-23 11:35:44 +0100 | [diff] [blame] | 501 | * struct batadv_dat_candidate - candidate destination for DAT operations |
| 502 | * @type: the type of the selected candidate. It can one of the following: |
| 503 | * - BATADV_DAT_CANDIDATE_NOT_FOUND |
| 504 | * - BATADV_DAT_CANDIDATE_ORIG |
| 505 | * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to the |
| 506 | * corresponding originator node structure |
| 507 | */ |
| 508 | struct batadv_dat_candidate { |
| 509 | int type; |
| 510 | struct batadv_orig_node *orig_node; |
| 511 | }; |
| 512 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 513 | #endif /* _NET_BATMAN_ADV_TYPES_H_ */ |