batman-adv: turn tt commit code into routing protocol agnostic API
PATCH 1/1 batman-adv: turn tt commit code into routing protocol agnostic API
Prior to this patch the translation table code made assumptions about how the routing protocol works and where its buffers are stored (to directly modify them).
Each protocol now calls the tt code with the relevant pointers, thereby abstracting the code.
--- bat_iv_ogm.c | 14 ++++-- send.c | 74 +--------------------------------- translation-table.c | 113 +++++++++++++++++++++++++++++++++++++++++++++------ translation-table.h | 6 +- types.h | 3 +- 5 files changed, 114 insertions(+), 96 deletions(-)
bat_iv_ogm.c +9 -5
@@ -559,22 +559,28 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, if_incoming, 0, bat_iv_ogm_fwd_send_time()); } -static void bat_iv_ogm_schedule (struct hard_iface *hard_iface, -int tt_num_changes) +static void bat_iv_ogm_schedule (struct hard_iface *hard_iface) {struct bat_priv *bat_priv =netdev_priv (hard_iface->soft_iface);struct batman_ogm_packet *batman_ogm_packet;struct hard_iface *primary_if; -int vis_server; +int vis_server, tt_num_changes =0 ; vis_server =atomic_read (&bat_priv->vis_mode); primary_if =primary_if_get_selected (bat_priv); +if (hard_iface == primary_if) + tt_num_changes =tt_append_changes (bat_priv, + &hard_iface->packet_buff, + &hard_iface->packet_len, +BATMAN_OGM_HLEN ); + batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;/* change sequence number to network order */ batman_ogm_packet->seqno =htonl ((uint32_t )atomic_read (&hard_iface->seqno)); +atomic_inc (&hard_iface->seqno); batman_ogm_packet->ttvn =atomic_read (&bat_priv->ttvn); batman_ogm_packet->tt_crc =htons (bat_priv->tt_crc);
@@ -593,8 +599,6 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface,else batman_ogm_packet->gw_flags =NO_FLAGS ; -atomic_inc (&hard_iface->seqno); -slide_own_bcast_window (hard_iface); bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, hard_iface->packet_len, hard_iface, 1,
send.c +1 -73
89 lines not on this page · raw message
translation-table.c +100 -13
156 lines not on this page · raw message
translation-table.h +3 -3
@@ -23,8 +23,6 @@#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_int tt_len (int changes_num); -int tt_changes_fill_buffer (struct bat_priv *bat_priv, -unsigned char *buff,int buff_len);int tt_init (struct bat_priv *bat_priv);void tt_local_add (struct net_device *soft_iface,const uint8_t *addr,int ifindex);
@@ -48,11 +46,13 @@ bool send_tt_response(struct bat_priv *bat_priv,bool is_my_client (struct bat_priv *bat_priv,const uint8_t *addr);void handle_tt_response (struct bat_priv *bat_priv,struct tt_query_packet *tt_response); -void tt_commit_changes (struct bat_priv *bat_priv);bool is_ap_isolated (struct bat_priv *bat_priv,uint8_t *src,uint8_t *dst);void tt_update_orig (struct bat_priv *bat_priv,struct orig_node *orig_node,const unsigned char *tt_buff,uint8_t tt_num_changes,uint8_t ttvn,uint16_t tt_crc); +int tt_append_changes (struct bat_priv *bat_priv, +unsigned char **packet_buff,int *packet_buff_len, +int packet_min_len);bool tt_global_client_is_roaming (struct bat_priv *bat_priv,uint8_t *addr);
types.h +1 -2
@@ -427,8 +427,7 @@ struct bat_algo_ops {/* called when primary interface is selected / changed */ void (*bat_primary_iface_set)(struct hard_iface *hard_iface);/* prepare a new outgoing OGM for the send queue */ -void (*bat_ogm_schedule)(struct hard_iface *hard_iface, -int tt_num_changes); +void (*bat_ogm_schedule)(struct hard_iface *hard_iface);/* send scheduled OGM */ void (*bat_ogm_emit)(struct forw_packet *forw_packet); };
Signature · 1 line
1.7.9.1
Quoted 7 lines · Marek Lindner
Prior to this patch the translation table code made assumptions about how the routing protocol works and where its buffers are stored (to directly modify them).
Each protocol now calls the tt code with the relevant pointers, thereby abstracting the code.Signed-off-by Marek Lindner <[email protected]>
Signature · 4 lines
Antonio Quartulli ..each of us alone is worth nothing.. Ernesto "Che" Guevara
Marek Lindner
AppliedQuoted 9 lines · On Monday, May 07, 2012 15:15:00 Antonio Quartulli wrote:
Quoted 8 lines · Marek Lindner
Prior to this patch the translation table code made assumptions about how the routing protocol works and where its buffers are stored (to directly modify them).
Each protocol now calls the tt code with the relevant pointers, thereby abstracting the code.
Quoted 3 lines
Quoted 1 line
Signed-off-by Marek Lindner <[email protected]>
Applied in revision 29ccfec.
Regards,
Marek