Commit b6da4bf5 authored by Marek Lindner's avatar Marek Lindner

batman-adv: rename all instances of batman_packet to batman_ogm_packet

The follow-up routing code changes are going to introduce additional
routing packet types which make this distinction necessary.
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent a943cac1
......@@ -27,7 +27,8 @@
#include "hard-interface.h"
/* return true if new_packet can be aggregated with forw_packet */
static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
static bool can_aggregate_with(const struct batman_ogm_packet
*new_batman_ogm_packet,
struct bat_priv *bat_priv,
int packet_len,
unsigned long send_time,
......@@ -35,8 +36,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
const struct hard_iface *if_incoming,
const struct forw_packet *forw_packet)
{
struct batman_packet *batman_packet =
(struct batman_packet *)forw_packet->skb->data;
struct batman_ogm_packet *batman_ogm_packet =
(struct batman_ogm_packet *)forw_packet->skb->data;
int aggregated_bytes = forw_packet->packet_len + packet_len;
struct hard_iface *primary_if = NULL;
bool res = false;
......@@ -71,8 +72,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
/* packets without direct link flag and high TTL
* are flooded through the net */
if ((!directlink) &&
(!(batman_packet->flags & DIRECTLINK)) &&
(batman_packet->ttl != 1) &&
(!(batman_ogm_packet->flags & DIRECTLINK)) &&
(batman_ogm_packet->ttl != 1) &&
/* own packets originating non-primary
* interfaces leave only that interface */
......@@ -85,13 +86,13 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
/* if the incoming packet is sent via this one
* interface only - we still can aggregate */
if ((directlink) &&
(new_batman_packet->ttl == 1) &&
(new_batman_ogm_packet->ttl == 1) &&
(forw_packet->if_incoming == if_incoming) &&
/* packets from direct neighbors or
* own secondary interface packets
* (= secondary interface packets in general) */
(batman_packet->flags & DIRECTLINK ||
(batman_ogm_packet->flags & DIRECTLINK ||
(forw_packet->own &&
forw_packet->if_incoming != primary_if))) {
res = true;
......@@ -213,9 +214,11 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
*/
struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL;
struct hlist_node *tmp_node;
struct batman_packet *batman_packet =
(struct batman_packet *)packet_buff;
bool direct_link = batman_packet->flags & DIRECTLINK ? 1 : 0;
struct batman_ogm_packet *batman_ogm_packet;
bool direct_link;
batman_ogm_packet = (struct batman_ogm_packet *)packet_buff;
direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0;
/* find position for the packet in the forward queue */
spin_lock_bh(&bat_priv->forw_bat_list_lock);
......@@ -223,7 +226,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) {
if (can_aggregate_with(batman_packet,
if (can_aggregate_with(batman_ogm_packet,
bat_priv,
packet_len,
send_time,
......@@ -267,27 +270,28 @@ void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
unsigned char *packet_buff, int packet_len,
struct hard_iface *if_incoming)
{
struct batman_packet *batman_packet;
struct batman_ogm_packet *batman_ogm_packet;
int buff_pos = 0;
unsigned char *tt_buff;
batman_packet = (struct batman_packet *)packet_buff;
batman_ogm_packet = (struct batman_ogm_packet *)packet_buff;
do {
/* network to host order for our 32bit seqno and the
orig_interval */
batman_packet->seqno = ntohl(batman_packet->seqno);
batman_packet->tt_crc = ntohs(batman_packet->tt_crc);
batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno);
batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc);
tt_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN;
receive_bat_packet(ethhdr, batman_packet, tt_buff, if_incoming);
receive_bat_packet(ethhdr, batman_ogm_packet,
tt_buff, if_incoming);
buff_pos += BAT_PACKET_LEN +
tt_len(batman_packet->tt_num_changes);
buff_pos += BATMAN_OGM_LEN +
tt_len(batman_ogm_packet->tt_num_changes);
batman_packet = (struct batman_packet *)
(packet_buff + buff_pos);
batman_ogm_packet = (struct batman_ogm_packet *)
(packet_buff + buff_pos);
} while (aggregated_packet(buff_pos, packet_len,
batman_packet->tt_num_changes));
batman_ogm_packet->tt_num_changes));
}
......@@ -28,7 +28,7 @@
static inline int aggregated_packet(int buff_pos, int packet_len,
int tt_num_changes)
{
int next_buff_pos = buff_pos + BAT_PACKET_LEN + tt_len(tt_num_changes);
int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes);
return (next_buff_pos <= packet_len) &&
(next_buff_pos <= MAX_AGGREGATION_BYTES);
......
......@@ -131,7 +131,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
struct hard_iface *new_hard_iface)
{
struct hard_iface *curr_hard_iface;
struct batman_packet *batman_packet;
struct batman_ogm_packet *batman_ogm_packet;
ASSERT_RTNL();
......@@ -147,9 +147,10 @@ static void primary_if_select(struct bat_priv *bat_priv,
if (!new_hard_iface)
return;
batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
batman_packet->flags = PRIMARIES_FIRST_HOP;
batman_packet->ttl = TTL;
batman_ogm_packet = (struct batman_ogm_packet *)
(new_hard_iface->packet_buff);
batman_ogm_packet->flags = PRIMARIES_FIRST_HOP;
batman_ogm_packet->ttl = TTL;
primary_if_update_addr(bat_priv);
}
......@@ -164,9 +165,12 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
static void update_mac_addresses(struct hard_iface *hard_iface)
{
memcpy(((struct batman_packet *)(hard_iface->packet_buff))->orig,
struct batman_ogm_packet *batman_ogm_packet;
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
memcpy(batman_ogm_packet->orig,
hard_iface->net_dev->dev_addr, ETH_ALEN);
memcpy(((struct batman_packet *)(hard_iface->packet_buff))->prev_sender,
memcpy(batman_ogm_packet->prev_sender,
hard_iface->net_dev->dev_addr, ETH_ALEN);
}
......@@ -283,7 +287,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
const char *iface_name)
{
struct bat_priv *bat_priv;
struct batman_packet *batman_packet;
struct batman_ogm_packet *batman_ogm_packet;
struct net_device *soft_iface;
int ret;
......@@ -318,7 +322,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->soft_iface = soft_iface;
bat_priv = netdev_priv(hard_iface->soft_iface);
hard_iface->packet_len = BAT_PACKET_LEN;
hard_iface->packet_len = BATMAN_OGM_LEN;
hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
if (!hard_iface->packet_buff) {
......@@ -328,14 +332,15 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
goto err;
}
batman_packet = (struct batman_packet *)(hard_iface->packet_buff);
batman_packet->packet_type = BAT_PACKET;
batman_packet->version = COMPAT_VERSION;
batman_packet->flags = NO_FLAGS;
batman_packet->ttl = 2;
batman_packet->tq = TQ_MAX_VALUE;
batman_packet->tt_num_changes = 0;
batman_packet->ttvn = 0;
batman_ogm_packet = (struct batman_ogm_packet *)
(hard_iface->packet_buff);
batman_ogm_packet->packet_type = BAT_OGM;
batman_ogm_packet->version = COMPAT_VERSION;
batman_ogm_packet->flags = NO_FLAGS;
batman_ogm_packet->ttl = 2;
batman_ogm_packet->tq = TQ_MAX_VALUE;
batman_ogm_packet->tt_num_changes = 0;
batman_ogm_packet->ttvn = 0;
hard_iface->if_num = bat_priv->num_ifaces;
bat_priv->num_ifaces++;
......@@ -580,7 +585,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev)
{
struct bat_priv *bat_priv;
struct batman_packet *batman_packet;
struct batman_ogm_packet *batman_ogm_packet;
struct hard_iface *hard_iface;
int ret;
......@@ -612,21 +617,21 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (hard_iface->if_status != IF_ACTIVE)
goto err_free;
batman_packet = (struct batman_packet *)skb->data;
batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
if (batman_packet->version != COMPAT_VERSION) {
if (batman_ogm_packet->version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n",
batman_packet->version);
batman_ogm_packet->version);
goto err_free;
}
/* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb. */
switch (batman_packet->packet_type) {
switch (batman_ogm_packet->packet_type) {
/* batman originator packet */
case BAT_PACKET:
case BAT_OGM:
ret = recv_bat_packet(skb, hard_iface);
break;
......
......@@ -25,14 +25,14 @@
#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype {
BAT_PACKET = 0x01,
BAT_ICMP = 0x02,
BAT_UNICAST = 0x03,
BAT_BCAST = 0x04,
BAT_VIS = 0x05,
BAT_OGM = 0x01,
BAT_ICMP = 0x02,
BAT_UNICAST = 0x03,
BAT_BCAST = 0x04,
BAT_VIS = 0x05,
BAT_UNICAST_FRAG = 0x06,
BAT_TT_QUERY = 0x07,
BAT_ROAM_ADV = 0x08
BAT_TT_QUERY = 0x07,
BAT_ROAM_ADV = 0x08
};
/* this file is included by batctl which needs these defines */
......@@ -90,7 +90,7 @@ enum tt_client_flags {
TT_CLIENT_PENDING = 1 << 10
};
struct batman_packet {
struct batman_ogm_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
......@@ -105,7 +105,7 @@ struct batman_packet {
uint16_t tt_crc;
} __packed;
#define BAT_PACKET_LEN sizeof(struct batman_packet)
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
struct icmp_packet {
uint8_t packet_type;
......
This diff is collapsed.
......@@ -24,7 +24,7 @@
void slide_own_bcast_window(struct hard_iface *hard_iface);
void receive_bat_packet(const struct ethhdr *ethhdr,
struct batman_packet *batman_packet,
struct batman_ogm_packet *batman_ogm_packet,
const unsigned char *tt_buff,
struct hard_iface *if_incoming);
void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node,
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
void schedule_own_packet(struct hard_iface *hard_iface);
void schedule_forward_packet(struct orig_node *orig_node,
const struct ethhdr *ethhdr,
struct batman_packet *batman_packet,
struct batman_ogm_packet *batman_ogm_packet,
int directlink,
struct hard_iface *if_outgoing);
int add_bcast_packet_to_list(struct bat_priv *bat_priv,
......
......@@ -445,30 +445,31 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct batman_packet *batman_packet;
struct batman_ogm_packet *batman_ogm_packet;
struct softif_neigh *softif_neigh = NULL;
struct hard_iface *primary_if = NULL;
struct softif_neigh *curr_softif_neigh = NULL;
if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
batman_packet = (struct batman_packet *)
batman_ogm_packet = (struct batman_ogm_packet *)
(skb->data + ETH_HLEN + VLAN_HLEN);
else
batman_packet = (struct batman_packet *)(skb->data + ETH_HLEN);
batman_ogm_packet = (struct batman_ogm_packet *)
(skb->data + ETH_HLEN);
if (batman_packet->version != COMPAT_VERSION)
if (batman_ogm_packet->version != COMPAT_VERSION)
goto out;
if (batman_packet->packet_type != BAT_PACKET)
if (batman_ogm_packet->packet_type != BAT_OGM)
goto out;
if (!(batman_packet->flags & PRIMARIES_FIRST_HOP))
if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
goto out;
if (is_my_mac(batman_packet->orig))
if (is_my_mac(batman_ogm_packet->orig))
goto out;
softif_neigh = softif_neigh_get(bat_priv, batman_packet->orig, vid);
softif_neigh = softif_neigh_get(bat_priv, batman_ogm_packet->orig, vid);
if (!softif_neigh)
goto out;
......
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