Commit 3e428fe0 authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Included changes:
- first set of patches that add the batadv_ prefix to all the exported symbols
- restyling of comments
parents 1c11a0a1 9cfc7bd6
/*
* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,12 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
#define _NET_BATMAN_ADV_BAT_ALGO_H_
int bat_iv_init(void);
int batadv_iv_init(void);
#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -76,7 +74,7 @@ static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
return 0;
}
int debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];
......@@ -94,13 +92,13 @@ static int log_open(struct inode *inode, struct file *file)
{
nonseekable_open(inode, file);
file->private_data = inode->i_private;
inc_module_count();
batadv_inc_module_count();
return 0;
}
static int log_release(struct inode *inode, struct file *file)
{
dec_module_count();
batadv_dec_module_count();
return 0;
}
......@@ -224,45 +222,46 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
static int bat_algorithms_open(struct inode *inode, struct file *file)
{
return single_open(file, bat_algo_seq_print_text, NULL);
return single_open(file, batadv_algo_seq_print_text, NULL);
}
static int originators_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, orig_seq_print_text, net_dev);
return single_open(file, batadv_orig_seq_print_text, net_dev);
}
static int gateways_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, gw_client_seq_print_text, net_dev);
return single_open(file, batadv_gw_client_seq_print_text, net_dev);
}
static int transtable_global_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, tt_global_seq_print_text, net_dev);
return single_open(file, batadv_tt_global_seq_print_text, net_dev);
}
#ifdef CONFIG_BATMAN_ADV_BLA
static int bla_claim_table_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, bla_claim_table_seq_print_text, net_dev);
return single_open(file, batadv_bla_claim_table_seq_print_text,
net_dev);
}
#endif
static int transtable_local_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, tt_local_seq_print_text, net_dev);
return single_open(file, batadv_tt_local_seq_print_text, net_dev);
}
static int vis_data_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, vis_seq_print_text, net_dev);
return single_open(file, batadv_vis_seq_print_text, net_dev);
}
struct bat_debuginfo {
......@@ -304,7 +303,7 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
NULL,
};
void debugfs_init(void)
void batadv_debugfs_init(void)
{
struct bat_debuginfo *bat_debug;
struct dentry *file;
......@@ -327,7 +326,7 @@ void debugfs_init(void)
return;
}
void debugfs_destroy(void)
void batadv_debugfs_destroy(void)
{
if (bat_debugfs) {
debugfs_remove_recursive(bat_debugfs);
......@@ -335,7 +334,7 @@ void debugfs_destroy(void)
}
}
int debugfs_add_meshif(struct net_device *dev)
int batadv_debugfs_add_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_debuginfo **bat_debug;
......@@ -348,7 +347,7 @@ int debugfs_add_meshif(struct net_device *dev)
if (!bat_priv->debug_dir)
goto out;
if (bat_socket_setup(bat_priv) < 0)
if (batadv_socket_setup(bat_priv) < 0)
goto rem_attr;
if (debug_log_setup(bat_priv) < 0)
......@@ -378,7 +377,7 @@ int debugfs_add_meshif(struct net_device *dev)
#endif /* CONFIG_DEBUG_FS */
}
void debugfs_del_meshif(struct net_device *dev)
void batadv_debugfs_del_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
......
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,18 +15,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_DEBUGFS_H_
#define _NET_BATMAN_ADV_DEBUGFS_H_
#define DEBUGFS_BAT_SUBDIR "batman_adv"
void debugfs_init(void);
void debugfs_destroy(void);
int debugfs_add_meshif(struct net_device *dev);
void debugfs_del_meshif(struct net_device *dev);
void batadv_debugfs_init(void);
void batadv_debugfs_destroy(void);
int batadv_debugfs_add_meshif(struct net_device *dev);
void batadv_debugfs_del_meshif(struct net_device *dev);
#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */
This diff is collapsed.
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -84,7 +82,8 @@ ssize_t show_##_name(struct kobject *kobj, \
} \
/* Use this, if you are going to turn a [name] in the soft-interface
* (bat_priv) on or off */
* (bat_priv) on or off
*/
#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \
static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
static BAT_ATTR_SIF_SHOW_BOOL(_name) \
......@@ -110,7 +109,8 @@ ssize_t show_##_name(struct kobject *kobj, \
} \
/* Use this, if you are going to set [name] in the soft-interface
* (bat_priv) to an unsigned integer value */
* (bat_priv) to an unsigned integer value
*/
#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \
static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
static BAT_ATTR_SIF_SHOW_UINT(_name) \
......@@ -122,9 +122,10 @@ ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \
char *buff, size_t count) \
{ \
struct net_device *net_dev = kobj_to_netdev(kobj); \
struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \
struct hard_iface *hard_iface; \
ssize_t length; \
\
hard_iface = batadv_hardif_get_by_netdev(net_dev); \
if (!hard_iface) \
return 0; \
\
......@@ -140,9 +141,10 @@ ssize_t show_##_name(struct kobject *kobj, \
struct attribute *attr, char *buff) \
{ \
struct net_device *net_dev = kobj_to_netdev(kobj); \
struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \
struct hard_iface *hard_iface; \
ssize_t length; \
\
hard_iface = batadv_hardif_get_by_netdev(net_dev); \
if (!hard_iface) \
return 0; \
\
......@@ -153,7 +155,8 @@ ssize_t show_##_name(struct kobject *kobj, \
}
/* Use this, if you are going to set [name] in hard_iface to an
* unsigned integer value*/
* unsigned integer value
*/
#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
static BAT_ATTR_HIF_SHOW_UINT(_name) \
......@@ -326,7 +329,7 @@ static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr,
static void post_gw_deselect(struct net_device *net_dev)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
gw_deselect(bat_priv);
batadv_gw_deselect(bat_priv);
}
static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
......@@ -397,7 +400,7 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
bat_info(net_dev, "Changing gw mode from: %s to: %s\n",
curr_gw_mode_str, buff);
gw_deselect(bat_priv);
batadv_gw_deselect(bat_priv);
atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
return count;
}
......@@ -409,7 +412,7 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr,
int down, up;
int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth);
gw_bandwidth_to_kbit(gw_bandwidth, &down, &up);
batadv_gw_bandwidth_to_kbit(gw_bandwidth, &down, &up);
return sprintf(buff, "%i%s/%i%s\n",
(down > 2048 ? down / 1024 : down),
(down > 2048 ? "MBit" : "KBit"),
......@@ -425,7 +428,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
return gw_bandwidth_set(net_dev, buff, count);
return batadv_gw_bandwidth_set(net_dev, buff, count);
}
BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
......@@ -433,7 +436,7 @@ BAT_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
#ifdef CONFIG_BATMAN_ADV_BLA
BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
#endif
BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL);
......@@ -469,7 +472,7 @@ static struct bat_attribute *mesh_attrs[] = {
NULL,
};
int sysfs_add_meshif(struct net_device *dev)
int batadv_sysfs_add_meshif(struct net_device *dev)
{
struct kobject *batif_kobject = &dev->dev.kobj;
struct bat_priv *bat_priv = netdev_priv(dev);
......@@ -507,7 +510,7 @@ int sysfs_add_meshif(struct net_device *dev)
return -ENOMEM;
}
void sysfs_del_meshif(struct net_device *dev)
void batadv_sysfs_del_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_attribute **bat_attr;
......@@ -523,7 +526,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
char *buff)
{
struct net_device *net_dev = kobj_to_netdev(kobj);
struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
ssize_t length;
if (!hard_iface)
......@@ -541,7 +544,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
char *buff, size_t count)
{
struct net_device *net_dev = kobj_to_netdev(kobj);
struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
int status_tmp = -1;
int ret = count;
......@@ -576,15 +579,15 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
}
if (status_tmp == IF_NOT_IN_USE) {
hardif_disable_interface(hard_iface);
batadv_hardif_disable_interface(hard_iface);
goto unlock;
}
/* if the interface already is in use */
if (hard_iface->if_status != IF_NOT_IN_USE)
hardif_disable_interface(hard_iface);
batadv_hardif_disable_interface(hard_iface);
ret = hardif_enable_interface(hard_iface, buff);
ret = batadv_hardif_enable_interface(hard_iface, buff);
unlock:
rtnl_unlock();
......@@ -597,7 +600,7 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
char *buff)
{
struct net_device *net_dev = kobj_to_netdev(kobj);
struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
ssize_t length;
if (!hard_iface)
......@@ -637,7 +640,7 @@ static struct bat_attribute *batman_attrs[] = {
NULL,
};
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
{
struct kobject *hardif_kobject = &dev->dev.kobj;
struct bat_attribute **bat_attr;
......@@ -671,13 +674,13 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
return -ENOMEM;
}
void sysfs_del_hardif(struct kobject **hardif_obj)
void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
{
kobject_put(*hardif_obj);
*hardif_obj = NULL;
}
int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
enum uev_action action, const char *data)
{
int ret = -ENOMEM;
......
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,10 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_SYSFS_H_
#define _NET_BATMAN_ADV_SYSFS_H_
......@@ -34,11 +31,12 @@ struct bat_attribute {
char *buf, size_t count);
};
int sysfs_add_meshif(struct net_device *dev);
void sysfs_del_meshif(struct net_device *dev);
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
void sysfs_del_hardif(struct kobject **hardif_obj);
int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
int batadv_sysfs_add_meshif(struct net_device *dev);
void batadv_sysfs_del_meshif(struct net_device *dev);
int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
struct net_device *dev);
void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
enum uev_action action, const char *data);
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
/*
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -25,7 +23,7 @@
#include <linux/bitops.h>
/* shift the packet array by n places. */
static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
{
if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE)
return;
......@@ -40,14 +38,14 @@ static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
* 1 if the window was moved (either new or very old)
* 0 if the window was not moved/shifted.
*/
int bit_get_packet(void *priv, unsigned long *seq_bits,
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int set_mark)
{
struct bat_priv *bat_priv = priv;
/* sequence number is slightly older. We already got a sequence number
* higher than this one, so we just mark it. */
* higher than this one, so we just mark it.
*/
if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) {
if (set_mark)
bat_set_bit(seq_bits, -seq_num_diff);
......@@ -55,10 +53,10 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
}
/* sequence number is slightly newer, so we shift the window and
* set the mark if required */
* set the mark if required
*/
if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) {
bat_bitmap_shift_left(seq_bits, seq_num_diff);
batadv_bitmap_shift_left(seq_bits, seq_num_diff);
if (set_mark)
bat_set_bit(seq_bits, 0);
......@@ -66,7 +64,6 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
}
/* sequence number is much newer, probably missed a lot of packets */
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) &&
(seq_num_diff < EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_priv,
......@@ -81,8 +78,8 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
/* received a much older packet. The other host either restarted
* or the old packet got delayed somewhere in the network. The
* packet should be dropped without calling this function if the
* seqno window is protected. */
* seqno window is protected.
*/
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
......
/*
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
*
......@@ -16,14 +15,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_BITARRAY_H_
#define _NET_BATMAN_ADV_BITARRAY_H_
/* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */
* and curr_seqno is within range of last_seqno
*/
static inline int bat_test_bit(const unsigned long *seq_bits,
uint32_t last_seqno, uint32_t curr_seqno)
{
......@@ -47,8 +46,9 @@ static inline void bat_set_bit(unsigned long *seq_bits, int32_t n)
}
/* receive and process one packet, returns 1 if received seq_num is considered
* new, 0 if old */
int bit_get_packet(void *priv, unsigned long *seq_bits,
* new, 0 if old
*/
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int set_mark);
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
This diff is collapsed.
/*
* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich
*
......@@ -16,80 +15,82 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_BLA_H_
#define _NET_BATMAN_ADV_BLA_H_
#ifdef CONFIG_BATMAN_ADV_BLA
int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int bla_is_backbone_gw(struct sk_buff *skb,
int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
struct orig_node *orig_node, int hdr_size);
int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
int bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet, int hdr_size);
void bla_update_orig_address(struct bat_priv *bat_priv,
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet,
int hdr_size);
void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
struct hard_iface *primary_if,
struct hard_iface *oldif);
int bla_init(struct bat_priv *bat_priv);
void bla_free(struct bat_priv *bat_priv);
int batadv_bla_init(struct bat_priv *bat_priv);
void batadv_bla_free(struct bat_priv *bat_priv);
#define BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */
static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
short vid)
{
return 0;
}
static inline int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
static inline int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
short vid)
{
return 0;
}
static inline int bla_is_backbone_gw(struct sk_buff *skb,
static inline int batadv_bla_is_backbone_gw(struct sk_buff *skb,
struct orig_node *orig_node,
int hdr_size)
{
return 0;
}
static inline int bla_claim_table_seq_print_text(struct seq_file *seq,
static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
void *offset)
{
return 0;
}
static inline int bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
uint8_t *orig)
{
return 0;
}
static inline int bla_check_bcast_duplist(struct bat_priv *bat_priv,
static inline int
batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet,
int hdr_size)
{
return 0;
}
static inline void bla_update_orig_address(struct bat_priv *bat_priv,
static inline void
batadv_bla_update_orig_address(struct bat_priv *bat_priv,
struct hard_iface *primary_if,
struct hard_iface *oldif)
{
}
static inline int bla_init(struct bat_priv *bat_priv)
static inline int batadv_bla_init(struct bat_priv *bat_priv)
{
return 1;
}
static inline void bla_free(struct bat_priv *bat_priv)
static inline void batadv_bla_free(struct bat_priv *bat_priv)
{
}
......
This diff is collapsed.
/*
* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,23 +15,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
void gw_deselect(struct bat_priv *bat_priv);
void gw_election(struct bat_priv *bat_priv);
struct orig_node *gw_get_selected_orig(struct bat_priv *bat_priv);
void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node);
void gw_node_update(struct bat_priv *bat_priv,
void batadv_gw_deselect(struct bat_priv *bat_priv);
void batadv_gw_election(struct bat_priv *bat_priv);
struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv);
void batadv_gw_check_election(struct bat_priv *bat_priv,
struct orig_node *orig_node);
void batadv_gw_node_update(struct bat_priv *bat_priv,
struct orig_node *orig_node, uint8_t new_gwflags);
void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node);
void gw_node_purge(struct bat_priv *bat_priv);
int gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool gw_out_of_range(struct bat_priv *bat_priv,
void batadv_gw_node_delete(struct bat_priv *bat_priv,
struct orig_node *orig_node);
void batadv_gw_node_purge(struct bat_priv *bat_priv);
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
struct sk_buff *skb, struct ethhdr *ethhdr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
/*
* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -59,7 +57,7 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
}
/* returns the up and downspeeds in kbit, calculated from the class */
void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
{
int sbit = (gw_srv_class & 0x80) >> 7;
int dpart = (gw_srv_class & 0x78) >> 3;
......@@ -136,7 +134,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
return true;
}
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0;
......@@ -155,17 +154,16 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp);
/**
* the gw bandwidth we guessed above might not match the given
/* the gw bandwidth we guessed above might not match the given
* speeds, hence we need to calculate it back to show the number
* that is going to be propagated
**/
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);
*/
batadv_gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);
if (atomic_read(&bat_priv->gw_bandwidth) == gw_bandwidth_tmp)
return count;
gw_deselect(bat_priv);
batadv_gw_deselect(bat_priv);
bat_info(net_dev,
"Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n",
atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
......
/*
* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_
......@@ -32,7 +30,8 @@ enum gw_modes {
#define GW_MODE_CLIENT_NAME "client"
#define GW_MODE_SERVER_NAME "server"
void gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up);
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count);
void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up);
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count);
#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
This diff is collapsed.
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
......@@ -31,23 +29,23 @@ enum hard_if_state {
IF_I_WANT_YOU
};
extern struct notifier_block hard_if_notifier;
extern struct notifier_block batadv_hard_if_notifier;
struct hard_iface*
hardif_get_by_netdev(const struct net_device *net_dev);
int hardif_enable_interface(struct hard_iface *hard_iface,
batadv_hardif_get_by_netdev(const struct net_device *net_dev);
int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
const char *iface_name);
void hardif_disable_interface(struct hard_iface *hard_iface);
void hardif_remove_interfaces(void);
int hardif_min_mtu(struct net_device *soft_iface);
void update_min_mtu(struct net_device *soft_iface);
void hardif_free_rcu(struct rcu_head *rcu);
bool is_wifi_iface(int ifindex);
void batadv_hardif_disable_interface(struct hard_iface *hard_iface);
void batadv_hardif_remove_interfaces(void);
int batadv_hardif_min_mtu(struct net_device *soft_iface);
void batadv_update_min_mtu(struct net_device *soft_iface);
void batadv_hardif_free_rcu(struct rcu_head *rcu);
bool batadv_is_wifi_iface(int ifindex);
static inline void hardif_free_ref(struct hard_iface *hard_iface)
{
if (atomic_dec_and_test(&hard_iface->refcount))
call_rcu(&hard_iface->rcu, hardif_free_rcu);
call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
}
static inline struct hard_iface *primary_if_get_selected(
......
/*
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -34,7 +32,7 @@ static void hash_init(struct hashtable_t *hash)
}
/* free only the hashtable and the hash itself. */
void hash_destroy(struct hashtable_t *hash)
void batadv_hash_destroy(struct hashtable_t *hash)
{
kfree(hash->list_locks);
kfree(hash->table);
......@@ -42,7 +40,7 @@ void hash_destroy(struct hashtable_t *hash)
}
/* allocates and clears the hash */
struct hashtable_t *hash_new(uint32_t size)
struct hashtable_t *batadv_hash_new(uint32_t size)
{
struct hashtable_t *hash;
......
/*
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_HASH_H_
......@@ -24,15 +22,15 @@
#include <linux/list.h>
/* callback to a compare function. should
* compare 2 element datas for their keys,
* return 0 if same and not 0 if not
* same */
/* callback to a compare function. should compare 2 element datas for their
* keys, return 0 if same and not 0 if not same
*/
typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *);
/* the hashfunction, should return an index
* based on the key in the data of the first
* argument and the size the second */
* argument and the size the second
*/
typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t);
typedef void (*hashdata_free_cb)(struct hlist_node *, void *);
......@@ -43,18 +41,19 @@ struct hashtable_t {
};
/* allocates and clears the hash */
struct hashtable_t *hash_new(uint32_t size);
struct hashtable_t *batadv_hash_new(uint32_t size);
/* set class key for all locks */
void batadv_hash_set_lock_class(struct hashtable_t *hash,
struct lock_class_key *key);
/* free only the hashtable and the hash itself. */
void hash_destroy(struct hashtable_t *hash);
void batadv_hash_destroy(struct hashtable_t *hash);
/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
* called to remove the elements inside of the hash. if you don't remove the
* elements, memory might be leaked. */
* elements, memory might be leaked.
*/
static inline void hash_delete(struct hashtable_t *hash,
hashdata_free_cb free_cb, void *arg)
{
......@@ -77,11 +76,10 @@ static inline void hash_delete(struct hashtable_t *hash,
spin_unlock_bh(list_lock);
}
hash_destroy(hash);
batadv_hash_destroy(hash);
}
/**
* hash_add - adds data to the hashtable
/* hash_add - adds data to the hashtable
* @hash: storage hash table
* @compare: callback to determine if 2 hash elements are identical
* @choose: callback calculating the hash index
......@@ -91,7 +89,6 @@ static inline void hash_delete(struct hashtable_t *hash,
* Returns 0 on success, 1 if the element already is in the hash
* and -1 on error.
*/
static inline int hash_add(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose,
......@@ -134,7 +131,8 @@ static inline int hash_add(struct hashtable_t *hash,
/* removes data from hash, if found. returns pointer do data on success, so you
* can remove the used structure yourself, or NULL on error . data could be the
* structure you use with just the key filled, we just need the key for
* comparing. */
* comparing.
*/
static inline void *hash_remove(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose, void *data)
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -34,7 +32,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet,
size_t icmp_len);
void bat_socket_init(void)
void batadv_socket_init(void)
{
memset(socket_client_hash, 0, sizeof(socket_client_hash));
}
......@@ -73,7 +71,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
file->private_data = socket_client;
inc_module_count();
batadv_inc_module_count();
return 0;
}
......@@ -98,7 +96,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
spin_unlock_bh(&socket_client->lock);
kfree(socket_client);
dec_module_count();
batadv_dec_module_count();
return 0;
}
......@@ -219,7 +217,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (!orig_node)
goto dst_unreach;
neigh_node = orig_node_get_router(orig_node);
neigh_node = batadv_orig_node_get_router(orig_node);
if (!neigh_node)
goto dst_unreach;
......@@ -236,7 +234,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
memcpy(icmp_packet->rr,
neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
goto out;
dst_unreach:
......@@ -248,9 +246,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (primary_if)
hardif_free_ref(primary_if);
if (neigh_node)
neigh_node_free_ref(neigh_node);
batadv_neigh_node_free_ref(neigh_node);
if (orig_node)
orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
return len;
}
......@@ -276,7 +274,7 @@ static const struct file_operations fops = {
.llseek = no_llseek,
};
int bat_socket_setup(struct bat_priv *bat_priv)
int batadv_socket_setup(struct bat_priv *bat_priv)
{
struct dentry *d;
......@@ -312,7 +310,8 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
spin_lock_bh(&socket_client->lock);
/* while waiting for the lock the socket_client could have been
* deleted */
* deleted
*/
if (!socket_client_hash[icmp_packet->uid]) {
spin_unlock_bh(&socket_client->lock);
kfree(socket_packet);
......@@ -336,7 +335,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
wake_up(&socket_client->queue_wait);
}
void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
size_t icmp_len)
{
struct socket_client *hash = socket_client_hash[icmp_packet->uid];
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
......@@ -24,9 +22,9 @@
#define ICMP_SOCKET "socket"
void bat_socket_init(void);
int bat_socket_setup(struct bat_priv *bat_priv);
void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
void batadv_socket_init(void);
int batadv_socket_setup(struct bat_priv *bat_priv);
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
size_t icmp_len);
#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -37,38 +35,40 @@
/* List manipulations on hardif_list have to be rtnl_lock()'ed,
* list traversals just rcu-locked */
struct list_head hardif_list;
* list traversals just rcu-locked
*/
struct list_head batadv_hardif_list;
static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *);
char bat_routing_algo[20] = "BATMAN_IV";
char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head bat_algo_list;
unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct workqueue_struct *bat_event_workqueue;
struct workqueue_struct *batadv_event_workqueue;
static void recv_handler_init(void);
static int __init batman_init(void)
{
INIT_LIST_HEAD(&hardif_list);
INIT_LIST_HEAD(&batadv_hardif_list);
INIT_HLIST_HEAD(&bat_algo_list);
recv_handler_init();
bat_iv_init();
batadv_iv_init();
/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
bat_event_workqueue = create_singlethread_workqueue("bat_events");
* http://lwn.net/Articles/23634/
*/
batadv_event_workqueue = create_singlethread_workqueue("bat_events");
if (!bat_event_workqueue)
if (!batadv_event_workqueue)
return -ENOMEM;
bat_socket_init();
debugfs_init();
batadv_socket_init();
batadv_debugfs_init();
register_netdevice_notifier(&hard_if_notifier);
register_netdevice_notifier(&batadv_hard_if_notifier);
pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
SOURCE_VERSION, COMPAT_VERSION);
......@@ -78,18 +78,18 @@ static int __init batman_init(void)
static void __exit batman_exit(void)
{
debugfs_destroy();
unregister_netdevice_notifier(&hard_if_notifier);
hardif_remove_interfaces();
batadv_debugfs_destroy();
unregister_netdevice_notifier(&batadv_hard_if_notifier);
batadv_hardif_remove_interfaces();
flush_workqueue(bat_event_workqueue);
destroy_workqueue(bat_event_workqueue);
bat_event_workqueue = NULL;
flush_workqueue(batadv_event_workqueue);
destroy_workqueue(batadv_event_workqueue);
batadv_event_workqueue = NULL;
rcu_barrier();
}
int mesh_init(struct net_device *soft_iface)
int batadv_mesh_init(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);
int ret;
......@@ -111,21 +111,21 @@ int mesh_init(struct net_device *soft_iface)
INIT_LIST_HEAD(&bat_priv->tt_req_list);
INIT_LIST_HEAD(&bat_priv->tt_roam_list);
ret = originator_init(bat_priv);
ret = batadv_originator_init(bat_priv);
if (ret < 0)
goto err;
ret = tt_init(bat_priv);
ret = batadv_tt_init(bat_priv);
if (ret < 0)
goto err;
tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
ret = vis_init(bat_priv);
ret = batadv_vis_init(bat_priv);
if (ret < 0)
goto err;
ret = bla_init(bat_priv);
ret = batadv_bla_init(bat_priv);
if (ret < 0)
goto err;
......@@ -135,48 +135,48 @@ int mesh_init(struct net_device *soft_iface)
return 0;
err:
mesh_free(soft_iface);
batadv_mesh_free(soft_iface);
return ret;
}
void mesh_free(struct net_device *soft_iface)
void batadv_mesh_free(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);
atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING);
purge_outstanding_packets(bat_priv, NULL);
batadv_purge_outstanding_packets(bat_priv, NULL);
vis_quit(bat_priv);
batadv_vis_quit(bat_priv);
gw_node_purge(bat_priv);
originator_free(bat_priv);
batadv_gw_node_purge(bat_priv);
batadv_originator_free(bat_priv);
tt_free(bat_priv);
batadv_tt_free(bat_priv);
bla_free(bat_priv);
batadv_bla_free(bat_priv);
free_percpu(bat_priv->bat_counters);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
}
void inc_module_count(void)
void batadv_inc_module_count(void)
{
try_module_get(THIS_MODULE);
}
void dec_module_count(void)
void batadv_dec_module_count(void)
{
module_put(THIS_MODULE);
}
int is_my_mac(const uint8_t *addr)
int batadv_is_my_mac(const uint8_t *addr)
{
const struct hard_iface *hard_iface;
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->if_status != IF_ACTIVE)
continue;
......@@ -198,8 +198,9 @@ static int recv_unhandled_packet(struct sk_buff *skb,
/* incoming packets with the batman ethertype received on any active hard
* interface
*/
int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
{
struct bat_priv *bat_priv;
struct batman_ogm_packet *batman_ogm_packet;
......@@ -272,22 +273,22 @@ static void recv_handler_init(void)
recv_packet_handler[i] = recv_unhandled_packet;
/* batman icmp packet */
recv_packet_handler[BAT_ICMP] = recv_icmp_packet;
recv_packet_handler[BAT_ICMP] = batadv_recv_icmp_packet;
/* unicast packet */
recv_packet_handler[BAT_UNICAST] = recv_unicast_packet;
recv_packet_handler[BAT_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */
recv_packet_handler[BAT_UNICAST_FRAG] = recv_ucast_frag_packet;
recv_packet_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
/* broadcast packet */
recv_packet_handler[BAT_BCAST] = recv_bcast_packet;
recv_packet_handler[BAT_BCAST] = batadv_recv_bcast_packet;
/* vis packet */
recv_packet_handler[BAT_VIS] = recv_vis_packet;
recv_packet_handler[BAT_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */
recv_packet_handler[BAT_TT_QUERY] = recv_tt_query;
recv_packet_handler[BAT_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */
recv_packet_handler[BAT_ROAM_ADV] = recv_roam_adv;
recv_packet_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
}
int recv_handler_register(uint8_t packet_type,
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *))
{
......@@ -298,7 +299,7 @@ int recv_handler_register(uint8_t packet_type,
return 0;
}
void recv_handler_unregister(uint8_t packet_type)
void batadv_recv_handler_unregister(uint8_t packet_type)
{
recv_packet_handler[packet_type] = recv_unhandled_packet;
}
......@@ -319,7 +320,7 @@ static struct bat_algo_ops *bat_algo_get(char *name)
return bat_algo_ops;
}
int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
{
struct bat_algo_ops *bat_algo_ops_tmp;
int ret;
......@@ -353,7 +354,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
return ret;
}
int bat_algo_select(struct bat_priv *bat_priv, char *name)
int batadv_algo_select(struct bat_priv *bat_priv, char *name)
{
struct bat_algo_ops *bat_algo_ops;
int ret = -EINVAL;
......@@ -369,7 +370,7 @@ int bat_algo_select(struct bat_priv *bat_priv, char *name)
return ret;
}
int bat_algo_seq_print_text(struct seq_file *seq, void *offset)
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
{
struct bat_algo_ops *bat_algo_ops;
struct hlist_node *node;
......@@ -407,8 +408,8 @@ static const struct kernel_param_ops param_ops_ra = {
};
static struct kparam_string __param_string_ra = {
.maxlen = sizeof(bat_routing_algo),
.string = bat_routing_algo,
.maxlen = sizeof(batadv_routing_algo),
.string = batadv_routing_algo,
};
module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644);
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_MAIN_H_
......@@ -36,19 +34,21 @@
#define TQ_MAX_VALUE 255
#define JITTER 20
/* Time To Live of broadcast messages */
/* Time To Live of broadcast messages */
#define TTL 50
/* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE
*/
#define PURGE_TIMEOUT 200000 /* 200 seconds */
#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
/* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) */
* (should be a multiple of our word size)
*/
#define TQ_LOCAL_WINDOW_SIZE 64
#define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep
* pending tt_req */
/* miliseconds we have to keep pending tt_req */
#define TT_REQUEST_TIMEOUT 3000
#define TQ_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
......@@ -57,8 +57,10 @@
#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */
#define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most
* ROAMING_MAX_COUNT times in miliseconds*/
/* Time in which a client can roam at most ROAMING_MAX_COUNT times in
* miliseconds
*/
#define ROAMING_MAX_TIME 20000
#define ROAMING_MAX_COUNT 5
#define NO_FLAGS 0
......@@ -72,11 +74,13 @@
#define VIS_INTERVAL 5000 /* 5 seconds */
/* how much worse secondary interfaces may be to be considered as bonding
* candidates */
* candidates
*/
#define BONDING_TQ_THRESHOLD 50
/* should not be bigger than 512 bytes or change the size of
* forw_packet->direct_link_flags */
* forw_packet->direct_link_flags
*/
#define MAX_AGGREGATION_BYTES 512
#define MAX_AGGREGATION_MS 100
......@@ -145,34 +149,36 @@ enum dbg_level {
#include <linux/seq_file.h>
#include "types.h"
extern char bat_routing_algo[];
extern struct list_head hardif_list;
extern unsigned char broadcast_addr[];
extern struct workqueue_struct *bat_event_workqueue;
int mesh_init(struct net_device *soft_iface);
void mesh_free(struct net_device *soft_iface);
void inc_module_count(void);
void dec_module_count(void);
int is_my_mac(const uint8_t *addr);
int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev);
int recv_handler_register(uint8_t packet_type,
extern char batadv_routing_algo[];
extern struct list_head batadv_hardif_list;
extern unsigned char batadv_broadcast_addr[];
extern struct workqueue_struct *batadv_event_workqueue;
int batadv_mesh_init(struct net_device *soft_iface);
void batadv_mesh_free(struct net_device *soft_iface);
void batadv_inc_module_count(void);
void batadv_dec_module_count(void);
int batadv_is_my_mac(const uint8_t *addr);
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev);
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *));
void recv_handler_unregister(uint8_t packet_type);
int bat_algo_register(struct bat_algo_ops *bat_algo_ops);
int bat_algo_select(struct bat_priv *bat_priv, char *name);
int bat_algo_seq_print_text(struct seq_file *seq, void *offset);
void batadv_recv_handler_unregister(uint8_t packet_type);
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops);
int batadv_algo_select(struct bat_priv *bat_priv, char *name);
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
#ifdef CONFIG_BATMAN_ADV_DEBUG
int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
__printf(2, 3);
#define bat_dbg(type, bat_priv, fmt, arg...) \
do { \
if (atomic_read(&bat_priv->log_level) & type) \
debug_log(bat_priv, fmt, ## arg); \
batadv_debug_log(bat_priv, fmt, ## arg);\
} \
while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */
......@@ -199,19 +205,16 @@ static inline void bat_dbg(int type __always_unused,
pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0)
/**
* returns 1 if they are the same ethernet addr
/* returns 1 if they are the same ethernet addr
*
* note: can't use compare_ether_addr() as it requires aligned memory
*/
static inline int compare_eth(const void *data1, const void *data2)
{
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
}
/**
* has_timed_out - compares current time (jiffies) and timestamp + timeout
/* has_timed_out - compares current time (jiffies) and timestamp + timeout
* @timestamp: base value to compare with (in jiffies)
* @timeout: added to base value before comparing (in milliseconds)
*
......@@ -235,7 +238,8 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout)
* - when adding nothing - it is neither a predecessor nor a successor
* - before adding more than 127 to the starting value - it is a predecessor,
* - when adding 128 - it is neither a predecessor nor a successor,
* - after adding more than 127 to the starting value - it is a successor */
* - after adding more than 127 to the starting value - it is a successor
*/
#define seq_before(x, y) ({typeof(x) _d1 = (x); \
typeof(y) _d2 = (y); \
typeof(x) _dummy = (_d1 - _d2); \
......
/*
* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -35,7 +33,7 @@ static void purge_orig(struct work_struct *work);
static void start_purge_timer(struct bat_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig);
queue_delayed_work(bat_event_workqueue,
queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work, msecs_to_jiffies(1000));
}
......@@ -47,12 +45,12 @@ static int compare_orig(const struct hlist_node *node, const void *data2)
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
}
int originator_init(struct bat_priv *bat_priv)
int batadv_originator_init(struct bat_priv *bat_priv)
{
if (bat_priv->orig_hash)
return 0;
bat_priv->orig_hash = hash_new(1024);
bat_priv->orig_hash = batadv_hash_new(1024);
if (!bat_priv->orig_hash)
goto err;
......@@ -64,14 +62,14 @@ int originator_init(struct bat_priv *bat_priv)
return -ENOMEM;
}
void neigh_node_free_ref(struct neigh_node *neigh_node)
void batadv_neigh_node_free_ref(struct neigh_node *neigh_node)
{
if (atomic_dec_and_test(&neigh_node->refcount))
kfree_rcu(neigh_node, rcu);
}
/* increases the refcounter of a found router */
struct neigh_node *orig_node_get_router(struct orig_node *orig_node)
struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node)
{
struct neigh_node *router;
......@@ -126,20 +124,20 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
list_for_each_entry_safe(neigh_node, tmp_neigh_node,
&orig_node->bond_list, bonding_list) {
list_del_rcu(&neigh_node->bonding_list);
neigh_node_free_ref(neigh_node);
batadv_neigh_node_free_ref(neigh_node);
}
/* for all neighbors towards this originator ... */
hlist_for_each_entry_safe(neigh_node, node, node_tmp,
&orig_node->neigh_list, list) {
hlist_del_rcu(&neigh_node->list);
neigh_node_free_ref(neigh_node);
batadv_neigh_node_free_ref(neigh_node);
}
spin_unlock_bh(&orig_node->neigh_list_lock);
frag_list_free(&orig_node->frag_list);
tt_global_del_orig(orig_node->bat_priv, orig_node,
batadv_frag_list_free(&orig_node->frag_list);
batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
"originator timed out");
kfree(orig_node->tt_buff);
......@@ -148,13 +146,13 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
kfree(orig_node);
}
void orig_node_free_ref(struct orig_node *orig_node)
void batadv_orig_node_free_ref(struct orig_node *orig_node)
{
if (atomic_dec_and_test(&orig_node->refcount))
call_rcu(&orig_node->rcu, orig_node_free_rcu);
}
void originator_free(struct bat_priv *bat_priv)
void batadv_originator_free(struct bat_priv *bat_priv)
{
struct hashtable_t *hash = bat_priv->orig_hash;
struct hlist_node *node, *node_tmp;
......@@ -179,17 +177,19 @@ void originator_free(struct bat_priv *bat_priv)
head, hash_entry) {
hlist_del_rcu(node);
orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
}
spin_unlock_bh(list_lock);
}
hash_destroy(hash);
batadv_hash_destroy(hash);
}
/* this function finds or creates an originator entry for the given
* address if it does not exits */
struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
* address if it does not exits
*/
struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
const uint8_t *addr)
{
struct orig_node *orig_node;
int size;
......@@ -306,8 +306,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
neigh_purged = true;
hlist_del_rcu(&neigh_node->list);
bonding_candidate_del(orig_node, neigh_node);
neigh_node_free_ref(neigh_node);
batadv_bonding_candidate_del(orig_node, neigh_node);
batadv_neigh_node_free_ref(neigh_node);
} else {
if ((!*best_neigh_node) ||
(neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
......@@ -333,7 +333,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
} else {
if (purge_orig_neighbors(bat_priv, orig_node,
&best_neigh_node))
update_route(bat_priv, orig_node, best_neigh_node);
batadv_update_route(bat_priv, orig_node,
best_neigh_node);
}
return false;
......@@ -361,21 +362,22 @@ static void _purge_orig(struct bat_priv *bat_priv)
head, hash_entry) {
if (purge_orig_node(bat_priv, orig_node)) {
if (orig_node->gw_flags)
gw_node_delete(bat_priv, orig_node);
batadv_gw_node_delete(bat_priv,
orig_node);
hlist_del_rcu(node);
orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
continue;
}
if (has_timed_out(orig_node->last_frag_packet,
FRAG_TIMEOUT))
frag_list_free(&orig_node->frag_list);
batadv_frag_list_free(&orig_node->frag_list);
}
spin_unlock_bh(list_lock);
}
gw_node_purge(bat_priv);
gw_election(bat_priv);
batadv_gw_node_purge(bat_priv);
batadv_gw_election(bat_priv);
}
static void purge_orig(struct work_struct *work)
......@@ -389,12 +391,12 @@ static void purge_orig(struct work_struct *work)
start_purge_timer(bat_priv);
}
void purge_orig_ref(struct bat_priv *bat_priv)
void batadv_purge_orig_ref(struct bat_priv *bat_priv)
{
_purge_orig(bat_priv);
}
int orig_seq_print_text(struct seq_file *seq, void *offset)
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev);
......@@ -438,7 +440,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
neigh_node = orig_node_get_router(orig_node);
neigh_node = batadv_orig_node_get_router(orig_node);
if (!neigh_node)
continue;
......@@ -467,7 +469,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
batman_count++;
next:
neigh_node_free_ref(neigh_node);
batadv_neigh_node_free_ref(neigh_node);
}
rcu_read_unlock();
}
......@@ -507,7 +509,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
return 0;
}
int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct hashtable_t *hash = bat_priv->orig_hash;
......@@ -518,7 +520,8 @@ int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
int ret;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
* if_num */
* if_num
*/
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
......@@ -589,7 +592,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
return 0;
}
int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct hashtable_t *hash = bat_priv->orig_hash;
......@@ -601,7 +604,8 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
int ret;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
* if_num */
* if_num
*/
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
......@@ -620,7 +624,7 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
/* renumber remaining batman interfaces _inside_ of orig_hash_lock */
rcu_read_lock();
list_for_each_entry_rcu(hard_iface_tmp, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) {
if (hard_iface_tmp->if_status == IF_NOT_IN_USE)
continue;
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
......@@ -24,23 +22,25 @@
#include "hash.h"
int originator_init(struct bat_priv *bat_priv);
void originator_free(struct bat_priv *bat_priv);
void purge_orig_ref(struct bat_priv *bat_priv);
void orig_node_free_ref(struct orig_node *orig_node);
struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr);
int batadv_originator_init(struct bat_priv *bat_priv);
void batadv_originator_free(struct bat_priv *bat_priv);
void batadv_purge_orig_ref(struct bat_priv *bat_priv);
void batadv_orig_node_free_ref(struct orig_node *orig_node);
struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
const uint8_t *addr);
struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
const uint8_t *neigh_addr,
uint32_t seqno);
void neigh_node_free_ref(struct neigh_node *neigh_node);
struct neigh_node *orig_node_get_router(struct orig_node *orig_node);
int orig_seq_print_text(struct seq_file *seq, void *offset);
int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num);
int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
void batadv_neigh_node_free_ref(struct neigh_node *neigh_node);
struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node);
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num);
int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
/* hashfunction to choose an entry in a hash table of given size */
/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
/* hashfunction to choose an entry in a hash table of given size
* hash algorithm from http://en.wikipedia.org/wiki/Hash_table
*/
static inline uint32_t choose_orig(const void *data, uint32_t size)
{
const unsigned char *key = data;
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_PACKET_H_
......@@ -81,7 +79,8 @@ enum tt_query_flags {
/* TT_CLIENT flags.
* Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to
* 1 << 15 are used for local computation only */
* 1 << 15 are used for local computation only
*/
enum tt_client_flags {
TT_CLIENT_DEL = 1 << 0,
TT_CLIENT_ROAM = 1 << 1,
......@@ -142,7 +141,8 @@ struct icmp_packet {
#define BAT_RR_LEN 16
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets */
* as this is assumed by code that handles ICMP packets
*/
struct icmp_packet_rr {
struct batman_header header;
uint8_t msg_type; /* see ICMP message types above */
......@@ -192,7 +192,8 @@ struct tt_query_packet {
struct batman_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE */
* - TT_FULL_TABLE
*/
uint8_t flags;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];
......@@ -200,12 +201,14 @@ struct tt_query_packet {
* if TT_REQUEST: ttvn that triggered the
* request
* if TT_RESPONSE: new ttvn for the src
* orig_node */
* orig_node
*/
uint8_t ttvn;
/* tt_data field is:
* if TT_REQUEST: crc associated with the
* ttvn
* if TT_RESPONSE: table_size */
* if TT_RESPONSE: table_size
*/
__be16 tt_data;
} __packed;
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,19 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
#include "ring_buffer.h"
void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value)
void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
uint8_t value)
{
lq_recv[*lq_index] = value;
*lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE;
}
uint8_t ring_buffer_avg(const uint8_t lq_recv[])
uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
{
const uint8_t *ptr;
uint16_t count = 0, i = 0, sum = 0;
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,13 +15,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_RING_BUFFER_H_
#define _NET_BATMAN_ADV_RING_BUFFER_H_
void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value);
uint8_t ring_buffer_avg(const uint8_t lq_recv[]);
void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
uint8_t value);
uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]);
#endif /* _NET_BATMAN_ADV_RING_BUFFER_H_ */
This diff is collapsed.
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,36 +15,37 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_ROUTING_H_
#define _NET_BATMAN_ADV_ROUTING_H_
void slide_own_bcast_window(struct hard_iface *hard_iface);
bool check_management_packet(struct sk_buff *skb,
void batadv_slide_own_bcast_window(struct hard_iface *hard_iface);
bool batadv_check_management_packet(struct sk_buff *skb,
struct hard_iface *hard_iface,
int header_len);
void update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
struct neigh_node *neigh_node);
int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if);
struct neigh_node *find_router(struct bat_priv *bat_priv,
int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct hard_iface *recv_if);
int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if);
struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const struct hard_iface *recv_if);
void bonding_candidate_del(struct orig_node *orig_node,
void batadv_bonding_candidate_del(struct orig_node *orig_node,
struct neigh_node *neigh_node);
void bonding_candidate_add(struct orig_node *orig_node,
void batadv_bonding_candidate_add(struct orig_node *orig_node,
struct neigh_node *neigh_node);
void bonding_save_primary(const struct orig_node *orig_node,
void batadv_bonding_save_primary(const struct orig_node *orig_node,
struct orig_node *orig_neigh_node,
const struct batman_ogm_packet *batman_ogm_packet);
int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
const struct batman_ogm_packet
*batman_ogm_packet);
int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
unsigned long *last_reset);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -32,8 +30,9 @@
static void send_outstanding_bcast_packet(struct work_struct *work);
/* send out an already prepared packet to the given address via the
* specified batman interface */
int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
* specified batman interface
*/
int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
const uint8_t *dst_addr)
{
struct ethhdr *ethhdr;
......@@ -51,7 +50,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
}
/* push to the ethernet header. */
if (my_skb_head_push(skb, ETH_HLEN) < 0)
if (batadv_skb_head_push(skb, ETH_HLEN) < 0)
goto send_skb_err;
skb_reset_mac_header(skb);
......@@ -69,15 +68,15 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
/* dev_queue_xmit() returns a negative result on error. However on
* congestion and traffic shaping, it drops and returns NET_XMIT_DROP
* (which is > 0). This will not be treated as an error. */
* (which is > 0). This will not be treated as an error.
*/
return dev_queue_xmit(skb);
send_skb_err:
kfree_skb(skb);
return NET_XMIT_DROP;
}
void schedule_bat_ogm(struct hard_iface *hard_iface)
void batadv_schedule_bat_ogm(struct hard_iface *hard_iface)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
......@@ -85,8 +84,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
(hard_iface->if_status == IF_TO_BE_REMOVED))
return;
/**
* the interface gets activated here to avoid race conditions between
/* the interface gets activated here to avoid race conditions between
* the moment of activating the interface in
* hardif_activate_interface() where the originator mac is set and
* outdated packets (especially uninitialized mac addresses) in the
......@@ -121,7 +119,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
/* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet->delayed_work,
send_outstanding_bcast_packet);
queue_delayed_work(bat_event_workqueue, &forw_packet->delayed_work,
queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
send_time);
}
......@@ -132,9 +130,11 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
* errors.
*
* The skb is not consumed, so the caller should make sure that the
* skb is freed. */
int add_bcast_packet_to_list(struct bat_priv *bat_priv,
const struct sk_buff *skb, unsigned long delay)
* skb is freed.
*/
int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
const struct sk_buff *skb,
unsigned long delay)
{
struct hard_iface *primary_if = NULL;
struct forw_packet *forw_packet;
......@@ -204,14 +204,15 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
/* rebroadcast packet */
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->soft_iface != soft_iface)
continue;
/* send a copy of the saved skb */
skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
if (skb1)
send_skb_packet(skb1, hard_iface, broadcast_addr);
batadv_send_skb_packet(skb1, hard_iface,
batadv_broadcast_addr);
}
rcu_read_unlock();
......@@ -229,7 +230,7 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
atomic_inc(&bat_priv->bcast_queue_left);
}
void send_outstanding_bat_ogm_packet(struct work_struct *work)
void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work)
{
struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work);
......@@ -247,13 +248,12 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet);
/**
* we have to have at least one packet in the queue
/* we have to have at least one packet in the queue
* to determine the queues wake up time unless we are
* shutting down
*/
if (forw_packet->own)
schedule_bat_ogm(forw_packet->if_incoming);
batadv_schedule_bat_ogm(forw_packet->if_incoming);
out:
/* don't count own packet */
......@@ -263,7 +263,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
forw_packet_free(forw_packet);
}
void purge_outstanding_packets(struct bat_priv *bat_priv,
void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
const struct hard_iface *hard_iface)
{
struct forw_packet *forw_packet;
......@@ -283,8 +283,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
&bat_priv->forw_bcast_list, list) {
/**
* if purge_outstanding_packets() was called with an argument
/* if purge_outstanding_packets() was called with an argument
* we delete only packets belonging to the given interface
*/
if ((hard_iface) &&
......@@ -293,8 +292,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
/**
* send_outstanding_bcast_packet() will lock the list to
/* send_outstanding_bcast_packet() will lock the list to
* delete the item from the list
*/
pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
......@@ -312,8 +310,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
&bat_priv->forw_bat_list, list) {
/**
* if purge_outstanding_packets() was called with an argument
/* if purge_outstanding_packets() was called with an argument
* we delete only packets belonging to the given interface
*/
if ((hard_iface) &&
......@@ -322,8 +319,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bat_list_lock);
/**
* send_outstanding_bat_packet() will lock the list to
/* send_outstanding_bat_packet() will lock the list to
* delete the item from the list
*/
pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,19 +15,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_SEND_H_
#define _NET_BATMAN_ADV_SEND_H_
int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
const uint8_t *dst_addr);
void schedule_bat_ogm(struct hard_iface *hard_iface);
int add_bcast_packet_to_list(struct bat_priv *bat_priv,
const struct sk_buff *skb, unsigned long delay);
void send_outstanding_bat_ogm_packet(struct work_struct *work);
void purge_outstanding_packets(struct bat_priv *bat_priv,
void batadv_schedule_bat_ogm(struct hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
const struct sk_buff *skb,
unsigned long delay);
void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work);
void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
const struct hard_iface *hard_iface);
#endif /* _NET_BATMAN_ADV_SEND_H_ */
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -61,12 +59,11 @@ static const struct ethtool_ops bat_ethtool_ops = {
.get_sset_count = batadv_get_sset_count,
};
int my_skb_head_push(struct sk_buff *skb, unsigned int len)
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
{
int result;
/**
* TODO: We must check if we can release all references to non-payload
/* TODO: We must check if we can release all references to non-payload
* data using skb_header_release in our skbs to allow skb_cow_header to
* work optimally. This means that those skbs are not allowed to read
* or write any data which is before the current position of skb->data
......@@ -109,9 +106,9 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
/* only modify transtable if it has been initialized before */
if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
tt_local_remove(bat_priv, dev->dev_addr,
batadv_tt_local_remove(bat_priv, dev->dev_addr,
"mac address changed", false);
tt_local_add(dev, addr->sa_data, NULL_IFINDEX);
batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX);
}
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
......@@ -122,7 +119,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
static int interface_change_mtu(struct net_device *dev, int new_mtu)
{
/* check ranges */
if ((new_mtu < 68) || (new_mtu > hardif_min_mtu(dev)))
if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
return -EINVAL;
dev->mtu = new_mtu;
......@@ -162,11 +159,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
goto dropped;
}
if (bla_tx(bat_priv, skb, vid))
if (batadv_bla_tx(bat_priv, skb, vid))
goto dropped;
/* Register the client MAC in the transtable */
tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
/* don't accept stp packets. STP does not help in meshes.
* better use the bridge loop avoidance ...
......@@ -180,15 +177,17 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
switch (atomic_read(&bat_priv->gw_mode)) {
case GW_MODE_SERVER:
/* gateway servers should not send dhcp
* requests into the mesh */
ret = gw_is_dhcp_target(skb, &header_len);
* requests into the mesh
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
goto dropped;
break;
case GW_MODE_CLIENT:
/* gateway clients should send dhcp requests
* via unicast to their gateway */
ret = gw_is_dhcp_target(skb, &header_len);
* via unicast to their gateway
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
do_bcast = false;
break;
......@@ -204,7 +203,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
if (!primary_if)
goto dropped;
if (my_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
goto dropped;
bcast_packet = (struct bcast_packet *)skb->data;
......@@ -215,7 +214,8 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
bcast_packet->header.packet_type = BAT_BCAST;
/* hw address of first interface is the orig mac because only
* this mac is known throughout the mesh */
* this mac is known throughout the mesh
*/
memcpy(bcast_packet->orig,
primary_if->net_dev->dev_addr, ETH_ALEN);
......@@ -223,21 +223,22 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
bcast_packet->seqno =
htonl(atomic_inc_return(&bat_priv->bcast_seqno));
add_bcast_packet_to_list(bat_priv, skb, 1);
batadv_add_bcast_packet_to_list(bat_priv, skb, 1);
/* a copy is stored in the bcast list, therefore removing
* the original skb. */
* the original skb.
*/
kfree_skb(skb);
/* unicast packet */
} else {
if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) {
ret = gw_out_of_range(bat_priv, skb, ethhdr);
ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
if (ret)
goto dropped;
}
ret = unicast_send_skb(skb, bat_priv);
ret = batadv_unicast_send_skb(skb, bat_priv);
if (ret != 0)
goto dropped_freed;
}
......@@ -256,7 +257,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
return NETDEV_TX_OK;
}
void interface_rx(struct net_device *soft_iface,
void batadv_interface_rx(struct net_device *soft_iface,
struct sk_buff *skb, struct hard_iface *recv_if,
int hdr_size)
{
......@@ -294,22 +295,23 @@ void interface_rx(struct net_device *soft_iface,
/* should not be necessary anymore as we use skb_pull_rcsum()
* TODO: please verify this and remove this TODO
* -- Dec 21st 2009, Simon Wunderlich */
* -- Dec 21st 2009, Simon Wunderlich
*/
/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/
/* skb->ip_summed = CHECKSUM_UNNECESSARY; */
bat_priv->stats.rx_packets++;
bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
soft_iface->last_rx = jiffies;
if (is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
goto dropped;
/* Let the bridge loop avoidance check the packet. If will
* not handle it, we can safely push it up.
*/
if (bla_rx(bat_priv, skb, vid))
if (batadv_bla_rx(bat_priv, skb, vid))
goto out;
netif_rx(skb);
......@@ -341,8 +343,7 @@ static void interface_setup(struct net_device *dev)
dev->destructor = free_netdev;
dev->tx_queue_len = 0;
/**
* can't call min_mtu, because the needed variables
/* can't call min_mtu, because the needed variables
* have not been initialized yet
*/
dev->mtu = ETH_DATA_LEN;
......@@ -357,7 +358,7 @@ static void interface_setup(struct net_device *dev)
memset(priv, 0, sizeof(*priv));
}
struct net_device *softif_create(const char *name)
struct net_device *batadv_softif_create(const char *name)
{
struct net_device *soft_iface;
struct bat_priv *bat_priv;
......@@ -411,28 +412,28 @@ struct net_device *softif_create(const char *name)
if (!bat_priv->bat_counters)
goto unreg_soft_iface;
ret = bat_algo_select(bat_priv, bat_routing_algo);
ret = batadv_algo_select(bat_priv, batadv_routing_algo);
if (ret < 0)
goto free_bat_counters;
ret = sysfs_add_meshif(soft_iface);
ret = batadv_sysfs_add_meshif(soft_iface);
if (ret < 0)
goto free_bat_counters;
ret = debugfs_add_meshif(soft_iface);
ret = batadv_debugfs_add_meshif(soft_iface);
if (ret < 0)
goto unreg_sysfs;
ret = mesh_init(soft_iface);
ret = batadv_mesh_init(soft_iface);
if (ret < 0)
goto unreg_debugfs;
return soft_iface;
unreg_debugfs:
debugfs_del_meshif(soft_iface);
batadv_debugfs_del_meshif(soft_iface);
unreg_sysfs:
sysfs_del_meshif(soft_iface);
batadv_sysfs_del_meshif(soft_iface);
free_bat_counters:
free_percpu(bat_priv->bat_counters);
unreg_soft_iface:
......@@ -445,15 +446,15 @@ struct net_device *softif_create(const char *name)
return NULL;
}
void softif_destroy(struct net_device *soft_iface)
void batadv_softif_destroy(struct net_device *soft_iface)
{
debugfs_del_meshif(soft_iface);
sysfs_del_meshif(soft_iface);
mesh_free(soft_iface);
batadv_debugfs_del_meshif(soft_iface);
batadv_sysfs_del_meshif(soft_iface);
batadv_mesh_free(soft_iface);
unregister_netdevice(soft_iface);
}
int softif_is_valid(const struct net_device *net_dev)
int batadv_softif_is_valid(const struct net_device *net_dev)
{
if (net_dev->netdev_ops->ndo_start_xmit == interface_tx)
return 1;
......
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
......@@ -16,18 +15,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_
#define _NET_BATMAN_ADV_SOFT_INTERFACE_H_
int my_skb_head_push(struct sk_buff *skb, unsigned int len);
void interface_rx(struct net_device *soft_iface,
struct sk_buff *skb, struct hard_iface *recv_if,
int hdr_size);
struct net_device *softif_create(const char *name);
void softif_destroy(struct net_device *soft_iface);
int softif_is_valid(const struct net_device *net_dev);
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb,
struct hard_iface *recv_if, int hdr_size);
struct net_device *batadv_softif_create(const char *name);
void batadv_softif_destroy(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev);
#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
This diff is collapsed.
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich, Antonio Quartulli
*
......@@ -16,43 +15,49 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
int tt_len(int changes_num);
int tt_init(struct bat_priv *bat_priv);
void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int batadv_tt_len(int changes_num);
int batadv_tt_init(struct bat_priv *bat_priv);
void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex);
void tt_local_remove(struct bat_priv *bat_priv,
const uint8_t *addr, const char *message, bool roaming);
int tt_local_seq_print_text(struct seq_file *seq, void *offset);
void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
void batadv_tt_local_remove(struct bat_priv *bat_priv,
const uint8_t *addr, const char *message,
bool roaming);
int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff, int tt_buff_len);
int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
const unsigned char *addr, uint8_t ttvn, bool roaming,
bool wifi);
int tt_global_seq_print_text(struct seq_file *seq, void *offset);
void tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, const char *message);
struct orig_node *transtable_search(struct bat_priv *bat_priv,
const uint8_t *src, const uint8_t *addr);
void tt_free(struct bat_priv *bat_priv);
bool send_tt_response(struct bat_priv *bat_priv,
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const char *message);
struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
const uint8_t *src,
const uint8_t *addr);
void batadv_tt_free(struct bat_priv *bat_priv);
bool batadv_send_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_request);
bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr);
void handle_tt_response(struct bat_priv *bat_priv,
bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr);
void batadv_handle_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_response);
bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst);
void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
uint8_t *dst);
void batadv_tt_update_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc);
int batadv_tt_append_diff(struct bat_priv *bat_priv,
unsigned char **packet_buff, int *packet_buff_len,
int packet_min_len);
bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr);
bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
uint8_t *addr);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
/*
* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
......@@ -16,11 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_TYPES_H_
#define _NET_BATMAN_ADV_TYPES_H_
......@@ -49,8 +45,7 @@ struct hard_iface {
struct rcu_head rcu;
};
/**
* orig_node - structure for orig_list maintaining nodes of mesh
/* orig_node - structure for orig_list maintaining nodes of mesh
* @primary_addr: hosts primary interface address
* @last_seen: when last packet from this node was received
* @bcast_seqno_reset: time when the broadcast seqno window was reset
......@@ -86,7 +81,8 @@ struct orig_node {
* If true, then I sent a Roaming_adv to this orig_node and I have to
* inspect every packet directed to it to check whether it is still
* the true destination or not. This flag will be reset to false as
* soon as I receive a new TTVN from this orig_node */
* soon as I receive a new TTVN from this orig_node
*/
bool tt_poss_change;
uint32_t last_real_seqno;
uint8_t last_ttl;
......@@ -101,7 +97,8 @@ struct orig_node {
struct bat_priv *bat_priv;
unsigned long last_frag_packet;
/* ogm_cnt_lock protects: bcast_own, bcast_own_sum,
* neigh_node->real_bits, neigh_node->real_packet_count */
* neigh_node->real_bits, neigh_node->real_packet_count
*/
spinlock_t ogm_cnt_lock;
/* bcast_seqno_lock protects bcast_bits, last_bcast_seqno */
spinlock_t bcast_seqno_lock;
......@@ -118,8 +115,7 @@ struct gw_node {
struct rcu_head rcu;
};
/**
* neigh_node
/* neigh_node
* @last_seen: when last packet via this neighbor was received
*/
struct neigh_node {
......@@ -191,7 +187,8 @@ struct bat_priv {
* If true, then I received a Roaming_adv and I have to inspect every
* packet directed to me to check whether I am still the true
* destination or not. This flag will be reset to false as soon as I
* increase my TTVN */
* increase my TTVN
*/
bool tt_poss_change;
char num_ifaces;
struct debug_log *debug_log;
......@@ -326,8 +323,7 @@ struct tt_roam_node {
struct list_head list;
};
/**
* forw_packet - structure for forw_list maintaining packets to be
/* forw_packet - structure for forw_list maintaining packets to be
* send/forwarded
*/
struct forw_packet {
......@@ -369,7 +365,8 @@ struct frag_packet_list_entry {
struct vis_info {
unsigned long first_seen;
/* list of server-neighbors we received a vis-packet
* from. we should not reply to them. */
* from. we should not reply to them.
*/
struct list_head recv_list;
struct list_head send_list;
struct kref refcount;
......@@ -377,7 +374,7 @@ struct vis_info {
struct bat_priv *bat_priv;
/* this packet might be part of the vis send queue. */
struct sk_buff *skb_packet;
/* vis_info may follow here*/
/* vis_info may follow here */
} __packed;
struct vis_info_entry {
......
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Andreas Langer
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#include "main.h"
......@@ -101,7 +99,7 @@ static int frag_create_buffer(struct list_head *head)
for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC);
if (!tfp) {
frag_list_free(head);
batadv_frag_list_free(head);
return -ENOMEM;
}
tfp->skb = NULL;
......@@ -151,7 +149,7 @@ static struct frag_packet_list_entry *frag_search_packet(struct list_head *head,
return NULL;
}
void frag_list_free(struct list_head *head)
void batadv_frag_list_free(struct list_head *head)
{
struct frag_packet_list_entry *pf, *tmp_pf;
......@@ -172,7 +170,7 @@ void frag_list_free(struct list_head *head)
* or the skb could be reassembled (skb_new will point to the new packet and
* skb was freed)
*/
int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct sk_buff **new_skb)
{
struct orig_node *orig_node;
......@@ -212,11 +210,11 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
out:
if (orig_node)
orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
return ret;
}
int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct hard_iface *hard_iface, const uint8_t dstaddr[])
{
struct unicast_packet tmp_uc, *unicast_packet;
......@@ -242,8 +240,8 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
memcpy(&tmp_uc, unicast_packet, uc_hdr_len);
skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len);
if (my_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 ||
my_skb_head_push(frag_skb, ucf_hdr_len) < 0)
if (batadv_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 ||
batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0)
goto drop_frag;
frag1 = (struct unicast_frag_packet *)skb->data;
......@@ -268,8 +266,8 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
frag1->seqno = htons(seqno - 1);
frag2->seqno = htons(seqno);
send_skb_packet(skb, hard_iface, dstaddr);
send_skb_packet(frag_skb, hard_iface, dstaddr);
batadv_send_skb_packet(skb, hard_iface, dstaddr);
batadv_send_skb_packet(frag_skb, hard_iface, dstaddr);
ret = NET_RX_SUCCESS;
goto out;
......@@ -283,7 +281,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
return ret;
}
int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
{
struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct unicast_packet *unicast_packet;
......@@ -294,28 +292,26 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
/* get routing information */
if (is_multicast_ether_addr(ethhdr->h_dest)) {
orig_node = gw_get_selected_orig(bat_priv);
orig_node = batadv_gw_get_selected_orig(bat_priv);
if (orig_node)
goto find_router;
}
/* check for tt host - increases orig_node refcount.
* returns NULL in case of AP isolation */
orig_node = transtable_search(bat_priv, ethhdr->h_source,
* returns NULL in case of AP isolation
*/
orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest);
find_router:
/**
* find_router():
/* find_router():
* - if orig_node is NULL it returns NULL
* - increases neigh_nodes refcount if found.
*/
neigh_node = find_router(bat_priv, orig_node, NULL);
neigh_node = batadv_find_router(bat_priv, orig_node, NULL);
if (!neigh_node)
goto out;
if (my_skb_head_push(skb, sizeof(*unicast_packet)) < 0)
if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0)
goto out;
unicast_packet = (struct unicast_packet *)skb->data;
......@@ -336,7 +332,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
* try to reroute it because the ttvn contained in the header is less
* than the current one
*/
if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
unicast_packet->ttvn = unicast_packet->ttvn - 1;
if (atomic_read(&bat_priv->fragmentation) &&
......@@ -344,20 +340,21 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
neigh_node->if_incoming->net_dev->mtu) {
/* send frag skb decreases ttl */
unicast_packet->header.ttl++;
ret = frag_send_skb(skb, bat_priv,
neigh_node->if_incoming, neigh_node->addr);
ret = batadv_frag_send_skb(skb, bat_priv,
neigh_node->if_incoming,
neigh_node->addr);
goto out;
}
send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
ret = 0;
goto out;
out:
if (neigh_node)
neigh_node_free_ref(neigh_node);
batadv_neigh_node_free_ref(neigh_node);
if (orig_node)
orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);
if (ret == 1)
kfree_skb(skb);
return ret;
......
/*
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
*
* Andreas Langer
*
......@@ -16,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_UNICAST_H_
......@@ -27,12 +25,13 @@
#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */
#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct sk_buff **new_skb);
void frag_list_free(struct list_head *head);
int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct hard_iface *hard_iface, const uint8_t dstaddr[]);
void batadv_frag_list_free(struct list_head *head);
int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct hard_iface *hard_iface,
const uint8_t dstaddr[]);
static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu)
{
......
This diff is collapsed.
/*
* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
/* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
*
......@@ -16,23 +15,22 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_VIS_H_
#define _NET_BATMAN_ADV_VIS_H_
#define VIS_TIMEOUT 200000 /* timeout of vis packets
* in miliseconds */
/* timeout of vis packets in miliseconds */
#define VIS_TIMEOUT 200000
int vis_seq_print_text(struct seq_file *seq, void *offset);
void receive_server_sync_packet(struct bat_priv *bat_priv,
int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet,
int vis_info_len);
void receive_client_update_packet(struct bat_priv *bat_priv,
void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet,
int vis_info_len);
int vis_init(struct bat_priv *bat_priv);
void vis_quit(struct bat_priv *bat_priv);
int batadv_vis_init(struct bat_priv *bat_priv);
void batadv_vis_quit(struct bat_priv *bat_priv);
#endif /* _NET_BATMAN_ADV_VIS_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment