summaryrefslogtreecommitdiff
path: root/net/batman-adv/vis.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-06 00:31:31 +0400
committerAntonio Quartulli <ordex@autistici.org>2012-07-02 00:47:21 +0400
commit56303d34a332be8e2f4daf7891ebc12cb7900529 (patch)
treebc972916771e698bd8a88fd66917950ce0bd48c1 /net/batman-adv/vis.c
parent96412690116afcc1b2705615b5a7c8dc6c5e905f (diff)
downloadlinux-56303d34a332be8e2f4daf7891ebc12cb7900529.tar.xz
batman-adv: Prefix types structs with batadv_
Reported-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r--net/batman-adv/vis.c173
1 files changed, 90 insertions, 83 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index 309493d9128a..f09cc9ad6ad8 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -28,14 +28,17 @@
#define BATADV_MAX_VIS_PACKET_SIZE 1000
-static void batadv_start_vis_timer(struct bat_priv *bat_priv);
+static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
/* free the info */
static void batadv_free_info(struct kref *ref)
{
- struct vis_info *info = container_of(ref, struct vis_info, refcount);
- struct bat_priv *bat_priv = info->bat_priv;
- struct recvlist_node *entry, *tmp;
+ struct batadv_vis_info *info;
+ struct batadv_priv *bat_priv;
+ struct batadv_recvlist_node *entry, *tmp;
+
+ info = container_of(ref, struct batadv_vis_info, refcount);
+ bat_priv = info->bat_priv;
list_del_init(&info->send_list);
spin_lock_bh(&bat_priv->vis_list_lock);
@@ -52,10 +55,10 @@ static void batadv_free_info(struct kref *ref)
/* Compare two vis packets, used by the hashing algorithm */
static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
{
- const struct vis_info *d1, *d2;
+ const struct batadv_vis_info *d1, *d2;
const struct batadv_vis_packet *p1, *p2;
- d1 = container_of(node, struct vis_info, hash_entry);
+ d1 = container_of(node, struct batadv_vis_info, hash_entry);
d2 = data2;
p1 = (struct batadv_vis_packet *)d1->skb_packet->data;
p2 = (struct batadv_vis_packet *)d2->skb_packet->data;
@@ -67,7 +70,7 @@ static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
*/
static uint32_t batadv_vis_info_choose(const void *data, uint32_t size)
{
- const struct vis_info *vis_info = data;
+ const struct batadv_vis_info *vis_info = data;
const struct batadv_vis_packet *packet;
const unsigned char *key;
uint32_t hash = 0;
@@ -88,13 +91,13 @@ static uint32_t batadv_vis_info_choose(const void *data, uint32_t size)
return hash % size;
}
-static struct vis_info *batadv_vis_hash_find(struct bat_priv *bat_priv,
- const void *data)
+static struct batadv_vis_info *
+batadv_vis_hash_find(struct batadv_priv *bat_priv, const void *data)
{
struct batadv_hashtable *hash = bat_priv->vis_hash;
struct hlist_head *head;
struct hlist_node *node;
- struct vis_info *vis_info, *vis_info_tmp = NULL;
+ struct batadv_vis_info *vis_info, *vis_info_tmp = NULL;
uint32_t index;
if (!hash)
@@ -123,7 +126,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface,
struct hlist_head *if_list,
bool primary)
{
- struct if_list_entry *entry;
+ struct batadv_if_list_entry *entry;
struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) {
@@ -143,7 +146,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface,
static void batadv_vis_data_read_prim_sec(struct seq_file *seq,
const struct hlist_head *if_list)
{
- struct if_list_entry *entry;
+ struct batadv_if_list_entry *entry;
struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) {
@@ -155,9 +158,10 @@ static void batadv_vis_data_read_prim_sec(struct seq_file *seq,
}
/* read an entry */
-static ssize_t batadv_vis_data_read_entry(struct seq_file *seq,
- const struct vis_info_entry *entry,
- const uint8_t *src, bool primary)
+static ssize_t
+batadv_vis_data_read_entry(struct seq_file *seq,
+ const struct batadv_vis_info_entry *entry,
+ const uint8_t *src, bool primary)
{
if (primary && entry->quality == 0)
return seq_printf(seq, "TT %pM, ", entry->dest);
@@ -168,9 +172,10 @@ static ssize_t batadv_vis_data_read_entry(struct seq_file *seq,
return 0;
}
-static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
- struct batadv_vis_packet *packet,
- struct vis_info_entry *entries)
+static void
+batadv_vis_data_insert_interfaces(struct hlist_head *list,
+ struct batadv_vis_packet *packet,
+ struct batadv_vis_info_entry *entries)
{
int i;
@@ -188,10 +193,10 @@ static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
static void batadv_vis_data_read_entries(struct seq_file *seq,
struct hlist_head *list,
struct batadv_vis_packet *packet,
- struct vis_info_entry *entries)
+ struct batadv_vis_info_entry *entries)
{
int i;
- struct if_list_entry *entry;
+ struct batadv_if_list_entry *entry;
struct hlist_node *pos;
hlist_for_each_entry(entry, pos, list, list) {
@@ -213,11 +218,11 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
const struct hlist_head *head)
{
struct hlist_node *node;
- struct vis_info *info;
+ struct batadv_vis_info *info;
struct batadv_vis_packet *packet;
uint8_t *entries_pos;
- struct vis_info_entry *entries;
- struct if_list_entry *entry;
+ struct batadv_vis_info_entry *entries;
+ struct batadv_if_list_entry *entry;
struct hlist_node *pos, *n;
HLIST_HEAD(vis_if_list);
@@ -225,7 +230,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
hlist_for_each_entry_rcu(info, node, head, hash_entry) {
packet = (struct batadv_vis_packet *)info->skb_packet->data;
entries_pos = (uint8_t *)packet + sizeof(*packet);
- entries = (struct vis_info_entry *)entries_pos;
+ entries = (struct batadv_vis_info_entry *)entries_pos;
batadv_vis_data_insert_interface(packet->vis_orig, &vis_if_list,
true);
@@ -243,10 +248,10 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
{
- struct hard_iface *primary_if;
+ struct batadv_hard_iface *primary_if;
struct hlist_head *head;
struct net_device *net_dev = (struct net_device *)seq->private;
- struct bat_priv *bat_priv = netdev_priv(net_dev);
+ struct batadv_priv *bat_priv = netdev_priv(net_dev);
struct batadv_hashtable *hash = bat_priv->vis_hash;
uint32_t i;
int ret = 0;
@@ -275,8 +280,8 @@ out:
/* add the info packet to the send list, if it was not
* already linked in.
*/
-static void batadv_send_list_add(struct bat_priv *bat_priv,
- struct vis_info *info)
+static void batadv_send_list_add(struct batadv_priv *bat_priv,
+ struct batadv_vis_info *info)
{
if (list_empty(&info->send_list)) {
kref_get(&info->refcount);
@@ -287,7 +292,7 @@ static void batadv_send_list_add(struct bat_priv *bat_priv,
/* delete the info packet from the send list, if it was
* linked in.
*/
-static void batadv_send_list_del(struct vis_info *info)
+static void batadv_send_list_del(struct batadv_vis_info *info)
{
if (!list_empty(&info->send_list)) {
list_del_init(&info->send_list);
@@ -296,10 +301,10 @@ static void batadv_send_list_del(struct vis_info *info)
}
/* tries to add one entry to the receive list. */
-static void batadv_recv_list_add(struct bat_priv *bat_priv,
+static void batadv_recv_list_add(struct batadv_priv *bat_priv,
struct list_head *recv_list, const char *mac)
{
- struct recvlist_node *entry;
+ struct batadv_recvlist_node *entry;
entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
@@ -312,11 +317,11 @@ static void batadv_recv_list_add(struct bat_priv *bat_priv,
}
/* returns 1 if this mac is in the recv_list */
-static int batadv_recv_list_is_in(struct bat_priv *bat_priv,
+static int batadv_recv_list_is_in(struct batadv_priv *bat_priv,
const struct list_head *recv_list,
const char *mac)
{
- const struct recvlist_node *entry;
+ const struct batadv_recvlist_node *entry;
spin_lock_bh(&bat_priv->vis_list_lock);
list_for_each_entry(entry, recv_list, list) {
@@ -333,18 +338,19 @@ static int batadv_recv_list_is_in(struct bat_priv *bat_priv,
* broken.. ). vis hash must be locked outside. is_new is set when the packet
* is newer than old entries in the hash.
*/
-static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
- struct batadv_vis_packet *vis_packet,
- int vis_info_len, int *is_new,
- int make_broadcast)
+static struct batadv_vis_info *
+batadv_add_packet(struct batadv_priv *bat_priv,
+ struct batadv_vis_packet *vis_packet, int vis_info_len,
+ int *is_new, int make_broadcast)
{
- struct vis_info *info, *old_info;
+ struct batadv_vis_info *info, *old_info;
struct batadv_vis_packet *search_packet, *old_packet;
- struct vis_info search_elem;
+ struct batadv_vis_info search_elem;
struct batadv_vis_packet *packet;
struct sk_buff *tmp_skb;
int hash_added;
size_t len;
+ size_t max_entries;
*is_new = 0;
/* sanity check */
@@ -413,8 +419,9 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
/* repair if entries is longer than packet. */
- if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len)
- packet->entries = vis_info_len / sizeof(struct vis_info_entry);
+ max_entries = vis_info_len / sizeof(struct batadv_vis_info_entry);
+ if (packet->entries > max_entries)
+ packet->entries = max_entries;
batadv_recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
@@ -432,11 +439,11 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
}
/* handle the server sync packet, forward if needed. */
-void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
+void batadv_receive_server_sync_packet(struct batadv_priv *bat_priv,
struct batadv_vis_packet *vis_packet,
int vis_info_len)
{
- struct vis_info *info;
+ struct batadv_vis_info *info;
int is_new, make_broadcast;
int vis_server = atomic_read(&bat_priv->vis_mode);
@@ -458,11 +465,11 @@ end:
}
/* handle an incoming client update packet and schedule forward if needed. */
-void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
+void batadv_receive_client_update_packet(struct batadv_priv *bat_priv,
struct batadv_vis_packet *vis_packet,
int vis_info_len)
{
- struct vis_info *info;
+ struct batadv_vis_info *info;
struct batadv_vis_packet *packet;
int is_new;
int vis_server = atomic_read(&bat_priv->vis_mode);
@@ -506,14 +513,14 @@ end:
*
* Must be called with the originator hash locked
*/
-static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
- struct vis_info *info)
+static int batadv_find_best_vis_server(struct batadv_priv *bat_priv,
+ struct batadv_vis_info *info)
{
struct batadv_hashtable *hash = bat_priv->orig_hash;
- struct neigh_node *router;
+ struct batadv_neigh_node *router;
struct hlist_node *node;
struct hlist_head *head;
- struct orig_node *orig_node;
+ struct batadv_orig_node *orig_node;
struct batadv_vis_packet *packet;
int best_tq = -1;
uint32_t i;
@@ -544,15 +551,15 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
}
/* Return true if the vis packet is full. */
-static bool batadv_vis_packet_full(const struct vis_info *info)
+static bool batadv_vis_packet_full(const struct batadv_vis_info *info)
{
const struct batadv_vis_packet *packet;
- size_t num_items;
+ size_t num;
packet = (struct batadv_vis_packet *)info->skb_packet->data;
- num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry);
+ num = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct batadv_vis_info_entry);
- if (num_items < packet->entries + 1)
+ if (num < packet->entries + 1)
return true;
return false;
}
@@ -560,17 +567,17 @@ static bool batadv_vis_packet_full(const struct vis_info *info)
/* generates a packet of own vis data,
* returns 0 on success, -1 if no packet could be generated
*/
-static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
+static int batadv_generate_vis_packet(struct batadv_priv *bat_priv)
{
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node;
struct hlist_head *head;
- struct orig_node *orig_node;
- struct neigh_node *router;
- struct vis_info *info = bat_priv->my_vis_info;
+ struct batadv_orig_node *orig_node;
+ struct batadv_neigh_node *router;
+ struct batadv_vis_info *info = bat_priv->my_vis_info;
struct batadv_vis_packet *packet;
- struct vis_info_entry *entry;
- struct tt_common_entry *tt_common_entry;
+ struct batadv_vis_info_entry *entry;
+ struct batadv_tt_common_entry *tt_common_entry;
int best_tq = -1;
uint32_t i;
@@ -610,7 +617,7 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
goto next;
/* fill one entry into buffer. */
- entry = (struct vis_info_entry *)
+ entry = (struct batadv_vis_info_entry *)
skb_put(info->skb_packet, sizeof(*entry));
memcpy(entry->src,
router->if_incoming->net_dev->dev_addr,
@@ -636,7 +643,7 @@ next:
rcu_read_lock();
hlist_for_each_entry_rcu(tt_common_entry, node, head,
hash_entry) {
- entry = (struct vis_info_entry *)
+ entry = (struct batadv_vis_info_entry *)
skb_put(info->skb_packet,
sizeof(*entry));
memset(entry->src, 0, ETH_ALEN);
@@ -660,13 +667,13 @@ unlock:
/* free old vis packets. Must be called with this vis_hash_lock
* held
*/
-static void batadv_purge_vis_packets(struct bat_priv *bat_priv)
+static void batadv_purge_vis_packets(struct batadv_priv *bat_priv)
{
uint32_t i;
struct batadv_hashtable *hash = bat_priv->vis_hash;
struct hlist_node *node, *node_tmp;
struct hlist_head *head;
- struct vis_info *info;
+ struct batadv_vis_info *info;
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
@@ -687,17 +694,17 @@ static void batadv_purge_vis_packets(struct bat_priv *bat_priv)
}
}
-static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv,
- struct vis_info *info)
+static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv,
+ struct batadv_vis_info *info)
{
- struct neigh_node *router;
+ struct batadv_neigh_node *router;
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node;
struct hlist_head *head;
- struct orig_node *orig_node;
+ struct batadv_orig_node *orig_node;
struct batadv_vis_packet *packet;
struct sk_buff *skb;
- struct hard_iface *hard_iface;
+ struct batadv_hard_iface *hard_iface;
uint8_t dstaddr[ETH_ALEN];
uint32_t i;
@@ -743,11 +750,11 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv,
}
}
-static void batadv_unicast_vis_packet(struct bat_priv *bat_priv,
- struct vis_info *info)
+static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv,
+ struct batadv_vis_info *info)
{
- struct orig_node *orig_node;
- struct neigh_node *router = NULL;
+ struct batadv_orig_node *orig_node;
+ struct batadv_neigh_node *router = NULL;
struct sk_buff *skb;
struct batadv_vis_packet *packet;
@@ -773,10 +780,10 @@ out:
}
/* only send one vis packet. called from batadv_send_vis_packets() */
-static void batadv_send_vis_packet(struct bat_priv *bat_priv,
- struct vis_info *info)
+static void batadv_send_vis_packet(struct batadv_priv *bat_priv,
+ struct batadv_vis_info *info)
{
- struct hard_iface *primary_if;
+ struct batadv_hard_iface *primary_if;
struct batadv_vis_packet *packet;
primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -808,10 +815,10 @@ static void batadv_send_vis_packets(struct work_struct *work)
{
struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work);
- struct bat_priv *bat_priv =
- container_of(delayed_work, struct bat_priv, vis_work);
- struct vis_info *info;
+ struct batadv_priv *bat_priv;
+ struct batadv_vis_info *info;
+ bat_priv = container_of(delayed_work, struct batadv_priv, vis_work);
spin_lock_bh(&bat_priv->vis_hash_lock);
batadv_purge_vis_packets(bat_priv);
@@ -840,7 +847,7 @@ static void batadv_send_vis_packets(struct work_struct *work)
/* init the vis server. this may only be called when if_list is already
* initialized (e.g. bat0 is initialized, interfaces have been added)
*/
-int batadv_vis_init(struct bat_priv *bat_priv)
+int batadv_vis_init(struct batadv_priv *bat_priv)
{
struct batadv_vis_packet *packet;
int hash_added;
@@ -914,15 +921,15 @@ err:
/* Decrease the reference count on a hash item info */
static void batadv_free_info_ref(struct hlist_node *node, void *arg)
{
- struct vis_info *info;
+ struct batadv_vis_info *info;
- info = container_of(node, struct vis_info, hash_entry);
+ info = container_of(node, struct batadv_vis_info, hash_entry);
batadv_send_list_del(info);
kref_put(&info->refcount, batadv_free_info);
}
/* shutdown vis-server */
-void batadv_vis_quit(struct bat_priv *bat_priv)
+void batadv_vis_quit(struct batadv_priv *bat_priv)
{
if (!bat_priv->vis_hash)
return;
@@ -938,7 +945,7 @@ void batadv_vis_quit(struct bat_priv *bat_priv)
}
/* schedule packets for (re)transmission */
-static void batadv_start_vis_timer(struct bat_priv *bat_priv)
+static void batadv_start_vis_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work,