Commit e87183c2 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:
- The last batch of patches aimed to clean the batman-adv namespace
- a couple of style fixes
- a fix for the ethtool support
- a fix to prevent sending unicast packets with an uninitialised header
  field
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a59a4d19 162d549c
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
# #
obj-$(CONFIG_BATMAN_ADV) += batman-adv.o obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
batman-adv-y += bat_debugfs.o
batman-adv-y += bat_iv_ogm.o batman-adv-y += bat_iv_ogm.o
batman-adv-y += bat_sysfs.o
batman-adv-y += bitarray.o batman-adv-y += bitarray.o
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
batman-adv-y += debugfs.o
batman-adv-y += gateway_client.o batman-adv-y += gateway_client.o
batman-adv-y += gateway_common.o batman-adv-y += gateway_common.o
batman-adv-y += hard-interface.o batman-adv-y += hard-interface.o
...@@ -35,6 +34,7 @@ batman-adv-y += ring_buffer.o ...@@ -35,6 +34,7 @@ batman-adv-y += ring_buffer.o
batman-adv-y += routing.o batman-adv-y += routing.o
batman-adv-y += send.o batman-adv-y += send.o
batman-adv-y += soft-interface.o batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-y += translation-table.o batman-adv-y += translation-table.o
batman-adv-y += unicast.o batman-adv-y += unicast.o
batman-adv-y += vis.o batman-adv-y += vis.o
This diff is collapsed.
...@@ -41,7 +41,7 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) ...@@ -41,7 +41,7 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
int batadv_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) int32_t seq_num_diff, int set_mark)
{ {
struct bat_priv *bat_priv = priv; struct batadv_priv *bat_priv = priv;
/* sequence number is slightly older. We already got a sequence number /* 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.
...@@ -66,7 +66,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -66,7 +66,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
/* sequence number is much newer, probably missed a lot of packets */ /* sequence number is much newer, probably missed a lot of packets */
if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE && if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) { seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"We missed a lot of packets (%i) !\n", "We missed a lot of packets (%i) !\n",
seq_num_diff - 1); seq_num_diff - 1);
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
...@@ -83,7 +83,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -83,7 +83,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Other host probably restarted!\n"); "Other host probably restarted!\n");
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
......
This diff is collapsed.
...@@ -21,38 +21,38 @@ ...@@ -21,38 +21,38 @@
#define _NET_BATMAN_ADV_BLA_H_ #define _NET_BATMAN_ADV_BLA_H_
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_rx(struct batadv_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_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_is_backbone_gw(struct sk_buff *skb, int batadv_bla_is_backbone_gw(struct sk_buff *skb,
struct orig_node *orig_node, int hdr_size); struct batadv_orig_node *orig_node, int hdr_size);
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 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_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig);
int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
struct bcast_packet *bcast_packet, struct batadv_bcast_packet *bcast_packet,
int hdr_size); int hdr_size);
void batadv_bla_update_orig_address(struct bat_priv *bat_priv, void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
struct hard_iface *primary_if, struct batadv_hard_iface *primary_if,
struct hard_iface *oldif); struct batadv_hard_iface *oldif);
int batadv_bla_init(struct bat_priv *bat_priv); int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct bat_priv *bat_priv); void batadv_bla_free(struct batadv_priv *bat_priv);
#define BATADV_BLA_CRC_INIT 0 #define BATADV_BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */ #else /* ifdef CONFIG_BATMAN_ADV_BLA */
static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, static inline int batadv_bla_rx(struct batadv_priv *bat_priv,
short vid) struct sk_buff *skb, short vid)
{ {
return 0; return 0;
} }
static inline int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, static inline int batadv_bla_tx(struct batadv_priv *bat_priv,
short vid) struct sk_buff *skb, short vid)
{ {
return 0; return 0;
} }
static inline int batadv_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, struct batadv_orig_node *orig_node,
int hdr_size) int hdr_size)
{ {
return 0; return 0;
...@@ -64,33 +64,33 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, ...@@ -64,33 +64,33 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
return 0; return 0;
} }
static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
uint8_t *orig) uint8_t *orig)
{ {
return 0; return 0;
} }
static inline int static inline int
batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
struct bcast_packet *bcast_packet, struct batadv_bcast_packet *bcast_packet,
int hdr_size) int hdr_size)
{ {
return 0; return 0;
} }
static inline void static inline void
batadv_bla_update_orig_address(struct bat_priv *bat_priv, batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
struct hard_iface *primary_if, struct batadv_hard_iface *primary_if,
struct hard_iface *oldif) struct batadv_hard_iface *oldif)
{ {
} }
static inline int batadv_bla_init(struct bat_priv *bat_priv) static inline int batadv_bla_init(struct batadv_priv *bat_priv)
{ {
return 1; return 1;
} }
static inline void batadv_bla_free(struct bat_priv *bat_priv) static inline void batadv_bla_free(struct batadv_priv *bat_priv)
{ {
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include "bat_debugfs.h" #include "debugfs.h"
#include "translation-table.h" #include "translation-table.h"
#include "originator.h" #include "originator.h"
#include "hard-interface.h" #include "hard-interface.h"
...@@ -36,13 +36,21 @@ static struct dentry *batadv_debugfs; ...@@ -36,13 +36,21 @@ static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
static int batadv_log_buff_len = BATADV_LOG_BUF_LEN; static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static void batadv_emit_log_char(struct debug_log *debug_log, char c) static char *batadv_log_char_addr(struct batadv_debug_log *debug_log,
size_t idx)
{ {
BATADV_LOG_BUFF(debug_log->log_end) = c; return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
}
static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c)
{
char *char_addr;
char_addr = batadv_log_char_addr(debug_log, debug_log->log_end);
*char_addr = c;
debug_log->log_end++; debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
...@@ -50,7 +58,8 @@ static void batadv_emit_log_char(struct debug_log *debug_log, char c) ...@@ -50,7 +58,8 @@ static void batadv_emit_log_char(struct debug_log *debug_log, char c)
} }
__printf(2, 3) __printf(2, 3)
static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...) static int batadv_fdebug_log(struct batadv_debug_log *debug_log,
const char *fmt, ...)
{ {
va_list args; va_list args;
static char debug_log_buf[256]; static char debug_log_buf[256];
...@@ -74,7 +83,7 @@ static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...) ...@@ -74,7 +83,7 @@ static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
return 0; return 0;
} }
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{ {
va_list args; va_list args;
char tmp_log_buf[256]; char tmp_log_buf[256];
...@@ -102,16 +111,21 @@ static int batadv_log_release(struct inode *inode, struct file *file) ...@@ -102,16 +111,21 @@ static int batadv_log_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int batadv_log_empty(struct batadv_debug_log *debug_log)
{
return !(debug_log->log_start - debug_log->log_end);
}
static ssize_t batadv_log_read(struct file *file, char __user *buf, static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct bat_priv *bat_priv = file->private_data; struct batadv_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log; struct batadv_debug_log *debug_log = bat_priv->debug_log;
int error, i = 0; int error, i = 0;
char *char_addr;
char c; char c;
if ((file->f_flags & O_NONBLOCK) && if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log))
!(debug_log->log_end - debug_log->log_start))
return -EAGAIN; return -EAGAIN;
if (!buf) if (!buf)
...@@ -124,7 +138,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -124,7 +138,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
return -EFAULT; return -EFAULT;
error = wait_event_interruptible(debug_log->queue_wait, error = wait_event_interruptible(debug_log->queue_wait,
(debug_log->log_start - debug_log->log_end)); (!batadv_log_empty(debug_log)));
if (error) if (error)
return error; return error;
...@@ -133,7 +147,9 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -133,7 +147,9 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
while ((!error) && (i < count) && while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) { (debug_log->log_start != debug_log->log_end)) {
c = BATADV_LOG_BUFF(debug_log->log_start); char_addr = batadv_log_char_addr(debug_log,
debug_log->log_start);
c = *char_addr;
debug_log->log_start++; debug_log->log_start++;
...@@ -158,12 +174,12 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -158,12 +174,12 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
static unsigned int batadv_log_poll(struct file *file, poll_table *wait) static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{ {
struct bat_priv *bat_priv = file->private_data; struct batadv_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log; struct batadv_debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait); poll_wait(file, &debug_log->queue_wait, wait);
if (debug_log->log_end - debug_log->log_start) if (!batadv_log_empty(debug_log))
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
return 0; return 0;
...@@ -177,7 +193,7 @@ static const struct file_operations batadv_log_fops = { ...@@ -177,7 +193,7 @@ static const struct file_operations batadv_log_fops = {
.llseek = no_llseek, .llseek = no_llseek,
}; };
static int batadv_debug_log_setup(struct bat_priv *bat_priv) static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{ {
struct dentry *d; struct dentry *d;
...@@ -203,19 +219,19 @@ static int batadv_debug_log_setup(struct bat_priv *bat_priv) ...@@ -203,19 +219,19 @@ static int batadv_debug_log_setup(struct bat_priv *bat_priv)
return -ENOMEM; return -ENOMEM;
} }
static void batadv_debug_log_cleanup(struct bat_priv *bat_priv) static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{ {
kfree(bat_priv->debug_log); kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL; bat_priv->debug_log = NULL;
} }
#else /* CONFIG_BATMAN_ADV_DEBUG */ #else /* CONFIG_BATMAN_ADV_DEBUG */
static int batadv_debug_log_setup(struct bat_priv *bat_priv) static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{ {
bat_priv->debug_log = NULL; bat_priv->debug_log = NULL;
return 0; return 0;
} }
static void batadv_debug_log_cleanup(struct bat_priv *bat_priv) static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{ {
return; return;
} }
...@@ -265,13 +281,13 @@ static int batadv_vis_data_open(struct inode *inode, struct file *file) ...@@ -265,13 +281,13 @@ static int batadv_vis_data_open(struct inode *inode, struct file *file)
return single_open(file, batadv_vis_seq_print_text, net_dev); return single_open(file, batadv_vis_seq_print_text, net_dev);
} }
struct bat_debuginfo { struct batadv_debuginfo {
struct attribute attr; struct attribute attr;
const struct file_operations fops; const struct file_operations fops;
}; };
#define BATADV_DEBUGINFO(_name, _mode, _open) \ #define BATADV_DEBUGINFO(_name, _mode, _open) \
struct bat_debuginfo batadv_debuginfo_##_name = { \ struct batadv_debuginfo batadv_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \ .attr = { .name = __stringify(_name), \
.mode = _mode, }, \ .mode = _mode, }, \
.fops = { .owner = THIS_MODULE, \ .fops = { .owner = THIS_MODULE, \
...@@ -294,7 +310,7 @@ static BATADV_DEBUGINFO(transtable_local, S_IRUGO, ...@@ -294,7 +310,7 @@ static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
batadv_transtable_local_open); batadv_transtable_local_open);
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
static struct bat_debuginfo *batadv_mesh_debuginfos[] = { static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
&batadv_debuginfo_originators, &batadv_debuginfo_originators,
&batadv_debuginfo_gateways, &batadv_debuginfo_gateways,
&batadv_debuginfo_transtable_global, &batadv_debuginfo_transtable_global,
...@@ -308,7 +324,7 @@ static struct bat_debuginfo *batadv_mesh_debuginfos[] = { ...@@ -308,7 +324,7 @@ static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
void batadv_debugfs_init(void) void batadv_debugfs_init(void)
{ {
struct bat_debuginfo *bat_debug; struct batadv_debuginfo *bat_debug;
struct dentry *file; struct dentry *file;
batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
...@@ -339,8 +355,8 @@ void batadv_debugfs_destroy(void) ...@@ -339,8 +355,8 @@ void batadv_debugfs_destroy(void)
int batadv_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 batadv_priv *bat_priv = netdev_priv(dev);
struct bat_debuginfo **bat_debug; struct batadv_debuginfo **bat_debug;
struct dentry *file; struct dentry *file;
if (!batadv_debugfs) if (!batadv_debugfs)
...@@ -382,7 +398,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev) ...@@ -382,7 +398,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
void batadv_debugfs_del_meshif(struct net_device *dev) void batadv_debugfs_del_meshif(struct net_device *dev)
{ {
struct bat_priv *bat_priv = netdev_priv(dev); struct batadv_priv *bat_priv = netdev_priv(dev);
batadv_debug_log_cleanup(bat_priv); batadv_debug_log_cleanup(bat_priv);
......
This diff is collapsed.
...@@ -20,19 +20,21 @@ ...@@ -20,19 +20,21 @@
#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
void batadv_gw_deselect(struct bat_priv *bat_priv); void batadv_gw_deselect(struct batadv_priv *bat_priv);
void batadv_gw_election(struct bat_priv *bat_priv); void batadv_gw_election(struct batadv_priv *bat_priv);
struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv); struct batadv_orig_node *
void batadv_gw_check_election(struct bat_priv *bat_priv, batadv_gw_get_selected_orig(struct batadv_priv *bat_priv);
struct orig_node *orig_node); void batadv_gw_check_election(struct batadv_priv *bat_priv,
void batadv_gw_node_update(struct bat_priv *bat_priv, struct batadv_orig_node *orig_node);
struct orig_node *orig_node, uint8_t new_gwflags); void batadv_gw_node_update(struct batadv_priv *bat_priv,
void batadv_gw_node_delete(struct bat_priv *bat_priv, struct batadv_orig_node *orig_node,
struct orig_node *orig_node); uint8_t new_gwflags);
void batadv_gw_node_purge(struct bat_priv *bat_priv); void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node);
void batadv_gw_node_purge(struct batadv_priv *bat_priv);
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); 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_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool batadv_gw_out_of_range(struct bat_priv *bat_priv, bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct ethhdr *ethhdr); struct sk_buff *skb, struct ethhdr *ethhdr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
...@@ -137,7 +137,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -137,7 +137,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count) size_t count)
{ {
struct bat_priv *bat_priv = netdev_priv(net_dev); struct batadv_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0; long gw_bandwidth_tmp = 0;
int up = 0, down = 0; int up = 0, down = 0;
bool ret; bool ret;
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_ #ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_
#define _NET_BATMAN_ADV_GATEWAY_COMMON_H_ #define _NET_BATMAN_ADV_GATEWAY_COMMON_H_
enum gw_modes { enum batadv_gw_modes {
GW_MODE_OFF, BATADV_GW_MODE_OFF,
GW_MODE_CLIENT, BATADV_GW_MODE_CLIENT,
GW_MODE_SERVER, BATADV_GW_MODE_SERVER,
}; };
#define BATADV_GW_MODE_OFF_NAME "off" #define BATADV_GW_MODE_OFF_NAME "off"
......
This diff is collapsed.
...@@ -20,22 +20,22 @@ ...@@ -20,22 +20,22 @@
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define _NET_BATMAN_ADV_HARD_INTERFACE_H_ #define _NET_BATMAN_ADV_HARD_INTERFACE_H_
enum hard_if_state { enum batadv_hard_if_state {
IF_NOT_IN_USE, BATADV_IF_NOT_IN_USE,
IF_TO_BE_REMOVED, BATADV_IF_TO_BE_REMOVED,
IF_INACTIVE, BATADV_IF_INACTIVE,
IF_ACTIVE, BATADV_IF_ACTIVE,
IF_TO_BE_ACTIVATED, BATADV_IF_TO_BE_ACTIVATED,
IF_I_WANT_YOU BATADV_IF_I_WANT_YOU,
}; };
extern struct notifier_block batadv_hard_if_notifier; extern struct notifier_block batadv_hard_if_notifier;
struct hard_iface* struct batadv_hard_iface*
batadv_hardif_get_by_netdev(const struct net_device *net_dev); batadv_hardif_get_by_netdev(const struct net_device *net_dev);
int batadv_hardif_enable_interface(struct hard_iface *hard_iface, int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
const char *iface_name); const char *iface_name);
void batadv_hardif_disable_interface(struct hard_iface *hard_iface); void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
void batadv_hardif_remove_interfaces(void); void batadv_hardif_remove_interfaces(void);
int batadv_hardif_min_mtu(struct net_device *soft_iface); int batadv_hardif_min_mtu(struct net_device *soft_iface);
void batadv_update_min_mtu(struct net_device *soft_iface); void batadv_update_min_mtu(struct net_device *soft_iface);
...@@ -43,16 +43,16 @@ void batadv_hardif_free_rcu(struct rcu_head *rcu); ...@@ -43,16 +43,16 @@ void batadv_hardif_free_rcu(struct rcu_head *rcu);
bool batadv_is_wifi_iface(int ifindex); bool batadv_is_wifi_iface(int ifindex);
static inline void static inline void
batadv_hardif_free_ref(struct hard_iface *hard_iface) batadv_hardif_free_ref(struct batadv_hard_iface *hard_iface)
{ {
if (atomic_dec_and_test(&hard_iface->refcount)) if (atomic_dec_and_test(&hard_iface->refcount))
call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu); call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
} }
static inline struct hard_iface * static inline struct batadv_hard_iface *
batadv_primary_if_get_selected(struct bat_priv *bat_priv) batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
{ {
struct hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
rcu_read_lock(); rcu_read_lock();
hard_iface = rcu_dereference(bat_priv->primary_if); hard_iface = rcu_dereference(bat_priv->primary_if);
......
...@@ -21,18 +21,18 @@ ...@@ -21,18 +21,18 @@
#include "hash.h" #include "hash.h"
/* clears the hash */ /* clears the hash */
static void batadv_hash_init(struct hashtable_t *hash) static void batadv_hash_init(struct batadv_hashtable *hash)
{ {
uint32_t i; uint32_t i;
for (i = 0 ; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
INIT_HLIST_HEAD(&hash->table[i]); INIT_HLIST_HEAD(&hash->table[i]);
spin_lock_init(&hash->list_locks[i]); spin_lock_init(&hash->list_locks[i]);
} }
} }
/* free only the hashtable and the hash itself. */ /* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct hashtable_t *hash) void batadv_hash_destroy(struct batadv_hashtable *hash)
{ {
kfree(hash->list_locks); kfree(hash->list_locks);
kfree(hash->table); kfree(hash->table);
...@@ -40,9 +40,9 @@ void batadv_hash_destroy(struct hashtable_t *hash) ...@@ -40,9 +40,9 @@ void batadv_hash_destroy(struct hashtable_t *hash)
} }
/* allocates and clears the hash */ /* allocates and clears the hash */
struct hashtable_t *batadv_hash_new(uint32_t size) struct batadv_hashtable *batadv_hash_new(uint32_t size)
{ {
struct hashtable_t *hash; struct batadv_hashtable *hash;
hash = kmalloc(sizeof(*hash), GFP_ATOMIC); hash = kmalloc(sizeof(*hash), GFP_ATOMIC);
if (!hash) if (!hash)
...@@ -68,7 +68,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size) ...@@ -68,7 +68,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size)
return NULL; return NULL;
} }
void batadv_hash_set_lock_class(struct hashtable_t *hash, void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key) struct lock_class_key *key)
{ {
uint32_t i; uint32_t i;
......
...@@ -25,37 +25,39 @@ ...@@ -25,37 +25,39 @@
/* callback to a compare function. should compare 2 element datas for their /* callback to a compare function. should compare 2 element datas for their
* keys, return 0 if same and not 0 if not same * keys, return 0 if same and not 0 if not same
*/ */
typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,
const void *);
/* the hashfunction, should return an index /* the hashfunction, should return an index
* based on the key in the data of the first * 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 uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t);
typedef void (*hashdata_free_cb)(struct hlist_node *, void *); typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
struct hashtable_t { struct batadv_hashtable {
struct hlist_head *table; /* the hashtable itself with the buckets */ struct hlist_head *table; /* the hashtable itself with the buckets */
spinlock_t *list_locks; /* spinlock for each hash list entry */ spinlock_t *list_locks; /* spinlock for each hash list entry */
uint32_t size; /* size of hashtable */ uint32_t size; /* size of hashtable */
}; };
/* allocates and clears the hash */ /* allocates and clears the hash */
struct hashtable_t *batadv_hash_new(uint32_t size); struct batadv_hashtable *batadv_hash_new(uint32_t size);
/* set class key for all locks */ /* set class key for all locks */
void batadv_hash_set_lock_class(struct hashtable_t *hash, void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key); struct lock_class_key *key);
/* free only the hashtable and the hash itself. */ /* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct hashtable_t *hash); void batadv_hash_destroy(struct batadv_hashtable *hash);
/* remove the hash structure. if hashdata_free_cb != NULL, this function will be /* 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 * 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 batadv_hash_delete(struct hashtable_t *hash, static inline void batadv_hash_delete(struct batadv_hashtable *hash,
hashdata_free_cb free_cb, void *arg) batadv_hashdata_free_cb free_cb,
void *arg)
{ {
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
...@@ -89,9 +91,9 @@ static inline void batadv_hash_delete(struct hashtable_t *hash, ...@@ -89,9 +91,9 @@ static inline void batadv_hash_delete(struct hashtable_t *hash,
* Returns 0 on success, 1 if the element already is in the hash * Returns 0 on success, 1 if the element already is in the hash
* and -1 on error. * and -1 on error.
*/ */
static inline int batadv_hash_add(struct hashtable_t *hash, static inline int batadv_hash_add(struct batadv_hashtable *hash,
hashdata_compare_cb compare, batadv_hashdata_compare_cb compare,
hashdata_choose_cb choose, batadv_hashdata_choose_cb choose,
const void *data, const void *data,
struct hlist_node *data_node) struct hlist_node *data_node)
{ {
...@@ -134,9 +136,10 @@ static inline int batadv_hash_add(struct hashtable_t *hash, ...@@ -134,9 +136,10 @@ static inline int batadv_hash_add(struct hashtable_t *hash,
* structure you use with just the key filled, we just need the key for * structure you use with just the key filled, we just need the key for
* comparing. * comparing.
*/ */
static inline void *batadv_hash_remove(struct hashtable_t *hash, static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
hashdata_compare_cb compare, batadv_hashdata_compare_cb compare,
hashdata_choose_cb choose, void *data) batadv_hashdata_choose_cb choose,
void *data)
{ {
uint32_t index; uint32_t index;
struct hlist_node *node; struct hlist_node *node;
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include "originator.h" #include "originator.h"
#include "hard-interface.h" #include "hard-interface.h"
static struct socket_client *batadv_socket_client_hash[256]; static struct batadv_socket_client *batadv_socket_client_hash[256];
static void batadv_socket_add_packet(struct socket_client *socket_client, static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
struct icmp_packet_rr *icmp_packet, struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len); size_t icmp_len);
void batadv_socket_init(void) void batadv_socket_init(void)
...@@ -40,7 +40,7 @@ void batadv_socket_init(void) ...@@ -40,7 +40,7 @@ void batadv_socket_init(void)
static int batadv_socket_open(struct inode *inode, struct file *file) static int batadv_socket_open(struct inode *inode, struct file *file)
{ {
unsigned int i; unsigned int i;
struct socket_client *socket_client; struct batadv_socket_client *socket_client;
nonseekable_open(inode, file); nonseekable_open(inode, file);
...@@ -77,8 +77,8 @@ static int batadv_socket_open(struct inode *inode, struct file *file) ...@@ -77,8 +77,8 @@ static int batadv_socket_open(struct inode *inode, struct file *file)
static int batadv_socket_release(struct inode *inode, struct file *file) static int batadv_socket_release(struct inode *inode, struct file *file)
{ {
struct socket_client *socket_client = file->private_data; struct batadv_socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet; struct batadv_socket_packet *socket_packet;
struct list_head *list_pos, *list_pos_tmp; struct list_head *list_pos, *list_pos_tmp;
spin_lock_bh(&socket_client->lock); spin_lock_bh(&socket_client->lock);
...@@ -86,7 +86,7 @@ static int batadv_socket_release(struct inode *inode, struct file *file) ...@@ -86,7 +86,7 @@ static int batadv_socket_release(struct inode *inode, struct file *file)
/* for all packets in the queue ... */ /* for all packets in the queue ... */
list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) {
socket_packet = list_entry(list_pos, socket_packet = list_entry(list_pos,
struct socket_packet, list); struct batadv_socket_packet, list);
list_del(list_pos); list_del(list_pos);
kfree(socket_packet); kfree(socket_packet);
...@@ -104,15 +104,15 @@ static int batadv_socket_release(struct inode *inode, struct file *file) ...@@ -104,15 +104,15 @@ static int batadv_socket_release(struct inode *inode, struct file *file)
static ssize_t batadv_socket_read(struct file *file, char __user *buf, static ssize_t batadv_socket_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct socket_client *socket_client = file->private_data; struct batadv_socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet; struct batadv_socket_packet *socket_packet;
size_t packet_len; size_t packet_len;
int error; int error;
if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0)) if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0))
return -EAGAIN; return -EAGAIN;
if ((!buf) || (count < sizeof(struct icmp_packet))) if ((!buf) || (count < sizeof(struct batadv_icmp_packet)))
return -EINVAL; return -EINVAL;
if (!access_ok(VERIFY_WRITE, buf, count)) if (!access_ok(VERIFY_WRITE, buf, count))
...@@ -127,7 +127,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf, ...@@ -127,7 +127,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
spin_lock_bh(&socket_client->lock); spin_lock_bh(&socket_client->lock);
socket_packet = list_first_entry(&socket_client->queue_list, socket_packet = list_first_entry(&socket_client->queue_list,
struct socket_packet, list); struct batadv_socket_packet, list);
list_del(&socket_packet->list); list_del(&socket_packet->list);
socket_client->queue_len--; socket_client->queue_len--;
...@@ -147,18 +147,18 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf, ...@@ -147,18 +147,18 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
static ssize_t batadv_socket_write(struct file *file, const char __user *buff, static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off) size_t len, loff_t *off)
{ {
struct socket_client *socket_client = file->private_data; struct batadv_socket_client *socket_client = file->private_data;
struct bat_priv *bat_priv = socket_client->bat_priv; struct batadv_priv *bat_priv = socket_client->bat_priv;
struct hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
struct sk_buff *skb; struct sk_buff *skb;
struct icmp_packet_rr *icmp_packet; struct batadv_icmp_packet_rr *icmp_packet;
struct orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
struct neigh_node *neigh_node = NULL; struct batadv_neigh_node *neigh_node = NULL;
size_t packet_len = sizeof(struct icmp_packet); size_t packet_len = sizeof(struct batadv_icmp_packet);
if (len < sizeof(struct icmp_packet)) { if (len < sizeof(struct batadv_icmp_packet)) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: invalid packet size\n"); "Error - can't send packet from char device: invalid packet size\n");
return -EINVAL; return -EINVAL;
} }
...@@ -170,8 +170,8 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -170,8 +170,8 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
goto out; goto out;
} }
if (len >= sizeof(struct icmp_packet_rr)) if (len >= sizeof(struct batadv_icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr); packet_len = sizeof(struct batadv_icmp_packet_rr);
skb = dev_alloc_skb(packet_len + ETH_HLEN); skb = dev_alloc_skb(packet_len + ETH_HLEN);
if (!skb) { if (!skb) {
...@@ -180,22 +180,22 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -180,22 +180,22 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
} }
skb_reserve(skb, ETH_HLEN); skb_reserve(skb, ETH_HLEN);
icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len); icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len);
if (copy_from_user(icmp_packet, buff, packet_len)) { if (copy_from_user(icmp_packet, buff, packet_len)) {
len = -EFAULT; len = -EFAULT;
goto free_skb; goto free_skb;
} }
if (icmp_packet->header.packet_type != BAT_ICMP) { if (icmp_packet->header.packet_type != BATADV_ICMP) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
len = -EINVAL; len = -EINVAL;
goto free_skb; goto free_skb;
} }
if (icmp_packet->msg_type != ECHO_REQUEST) { if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
len = -EINVAL; len = -EINVAL;
goto free_skb; goto free_skb;
...@@ -204,14 +204,14 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -204,14 +204,14 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
icmp_packet->uid = socket_client->index; icmp_packet->uid = socket_client->index;
if (icmp_packet->header.version != BATADV_COMPAT_VERSION) { if (icmp_packet->header.version != BATADV_COMPAT_VERSION) {
icmp_packet->msg_type = PARAMETER_PROBLEM; icmp_packet->msg_type = BATADV_PARAMETER_PROBLEM;
icmp_packet->header.version = BATADV_COMPAT_VERSION; icmp_packet->header.version = BATADV_COMPAT_VERSION;
batadv_socket_add_packet(socket_client, icmp_packet, batadv_socket_add_packet(socket_client, icmp_packet,
packet_len); packet_len);
goto free_skb; goto free_skb;
} }
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dst_unreach; goto dst_unreach;
orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst); orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
...@@ -225,13 +225,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -225,13 +225,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
if (!neigh_node->if_incoming) if (!neigh_node->if_incoming)
goto dst_unreach; goto dst_unreach;
if (neigh_node->if_incoming->if_status != IF_ACTIVE) if (neigh_node->if_incoming->if_status != BATADV_IF_ACTIVE)
goto dst_unreach; goto dst_unreach;
memcpy(icmp_packet->orig, memcpy(icmp_packet->orig,
primary_if->net_dev->dev_addr, ETH_ALEN); primary_if->net_dev->dev_addr, ETH_ALEN);
if (packet_len == sizeof(struct icmp_packet_rr)) if (packet_len == sizeof(struct batadv_icmp_packet_rr))
memcpy(icmp_packet->rr, memcpy(icmp_packet->rr,
neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN); neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
...@@ -239,7 +239,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -239,7 +239,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
goto out; goto out;
dst_unreach: dst_unreach:
icmp_packet->msg_type = DESTINATION_UNREACHABLE; icmp_packet->msg_type = BATADV_DESTINATION_UNREACHABLE;
batadv_socket_add_packet(socket_client, icmp_packet, packet_len); batadv_socket_add_packet(socket_client, icmp_packet, packet_len);
free_skb: free_skb:
kfree_skb(skb); kfree_skb(skb);
...@@ -255,7 +255,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -255,7 +255,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
static unsigned int batadv_socket_poll(struct file *file, poll_table *wait) static unsigned int batadv_socket_poll(struct file *file, poll_table *wait)
{ {
struct socket_client *socket_client = file->private_data; struct batadv_socket_client *socket_client = file->private_data;
poll_wait(file, &socket_client->queue_wait, wait); poll_wait(file, &socket_client->queue_wait, wait);
...@@ -275,7 +275,7 @@ static const struct file_operations batadv_fops = { ...@@ -275,7 +275,7 @@ static const struct file_operations batadv_fops = {
.llseek = no_llseek, .llseek = no_llseek,
}; };
int batadv_socket_setup(struct bat_priv *bat_priv) int batadv_socket_setup(struct batadv_priv *bat_priv)
{ {
struct dentry *d; struct dentry *d;
...@@ -293,11 +293,11 @@ int batadv_socket_setup(struct bat_priv *bat_priv) ...@@ -293,11 +293,11 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
return -ENOMEM; return -ENOMEM;
} }
static void batadv_socket_add_packet(struct socket_client *socket_client, static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
struct icmp_packet_rr *icmp_packet, struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len) size_t icmp_len)
{ {
struct socket_packet *socket_packet; struct batadv_socket_packet *socket_packet;
socket_packet = kmalloc(sizeof(*socket_packet), GFP_ATOMIC); socket_packet = kmalloc(sizeof(*socket_packet), GFP_ATOMIC);
...@@ -324,7 +324,8 @@ static void batadv_socket_add_packet(struct socket_client *socket_client, ...@@ -324,7 +324,8 @@ static void batadv_socket_add_packet(struct socket_client *socket_client,
if (socket_client->queue_len > 100) { if (socket_client->queue_len > 100) {
socket_packet = list_first_entry(&socket_client->queue_list, socket_packet = list_first_entry(&socket_client->queue_list,
struct socket_packet, list); struct batadv_socket_packet,
list);
list_del(&socket_packet->list); list_del(&socket_packet->list);
kfree(socket_packet); kfree(socket_packet);
...@@ -336,10 +337,10 @@ static void batadv_socket_add_packet(struct socket_client *socket_client, ...@@ -336,10 +337,10 @@ static void batadv_socket_add_packet(struct socket_client *socket_client,
wake_up(&socket_client->queue_wait); wake_up(&socket_client->queue_wait);
} }
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len) size_t icmp_len)
{ {
struct socket_client *hash; struct batadv_socket_client *hash;
hash = batadv_socket_client_hash[icmp_packet->uid]; hash = batadv_socket_client_hash[icmp_packet->uid];
if (hash) if (hash)
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#define BATADV_ICMP_SOCKET "socket" #define BATADV_ICMP_SOCKET "socket"
void batadv_socket_init(void); void batadv_socket_init(void);
int batadv_socket_setup(struct bat_priv *bat_priv); int batadv_socket_setup(struct batadv_priv *bat_priv);
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len); size_t icmp_len);
#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ #endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
*/ */
#include "main.h" #include "main.h"
#include "bat_sysfs.h" #include "sysfs.h"
#include "bat_debugfs.h" #include "debugfs.h"
#include "routing.h" #include "routing.h"
#include "send.h" #include "send.h"
#include "originator.h" #include "originator.h"
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
*/ */
struct list_head batadv_hardif_list; struct list_head batadv_hardif_list;
static int (*batadv_rx_handler[256])(struct sk_buff *, static int (*batadv_rx_handler[256])(struct sk_buff *,
struct hard_iface *); struct batadv_hard_iface *);
char batadv_routing_algo[20] = "BATMAN_IV"; char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head batadv_algo_list; static struct hlist_head batadv_algo_list;
...@@ -92,7 +92,7 @@ static void __exit batadv_exit(void) ...@@ -92,7 +92,7 @@ static void __exit batadv_exit(void)
int batadv_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); struct batadv_priv *bat_priv = netdev_priv(soft_iface);
int ret; int ret;
spin_lock_init(&bat_priv->forw_bat_list_lock); spin_lock_init(&bat_priv->forw_bat_list_lock);
...@@ -132,7 +132,7 @@ int batadv_mesh_init(struct net_device *soft_iface) ...@@ -132,7 +132,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
goto err; goto err;
atomic_set(&bat_priv->gw_reselect, 0); atomic_set(&bat_priv->gw_reselect, 0);
atomic_set(&bat_priv->mesh_state, MESH_ACTIVE); atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
return 0; return 0;
...@@ -143,9 +143,9 @@ int batadv_mesh_init(struct net_device *soft_iface) ...@@ -143,9 +143,9 @@ int batadv_mesh_init(struct net_device *soft_iface)
void batadv_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); struct batadv_priv *bat_priv = netdev_priv(soft_iface);
atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING); atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
batadv_purge_outstanding_packets(bat_priv, NULL); batadv_purge_outstanding_packets(bat_priv, NULL);
...@@ -160,7 +160,7 @@ void batadv_mesh_free(struct net_device *soft_iface) ...@@ -160,7 +160,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
free_percpu(bat_priv->bat_counters); free_percpu(bat_priv->bat_counters);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
} }
void batadv_inc_module_count(void) void batadv_inc_module_count(void)
...@@ -175,11 +175,11 @@ void batadv_dec_module_count(void) ...@@ -175,11 +175,11 @@ void batadv_dec_module_count(void)
int batadv_is_my_mac(const uint8_t *addr) int batadv_is_my_mac(const uint8_t *addr)
{ {
const struct hard_iface *hard_iface; const struct batadv_hard_iface *hard_iface;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->if_status != IF_ACTIVE) if (hard_iface->if_status != BATADV_IF_ACTIVE)
continue; continue;
if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
...@@ -192,7 +192,7 @@ int batadv_is_my_mac(const uint8_t *addr) ...@@ -192,7 +192,7 @@ int batadv_is_my_mac(const uint8_t *addr)
} }
static int batadv_recv_unhandled_packet(struct sk_buff *skb, static int batadv_recv_unhandled_packet(struct sk_buff *skb,
struct hard_iface *recv_if) struct batadv_hard_iface *recv_if)
{ {
return NET_RX_DROP; return NET_RX_DROP;
} }
...@@ -204,13 +204,14 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -204,13 +204,14 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct packet_type *ptype,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct bat_priv *bat_priv; struct batadv_priv *bat_priv;
struct batman_ogm_packet *batman_ogm_packet; struct batadv_ogm_packet *batadv_ogm_packet;
struct hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
uint8_t idx; uint8_t idx;
int ret; int ret;
hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype); hard_iface = container_of(ptype, struct batadv_hard_iface,
batman_adv_ptype);
skb = skb_share_check(skb, GFP_ATOMIC); skb = skb_share_check(skb, GFP_ATOMIC);
/* skb was released by skb_share_check() */ /* skb was released by skb_share_check() */
...@@ -230,26 +231,26 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -230,26 +231,26 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
bat_priv = netdev_priv(hard_iface->soft_iface); bat_priv = netdev_priv(hard_iface->soft_iface);
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto err_free; goto err_free;
/* discard frames on not active interfaces */ /* discard frames on not active interfaces */
if (hard_iface->if_status != IF_ACTIVE) if (hard_iface->if_status != BATADV_IF_ACTIVE)
goto err_free; goto err_free;
batman_ogm_packet = (struct batman_ogm_packet *)skb->data; batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
batadv_dbg(DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n", "Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->header.version); batadv_ogm_packet->header.version);
goto err_free; goto err_free;
} }
/* all receive handlers return whether they received or reused /* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb. * the supplied skb. if not, we have to free the skb.
*/ */
idx = batman_ogm_packet->header.packet_type; idx = batadv_ogm_packet->header.packet_type;
ret = (*batadv_rx_handler[idx])(skb, hard_iface); ret = (*batadv_rx_handler[idx])(skb, hard_iface);
if (ret == NET_RX_DROP) if (ret == NET_RX_DROP)
...@@ -275,24 +276,25 @@ static void batadv_recv_handler_init(void) ...@@ -275,24 +276,25 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[i] = batadv_recv_unhandled_packet; batadv_rx_handler[i] = batadv_recv_unhandled_packet;
/* batman icmp packet */ /* batman icmp packet */
batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet; batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
/* unicast packet */ /* unicast packet */
batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet; batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */ /* fragmented unicast packet */
batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
/* broadcast packet */ /* broadcast packet */
batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet; batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* vis packet */ /* vis packet */
batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet; batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */ /* Translation table query (request or response) */
batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query; batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */ /* Roaming advertisement */
batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv; batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv;
} }
int batadv_recv_handler_register(uint8_t packet_type, int
batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct hard_iface *)) struct batadv_hard_iface *))
{ {
if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet) if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet)
return -EBUSY; return -EBUSY;
...@@ -306,9 +308,9 @@ void batadv_recv_handler_unregister(uint8_t packet_type) ...@@ -306,9 +308,9 @@ void batadv_recv_handler_unregister(uint8_t packet_type)
batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet; batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
} }
static struct bat_algo_ops *batadv_algo_get(char *name) static struct batadv_algo_ops *batadv_algo_get(char *name)
{ {
struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
struct hlist_node *node; struct hlist_node *node;
hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) { hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) {
...@@ -322,9 +324,9 @@ static struct bat_algo_ops *batadv_algo_get(char *name) ...@@ -322,9 +324,9 @@ static struct bat_algo_ops *batadv_algo_get(char *name)
return bat_algo_ops; return bat_algo_ops;
} }
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops) int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
{ {
struct bat_algo_ops *bat_algo_ops_tmp; struct batadv_algo_ops *bat_algo_ops_tmp;
int ret; int ret;
bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name); bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
...@@ -356,9 +358,9 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops) ...@@ -356,9 +358,9 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
return ret; return ret;
} }
int batadv_algo_select(struct bat_priv *bat_priv, char *name) int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
{ {
struct bat_algo_ops *bat_algo_ops; struct batadv_algo_ops *bat_algo_ops;
int ret = -EINVAL; int ret = -EINVAL;
bat_algo_ops = batadv_algo_get(name); bat_algo_ops = batadv_algo_get(name);
...@@ -374,7 +376,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name) ...@@ -374,7 +376,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name)
int batadv_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 batadv_algo_ops *bat_algo_ops;
struct hlist_node *node; struct hlist_node *node;
seq_printf(seq, "Available routing algorithms:\n"); seq_printf(seq, "Available routing algorithms:\n");
...@@ -388,7 +390,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) ...@@ -388,7 +390,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
{ {
struct bat_algo_ops *bat_algo_ops; struct batadv_algo_ops *bat_algo_ops;
char *algo_name = (char *)val; char *algo_name = (char *)val;
size_t name_len = strlen(algo_name); size_t name_len = strlen(algo_name);
......
...@@ -95,23 +95,23 @@ ...@@ -95,23 +95,23 @@
#define BATADV_RESET_PROTECTION_MS 30000 #define BATADV_RESET_PROTECTION_MS 30000
#define BATADV_EXPECTED_SEQNO_RANGE 65536 #define BATADV_EXPECTED_SEQNO_RANGE 65536
enum mesh_state { enum batadv_mesh_state {
MESH_INACTIVE, BATADV_MESH_INACTIVE,
MESH_ACTIVE, BATADV_MESH_ACTIVE,
MESH_DEACTIVATING BATADV_MESH_DEACTIVATING,
}; };
#define BATADV_BCAST_QUEUE_LEN 256 #define BATADV_BCAST_QUEUE_LEN 256
#define BATADV_BATMAN_QUEUE_LEN 256 #define BATADV_BATMAN_QUEUE_LEN 256
enum uev_action { enum batadv_uev_action {
UEV_ADD = 0, BATADV_UEV_ADD = 0,
UEV_DEL, BATADV_UEV_DEL,
UEV_CHANGE BATADV_UEV_CHANGE,
}; };
enum uev_type { enum batadv_uev_type {
UEV_GW = 0 BATADV_UEV_GW = 0,
}; };
#define BATADV_GW_THRESHOLD 50 #define BATADV_GW_THRESHOLD 50
...@@ -124,12 +124,12 @@ enum uev_type { ...@@ -124,12 +124,12 @@ enum uev_type {
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* all messages related to routing / flooding / broadcasting / etc */ /* all messages related to routing / flooding / broadcasting / etc */
enum dbg_level { enum batadv_dbg_level {
DBG_BATMAN = 1 << 0, BATADV_DBG_BATMAN = 1 << 0,
DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ BATADV_DBG_ROUTES = 1 << 1, /* route added / changed / deleted */
DBG_TT = 1 << 2, /* translation table operations */ BATADV_DBG_TT = 1 << 2, /* translation table operations */
DBG_BLA = 1 << 3, /* bridge loop avoidance */ BATADV_DBG_BLA = 1 << 3, /* bridge loop avoidance */
DBG_ALL = 15 BATADV_DBG_ALL = 15,
}; };
/* Kernel headers */ /* Kernel headers */
...@@ -164,16 +164,17 @@ int batadv_is_my_mac(const uint8_t *addr); ...@@ -164,16 +164,17 @@ int batadv_is_my_mac(const uint8_t *addr);
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct packet_type *ptype,
struct net_device *orig_dev); struct net_device *orig_dev);
int batadv_recv_handler_register(uint8_t packet_type, int
batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct hard_iface *)); struct batadv_hard_iface *));
void batadv_recv_handler_unregister(uint8_t packet_type); void batadv_recv_handler_unregister(uint8_t packet_type);
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops); int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
int batadv_algo_select(struct bat_priv *bat_priv, char *name); int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
__printf(2, 3); __printf(2, 3);
#define batadv_dbg(type, bat_priv, fmt, arg...) \ #define batadv_dbg(type, bat_priv, fmt, arg...) \
...@@ -185,7 +186,7 @@ __printf(2, 3); ...@@ -185,7 +186,7 @@ __printf(2, 3);
#else /* !CONFIG_BATMAN_ADV_DEBUG */ #else /* !CONFIG_BATMAN_ADV_DEBUG */
__printf(3, 4) __printf(3, 4)
static inline void batadv_dbg(int type __always_unused, static inline void batadv_dbg(int type __always_unused,
struct bat_priv *bat_priv __always_unused, struct batadv_priv *bat_priv __always_unused,
const char *fmt __always_unused, ...) const char *fmt __always_unused, ...)
{ {
} }
...@@ -194,15 +195,15 @@ static inline void batadv_dbg(int type __always_unused, ...@@ -194,15 +195,15 @@ static inline void batadv_dbg(int type __always_unused,
#define batadv_info(net_dev, fmt, arg...) \ #define batadv_info(net_dev, fmt, arg...) \
do { \ do { \
struct net_device *_netdev = (net_dev); \ struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \ struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \ pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0) } while (0)
#define batadv_err(net_dev, fmt, arg...) \ #define batadv_err(net_dev, fmt, arg...) \
do { \ do { \
struct net_device *_netdev = (net_dev); \ struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \ struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_err("%s: " fmt, _netdev->name, ## arg); \ pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0) } while (0)
...@@ -250,7 +251,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, ...@@ -250,7 +251,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
#define batadv_seq_after(x, y) batadv_seq_before(y, x) #define batadv_seq_after(x, y) batadv_seq_before(y, x)
/* Stop preemption on local cpu while incrementing the counter */ /* Stop preemption on local cpu while incrementing the counter */
static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx, static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
size_t count) size_t count)
{ {
int cpu = get_cpu(); int cpu = get_cpu();
...@@ -261,11 +262,11 @@ static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx, ...@@ -261,11 +262,11 @@ static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1) #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
/* Sum and return the cpu-local counters for index 'idx' */ /* Sum and return the cpu-local counters for index 'idx' */
static inline uint64_t batadv_sum_counter(struct bat_priv *bat_priv, size_t idx) static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,
size_t idx)
{ {
uint64_t *counters; uint64_t *counters, sum = 0;
int cpu; int cpu;
int sum = 0;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
counters = per_cpu_ptr(bat_priv->bat_counters, cpu); counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
......
This diff is collapsed.
...@@ -22,20 +22,23 @@ ...@@ -22,20 +22,23 @@
#include "hash.h" #include "hash.h"
int batadv_originator_init(struct bat_priv *bat_priv); int batadv_originator_init(struct batadv_priv *bat_priv);
void batadv_originator_free(struct bat_priv *bat_priv); void batadv_originator_free(struct batadv_priv *bat_priv);
void batadv_purge_orig_ref(struct bat_priv *bat_priv); void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
void batadv_orig_node_free_ref(struct orig_node *orig_node); void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node);
struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
const uint8_t *addr); const uint8_t *addr);
struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, struct batadv_neigh_node *
const uint8_t *neigh_addr, batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
uint32_t seqno); const uint8_t *neigh_addr, uint32_t seqno);
void batadv_neigh_node_free_ref(struct neigh_node *neigh_node); void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node);
struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node); struct batadv_neigh_node *
batadv_orig_node_get_router(struct batadv_orig_node *orig_node);
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); 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_add_if(struct batadv_hard_iface *hard_iface,
int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); int max_if_num);
int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
int max_if_num);
/* hashfunction to choose an entry in a hash table of given size /* hashfunction to choose an entry in a hash table of given size
...@@ -60,13 +63,13 @@ static inline uint32_t batadv_choose_orig(const void *data, uint32_t size) ...@@ -60,13 +63,13 @@ static inline uint32_t batadv_choose_orig(const void *data, uint32_t size)
return hash % size; return hash % size;
} }
static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv, static inline struct batadv_orig_node *
const void *data) batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
{ {
struct hashtable_t *hash = bat_priv->orig_hash; struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node; struct hlist_node *node;
struct orig_node *orig_node, *orig_node_tmp = NULL; struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
int index; int index;
if (!hash) if (!hash)
......
...@@ -22,99 +22,99 @@ ...@@ -22,99 +22,99 @@
#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ #define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype { enum batadv_packettype {
BAT_IV_OGM = 0x01, BATADV_IV_OGM = 0x01,
BAT_ICMP = 0x02, BATADV_ICMP = 0x02,
BAT_UNICAST = 0x03, BATADV_UNICAST = 0x03,
BAT_BCAST = 0x04, BATADV_BCAST = 0x04,
BAT_VIS = 0x05, BATADV_VIS = 0x05,
BAT_UNICAST_FRAG = 0x06, BATADV_UNICAST_FRAG = 0x06,
BAT_TT_QUERY = 0x07, BATADV_TT_QUERY = 0x07,
BAT_ROAM_ADV = 0x08 BATADV_ROAM_ADV = 0x08,
}; };
/* this file is included by batctl which needs these defines */ /* this file is included by batctl which needs these defines */
#define BATADV_COMPAT_VERSION 14 #define BATADV_COMPAT_VERSION 14
enum batman_iv_flags { enum batadv_iv_flags {
NOT_BEST_NEXT_HOP = 1 << 3, BATADV_NOT_BEST_NEXT_HOP = 1 << 3,
PRIMARIES_FIRST_HOP = 1 << 4, BATADV_PRIMARIES_FIRST_HOP = 1 << 4,
VIS_SERVER = 1 << 5, BATADV_VIS_SERVER = 1 << 5,
DIRECTLINK = 1 << 6 BATADV_DIRECTLINK = 1 << 6,
}; };
/* ICMP message types */ /* ICMP message types */
enum icmp_packettype { enum batadv_icmp_packettype {
ECHO_REPLY = 0, BATADV_ECHO_REPLY = 0,
DESTINATION_UNREACHABLE = 3, BATADV_DESTINATION_UNREACHABLE = 3,
ECHO_REQUEST = 8, BATADV_ECHO_REQUEST = 8,
TTL_EXCEEDED = 11, BATADV_TTL_EXCEEDED = 11,
PARAMETER_PROBLEM = 12 BATADV_PARAMETER_PROBLEM = 12,
}; };
/* vis defines */ /* vis defines */
enum vis_packettype { enum batadv_vis_packettype {
VIS_TYPE_SERVER_SYNC = 0, BATADV_VIS_TYPE_SERVER_SYNC = 0,
VIS_TYPE_CLIENT_UPDATE = 1 BATADV_VIS_TYPE_CLIENT_UPDATE = 1,
}; };
/* fragmentation defines */ /* fragmentation defines */
enum unicast_frag_flags { enum batadv_unicast_frag_flags {
UNI_FRAG_HEAD = 1 << 0, BATADV_UNI_FRAG_HEAD = 1 << 0,
UNI_FRAG_LARGETAIL = 1 << 1 BATADV_UNI_FRAG_LARGETAIL = 1 << 1,
}; };
/* TT_QUERY subtypes */ /* TT_QUERY subtypes */
#define BATADV_TT_QUERY_TYPE_MASK 0x3 #define BATADV_TT_QUERY_TYPE_MASK 0x3
enum tt_query_packettype { enum batadv_tt_query_packettype {
TT_REQUEST = 0, BATADV_TT_REQUEST = 0,
TT_RESPONSE = 1 BATADV_TT_RESPONSE = 1,
}; };
/* TT_QUERY flags */ /* TT_QUERY flags */
enum tt_query_flags { enum batadv_tt_query_flags {
TT_FULL_TABLE = 1 << 2 BATADV_TT_FULL_TABLE = 1 << 2,
}; };
/* TT_CLIENT flags. /* BATADV_TT_CLIENT flags.
* Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to * 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 { enum batadv_tt_client_flags {
TT_CLIENT_DEL = 1 << 0, BATADV_TT_CLIENT_DEL = 1 << 0,
TT_CLIENT_ROAM = 1 << 1, BATADV_TT_CLIENT_ROAM = 1 << 1,
TT_CLIENT_WIFI = 1 << 2, BATADV_TT_CLIENT_WIFI = 1 << 2,
TT_CLIENT_NOPURGE = 1 << 8, BATADV_TT_CLIENT_NOPURGE = 1 << 8,
TT_CLIENT_NEW = 1 << 9, BATADV_TT_CLIENT_NEW = 1 << 9,
TT_CLIENT_PENDING = 1 << 10 BATADV_TT_CLIENT_PENDING = 1 << 10,
}; };
/* claim frame types for the bridge loop avoidance */ /* claim frame types for the bridge loop avoidance */
enum bla_claimframe { enum batadv_bla_claimframe {
CLAIM_TYPE_ADD = 0x00, BATADV_CLAIM_TYPE_ADD = 0x00,
CLAIM_TYPE_DEL = 0x01, BATADV_CLAIM_TYPE_DEL = 0x01,
CLAIM_TYPE_ANNOUNCE = 0x02, BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
CLAIM_TYPE_REQUEST = 0x03 BATADV_CLAIM_TYPE_REQUEST = 0x03,
}; };
/* the destination hardware field in the ARP frame is used to /* the destination hardware field in the ARP frame is used to
* transport the claim type and the group id * transport the claim type and the group id
*/ */
struct bla_claim_dst { struct batadv_bla_claim_dst {
uint8_t magic[3]; /* FF:43:05 */ uint8_t magic[3]; /* FF:43:05 */
uint8_t type; /* bla_claimframe */ uint8_t type; /* bla_claimframe */
__be16 group; /* group id */ __be16 group; /* group id */
} __packed; } __packed;
struct batman_header { struct batadv_header {
uint8_t packet_type; uint8_t packet_type;
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
uint8_t ttl; uint8_t ttl;
} __packed; } __packed;
struct batman_ogm_packet { struct batadv_ogm_packet {
struct batman_header header; struct batadv_header header;
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
__be32 seqno; __be32 seqno;
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
...@@ -126,10 +126,10 @@ struct batman_ogm_packet { ...@@ -126,10 +126,10 @@ struct batman_ogm_packet {
__be16 tt_crc; __be16 tt_crc;
} __packed; } __packed;
#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet) #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
struct icmp_packet { struct batadv_icmp_packet {
struct batman_header header; struct batadv_header header;
uint8_t msg_type; /* see ICMP message types above */ uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN]; uint8_t dst[ETH_ALEN];
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
...@@ -143,8 +143,8 @@ struct icmp_packet { ...@@ -143,8 +143,8 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet /* 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 batadv_icmp_packet_rr {
struct batman_header header; struct batadv_header header;
uint8_t msg_type; /* see ICMP message types above */ uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN]; uint8_t dst[ETH_ALEN];
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
...@@ -154,14 +154,14 @@ struct icmp_packet_rr { ...@@ -154,14 +154,14 @@ struct icmp_packet_rr {
uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
} __packed; } __packed;
struct unicast_packet { struct batadv_unicast_packet {
struct batman_header header; struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */ uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN]; uint8_t dest[ETH_ALEN];
} __packed; } __packed;
struct unicast_frag_packet { struct batadv_unicast_frag_packet {
struct batman_header header; struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */ uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN]; uint8_t dest[ETH_ALEN];
uint8_t flags; uint8_t flags;
...@@ -170,15 +170,15 @@ struct unicast_frag_packet { ...@@ -170,15 +170,15 @@ struct unicast_frag_packet {
__be16 seqno; __be16 seqno;
} __packed; } __packed;
struct bcast_packet { struct batadv_bcast_packet {
struct batman_header header; struct batadv_header header;
uint8_t reserved; uint8_t reserved;
__be32 seqno; __be32 seqno;
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
} __packed; } __packed;
struct vis_packet { struct batadv_vis_packet {
struct batman_header header; struct batadv_header header;
uint8_t vis_type; /* which type of vis-participant sent this? */ uint8_t vis_type; /* which type of vis-participant sent this? */
__be32 seqno; /* sequence number */ __be32 seqno; /* sequence number */
uint8_t entries; /* number of entries behind this struct */ uint8_t entries; /* number of entries behind this struct */
...@@ -188,8 +188,8 @@ struct vis_packet { ...@@ -188,8 +188,8 @@ struct vis_packet {
uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
} __packed; } __packed;
struct tt_query_packet { struct batadv_tt_query_packet {
struct batman_header header; struct batadv_header header;
/* the flag field is a combination of: /* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE * - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE * - TT_FULL_TABLE
...@@ -212,15 +212,15 @@ struct tt_query_packet { ...@@ -212,15 +212,15 @@ struct tt_query_packet {
__be16 tt_data; __be16 tt_data;
} __packed; } __packed;
struct roam_adv_packet { struct batadv_roam_adv_packet {
struct batman_header header; struct batadv_header header;
uint8_t reserved; uint8_t reserved;
uint8_t dst[ETH_ALEN]; uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN]; uint8_t src[ETH_ALEN];
uint8_t client[ETH_ALEN]; uint8_t client[ETH_ALEN];
} __packed; } __packed;
struct tt_change { struct batadv_tt_change {
uint8_t flags; uint8_t flags;
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
} __packed; } __packed;
......
This diff is collapsed.
...@@ -20,32 +20,40 @@ ...@@ -20,32 +20,40 @@
#ifndef _NET_BATMAN_ADV_ROUTING_H_ #ifndef _NET_BATMAN_ADV_ROUTING_H_
#define _NET_BATMAN_ADV_ROUTING_H_ #define _NET_BATMAN_ADV_ROUTING_H_
void batadv_slide_own_bcast_window(struct hard_iface *hard_iface); void batadv_slide_own_bcast_window(struct batadv_hard_iface *hard_iface);
bool batadv_check_management_packet(struct sk_buff *skb, bool batadv_check_management_packet(struct sk_buff *skb,
struct hard_iface *hard_iface, struct batadv_hard_iface *hard_iface,
int header_len); int header_len);
void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, void batadv_update_route(struct batadv_priv *bat_priv,
struct neigh_node *neigh_node); struct batadv_orig_node *orig_node,
int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if); struct batadv_neigh_node *neigh_node);
int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if); int batadv_recv_icmp_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_ucast_frag_packet(struct sk_buff *skb, int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct hard_iface *recv_if); struct batadv_hard_iface *recv_if);
int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if); int batadv_recv_bcast_packet(struct sk_buff *skb,
int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if); struct batadv_hard_iface *recv_if);
int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if); int batadv_recv_vis_packet(struct sk_buff *skb,
int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if); struct batadv_hard_iface *recv_if);
struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, int batadv_recv_tt_query(struct sk_buff *skb,
struct orig_node *orig_node, struct batadv_hard_iface *recv_if);
const struct hard_iface *recv_if); int batadv_recv_roam_adv(struct sk_buff *skb,
void batadv_bonding_candidate_del(struct orig_node *orig_node, struct batadv_hard_iface *recv_if);
struct neigh_node *neigh_node); struct batadv_neigh_node *
void batadv_bonding_candidate_add(struct orig_node *orig_node, batadv_find_router(struct batadv_priv *bat_priv,
struct neigh_node *neigh_node); struct batadv_orig_node *orig_node,
void batadv_bonding_save_primary(const struct orig_node *orig_node, const struct batadv_hard_iface *recv_if);
struct orig_node *orig_neigh_node, void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node,
const struct batman_ogm_packet struct batadv_neigh_node *neigh_node);
void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node);
void batadv_bonding_save_primary(const struct batadv_orig_node *orig_node,
struct batadv_orig_node *orig_neigh_node,
const struct batadv_ogm_packet
*batman_ogm_packet); *batman_ogm_packet);
int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff,
unsigned long *last_reset); unsigned long *last_reset);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */ #endif /* _NET_BATMAN_ADV_ROUTING_H_ */
This diff is collapsed.
...@@ -20,14 +20,16 @@ ...@@ -20,14 +20,16 @@
#ifndef _NET_BATMAN_ADV_SEND_H_ #ifndef _NET_BATMAN_ADV_SEND_H_
#define _NET_BATMAN_ADV_SEND_H_ #define _NET_BATMAN_ADV_SEND_H_
int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr); const uint8_t *dst_addr);
void batadv_schedule_bat_ogm(struct hard_iface *hard_iface); void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
const struct sk_buff *skb, const struct sk_buff *skb,
unsigned long delay); unsigned long delay);
void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work); void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work);
void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, void
const struct hard_iface *hard_iface); batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
const struct batadv_hard_iface *hard_iface);
#endif /* _NET_BATMAN_ADV_SEND_H_ */ #endif /* _NET_BATMAN_ADV_SEND_H_ */
This diff is collapsed.
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len); 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, void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb,
struct hard_iface *recv_if, int hdr_size); struct batadv_hard_iface *recv_if, int hdr_size);
struct net_device *batadv_softif_create(const char *name); struct net_device *batadv_softif_create(const char *name);
void batadv_softif_destroy(struct net_device *soft_iface); void batadv_softif_destroy(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev); int batadv_softif_is_valid(const struct net_device *net_dev);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh" #define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv" #define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
struct bat_attribute { struct batadv_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr, ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf); char *buf);
...@@ -36,7 +36,7 @@ void batadv_sysfs_del_meshif(struct net_device *dev); ...@@ -36,7 +36,7 @@ void batadv_sysfs_del_meshif(struct net_device *dev);
int batadv_sysfs_add_hardif(struct kobject **hardif_obj, int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
struct net_device *dev); struct net_device *dev);
void batadv_sysfs_del_hardif(struct kobject **hardif_obj); void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
enum uev_action action, const char *data); enum batadv_uev_action action, const char *data);
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */ #endif /* _NET_BATMAN_ADV_SYSFS_H_ */
This diff is collapsed.
...@@ -21,42 +21,43 @@ ...@@ -21,42 +21,43 @@
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
int batadv_tt_len(int changes_num); int batadv_tt_len(int changes_num);
int batadv_tt_init(struct bat_priv *bat_priv); int batadv_tt_init(struct batadv_priv *bat_priv);
void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex); int ifindex);
void batadv_tt_local_remove(struct bat_priv *bat_priv, void batadv_tt_local_remove(struct batadv_priv *bat_priv,
const uint8_t *addr, const char *message, const uint8_t *addr, const char *message,
bool roaming); bool roaming);
int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_add_orig(struct bat_priv *bat_priv, void batadv_tt_global_add_orig(struct batadv_priv *bat_priv,
struct orig_node *orig_node, struct batadv_orig_node *orig_node,
const unsigned char *tt_buff, int tt_buff_len); const unsigned char *tt_buff, int tt_buff_len);
int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, int batadv_tt_global_add(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
const unsigned char *addr, uint8_t flags, const unsigned char *addr, uint8_t flags,
uint8_t ttvn); uint8_t ttvn);
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_del_orig(struct bat_priv *bat_priv, void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
struct orig_node *orig_node, struct batadv_orig_node *orig_node,
const char *message); const char *message);
struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
const uint8_t *src, const uint8_t *src,
const uint8_t *addr); const uint8_t *addr);
void batadv_tt_free(struct bat_priv *bat_priv); void batadv_tt_free(struct batadv_priv *bat_priv);
bool batadv_send_tt_response(struct bat_priv *bat_priv, bool batadv_send_tt_response(struct batadv_priv *bat_priv,
struct tt_query_packet *tt_request); struct batadv_tt_query_packet *tt_request);
bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr);
void batadv_handle_tt_response(struct bat_priv *bat_priv, void batadv_handle_tt_response(struct batadv_priv *bat_priv,
struct tt_query_packet *tt_response); struct batadv_tt_query_packet *tt_response);
bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src,
uint8_t *dst); uint8_t *dst);
void batadv_tt_update_orig(struct bat_priv *bat_priv, void batadv_tt_update_orig(struct batadv_priv *bat_priv,
struct orig_node *orig_node, struct batadv_orig_node *orig_node,
const unsigned char *tt_buff, uint8_t tt_num_changes, const unsigned char *tt_buff, uint8_t tt_num_changes,
uint8_t ttvn, uint16_t tt_crc); uint8_t ttvn, uint16_t tt_crc);
int batadv_tt_append_diff(struct bat_priv *bat_priv, int batadv_tt_append_diff(struct batadv_priv *bat_priv,
unsigned char **packet_buff, int *packet_buff_len, unsigned char **packet_buff, int *packet_buff_len,
int packet_min_len); int packet_min_len);
bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
uint8_t *addr); uint8_t *addr);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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