Commit 96412690 authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Antonio Quartulli

batman-adv: Prefix packet structs with batadv_

Reported-by: default avatarMartin Hundebøll <martin@hundeboll.net>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
parent b4d66b87
This diff is collapsed.
...@@ -255,7 +255,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -255,7 +255,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
struct hard_iface *primary_if; struct hard_iface *primary_if;
struct net_device *soft_iface; struct net_device *soft_iface;
uint8_t *hw_src; uint8_t *hw_src;
struct bla_claim_dst local_claim_dest; struct batadv_bla_claim_dst local_claim_dest;
__be32 zeroip = 0; __be32 zeroip = 0;
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
...@@ -759,9 +759,9 @@ static int batadv_check_claim_group(struct bat_priv *bat_priv, ...@@ -759,9 +759,9 @@ static int batadv_check_claim_group(struct bat_priv *bat_priv,
{ {
uint8_t *backbone_addr; uint8_t *backbone_addr;
struct orig_node *orig_node; struct orig_node *orig_node;
struct bla_claim_dst *bla_dst, *bla_dst_own; struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
bla_dst = (struct bla_claim_dst *)hw_dst; bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
bla_dst_own = &bat_priv->claim_dest; bla_dst_own = &bat_priv->claim_dest;
/* check if it is a claim packet in general */ /* check if it is a claim packet in general */
...@@ -832,7 +832,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv, ...@@ -832,7 +832,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv,
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
struct arphdr *arphdr; struct arphdr *arphdr;
uint8_t *hw_src, *hw_dst; uint8_t *hw_src, *hw_dst;
struct bla_claim_dst *bla_dst; struct batadv_bla_claim_dst *bla_dst;
uint16_t proto; uint16_t proto;
int headlen; int headlen;
short vid = -1; short vid = -1;
...@@ -876,7 +876,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv, ...@@ -876,7 +876,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv,
hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); hw_src = (uint8_t *)arphdr + sizeof(struct arphdr);
hw_dst = hw_src + ETH_ALEN + 4; hw_dst = hw_src + ETH_ALEN + 4;
bla_dst = (struct bla_claim_dst *)hw_dst; bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
/* check if it is a claim frame. */ /* check if it is a claim frame. */
ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
...@@ -1201,7 +1201,7 @@ int batadv_bla_init(struct bat_priv *bat_priv) ...@@ -1201,7 +1201,7 @@ int batadv_bla_init(struct bat_priv *bat_priv)
* the same host however as this might be intended. * the same host however as this might be intended.
*/ */
int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet, struct batadv_bcast_packet *bcast_packet,
int hdr_size) int hdr_size)
{ {
int i, length, curr; int i, length, curr;
......
...@@ -28,7 +28,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, ...@@ -28,7 +28,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
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 bat_priv *bat_priv, uint8_t *orig);
int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, int batadv_bla_check_bcast_duplist(struct bat_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 bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
...@@ -72,7 +72,7 @@ static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, ...@@ -72,7 +72,7 @@ static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
static inline int static inline int
batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet, struct batadv_bcast_packet *bcast_packet,
int hdr_size) int hdr_size)
{ {
return 0; return 0;
......
...@@ -100,14 +100,14 @@ batadv_hardif_get_active(const struct net_device *soft_iface) ...@@ -100,14 +100,14 @@ batadv_hardif_get_active(const struct net_device *soft_iface)
static void batadv_primary_if_update_addr(struct bat_priv *bat_priv, static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
struct hard_iface *oldif) struct hard_iface *oldif)
{ {
struct vis_packet *vis_packet; struct batadv_vis_packet *vis_packet;
struct hard_iface *primary_if; struct hard_iface *primary_if;
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
vis_packet = (struct vis_packet *) vis_packet = (struct batadv_vis_packet *)
bat_priv->my_vis_info->skb_packet->data; bat_priv->my_vis_info->skb_packet->data;
memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
memcpy(vis_packet->sender_orig, memcpy(vis_packet->sender_orig,
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
static struct socket_client *batadv_socket_client_hash[256]; static struct 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 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)
...@@ -112,7 +112,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf, ...@@ -112,7 +112,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
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))
...@@ -151,13 +151,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -151,13 +151,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
struct bat_priv *bat_priv = socket_client->bat_priv; struct bat_priv *bat_priv = socket_client->bat_priv;
struct hard_iface *primary_if = NULL; struct 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 orig_node *orig_node = NULL;
struct neigh_node *neigh_node = NULL; struct 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(BATADV_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,7 +180,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -180,7 +180,7 @@ 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;
...@@ -231,7 +231,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -231,7 +231,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
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);
...@@ -294,7 +294,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv) ...@@ -294,7 +294,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
} }
static void batadv_socket_add_packet(struct socket_client *socket_client, static void batadv_socket_add_packet(struct 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 socket_packet *socket_packet;
...@@ -336,7 +336,7 @@ static void batadv_socket_add_packet(struct socket_client *socket_client, ...@@ -336,7 +336,7 @@ 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 socket_client *hash;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
void batadv_socket_init(void); void batadv_socket_init(void);
int batadv_socket_setup(struct bat_priv *bat_priv); int batadv_socket_setup(struct bat_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_ */
...@@ -205,7 +205,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -205,7 +205,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
struct batman_ogm_packet *batman_ogm_packet; struct batadv_ogm_packet *batadv_ogm_packet;
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
uint8_t idx; uint8_t idx;
int ret; int ret;
...@@ -237,19 +237,19 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -237,19 +237,19 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (hard_iface->if_status != BATADV_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(BATADV_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)
......
...@@ -101,20 +101,20 @@ enum batadv_bla_claimframe { ...@@ -101,20 +101,20 @@ enum batadv_bla_claimframe {
/* 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.
...@@ -43,7 +43,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, ...@@ -43,7 +43,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
struct neigh_node *neigh_node); struct neigh_node *neigh_node);
void batadv_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, struct orig_node *orig_neigh_node,
const struct batman_ogm_packet 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 bat_priv *bat_priv, int32_t seq_num_diff,
unsigned long *last_reset); unsigned long *last_reset);
......
...@@ -138,7 +138,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -138,7 +138,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
{ {
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
struct forw_packet *forw_packet; struct forw_packet *forw_packet;
struct bcast_packet *bcast_packet; struct batadv_bcast_packet *bcast_packet;
struct sk_buff *newskb; struct sk_buff *newskb;
if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
...@@ -161,7 +161,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -161,7 +161,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
goto packet_free; goto packet_free;
/* as we have a copy now, it is safe to decrease the TTL */ /* as we have a copy now, it is safe to decrease the TTL */
bcast_packet = (struct bcast_packet *)newskb->data; bcast_packet = (struct batadv_bcast_packet *)newskb->data;
bcast_packet->header.ttl--; bcast_packet->header.ttl--;
skb_reset_mac_header(newskb); skb_reset_mac_header(newskb);
......
...@@ -133,7 +133,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -133,7 +133,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct bat_priv *bat_priv = netdev_priv(soft_iface); struct bat_priv *bat_priv = netdev_priv(soft_iface);
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
struct bcast_packet *bcast_packet; struct batadv_bcast_packet *bcast_packet;
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
__be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00,
...@@ -208,7 +208,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -208,7 +208,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0) if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
goto dropped; goto dropped;
bcast_packet = (struct bcast_packet *)skb->data; bcast_packet = (struct batadv_bcast_packet *)skb->data;
bcast_packet->header.version = BATADV_COMPAT_VERSION; bcast_packet->header.version = BATADV_COMPAT_VERSION;
bcast_packet->header.ttl = BATADV_TTL; bcast_packet->header.ttl = BATADV_TTL;
......
This diff is collapsed.
...@@ -43,10 +43,10 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, ...@@ -43,10 +43,10 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
const uint8_t *addr); const uint8_t *addr);
void batadv_tt_free(struct bat_priv *bat_priv); void batadv_tt_free(struct bat_priv *bat_priv);
bool batadv_send_tt_response(struct bat_priv *bat_priv, bool batadv_send_tt_response(struct bat_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 bat_priv *bat_priv, const uint8_t *addr);
void batadv_handle_tt_response(struct bat_priv *bat_priv, void batadv_handle_tt_response(struct bat_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 bat_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 bat_priv *bat_priv,
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#define BATADV_HEADER_LEN \ #define BATADV_HEADER_LEN \
(ETH_HLEN + max(sizeof(struct unicast_packet), \ (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \
sizeof(struct bcast_packet))) sizeof(struct batadv_bcast_packet)))
struct hard_iface { struct hard_iface {
struct list_head list; struct list_head list;
...@@ -211,7 +211,7 @@ struct bat_priv { ...@@ -211,7 +211,7 @@ struct bat_priv {
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
int bcast_duplist_curr; int bcast_duplist_curr;
struct bla_claim_dst claim_dest; struct batadv_bla_claim_dst claim_dest;
#endif #endif
spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
spinlock_t forw_bcast_list_lock; /* protects */ spinlock_t forw_bcast_list_lock; /* protects */
...@@ -250,7 +250,7 @@ struct socket_client { ...@@ -250,7 +250,7 @@ struct socket_client {
struct socket_packet { struct socket_packet {
struct list_head list; struct list_head list;
size_t icmp_len; size_t icmp_len;
struct icmp_packet_rr icmp_packet; struct batadv_icmp_packet_rr icmp_packet;
}; };
struct tt_common_entry { struct tt_common_entry {
...@@ -306,7 +306,7 @@ struct claim { ...@@ -306,7 +306,7 @@ struct claim {
struct tt_change_node { struct tt_change_node {
struct list_head list; struct list_head list;
struct tt_change change; struct batadv_tt_change change;
}; };
struct tt_req_node { struct tt_req_node {
......
...@@ -34,13 +34,13 @@ batadv_frag_merge_packet(struct list_head *head, ...@@ -34,13 +34,13 @@ batadv_frag_merge_packet(struct list_head *head,
struct frag_packet_list_entry *tfp, struct frag_packet_list_entry *tfp,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct unicast_frag_packet *up = struct batadv_unicast_frag_packet *up;
(struct unicast_frag_packet *)skb->data;
struct sk_buff *tmp_skb; struct sk_buff *tmp_skb;
struct unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
int hdr_len = sizeof(*unicast_packet); int hdr_len = sizeof(*unicast_packet);
int uni_diff = sizeof(*up) - hdr_len; int uni_diff = sizeof(*up) - hdr_len;
up = (struct batadv_unicast_frag_packet *)skb->data;
/* set skb to the first part and tmp_skb to the second part */ /* set skb to the first part and tmp_skb to the second part */
if (up->flags & BATADV_UNI_FRAG_HEAD) { if (up->flags & BATADV_UNI_FRAG_HEAD) {
tmp_skb = tfp->skb; tmp_skb = tfp->skb;
...@@ -65,7 +65,8 @@ batadv_frag_merge_packet(struct list_head *head, ...@@ -65,7 +65,8 @@ batadv_frag_merge_packet(struct list_head *head,
kfree_skb(tmp_skb); kfree_skb(tmp_skb);
memmove(skb->data + uni_diff, skb->data, hdr_len); memmove(skb->data + uni_diff, skb->data, hdr_len);
unicast_packet = (struct unicast_packet *)skb_pull(skb, uni_diff); unicast_packet = (struct batadv_unicast_packet *)skb_pull(skb,
uni_diff);
unicast_packet->header.packet_type = BATADV_UNICAST; unicast_packet->header.packet_type = BATADV_UNICAST;
return skb; return skb;
...@@ -80,8 +81,9 @@ static void batadv_frag_create_entry(struct list_head *head, ...@@ -80,8 +81,9 @@ static void batadv_frag_create_entry(struct list_head *head,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct frag_packet_list_entry *tfp; struct frag_packet_list_entry *tfp;
struct unicast_frag_packet *up = struct batadv_unicast_frag_packet *up;
(struct unicast_frag_packet *)skb->data;
up = (struct batadv_unicast_frag_packet *)skb->data;
/* free and oldest packets stand at the end */ /* free and oldest packets stand at the end */
tfp = list_entry((head)->prev, typeof(*tfp), list); tfp = list_entry((head)->prev, typeof(*tfp), list);
...@@ -115,10 +117,10 @@ static int batadv_frag_create_buffer(struct list_head *head) ...@@ -115,10 +117,10 @@ static int batadv_frag_create_buffer(struct list_head *head)
static struct frag_packet_list_entry * static struct frag_packet_list_entry *
batadv_frag_search_packet(struct list_head *head, batadv_frag_search_packet(struct list_head *head,
const struct unicast_frag_packet *up) const struct batadv_unicast_frag_packet *up)
{ {
struct frag_packet_list_entry *tfp; struct frag_packet_list_entry *tfp;
struct unicast_frag_packet *tmp_up = NULL; struct batadv_unicast_frag_packet *tmp_up = NULL;
uint16_t search_seqno; uint16_t search_seqno;
if (up->flags & BATADV_UNI_FRAG_HEAD) if (up->flags & BATADV_UNI_FRAG_HEAD)
...@@ -134,7 +136,7 @@ batadv_frag_search_packet(struct list_head *head, ...@@ -134,7 +136,7 @@ batadv_frag_search_packet(struct list_head *head,
if (tfp->seqno == ntohs(up->seqno)) if (tfp->seqno == ntohs(up->seqno))
goto mov_tail; goto mov_tail;
tmp_up = (struct unicast_frag_packet *)tfp->skb->data; tmp_up = (struct batadv_unicast_frag_packet *)tfp->skb->data;
if (tfp->seqno == search_seqno) { if (tfp->seqno == search_seqno) {
...@@ -179,9 +181,9 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -179,9 +181,9 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct orig_node *orig_node; struct orig_node *orig_node;
struct frag_packet_list_entry *tmp_frag_entry; struct frag_packet_list_entry *tmp_frag_entry;
int ret = NET_RX_DROP; int ret = NET_RX_DROP;
struct unicast_frag_packet *unicast_packet = struct batadv_unicast_frag_packet *unicast_packet;
(struct unicast_frag_packet *)skb->data;
unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
*new_skb = NULL; *new_skb = NULL;
orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig); orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig);
...@@ -220,10 +222,10 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -220,10 +222,10 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int batadv_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 hard_iface *hard_iface, const uint8_t dstaddr[])
{ {
struct unicast_packet tmp_uc, *unicast_packet; struct batadv_unicast_packet tmp_uc, *unicast_packet;
struct hard_iface *primary_if; struct hard_iface *primary_if;
struct sk_buff *frag_skb; struct sk_buff *frag_skb;
struct unicast_frag_packet *frag1, *frag2; struct batadv_unicast_frag_packet *frag1, *frag2;
int uc_hdr_len = sizeof(*unicast_packet); int uc_hdr_len = sizeof(*unicast_packet);
int ucf_hdr_len = sizeof(*frag1); int ucf_hdr_len = sizeof(*frag1);
int data_len = skb->len - uc_hdr_len; int data_len = skb->len - uc_hdr_len;
...@@ -239,7 +241,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -239,7 +241,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
goto dropped; goto dropped;
skb_reserve(frag_skb, ucf_hdr_len); skb_reserve(frag_skb, ucf_hdr_len);
unicast_packet = (struct unicast_packet *)skb->data; unicast_packet = (struct batadv_unicast_packet *)skb->data;
memcpy(&tmp_uc, unicast_packet, uc_hdr_len); memcpy(&tmp_uc, unicast_packet, uc_hdr_len);
skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len); skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len);
...@@ -247,8 +249,8 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -247,8 +249,8 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0) batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0)
goto drop_frag; goto drop_frag;
frag1 = (struct unicast_frag_packet *)skb->data; frag1 = (struct batadv_unicast_frag_packet *)skb->data;
frag2 = (struct unicast_frag_packet *)frag_skb->data; frag2 = (struct batadv_unicast_frag_packet *)frag_skb->data;
memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
...@@ -287,7 +289,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -287,7 +289,7 @@ int batadv_frag_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) int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
{ {
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct orig_node *orig_node; struct orig_node *orig_node;
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
int data_len = skb->len; int data_len = skb->len;
...@@ -317,7 +319,7 @@ int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) ...@@ -317,7 +319,7 @@ int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0) if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0)
goto out; goto out;
unicast_packet = (struct unicast_packet *)skb->data; unicast_packet = (struct batadv_unicast_packet *)skb->data;
unicast_packet->header.version = BATADV_COMPAT_VERSION; unicast_packet->header.version = BATADV_COMPAT_VERSION;
/* batman packet type: unicast */ /* batman packet type: unicast */
......
...@@ -35,11 +35,11 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -35,11 +35,11 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu) static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
{ {
const struct unicast_frag_packet *unicast_packet; const struct batadv_unicast_frag_packet *unicast_packet;
int uneven_correction = 0; int uneven_correction = 0;
unsigned int merged_size; unsigned int merged_size;
unicast_packet = (struct unicast_frag_packet *)skb->data; unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) { if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) {
if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD) if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD)
...@@ -49,7 +49,7 @@ static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu) ...@@ -49,7 +49,7 @@ static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
} }
merged_size = (skb->len - sizeof(*unicast_packet)) * 2; merged_size = (skb->len - sizeof(*unicast_packet)) * 2;
merged_size += sizeof(struct unicast_packet) + uneven_correction; merged_size += sizeof(struct batadv_unicast_packet) + uneven_correction;
return merged_size <= mtu; return merged_size <= mtu;
} }
......
...@@ -53,12 +53,12 @@ static void batadv_free_info(struct kref *ref) ...@@ -53,12 +53,12 @@ static void batadv_free_info(struct kref *ref)
static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
{ {
const struct vis_info *d1, *d2; const struct vis_info *d1, *d2;
const struct vis_packet *p1, *p2; const struct batadv_vis_packet *p1, *p2;
d1 = container_of(node, struct vis_info, hash_entry); d1 = container_of(node, struct vis_info, hash_entry);
d2 = data2; d2 = data2;
p1 = (struct vis_packet *)d1->skb_packet->data; p1 = (struct batadv_vis_packet *)d1->skb_packet->data;
p2 = (struct vis_packet *)d2->skb_packet->data; p2 = (struct batadv_vis_packet *)d2->skb_packet->data;
return batadv_compare_eth(p1->vis_orig, p2->vis_orig); return batadv_compare_eth(p1->vis_orig, p2->vis_orig);
} }
...@@ -68,12 +68,12 @@ static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) ...@@ -68,12 +68,12 @@ static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
static uint32_t batadv_vis_info_choose(const void *data, uint32_t size) static uint32_t batadv_vis_info_choose(const void *data, uint32_t size)
{ {
const struct vis_info *vis_info = data; const struct vis_info *vis_info = data;
const struct vis_packet *packet; const struct batadv_vis_packet *packet;
const unsigned char *key; const unsigned char *key;
uint32_t hash = 0; uint32_t hash = 0;
size_t i; size_t i;
packet = (struct vis_packet *)vis_info->skb_packet->data; packet = (struct batadv_vis_packet *)vis_info->skb_packet->data;
key = packet->vis_orig; key = packet->vis_orig;
for (i = 0; i < ETH_ALEN; i++) { for (i = 0; i < ETH_ALEN; i++) {
hash += key[i]; hash += key[i];
...@@ -169,7 +169,7 @@ static ssize_t batadv_vis_data_read_entry(struct seq_file *seq, ...@@ -169,7 +169,7 @@ static ssize_t batadv_vis_data_read_entry(struct seq_file *seq,
} }
static void batadv_vis_data_insert_interfaces(struct hlist_head *list, static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
struct vis_packet *packet, struct batadv_vis_packet *packet,
struct vis_info_entry *entries) struct vis_info_entry *entries)
{ {
int i; int i;
...@@ -187,7 +187,7 @@ static void batadv_vis_data_insert_interfaces(struct hlist_head *list, ...@@ -187,7 +187,7 @@ static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
static void batadv_vis_data_read_entries(struct seq_file *seq, static void batadv_vis_data_read_entries(struct seq_file *seq,
struct hlist_head *list, struct hlist_head *list,
struct vis_packet *packet, struct batadv_vis_packet *packet,
struct vis_info_entry *entries) struct vis_info_entry *entries)
{ {
int i; int i;
...@@ -214,7 +214,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq, ...@@ -214,7 +214,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
{ {
struct hlist_node *node; struct hlist_node *node;
struct vis_info *info; struct vis_info *info;
struct vis_packet *packet; struct batadv_vis_packet *packet;
uint8_t *entries_pos; uint8_t *entries_pos;
struct vis_info_entry *entries; struct vis_info_entry *entries;
struct if_list_entry *entry; struct if_list_entry *entry;
...@@ -223,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq, ...@@ -223,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
HLIST_HEAD(vis_if_list); HLIST_HEAD(vis_if_list);
hlist_for_each_entry_rcu(info, node, head, hash_entry) { hlist_for_each_entry_rcu(info, node, head, hash_entry) {
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
entries_pos = (uint8_t *)packet + sizeof(*packet); entries_pos = (uint8_t *)packet + sizeof(*packet);
entries = (struct vis_info_entry *)entries_pos; entries = (struct vis_info_entry *)entries_pos;
...@@ -334,15 +334,17 @@ static int batadv_recv_list_is_in(struct bat_priv *bat_priv, ...@@ -334,15 +334,17 @@ static int batadv_recv_list_is_in(struct bat_priv *bat_priv,
* is newer than old entries in the hash. * is newer than old entries in the hash.
*/ */
static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet, struct batadv_vis_packet *vis_packet,
int vis_info_len, int *is_new, int vis_info_len, int *is_new,
int make_broadcast) int make_broadcast)
{ {
struct vis_info *info, *old_info; struct vis_info *info, *old_info;
struct vis_packet *search_packet, *old_packet; struct batadv_vis_packet *search_packet, *old_packet;
struct vis_info search_elem; struct vis_info search_elem;
struct vis_packet *packet; struct batadv_vis_packet *packet;
struct sk_buff *tmp_skb;
int hash_added; int hash_added;
size_t len;
*is_new = 0; *is_new = 0;
/* sanity check */ /* sanity check */
...@@ -353,15 +355,17 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, ...@@ -353,15 +355,17 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet));
if (!search_elem.skb_packet) if (!search_elem.skb_packet)
return NULL; return NULL;
search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet, len = sizeof(*search_packet);
sizeof(*search_packet)); tmp_skb = search_elem.skb_packet;
search_packet = (struct batadv_vis_packet *)skb_put(tmp_skb, len);
memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN);
old_info = batadv_vis_hash_find(bat_priv, &search_elem); old_info = batadv_vis_hash_find(bat_priv, &search_elem);
kfree_skb(search_elem.skb_packet); kfree_skb(search_elem.skb_packet);
if (old_info) { if (old_info) {
old_packet = (struct vis_packet *)old_info->skb_packet->data; tmp_skb = old_info->skb_packet;
old_packet = (struct batadv_vis_packet *)tmp_skb->data;
if (!batadv_seq_after(ntohl(vis_packet->seqno), if (!batadv_seq_after(ntohl(vis_packet->seqno),
ntohl(old_packet->seqno))) { ntohl(old_packet->seqno))) {
if (old_packet->seqno == vis_packet->seqno) { if (old_packet->seqno == vis_packet->seqno) {
...@@ -385,22 +389,21 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, ...@@ -385,22 +389,21 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
if (!info) if (!info)
return NULL; return NULL;
info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + len = sizeof(*packet) + vis_info_len;
ETH_HLEN); info->skb_packet = dev_alloc_skb(len + ETH_HLEN);
if (!info->skb_packet) { if (!info->skb_packet) {
kfree(info); kfree(info);
return NULL; return NULL;
} }
skb_reserve(info->skb_packet, ETH_HLEN); skb_reserve(info->skb_packet, ETH_HLEN);
packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len);
+ vis_info_len);
kref_init(&info->refcount); kref_init(&info->refcount);
INIT_LIST_HEAD(&info->send_list); INIT_LIST_HEAD(&info->send_list);
INIT_LIST_HEAD(&info->recv_list); INIT_LIST_HEAD(&info->recv_list);
info->first_seen = jiffies; info->first_seen = jiffies;
info->bat_priv = bat_priv; info->bat_priv = bat_priv;
memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len); memcpy(packet, vis_packet, len);
/* initialize and add new packet. */ /* initialize and add new packet. */
*is_new = 1; *is_new = 1;
...@@ -430,7 +433,7 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, ...@@ -430,7 +433,7 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
/* handle the server sync packet, forward if needed. */ /* handle the server sync packet, forward if needed. */
void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet, struct batadv_vis_packet *vis_packet,
int vis_info_len) int vis_info_len)
{ {
struct vis_info *info; struct vis_info *info;
...@@ -456,11 +459,11 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, ...@@ -456,11 +459,11 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
/* handle an incoming client update packet and schedule forward if needed. */ /* handle an incoming client update packet and schedule forward if needed. */
void batadv_receive_client_update_packet(struct bat_priv *bat_priv, void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet, struct batadv_vis_packet *vis_packet,
int vis_info_len) int vis_info_len)
{ {
struct vis_info *info; struct vis_info *info;
struct vis_packet *packet; struct batadv_vis_packet *packet;
int is_new; int is_new;
int vis_server = atomic_read(&bat_priv->vis_mode); int vis_server = atomic_read(&bat_priv->vis_mode);
int are_target = 0; int are_target = 0;
...@@ -482,7 +485,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv, ...@@ -482,7 +485,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
goto end; goto end;
/* note that outdated packets will be dropped at this point. */ /* note that outdated packets will be dropped at this point. */
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
/* send only if we're the target server or ... */ /* send only if we're the target server or ... */
if (are_target && is_new) { if (are_target && is_new) {
...@@ -511,11 +514,11 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, ...@@ -511,11 +514,11 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
struct hlist_node *node; struct hlist_node *node;
struct hlist_head *head; struct hlist_head *head;
struct orig_node *orig_node; struct orig_node *orig_node;
struct vis_packet *packet; struct batadv_vis_packet *packet;
int best_tq = -1; int best_tq = -1;
uint32_t i; uint32_t i;
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
...@@ -543,10 +546,10 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, ...@@ -543,10 +546,10 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
/* Return true if the vis packet is full. */ /* Return true if the vis packet is full. */
static bool batadv_vis_packet_full(const struct vis_info *info) static bool batadv_vis_packet_full(const struct vis_info *info)
{ {
const struct vis_packet *packet; const struct batadv_vis_packet *packet;
size_t num_items; size_t num_items;
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry);
if (num_items < packet->entries + 1) if (num_items < packet->entries + 1)
...@@ -565,13 +568,14 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv) ...@@ -565,13 +568,14 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
struct orig_node *orig_node; struct orig_node *orig_node;
struct neigh_node *router; struct neigh_node *router;
struct vis_info *info = bat_priv->my_vis_info; struct vis_info *info = bat_priv->my_vis_info;
struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; struct batadv_vis_packet *packet;
struct vis_info_entry *entry; struct vis_info_entry *entry;
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
int best_tq = -1; int best_tq = -1;
uint32_t i; uint32_t i;
info->first_seen = jiffies; info->first_seen = jiffies;
packet = (struct batadv_vis_packet *)info->skb_packet->data;
packet->vis_type = atomic_read(&bat_priv->vis_mode); packet->vis_type = atomic_read(&bat_priv->vis_mode);
memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
...@@ -691,14 +695,14 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv, ...@@ -691,14 +695,14 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv,
struct hlist_node *node; struct hlist_node *node;
struct hlist_head *head; struct hlist_head *head;
struct orig_node *orig_node; struct orig_node *orig_node;
struct vis_packet *packet; struct batadv_vis_packet *packet;
struct sk_buff *skb; struct sk_buff *skb;
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
uint8_t dstaddr[ETH_ALEN]; uint8_t dstaddr[ETH_ALEN];
uint32_t i; uint32_t i;
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
/* send to all routers in range. */ /* send to all routers in range. */
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
...@@ -745,9 +749,9 @@ static void batadv_unicast_vis_packet(struct bat_priv *bat_priv, ...@@ -745,9 +749,9 @@ static void batadv_unicast_vis_packet(struct bat_priv *bat_priv,
struct orig_node *orig_node; struct orig_node *orig_node;
struct neigh_node *router = NULL; struct neigh_node *router = NULL;
struct sk_buff *skb; struct sk_buff *skb;
struct vis_packet *packet; struct batadv_vis_packet *packet;
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig);
if (!orig_node) if (!orig_node)
...@@ -773,13 +777,13 @@ static void batadv_send_vis_packet(struct bat_priv *bat_priv, ...@@ -773,13 +777,13 @@ static void batadv_send_vis_packet(struct bat_priv *bat_priv,
struct vis_info *info) struct vis_info *info)
{ {
struct hard_iface *primary_if; struct hard_iface *primary_if;
struct vis_packet *packet; struct batadv_vis_packet *packet;
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct batadv_vis_packet *)info->skb_packet->data;
if (packet->header.ttl < 2) { if (packet->header.ttl < 2) {
pr_debug("Error - can't send vis packet: ttl exceeded\n"); pr_debug("Error - can't send vis packet: ttl exceeded\n");
goto out; goto out;
...@@ -838,10 +842,11 @@ static void batadv_send_vis_packets(struct work_struct *work) ...@@ -838,10 +842,11 @@ static void batadv_send_vis_packets(struct work_struct *work)
*/ */
int batadv_vis_init(struct bat_priv *bat_priv) int batadv_vis_init(struct bat_priv *bat_priv)
{ {
struct vis_packet *packet; struct batadv_vis_packet *packet;
int hash_added; int hash_added;
unsigned int len; unsigned int len;
unsigned long first_seen; unsigned long first_seen;
struct sk_buff *tmp_skb;
if (bat_priv->vis_hash) if (bat_priv->vis_hash)
return 0; return 0;
...@@ -864,8 +869,8 @@ int batadv_vis_init(struct bat_priv *bat_priv) ...@@ -864,8 +869,8 @@ int batadv_vis_init(struct bat_priv *bat_priv)
goto free_info; goto free_info;
skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, tmp_skb = bat_priv->my_vis_info->skb_packet;
sizeof(*packet)); packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet));
/* prefill the vis info */ /* prefill the vis info */
first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL);
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet, struct batadv_vis_packet *vis_packet,
int vis_info_len); int vis_info_len);
void batadv_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, struct batadv_vis_packet *vis_packet,
int vis_info_len); int vis_info_len);
int batadv_vis_init(struct bat_priv *bat_priv); int batadv_vis_init(struct bat_priv *bat_priv);
void batadv_vis_quit(struct bat_priv *bat_priv); void batadv_vis_quit(struct bat_priv *bat_priv);
......
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