Commit 335fbe0f authored by Marek Lindner's avatar Marek Lindner Committed by Antonio Quartulli

batman-adv: tvlv - convert tt query packet to use tvlv unicast packets

Instead of generating TT specific packets the TVLV unicast API is used
to send translation table data.
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarAntonio Quartulli <antonio@meshcoding.com>
parent e1bf0c14
......@@ -414,8 +414,6 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* vis packet */
batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */
batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */
batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv;
/* unicast tvlv packet */
......
......@@ -31,7 +31,6 @@ enum batadv_packettype {
BATADV_BCAST = 0x04,
BATADV_VIS = 0x05,
BATADV_UNICAST_FRAG = 0x06,
BATADV_TT_QUERY = 0x07,
BATADV_ROAM_ADV = 0x08,
BATADV_UNICAST_4ADDR = 0x09,
BATADV_CODED = 0x0a,
......@@ -83,9 +82,6 @@ enum batadv_unicast_frag_flags {
BATADV_UNI_FRAG_LARGETAIL = BIT(1),
};
/* TT_QUERY subtypes */
#define BATADV_TT_QUERY_TYPE_MASK 0x3
/* tt data subtypes */
#define BATADV_TT_DATA_TYPE_MASK 0x0F
......@@ -271,30 +267,6 @@ struct batadv_vis_packet {
uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
};
struct batadv_tt_query_packet {
struct batadv_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE
*/
uint8_t flags;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];
/* the ttvn field is:
* if TT_REQUEST: ttvn that triggered the
* request
* if TT_RESPONSE: new ttvn for the src
* orig_node
*/
uint8_t ttvn;
/* tt_data field is:
* if TT_REQUEST: crc associated with the
* ttvn
* if TT_RESPONSE: table_size
*/
__be16 tt_data;
} __packed;
struct batadv_roam_adv_packet {
struct batadv_header header;
uint8_t reserved;
......@@ -303,11 +275,6 @@ struct batadv_roam_adv_packet {
uint8_t client[ETH_ALEN];
} __packed;
struct batadv_tt_change {
uint8_t flags;
uint8_t addr[ETH_ALEN];
} __packed;
/**
* struct batadv_coded_packet - network coded packet
* @header: common batman packet header and ttl of first included packet
......
......@@ -557,84 +557,6 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
return 0;
}
int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_tt_query_packet *tt_query;
uint16_t tt_size;
int hdr_size = sizeof(*tt_query);
char tt_flag;
size_t packet_size;
if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
return NET_RX_DROP;
/* I could need to modify it */
if (skb_cow(skb, sizeof(struct batadv_tt_query_packet)) < 0)
goto out;
tt_query = (struct batadv_tt_query_packet *)skb->data;
switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {
case BATADV_TT_REQUEST:
batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_RX);
/* If we cannot provide an answer the tt_request is
* forwarded
*/
if (!batadv_send_tt_response(bat_priv, tt_query)) {
if (tt_query->flags & BATADV_TT_FULL_TABLE)
tt_flag = 'F';
else
tt_flag = '.';
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Routing TT_REQUEST to %pM [%c]\n",
tt_query->dst,
tt_flag);
return batadv_route_unicast_packet(skb, recv_if);
}
break;
case BATADV_TT_RESPONSE:
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX);
if (batadv_is_my_mac(bat_priv, tt_query->dst)) {
/* packet needs to be linearized to access the TT
* changes
*/
if (skb_linearize(skb) < 0)
goto out;
/* skb_linearize() possibly changed skb->data */
tt_query = (struct batadv_tt_query_packet *)skb->data;
tt_size = batadv_tt_len(ntohs(tt_query->tt_data));
/* Ensure we have all the claimed data */
packet_size = sizeof(struct batadv_tt_query_packet);
packet_size += tt_size;
if (unlikely(skb_headlen(skb) < packet_size))
goto out;
batadv_handle_tt_response(bat_priv, tt_query);
} else {
if (tt_query->flags & BATADV_TT_FULL_TABLE)
tt_flag = 'F';
else
tt_flag = '.';
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Routing TT_RESPONSE to %pM [%c]\n",
tt_query->dst,
tt_flag);
return batadv_route_unicast_packet(skb, recv_if);
}
break;
}
out:
/* returning NET_RX_DROP will make the caller function kfree the skb */
return NET_RX_DROP;
}
int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
......
This diff is collapsed.
......@@ -20,7 +20,6 @@
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
int batadv_tt_len(int changes_num);
int batadv_tt_init(struct batadv_priv *bat_priv);
void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int ifindex);
......@@ -43,11 +42,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
const uint8_t *src,
const uint8_t *addr);
void batadv_tt_free(struct batadv_priv *bat_priv);
bool batadv_send_tt_response(struct batadv_priv *bat_priv,
struct batadv_tt_query_packet *tt_request);
bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr);
void batadv_handle_tt_response(struct batadv_priv *bat_priv,
struct batadv_tt_query_packet *tt_response);
bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src,
uint8_t *dst);
void batadv_tt_local_commit_changes(struct batadv_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