aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/translation-table.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-03 16:19:21 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-07-01 16:47:19 -0400
commitacd34afa89772f6379b642bb979d0a112328c769 (patch)
treedc72002fdefbd521253f651a53bbed762d3af899 /net/batman-adv/translation-table.c
parentd69909d2fc9e00bd8149cc8df9b18c35008e3e62 (diff)
batman-adv: Prefix packet enum with BATADV_
Reported-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r--net/batman-adv/translation-table.c191
1 files changed, 98 insertions, 93 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f36d1d52bff9..309d691abe64 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -169,7 +169,7 @@ static void batadv_tt_local_event(struct bat_priv *bat_priv,
169 tt_change_node->change.flags = flags; 169 tt_change_node->change.flags = flags;
170 memcpy(tt_change_node->change.addr, addr, ETH_ALEN); 170 memcpy(tt_change_node->change.addr, addr, ETH_ALEN);
171 171
172 del_op_requested = flags & TT_CLIENT_DEL; 172 del_op_requested = flags & BATADV_TT_CLIENT_DEL;
173 173
174 /* check for ADD+DEL or DEL+ADD events */ 174 /* check for ADD+DEL or DEL+ADD events */
175 spin_lock_bh(&bat_priv->tt_changes_list_lock); 175 spin_lock_bh(&bat_priv->tt_changes_list_lock);
@@ -185,7 +185,7 @@ static void batadv_tt_local_event(struct bat_priv *bat_priv,
185 * now possible due to automatically recognition of "temporary" 185 * now possible due to automatically recognition of "temporary"
186 * clients 186 * clients
187 */ 187 */
188 del_op_entry = entry->change.flags & TT_CLIENT_DEL; 188 del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL;
189 if (!del_op_requested && del_op_entry) 189 if (!del_op_requested && del_op_entry)
190 goto del; 190 goto del;
191 if (del_op_requested && !del_op_entry) 191 if (del_op_requested && !del_op_entry)
@@ -243,8 +243,8 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
243 243
244 if (tt_local_entry) { 244 if (tt_local_entry) {
245 tt_local_entry->last_seen = jiffies; 245 tt_local_entry->last_seen = jiffies;
246 /* possibly unset the TT_CLIENT_PENDING flag */ 246 /* possibly unset the BATADV_TT_CLIENT_PENDING flag */
247 tt_local_entry->common.flags &= ~TT_CLIENT_PENDING; 247 tt_local_entry->common.flags &= ~BATADV_TT_CLIENT_PENDING;
248 goto out; 248 goto out;
249 } 249 }
250 250
@@ -259,19 +259,19 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
260 tt_local_entry->common.flags = BATADV_NO_FLAGS; 260 tt_local_entry->common.flags = BATADV_NO_FLAGS;
261 if (batadv_is_wifi_iface(ifindex)) 261 if (batadv_is_wifi_iface(ifindex))
262 tt_local_entry->common.flags |= TT_CLIENT_WIFI; 262 tt_local_entry->common.flags |= BATADV_TT_CLIENT_WIFI;
263 atomic_set(&tt_local_entry->common.refcount, 2); 263 atomic_set(&tt_local_entry->common.refcount, 2);
264 tt_local_entry->last_seen = jiffies; 264 tt_local_entry->last_seen = jiffies;
265 265
266 /* the batman interface mac address should never be purged */ 266 /* the batman interface mac address should never be purged */
267 if (batadv_compare_eth(addr, soft_iface->dev_addr)) 267 if (batadv_compare_eth(addr, soft_iface->dev_addr))
268 tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; 268 tt_local_entry->common.flags |= BATADV_TT_CLIENT_NOPURGE;
269 269
270 /* The local entry has to be marked as NEW to avoid to send it in 270 /* The local entry has to be marked as NEW to avoid to send it in
271 * a full table response going out before the next ttvn increment 271 * a full table response going out before the next ttvn increment
272 * (consistency check) 272 * (consistency check)
273 */ 273 */
274 tt_local_entry->common.flags |= TT_CLIENT_NEW; 274 tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW;
275 275
276 hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt, 276 hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt,
277 batadv_choose_orig, 277 batadv_choose_orig,
@@ -305,7 +305,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
305 /* The global entry has to be marked as ROAMING and 305 /* The global entry has to be marked as ROAMING and
306 * has to be kept for consistency purpose 306 * has to be kept for consistency purpose
307 */ 307 */
308 tt_global_entry->common.flags |= TT_CLIENT_ROAM; 308 tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
309 tt_global_entry->roam_at = jiffies; 309 tt_global_entry->roam_at = jiffies;
310 } 310 }
311out: 311out:
@@ -453,15 +453,15 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
453 seq_printf(seq, " * %pM [%c%c%c%c%c]\n", 453 seq_printf(seq, " * %pM [%c%c%c%c%c]\n",
454 tt_common_entry->addr, 454 tt_common_entry->addr,
455 (tt_common_entry->flags & 455 (tt_common_entry->flags &
456 TT_CLIENT_ROAM ? 'R' : '.'), 456 BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
457 (tt_common_entry->flags & 457 (tt_common_entry->flags &
458 TT_CLIENT_NOPURGE ? 'P' : '.'), 458 BATADV_TT_CLIENT_NOPURGE ? 'P' : '.'),
459 (tt_common_entry->flags & 459 (tt_common_entry->flags &
460 TT_CLIENT_NEW ? 'N' : '.'), 460 BATADV_TT_CLIENT_NEW ? 'N' : '.'),
461 (tt_common_entry->flags & 461 (tt_common_entry->flags &
462 TT_CLIENT_PENDING ? 'X' : '.'), 462 BATADV_TT_CLIENT_PENDING ? 'X' : '.'),
463 (tt_common_entry->flags & 463 (tt_common_entry->flags &
464 TT_CLIENT_WIFI ? 'W' : '.')); 464 BATADV_TT_CLIENT_WIFI ? 'W' : '.'));
465 } 465 }
466 rcu_read_unlock(); 466 rcu_read_unlock();
467 } 467 }
@@ -482,7 +482,7 @@ static void batadv_tt_local_set_pending(struct bat_priv *bat_priv,
482 * to be kept in the table in order to send it in a full table 482 * to be kept in the table in order to send it in a full table
483 * response issued before the net ttvn increment (consistency check) 483 * response issued before the net ttvn increment (consistency check)
484 */ 484 */
485 tt_local_entry->common.flags |= TT_CLIENT_PENDING; 485 tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING;
486 486
487 batadv_dbg(DBG_TT, bat_priv, 487 batadv_dbg(DBG_TT, bat_priv,
488 "Local tt entry (%pM) pending to be removed: %s\n", 488 "Local tt entry (%pM) pending to be removed: %s\n",
@@ -499,9 +499,9 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
499 if (!tt_local_entry) 499 if (!tt_local_entry)
500 goto out; 500 goto out;
501 501
502 flags = TT_CLIENT_DEL; 502 flags = BATADV_TT_CLIENT_DEL;
503 if (roaming) 503 if (roaming)
504 flags |= TT_CLIENT_ROAM; 504 flags |= BATADV_TT_CLIENT_ROAM;
505 505
506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); 506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
507out: 507out:
@@ -509,12 +509,36 @@ out:
509 batadv_tt_local_entry_free_ref(tt_local_entry); 509 batadv_tt_local_entry_free_ref(tt_local_entry);
510} 510}
511 511
512static void batadv_tt_local_purge(struct bat_priv *bat_priv) 512static void batadv_tt_local_purge_list(struct bat_priv *bat_priv,
513 struct hlist_head *head)
513{ 514{
514 struct hashtable_t *hash = bat_priv->tt_local_hash;
515 struct tt_local_entry *tt_local_entry; 515 struct tt_local_entry *tt_local_entry;
516 struct tt_common_entry *tt_common_entry; 516 struct tt_common_entry *tt_common_entry;
517 struct hlist_node *node, *node_tmp; 517 struct hlist_node *node, *node_tmp;
518
519 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head,
520 hash_entry) {
521 tt_local_entry = container_of(tt_common_entry,
522 struct tt_local_entry, common);
523 if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE)
524 continue;
525
526 /* entry already marked for deletion */
527 if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)
528 continue;
529
530 if (!batadv_has_timed_out(tt_local_entry->last_seen,
531 BATADV_TT_LOCAL_TIMEOUT))
532 continue;
533
534 batadv_tt_local_set_pending(bat_priv, tt_local_entry,
535 BATADV_TT_CLIENT_DEL, "timed out");
536 }
537}
538
539static void batadv_tt_local_purge(struct bat_priv *bat_priv)
540{
541 struct hashtable_t *hash = bat_priv->tt_local_hash;
518 struct hlist_head *head; 542 struct hlist_head *head;
519 spinlock_t *list_lock; /* protects write access to the hash lists */ 543 spinlock_t *list_lock; /* protects write access to the hash lists */
520 uint32_t i; 544 uint32_t i;
@@ -524,25 +548,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv)
524 list_lock = &hash->list_locks[i]; 548 list_lock = &hash->list_locks[i];
525 549
526 spin_lock_bh(list_lock); 550 spin_lock_bh(list_lock);
527 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 551 batadv_tt_local_purge_list(bat_priv, head);
528 head, hash_entry) {
529 tt_local_entry = container_of(tt_common_entry,
530 struct tt_local_entry,
531 common);
532 if (tt_local_entry->common.flags & TT_CLIENT_NOPURGE)
533 continue;
534
535 /* entry already marked for deletion */
536 if (tt_local_entry->common.flags & TT_CLIENT_PENDING)
537 continue;
538
539 if (!batadv_has_timed_out(tt_local_entry->last_seen,
540 BATADV_TT_LOCAL_TIMEOUT))
541 continue;
542
543 batadv_tt_local_set_pending(bat_priv, tt_local_entry,
544 TT_CLIENT_DEL, "timed out");
545 }
546 spin_unlock_bh(list_lock); 552 spin_unlock_bh(list_lock);
547 } 553 }
548 554
@@ -701,16 +707,16 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
701 } else { 707 } else {
702 /* there is already a global entry, use this one. */ 708 /* there is already a global entry, use this one. */
703 709
704 /* If there is the TT_CLIENT_ROAM flag set, there is only one 710 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
705 * originator left in the list and we previously received a 711 * one originator left in the list and we previously received a
706 * delete + roaming change for this originator. 712 * delete + roaming change for this originator.
707 * 713 *
708 * We should first delete the old originator before adding the 714 * We should first delete the old originator before adding the
709 * new one. 715 * new one.
710 */ 716 */
711 if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { 717 if (tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM) {
712 batadv_tt_global_del_orig_list(tt_global_entry); 718 batadv_tt_global_del_orig_list(tt_global_entry);
713 tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; 719 tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM;
714 tt_global_entry->roam_at = 0; 720 tt_global_entry->roam_at = 0;
715 } 721 }
716 722
@@ -727,7 +733,8 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
727out_remove: 733out_remove:
728 /* remove address from local hash if present */ 734 /* remove address from local hash if present */
729 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, 735 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
730 "global tt received", flags & TT_CLIENT_ROAM); 736 "global tt received",
737 flags & BATADV_TT_CLIENT_ROAM);
731 ret = 1; 738 ret = 1;
732out: 739out:
733 if (tt_global_entry) 740 if (tt_global_entry)
@@ -759,8 +766,8 @@ batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry,
759 seq_printf(seq, " * %pM (%3u) via %pM (%3u) [%c%c]\n", 766 seq_printf(seq, " * %pM (%3u) via %pM (%3u) [%c%c]\n",
760 tt_global_entry->common.addr, orig_entry->ttvn, 767 tt_global_entry->common.addr, orig_entry->ttvn,
761 orig_entry->orig_node->orig, last_ttvn, 768 orig_entry->orig_node->orig, last_ttvn,
762 (flags & TT_CLIENT_ROAM ? 'R' : '.'), 769 (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
763 (flags & TT_CLIENT_WIFI ? 'W' : '.')); 770 (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'));
764 } 771 }
765} 772}
766 773
@@ -874,8 +881,8 @@ static void batadv_tt_global_del_struct(struct bat_priv *bat_priv,
874} 881}
875 882
876/* If the client is to be deleted, we check if it is the last origantor entry 883/* If the client is to be deleted, we check if it is the last origantor entry
877 * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, 884 * within tt_global entry. If yes, we set the BATADV_TT_CLIENT_ROAM flag and the
878 * otherwise we simply remove the originator scheduled for deletion. 885 * timer, otherwise we simply remove the originator scheduled for deletion.
879 */ 886 */
880static void 887static void
881batadv_tt_global_del_roaming(struct bat_priv *bat_priv, 888batadv_tt_global_del_roaming(struct bat_priv *bat_priv,
@@ -903,7 +910,7 @@ batadv_tt_global_del_roaming(struct bat_priv *bat_priv,
903 910
904 if (last_entry) { 911 if (last_entry) {
905 /* its the last one, mark for roaming. */ 912 /* its the last one, mark for roaming. */
906 tt_global_entry->common.flags |= TT_CLIENT_ROAM; 913 tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
907 tt_global_entry->roam_at = jiffies; 914 tt_global_entry->roam_at = jiffies;
908 } else 915 } else
909 /* there is another entry, we can simply delete this 916 /* there is another entry, we can simply delete this
@@ -942,7 +949,7 @@ static void batadv_tt_global_del(struct bat_priv *bat_priv,
942 * event, there are two possibilities: 949 * event, there are two possibilities:
943 * 1) the client roamed from node A to node B => if there 950 * 1) the client roamed from node A to node B => if there
944 * is only one originator left for this client, we mark 951 * is only one originator left for this client, we mark
945 * it with TT_CLIENT_ROAM, we start a timer and we 952 * it with BATADV_TT_CLIENT_ROAM, we start a timer and we
946 * wait for node B to claim it. In case of timeout 953 * wait for node B to claim it. In case of timeout
947 * the entry is purged. 954 * the entry is purged.
948 * 955 *
@@ -1022,7 +1029,7 @@ static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv,
1022 hash_entry) { 1029 hash_entry) {
1023 tt_global_entry = container_of(tt_common_entry, 1030 tt_global_entry = container_of(tt_common_entry,
1024 struct tt_global_entry, common); 1031 struct tt_global_entry, common);
1025 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) 1032 if (!(tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM))
1026 continue; 1033 continue;
1027 if (!batadv_has_timed_out(tt_global_entry->roam_at, 1034 if (!batadv_has_timed_out(tt_global_entry->roam_at,
1028 BATADV_TT_CLIENT_ROAM_TIMEOUT)) 1035 BATADV_TT_CLIENT_ROAM_TIMEOUT))
@@ -1096,8 +1103,8 @@ static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry,
1096{ 1103{
1097 bool ret = false; 1104 bool ret = false;
1098 1105
1099 if (tt_local_entry->common.flags & TT_CLIENT_WIFI && 1106 if (tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI &&
1100 tt_global_entry->common.flags & TT_CLIENT_WIFI) 1107 tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI)
1101 ret = true; 1108 ret = true;
1102 1109
1103 return ret; 1110 return ret;
@@ -1167,7 +1174,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
1167{ 1174{
1168 uint16_t total = 0, total_one; 1175 uint16_t total = 0, total_one;
1169 struct hashtable_t *hash = bat_priv->tt_global_hash; 1176 struct hashtable_t *hash = bat_priv->tt_global_hash;
1170 struct tt_common_entry *tt_common_entry; 1177 struct tt_common_entry *tt_common;
1171 struct tt_global_entry *tt_global_entry; 1178 struct tt_global_entry *tt_global_entry;
1172 struct hlist_node *node; 1179 struct hlist_node *node;
1173 struct hlist_head *head; 1180 struct hlist_head *head;
@@ -1178,9 +1185,8 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
1178 head = &hash->table[i]; 1185 head = &hash->table[i];
1179 1186
1180 rcu_read_lock(); 1187 rcu_read_lock();
1181 hlist_for_each_entry_rcu(tt_common_entry, node, 1188 hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) {
1182 head, hash_entry) { 1189 tt_global_entry = container_of(tt_common,
1183 tt_global_entry = container_of(tt_common_entry,
1184 struct tt_global_entry, 1190 struct tt_global_entry,
1185 common); 1191 common);
1186 /* Roaming clients are in the global table for 1192 /* Roaming clients are in the global table for
@@ -1188,7 +1194,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
1188 * taken into account while computing the 1194 * taken into account while computing the
1189 * global crc 1195 * global crc
1190 */ 1196 */
1191 if (tt_global_entry->common.flags & TT_CLIENT_ROAM) 1197 if (tt_common->flags & BATADV_TT_CLIENT_ROAM)
1192 continue; 1198 continue;
1193 1199
1194 /* find out if this global entry is announced by this 1200 /* find out if this global entry is announced by this
@@ -1201,7 +1207,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
1201 total_one = 0; 1207 total_one = 0;
1202 for (j = 0; j < ETH_ALEN; j++) 1208 for (j = 0; j < ETH_ALEN; j++)
1203 total_one = crc16_byte(total_one, 1209 total_one = crc16_byte(total_one,
1204 tt_global_entry->common.addr[j]); 1210 tt_common->addr[j]);
1205 total ^= total_one; 1211 total ^= total_one;
1206 } 1212 }
1207 rcu_read_unlock(); 1213 rcu_read_unlock();
@@ -1215,7 +1221,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv)
1215{ 1221{
1216 uint16_t total = 0, total_one; 1222 uint16_t total = 0, total_one;
1217 struct hashtable_t *hash = bat_priv->tt_local_hash; 1223 struct hashtable_t *hash = bat_priv->tt_local_hash;
1218 struct tt_common_entry *tt_common_entry; 1224 struct tt_common_entry *tt_common;
1219 struct hlist_node *node; 1225 struct hlist_node *node;
1220 struct hlist_head *head; 1226 struct hlist_head *head;
1221 uint32_t i; 1227 uint32_t i;
@@ -1225,17 +1231,16 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv)
1225 head = &hash->table[i]; 1231 head = &hash->table[i];
1226 1232
1227 rcu_read_lock(); 1233 rcu_read_lock();
1228 hlist_for_each_entry_rcu(tt_common_entry, node, 1234 hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) {
1229 head, hash_entry) {
1230 /* not yet committed clients have not to be taken into 1235 /* not yet committed clients have not to be taken into
1231 * account while computing the CRC 1236 * account while computing the CRC
1232 */ 1237 */
1233 if (tt_common_entry->flags & TT_CLIENT_NEW) 1238 if (tt_common->flags & BATADV_TT_CLIENT_NEW)
1234 continue; 1239 continue;
1235 total_one = 0; 1240 total_one = 0;
1236 for (j = 0; j < ETH_ALEN; j++) 1241 for (j = 0; j < ETH_ALEN; j++)
1237 total_one = crc16_byte(total_one, 1242 total_one = crc16_byte(total_one,
1238 tt_common_entry->addr[j]); 1243 tt_common->addr[j]);
1239 total ^= total_one; 1244 total ^= total_one;
1240 } 1245 }
1241 rcu_read_unlock(); 1246 rcu_read_unlock();
@@ -1331,7 +1336,7 @@ static int batadv_tt_local_valid_entry(const void *entry_ptr,
1331{ 1336{
1332 const struct tt_common_entry *tt_common_entry = entry_ptr; 1337 const struct tt_common_entry *tt_common_entry = entry_ptr;
1333 1338
1334 if (tt_common_entry->flags & TT_CLIENT_NEW) 1339 if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW)
1335 return 0; 1340 return 0;
1336 return 1; 1341 return 1;
1337} 1342}
@@ -1343,7 +1348,7 @@ static int batadv_tt_global_valid(const void *entry_ptr,
1343 const struct tt_global_entry *tt_global_entry; 1348 const struct tt_global_entry *tt_global_entry;
1344 const struct orig_node *orig_node = data_ptr; 1349 const struct orig_node *orig_node = data_ptr;
1345 1350
1346 if (tt_common_entry->flags & TT_CLIENT_ROAM) 1351 if (tt_common_entry->flags & BATADV_TT_CLIENT_ROAM)
1347 return 0; 1352 return 0;
1348 1353
1349 tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, 1354 tt_global_entry = container_of(tt_common_entry, struct tt_global_entry,
@@ -1450,17 +1455,17 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv,
1450 tt_request = (struct tt_query_packet *)skb_put(skb, 1455 tt_request = (struct tt_query_packet *)skb_put(skb,
1451 sizeof(struct tt_query_packet)); 1456 sizeof(struct tt_query_packet));
1452 1457
1453 tt_request->header.packet_type = BAT_TT_QUERY; 1458 tt_request->header.packet_type = BATADV_TT_QUERY;
1454 tt_request->header.version = BATADV_COMPAT_VERSION; 1459 tt_request->header.version = BATADV_COMPAT_VERSION;
1455 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1460 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1456 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); 1461 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN);
1457 tt_request->header.ttl = BATADV_TTL; 1462 tt_request->header.ttl = BATADV_TTL;
1458 tt_request->ttvn = ttvn; 1463 tt_request->ttvn = ttvn;
1459 tt_request->tt_data = htons(tt_crc); 1464 tt_request->tt_data = htons(tt_crc);
1460 tt_request->flags = TT_REQUEST; 1465 tt_request->flags = BATADV_TT_REQUEST;
1461 1466
1462 if (full_table) 1467 if (full_table)
1463 tt_request->flags |= TT_FULL_TABLE; 1468 tt_request->flags |= BATADV_TT_FULL_TABLE;
1464 1469
1465 neigh_node = batadv_orig_node_get_router(dst_orig_node); 1470 neigh_node = batadv_orig_node_get_router(dst_orig_node);
1466 if (!neigh_node) 1471 if (!neigh_node)
@@ -1509,7 +1514,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1509 batadv_dbg(DBG_TT, bat_priv, 1514 batadv_dbg(DBG_TT, bat_priv,
1510 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", 1515 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n",
1511 tt_request->src, tt_request->ttvn, tt_request->dst, 1516 tt_request->src, tt_request->ttvn, tt_request->dst,
1512 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1517 (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
1513 1518
1514 /* Let's get the orig node of the REAL destination */ 1519 /* Let's get the orig node of the REAL destination */
1515 req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst); 1520 req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst);
@@ -1537,7 +1542,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1537 goto out; 1542 goto out;
1538 1543
1539 /* If the full table has been explicitly requested */ 1544 /* If the full table has been explicitly requested */
1540 if (tt_request->flags & TT_FULL_TABLE || 1545 if (tt_request->flags & BATADV_TT_FULL_TABLE ||
1541 !req_dst_orig_node->tt_buff) 1546 !req_dst_orig_node->tt_buff)
1542 full_table = true; 1547 full_table = true;
1543 else 1548 else
@@ -1584,15 +1589,15 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1584 tt_response = (struct tt_query_packet *)skb->data; 1589 tt_response = (struct tt_query_packet *)skb->data;
1585 } 1590 }
1586 1591
1587 tt_response->header.packet_type = BAT_TT_QUERY; 1592 tt_response->header.packet_type = BATADV_TT_QUERY;
1588 tt_response->header.version = BATADV_COMPAT_VERSION; 1593 tt_response->header.version = BATADV_COMPAT_VERSION;
1589 tt_response->header.ttl = BATADV_TTL; 1594 tt_response->header.ttl = BATADV_TTL;
1590 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); 1595 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN);
1591 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1596 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1592 tt_response->flags = TT_RESPONSE; 1597 tt_response->flags = BATADV_TT_RESPONSE;
1593 1598
1594 if (full_table) 1599 if (full_table)
1595 tt_response->flags |= TT_FULL_TABLE; 1600 tt_response->flags |= BATADV_TT_FULL_TABLE;
1596 1601
1597 batadv_dbg(DBG_TT, bat_priv, 1602 batadv_dbg(DBG_TT, bat_priv,
1598 "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", 1603 "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n",
@@ -1639,7 +1644,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1639 batadv_dbg(DBG_TT, bat_priv, 1644 batadv_dbg(DBG_TT, bat_priv,
1640 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", 1645 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n",
1641 tt_request->src, tt_request->ttvn, 1646 tt_request->src, tt_request->ttvn,
1642 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1647 (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
1643 1648
1644 1649
1645 my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 1650 my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
@@ -1660,7 +1665,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1660 /* If the full table has been explicitly requested or the gap 1665 /* If the full table has been explicitly requested or the gap
1661 * is too big send the whole local translation table 1666 * is too big send the whole local translation table
1662 */ 1667 */
1663 if (tt_request->flags & TT_FULL_TABLE || my_ttvn != req_ttvn || 1668 if (tt_request->flags & BATADV_TT_FULL_TABLE || my_ttvn != req_ttvn ||
1664 !bat_priv->tt_buff) 1669 !bat_priv->tt_buff)
1665 full_table = true; 1670 full_table = true;
1666 else 1671 else
@@ -1705,20 +1710,20 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1705 tt_response = (struct tt_query_packet *)skb->data; 1710 tt_response = (struct tt_query_packet *)skb->data;
1706 } 1711 }
1707 1712
1708 tt_response->header.packet_type = BAT_TT_QUERY; 1713 tt_response->header.packet_type = BATADV_TT_QUERY;
1709 tt_response->header.version = BATADV_COMPAT_VERSION; 1714 tt_response->header.version = BATADV_COMPAT_VERSION;
1710 tt_response->header.ttl = BATADV_TTL; 1715 tt_response->header.ttl = BATADV_TTL;
1711 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1716 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1712 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1717 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1713 tt_response->flags = TT_RESPONSE; 1718 tt_response->flags = BATADV_TT_RESPONSE;
1714 1719
1715 if (full_table) 1720 if (full_table)
1716 tt_response->flags |= TT_FULL_TABLE; 1721 tt_response->flags |= BATADV_TT_FULL_TABLE;
1717 1722
1718 batadv_dbg(DBG_TT, bat_priv, 1723 batadv_dbg(DBG_TT, bat_priv,
1719 "Sending TT_RESPONSE to %pM via %pM [%c]\n", 1724 "Sending TT_RESPONSE to %pM via %pM [%c]\n",
1720 orig_node->orig, neigh_node->addr, 1725 orig_node->orig, neigh_node->addr,
1721 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1726 (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
1722 1727
1723 batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); 1728 batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
1724 1729
@@ -1764,8 +1769,8 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1764 int roams; 1769 int roams;
1765 1770
1766 for (i = 0; i < tt_num_changes; i++) { 1771 for (i = 0; i < tt_num_changes; i++) {
1767 if ((tt_change + i)->flags & TT_CLIENT_DEL) { 1772 if ((tt_change + i)->flags & BATADV_TT_CLIENT_DEL) {
1768 roams = (tt_change + i)->flags & TT_CLIENT_ROAM; 1773 roams = (tt_change + i)->flags & BATADV_TT_CLIENT_ROAM;
1769 batadv_tt_global_del(bat_priv, orig_node, 1774 batadv_tt_global_del(bat_priv, orig_node,
1770 (tt_change + i)->addr, 1775 (tt_change + i)->addr,
1771 "tt removed by changes", 1776 "tt removed by changes",
@@ -1840,7 +1845,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
1840 /* Check if the client has been logically deleted (but is kept for 1845 /* Check if the client has been logically deleted (but is kept for
1841 * consistency purpose) 1846 * consistency purpose)
1842 */ 1847 */
1843 if (tt_local_entry->common.flags & TT_CLIENT_PENDING) 1848 if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)
1844 goto out; 1849 goto out;
1845 ret = true; 1850 ret = true;
1846out: 1851out:
@@ -1859,7 +1864,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
1859 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", 1864 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n",
1860 tt_response->src, tt_response->ttvn, 1865 tt_response->src, tt_response->ttvn,
1861 ntohs(tt_response->tt_data), 1866 ntohs(tt_response->tt_data),
1862 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1867 (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
1863 1868
1864 /* we should have never asked a backbone gw */ 1869 /* we should have never asked a backbone gw */
1865 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) 1870 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src))
@@ -1869,7 +1874,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
1869 if (!orig_node) 1874 if (!orig_node)
1870 goto out; 1875 goto out;
1871 1876
1872 if (tt_response->flags & TT_FULL_TABLE) 1877 if (tt_response->flags & BATADV_TT_FULL_TABLE)
1873 batadv_tt_fill_gtable(bat_priv, tt_response); 1878 batadv_tt_fill_gtable(bat_priv, tt_response);
1874 else 1879 else
1875 batadv_tt_update_changes(bat_priv, orig_node, 1880 batadv_tt_update_changes(bat_priv, orig_node,
@@ -2019,7 +2024,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
2019 roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, 2024 roam_adv_packet = (struct roam_adv_packet *)skb_put(skb,
2020 sizeof(struct roam_adv_packet)); 2025 sizeof(struct roam_adv_packet));
2021 2026
2022 roam_adv_packet->header.packet_type = BAT_ROAM_ADV; 2027 roam_adv_packet->header.packet_type = BATADV_ROAM_ADV;
2023 roam_adv_packet->header.version = BATADV_COMPAT_VERSION; 2028 roam_adv_packet->header.version = BATADV_COMPAT_VERSION;
2024 roam_adv_packet->header.ttl = BATADV_TTL; 2029 roam_adv_packet->header.ttl = BATADV_TTL;
2025 primary_if = batadv_primary_if_get_selected(bat_priv); 2030 primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -2117,11 +2122,11 @@ out:
2117 return changed_num; 2122 return changed_num;
2118} 2123}
2119 2124
2120/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ 2125/* Purge out all the tt local entries marked with BATADV_TT_CLIENT_PENDING */
2121static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) 2126static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv)
2122{ 2127{
2123 struct hashtable_t *hash = bat_priv->tt_local_hash; 2128 struct hashtable_t *hash = bat_priv->tt_local_hash;
2124 struct tt_common_entry *tt_common_entry; 2129 struct tt_common_entry *tt_common;
2125 struct tt_local_entry *tt_local_entry; 2130 struct tt_local_entry *tt_local_entry;
2126 struct hlist_node *node, *node_tmp; 2131 struct hlist_node *node, *node_tmp;
2127 struct hlist_head *head; 2132 struct hlist_head *head;
@@ -2136,18 +2141,18 @@ static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv)
2136 list_lock = &hash->list_locks[i]; 2141 list_lock = &hash->list_locks[i];
2137 2142
2138 spin_lock_bh(list_lock); 2143 spin_lock_bh(list_lock);
2139 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 2144 hlist_for_each_entry_safe(tt_common, node, node_tmp, head,
2140 head, hash_entry) { 2145 hash_entry) {
2141 if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) 2146 if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING))
2142 continue; 2147 continue;
2143 2148
2144 batadv_dbg(DBG_TT, bat_priv, 2149 batadv_dbg(DBG_TT, bat_priv,
2145 "Deleting local tt entry (%pM): pending\n", 2150 "Deleting local tt entry (%pM): pending\n",
2146 tt_common_entry->addr); 2151 tt_common->addr);
2147 2152
2148 atomic_dec(&bat_priv->num_local_tt); 2153 atomic_dec(&bat_priv->num_local_tt);
2149 hlist_del_rcu(node); 2154 hlist_del_rcu(node);
2150 tt_local_entry = container_of(tt_common_entry, 2155 tt_local_entry = container_of(tt_common,
2151 struct tt_local_entry, 2156 struct tt_local_entry,
2152 common); 2157 common);
2153 batadv_tt_local_entry_free_ref(tt_local_entry); 2158 batadv_tt_local_entry_free_ref(tt_local_entry);
@@ -2167,7 +2172,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
2167 return -ENOENT; 2172 return -ENOENT;
2168 2173
2169 changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash, 2174 changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash,
2170 TT_CLIENT_NEW, false); 2175 BATADV_TT_CLIENT_NEW, false);
2171 2176
2172 /* all reset entries have to be counted as local entries */ 2177 /* all reset entries have to be counted as local entries */
2173 atomic_add(changed_num, &bat_priv->num_local_tt); 2178 atomic_add(changed_num, &bat_priv->num_local_tt);
@@ -2326,7 +2331,7 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
2326 if (!tt_global_entry) 2331 if (!tt_global_entry)
2327 goto out; 2332 goto out;
2328 2333
2329 ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; 2334 ret = tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM;
2330 batadv_tt_global_entry_free_ref(tt_global_entry); 2335 batadv_tt_global_entry_free_ref(tt_global_entry);
2331out: 2336out:
2332 return ret; 2337 return ret;