aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-11-28 08:31:55 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-16 13:50:20 -0500
commit01c4224b51feba2ba64d070ab9f4aa32c9d0bb29 (patch)
tree80ca19da3b90b2b69f01492c06310be4c8678efc /net/batman-adv
parent1c280471b013e26c833fc86acc231c73442cfa21 (diff)
batman-adv: convert batman iv algorithm to use dynamic infrastructure
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/bat_iv_ogm.c179
-rw-r--r--net/batman-adv/bat_ogm.h34
-rw-r--r--net/batman-adv/hard-interface.c10
-rw-r--r--net/batman-adv/main.c12
-rw-r--r--net/batman-adv/routing.c4
-rw-r--r--net/batman-adv/send.c5
-rw-r--r--net/batman-adv/types.h14
7 files changed, 129 insertions, 129 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1847efaaa6fd..1c483a5dd808 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include "main.h" 22#include "main.h"
23#include "bat_ogm.h"
24#include "translation-table.h" 23#include "translation-table.h"
25#include "ring_buffer.h" 24#include "ring_buffer.h"
26#include "originator.h" 25#include "originator.h"
@@ -31,7 +30,7 @@
31#include "send.h" 30#include "send.h"
32#include "bat_algo.h" 31#include "bat_algo.h"
33 32
34void bat_ogm_init(struct hard_iface *hard_iface) 33static void bat_iv_ogm_init(struct hard_iface *hard_iface)
35{ 34{
36 struct batman_ogm_packet *batman_ogm_packet; 35 struct batman_ogm_packet *batman_ogm_packet;
37 36
@@ -48,7 +47,7 @@ void bat_ogm_init(struct hard_iface *hard_iface)
48 batman_ogm_packet->ttvn = 0; 47 batman_ogm_packet->ttvn = 0;
49} 48}
50 49
51void bat_ogm_init_primary(struct hard_iface *hard_iface) 50static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface)
52{ 51{
53 struct batman_ogm_packet *batman_ogm_packet; 52 struct batman_ogm_packet *batman_ogm_packet;
54 53
@@ -57,7 +56,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)
57 batman_ogm_packet->header.ttl = TTL; 56 batman_ogm_packet->header.ttl = TTL;
58} 57}
59 58
60void bat_ogm_update_mac(struct hard_iface *hard_iface) 59static void bat_iv_ogm_update_mac(struct hard_iface *hard_iface)
61{ 60{
62 struct batman_ogm_packet *batman_ogm_packet; 61 struct batman_ogm_packet *batman_ogm_packet;
63 62
@@ -69,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface)
69} 68}
70 69
71/* when do we schedule our own ogm to be sent */ 70/* when do we schedule our own ogm to be sent */
72static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv) 71static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
73{ 72{
74 return jiffies + msecs_to_jiffies( 73 return jiffies + msecs_to_jiffies(
75 atomic_read(&bat_priv->orig_interval) - 74 atomic_read(&bat_priv->orig_interval) -
@@ -77,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
77} 76}
78 77
79/* when do we schedule a ogm packet to be sent */ 78/* when do we schedule a ogm packet to be sent */
80static unsigned long bat_ogm_fwd_send_time(void) 79static unsigned long bat_iv_ogm_fwd_send_time(void)
81{ 80{
82 return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); 81 return jiffies + msecs_to_jiffies(random32() % (JITTER/2));
83} 82}
@@ -90,8 +89,8 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
90} 89}
91 90
92/* is there another aggregated packet here? */ 91/* is there another aggregated packet here? */
93static int bat_ogm_aggr_packet(int buff_pos, int packet_len, 92static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
94 int tt_num_changes) 93 int tt_num_changes)
95{ 94{
96 int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes); 95 int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes);
97 96
@@ -100,8 +99,8 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
100} 99}
101 100
102/* send a batman ogm to a given interface */ 101/* send a batman ogm to a given interface */
103static void bat_ogm_send_to_if(struct forw_packet *forw_packet, 102static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
104 struct hard_iface *hard_iface) 103 struct hard_iface *hard_iface)
105{ 104{
106 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 105 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
107 char *fwd_str; 106 char *fwd_str;
@@ -118,8 +117,8 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
118 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 117 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
119 118
120 /* adjust all flags and log packets */ 119 /* adjust all flags and log packets */
121 while (bat_ogm_aggr_packet(buff_pos, forw_packet->packet_len, 120 while (bat_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
122 batman_ogm_packet->tt_num_changes)) { 121 batman_ogm_packet->tt_num_changes)) {
123 122
124 /* we might have aggregated direct link packets with an 123 /* we might have aggregated direct link packets with an
125 * ordinary base packet */ 124 * ordinary base packet */
@@ -158,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
158} 157}
159 158
160/* send a batman ogm packet */ 159/* send a batman ogm packet */
161void bat_ogm_emit(struct forw_packet *forw_packet) 160static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
162{ 161{
163 struct hard_iface *hard_iface; 162 struct hard_iface *hard_iface;
164 struct net_device *soft_iface; 163 struct net_device *soft_iface;
@@ -217,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
217 if (hard_iface->soft_iface != soft_iface) 216 if (hard_iface->soft_iface != soft_iface)
218 continue; 217 continue;
219 218
220 bat_ogm_send_to_if(forw_packet, hard_iface); 219 bat_iv_ogm_send_to_if(forw_packet, hard_iface);
221 } 220 }
222 rcu_read_unlock(); 221 rcu_read_unlock();
223 222
@@ -227,13 +226,13 @@ out:
227} 226}
228 227
229/* return true if new_packet can be aggregated with forw_packet */ 228/* return true if new_packet can be aggregated with forw_packet */
230static bool bat_ogm_can_aggregate(const struct batman_ogm_packet 229static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
231 *new_batman_ogm_packet, 230 *new_batman_ogm_packet,
232 struct bat_priv *bat_priv, 231 struct bat_priv *bat_priv,
233 int packet_len, unsigned long send_time, 232 int packet_len, unsigned long send_time,
234 bool directlink, 233 bool directlink,
235 const struct hard_iface *if_incoming, 234 const struct hard_iface *if_incoming,
236 const struct forw_packet *forw_packet) 235 const struct forw_packet *forw_packet)
237{ 236{
238 struct batman_ogm_packet *batman_ogm_packet; 237 struct batman_ogm_packet *batman_ogm_packet;
239 int aggregated_bytes = forw_packet->packet_len + packet_len; 238 int aggregated_bytes = forw_packet->packet_len + packet_len;
@@ -307,11 +306,11 @@ out:
307} 306}
308 307
309/* create a new aggregated packet and add this packet to it */ 308/* create a new aggregated packet and add this packet to it */
310static void bat_ogm_aggregate_new(const unsigned char *packet_buff, 309static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
311 int packet_len, unsigned long send_time, 310 int packet_len, unsigned long send_time,
312 bool direct_link, 311 bool direct_link,
313 struct hard_iface *if_incoming, 312 struct hard_iface *if_incoming,
314 int own_packet) 313 int own_packet)
315{ 314{
316 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 315 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
317 struct forw_packet *forw_packet_aggr; 316 struct forw_packet *forw_packet_aggr;
@@ -386,9 +385,9 @@ out:
386} 385}
387 386
388/* aggregate a new packet into the existing ogm packet */ 387/* aggregate a new packet into the existing ogm packet */
389static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr, 388static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
390 const unsigned char *packet_buff, 389 const unsigned char *packet_buff,
391 int packet_len, bool direct_link) 390 int packet_len, bool direct_link)
392{ 391{
393 unsigned char *skb_buff; 392 unsigned char *skb_buff;
394 393
@@ -403,10 +402,10 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
403 (1 << forw_packet_aggr->num_packets); 402 (1 << forw_packet_aggr->num_packets);
404} 403}
405 404
406static void bat_ogm_queue_add(struct bat_priv *bat_priv, 405static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
407 unsigned char *packet_buff, 406 unsigned char *packet_buff,
408 int packet_len, struct hard_iface *if_incoming, 407 int packet_len, struct hard_iface *if_incoming,
409 int own_packet, unsigned long send_time) 408 int own_packet, unsigned long send_time)
410{ 409{
411 /** 410 /**
412 * _aggr -> pointer to the packet we want to aggregate with 411 * _aggr -> pointer to the packet we want to aggregate with
@@ -426,11 +425,11 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
426 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { 425 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
427 hlist_for_each_entry(forw_packet_pos, tmp_node, 426 hlist_for_each_entry(forw_packet_pos, tmp_node,
428 &bat_priv->forw_bat_list, list) { 427 &bat_priv->forw_bat_list, list) {
429 if (bat_ogm_can_aggregate(batman_ogm_packet, 428 if (bat_iv_ogm_can_aggregate(batman_ogm_packet,
430 bat_priv, packet_len, 429 bat_priv, packet_len,
431 send_time, direct_link, 430 send_time, direct_link,
432 if_incoming, 431 if_incoming,
433 forw_packet_pos)) { 432 forw_packet_pos)) {
434 forw_packet_aggr = forw_packet_pos; 433 forw_packet_aggr = forw_packet_pos;
435 break; 434 break;
436 } 435 }
@@ -452,20 +451,20 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
452 (atomic_read(&bat_priv->aggregated_ogms))) 451 (atomic_read(&bat_priv->aggregated_ogms)))
453 send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); 452 send_time += msecs_to_jiffies(MAX_AGGREGATION_MS);
454 453
455 bat_ogm_aggregate_new(packet_buff, packet_len, 454 bat_iv_ogm_aggregate_new(packet_buff, packet_len,
456 send_time, direct_link, 455 send_time, direct_link,
457 if_incoming, own_packet); 456 if_incoming, own_packet);
458 } else { 457 } else {
459 bat_ogm_aggregate(forw_packet_aggr, packet_buff, packet_len, 458 bat_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
460 direct_link); 459 packet_len, direct_link);
461 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 460 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
462 } 461 }
463} 462}
464 463
465static void bat_ogm_forward(struct orig_node *orig_node, 464static void bat_iv_ogm_forward(struct orig_node *orig_node,
466 const struct ethhdr *ethhdr, 465 const struct ethhdr *ethhdr,
467 struct batman_ogm_packet *batman_ogm_packet, 466 struct batman_ogm_packet *batman_ogm_packet,
468 int directlink, struct hard_iface *if_incoming) 467 int directlink, struct hard_iface *if_incoming)
469{ 468{
470 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 469 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
471 struct neigh_node *router; 470 struct neigh_node *router;
@@ -524,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
524 else 523 else
525 batman_ogm_packet->flags &= ~DIRECTLINK; 524 batman_ogm_packet->flags &= ~DIRECTLINK;
526 525
527 bat_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 526 bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
528 BATMAN_OGM_LEN + tt_len(tt_num_changes), 527 BATMAN_OGM_LEN + tt_len(tt_num_changes),
529 if_incoming, 0, bat_ogm_fwd_send_time()); 528 if_incoming, 0, bat_iv_ogm_fwd_send_time());
530} 529}
531 530
532void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes) 531static void bat_iv_ogm_schedule(struct hard_iface *hard_iface,
532 int tt_num_changes)
533{ 533{
534 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 534 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
535 struct batman_ogm_packet *batman_ogm_packet; 535 struct batman_ogm_packet *batman_ogm_packet;
@@ -566,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
566 atomic_inc(&hard_iface->seqno); 566 atomic_inc(&hard_iface->seqno);
567 567
568 slide_own_bcast_window(hard_iface); 568 slide_own_bcast_window(hard_iface);
569 bat_ogm_queue_add(bat_priv, hard_iface->packet_buff, 569 bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
570 hard_iface->packet_len, hard_iface, 1, 570 hard_iface->packet_len, hard_iface, 1,
571 bat_ogm_emit_send_time(bat_priv)); 571 bat_iv_ogm_emit_send_time(bat_priv));
572 572
573 if (primary_if) 573 if (primary_if)
574 hardif_free_ref(primary_if); 574 hardif_free_ref(primary_if);
575} 575}
576 576
577static void bat_ogm_orig_update(struct bat_priv *bat_priv, 577static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
578 struct orig_node *orig_node, 578 struct orig_node *orig_node,
579 const struct ethhdr *ethhdr, 579 const struct ethhdr *ethhdr,
580 const struct batman_ogm_packet 580 const struct batman_ogm_packet
581 *batman_ogm_packet, 581 *batman_ogm_packet,
582 struct hard_iface *if_incoming, 582 struct hard_iface *if_incoming,
583 const unsigned char *tt_buff, int is_duplicate) 583 const unsigned char *tt_buff,
584 int is_duplicate)
584{ 585{
585 struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 586 struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
586 struct neigh_node *router = NULL; 587 struct neigh_node *router = NULL;
@@ -715,10 +716,10 @@ out:
715 neigh_node_free_ref(router); 716 neigh_node_free_ref(router);
716} 717}
717 718
718static int bat_ogm_calc_tq(struct orig_node *orig_node, 719static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
719 struct orig_node *orig_neigh_node, 720 struct orig_node *orig_neigh_node,
720 struct batman_ogm_packet *batman_ogm_packet, 721 struct batman_ogm_packet *batman_ogm_packet,
721 struct hard_iface *if_incoming) 722 struct hard_iface *if_incoming)
722{ 723{
723 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 724 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
724 struct neigh_node *neigh_node = NULL, *tmp_neigh_node; 725 struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
@@ -827,10 +828,10 @@ out:
827 * -1 the packet is old and has been received while the seqno window 828 * -1 the packet is old and has been received while the seqno window
828 * was protected. Caller should drop it. 829 * was protected. Caller should drop it.
829 */ 830 */
830static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr, 831static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
831 const struct batman_ogm_packet 832 const struct batman_ogm_packet
832 *batman_ogm_packet, 833 *batman_ogm_packet,
833 const struct hard_iface *if_incoming) 834 const struct hard_iface *if_incoming)
834{ 835{
835 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 836 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
836 struct orig_node *orig_node; 837 struct orig_node *orig_node;
@@ -892,10 +893,10 @@ out:
892 return ret; 893 return ret;
893} 894}
894 895
895static void bat_ogm_process(const struct ethhdr *ethhdr, 896static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
896 struct batman_ogm_packet *batman_ogm_packet, 897 struct batman_ogm_packet *batman_ogm_packet,
897 const unsigned char *tt_buff, 898 const unsigned char *tt_buff,
898 struct hard_iface *if_incoming) 899 struct hard_iface *if_incoming)
899{ 900{
900 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 901 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
901 struct hard_iface *hard_iface; 902 struct hard_iface *hard_iface;
@@ -1033,8 +1034,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
1033 if (!orig_node) 1034 if (!orig_node)
1034 return; 1035 return;
1035 1036
1036 is_duplicate = bat_ogm_update_seqnos(ethhdr, batman_ogm_packet, 1037 is_duplicate = bat_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet,
1037 if_incoming); 1038 if_incoming);
1038 1039
1039 if (is_duplicate == -1) { 1040 if (is_duplicate == -1) {
1040 bat_dbg(DBG_BATMAN, bat_priv, 1041 bat_dbg(DBG_BATMAN, bat_priv,
@@ -1083,8 +1084,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
1083 goto out_neigh; 1084 goto out_neigh;
1084 } 1085 }
1085 1086
1086 is_bidirectional = bat_ogm_calc_tq(orig_node, orig_neigh_node, 1087 is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node,
1087 batman_ogm_packet, if_incoming); 1088 batman_ogm_packet, if_incoming);
1088 1089
1089 bonding_save_primary(orig_node, orig_neigh_node, batman_ogm_packet); 1090 bonding_save_primary(orig_node, orig_neigh_node, batman_ogm_packet);
1090 1091
@@ -1094,16 +1095,16 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
1094 (!is_duplicate || 1095 (!is_duplicate ||
1095 ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && 1096 ((orig_node->last_real_seqno == batman_ogm_packet->seqno) &&
1096 (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) 1097 (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl))))
1097 bat_ogm_orig_update(bat_priv, orig_node, ethhdr, 1098 bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1098 batman_ogm_packet, if_incoming, 1099 batman_ogm_packet, if_incoming,
1099 tt_buff, is_duplicate); 1100 tt_buff, is_duplicate);
1100 1101
1101 /* is single hop (direct) neighbor */ 1102 /* is single hop (direct) neighbor */
1102 if (is_single_hop_neigh) { 1103 if (is_single_hop_neigh) {
1103 1104
1104 /* mark direct link on incoming interface */ 1105 /* mark direct link on incoming interface */
1105 bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1106 bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
1106 1, if_incoming); 1107 1, if_incoming);
1107 1108
1108 bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: " 1109 bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: "
1109 "rebroadcast neighbor packet with direct link flag\n"); 1110 "rebroadcast neighbor packet with direct link flag\n");
@@ -1125,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
1125 1126
1126 bat_dbg(DBG_BATMAN, bat_priv, 1127 bat_dbg(DBG_BATMAN, bat_priv,
1127 "Forwarding packet: rebroadcast originator packet\n"); 1128 "Forwarding packet: rebroadcast originator packet\n");
1128 bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 0, if_incoming); 1129 bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
1130 0, if_incoming);
1129 1131
1130out_neigh: 1132out_neigh:
1131 if ((orig_neigh_node) && (!is_single_hop_neigh)) 1133 if ((orig_neigh_node) && (!is_single_hop_neigh))
@@ -1141,7 +1143,8 @@ out:
1141 orig_node_free_ref(orig_node); 1143 orig_node_free_ref(orig_node);
1142} 1144}
1143 1145
1144void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb) 1146static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
1147 struct sk_buff *skb)
1145{ 1148{
1146 struct batman_ogm_packet *batman_ogm_packet; 1149 struct batman_ogm_packet *batman_ogm_packet;
1147 struct ethhdr *ethhdr; 1150 struct ethhdr *ethhdr;
@@ -1162,20 +1165,26 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
1162 1165
1163 tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN; 1166 tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN;
1164 1167
1165 bat_ogm_process(ethhdr, batman_ogm_packet, 1168 bat_iv_ogm_process(ethhdr, batman_ogm_packet,
1166 tt_buff, if_incoming); 1169 tt_buff, if_incoming);
1167 1170
1168 buff_pos += BATMAN_OGM_LEN + 1171 buff_pos += BATMAN_OGM_LEN +
1169 tt_len(batman_ogm_packet->tt_num_changes); 1172 tt_len(batman_ogm_packet->tt_num_changes);
1170 1173
1171 batman_ogm_packet = (struct batman_ogm_packet *) 1174 batman_ogm_packet = (struct batman_ogm_packet *)
1172 (packet_buff + buff_pos); 1175 (packet_buff + buff_pos);
1173 } while (bat_ogm_aggr_packet(buff_pos, packet_len, 1176 } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len,
1174 batman_ogm_packet->tt_num_changes)); 1177 batman_ogm_packet->tt_num_changes));
1175} 1178}
1176 1179
1177static struct bat_algo_ops batman_iv __read_mostly = { 1180static struct bat_algo_ops batman_iv __read_mostly = {
1178 .name = "BATMAN IV", 1181 .name = "BATMAN IV",
1182 .bat_ogm_init = bat_iv_ogm_init,
1183 .bat_ogm_init_primary = bat_iv_ogm_init_primary,
1184 .bat_ogm_update_mac = bat_iv_ogm_update_mac,
1185 .bat_ogm_schedule = bat_iv_ogm_schedule,
1186 .bat_ogm_emit = bat_iv_ogm_emit,
1187 .bat_ogm_receive = bat_iv_ogm_receive,
1179}; 1188};
1180 1189
1181int __init bat_iv_init(void) 1190int __init bat_iv_init(void)
diff --git a/net/batman-adv/bat_ogm.h b/net/batman-adv/bat_ogm.h
deleted file mode 100644
index 47edfde6f924..000000000000
--- a/net/batman-adv/bat_ogm.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
3 *
4 * Marek Lindner, Simon Wunderlich
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA
19 *
20 */
21
22#ifndef _NET_BATMAN_ADV_OGM_H_
23#define _NET_BATMAN_ADV_OGM_H_
24
25#include "main.h"
26
27void bat_ogm_init(struct hard_iface *hard_iface);
28void bat_ogm_init_primary(struct hard_iface *hard_iface);
29void bat_ogm_update_mac(struct hard_iface *hard_iface);
30void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes);
31void bat_ogm_emit(struct forw_packet *forw_packet);
32void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb);
33
34#endif /* _NET_BATMAN_ADV_OGM_H_ */
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 68b667c1d85e..ff5ba406b1cf 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -28,7 +28,6 @@
28#include "bat_sysfs.h" 28#include "bat_sysfs.h"
29#include "originator.h" 29#include "originator.h"
30#include "hash.h" 30#include "hash.h"
31#include "bat_ogm.h"
32 31
33#include <linux/if_arp.h> 32#include <linux/if_arp.h>
34 33
@@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
147 if (!new_hard_iface) 146 if (!new_hard_iface)
148 return; 147 return;
149 148
150 bat_ogm_init_primary(new_hard_iface); 149 bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface);
151 primary_if_update_addr(bat_priv); 150 primary_if_update_addr(bat_priv);
152} 151}
153 152
@@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
233 232
234 bat_priv = netdev_priv(hard_iface->soft_iface); 233 bat_priv = netdev_priv(hard_iface->soft_iface);
235 234
236 bat_ogm_update_mac(hard_iface); 235 bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
237 hard_iface->if_status = IF_TO_BE_ACTIVATED; 236 hard_iface->if_status = IF_TO_BE_ACTIVATED;
238 237
239 /** 238 /**
@@ -315,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
315 hard_iface->soft_iface = soft_iface; 314 hard_iface->soft_iface = soft_iface;
316 bat_priv = netdev_priv(hard_iface->soft_iface); 315 bat_priv = netdev_priv(hard_iface->soft_iface);
317 316
318 bat_ogm_init(hard_iface); 317 bat_priv->bat_algo_ops->bat_ogm_init(hard_iface);
319 318
320 if (!hard_iface->packet_buff) { 319 if (!hard_iface->packet_buff) {
321 bat_err(hard_iface->soft_iface, "Can't add interface packet " 320 bat_err(hard_iface->soft_iface, "Can't add interface packet "
@@ -535,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
535 goto hardif_put; 534 goto hardif_put;
536 535
537 check_known_mac_addr(hard_iface->net_dev); 536 check_known_mac_addr(hard_iface->net_dev);
538 bat_ogm_update_mac(hard_iface);
539 537
540 bat_priv = netdev_priv(hard_iface->soft_iface); 538 bat_priv = netdev_priv(hard_iface->soft_iface);
539 bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
540
541 primary_if = primary_if_get_selected(bat_priv); 541 primary_if = primary_if_get_selected(bat_priv);
542 if (!primary_if) 542 if (!primary_if)
543 goto hardif_put; 543 goto hardif_put;
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 7c87a341f29f..bcc2bddd893a 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -206,6 +206,18 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
206 goto out; 206 goto out;
207 } 207 }
208 208
209 /* all algorithms must implement all ops (for now) */
210 if (!bat_algo_ops->bat_ogm_init ||
211 !bat_algo_ops->bat_ogm_init_primary ||
212 !bat_algo_ops->bat_ogm_update_mac ||
213 !bat_algo_ops->bat_ogm_schedule ||
214 !bat_algo_ops->bat_ogm_emit ||
215 !bat_algo_ops->bat_ogm_receive) {
216 pr_info("Routing algo '%s' does not implement required ops\n",
217 bat_algo_ops->name);
218 goto out;
219 }
220
209 INIT_HLIST_NODE(&bat_algo_ops->list); 221 INIT_HLIST_NODE(&bat_algo_ops->list);
210 hlist_add_head(&bat_algo_ops->list, &bat_algo_list); 222 hlist_add_head(&bat_algo_ops->list, &bat_algo_list);
211 ret = 0; 223 ret = 0;
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 5bc41c896e35..b72d7f3b3c6a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -29,7 +29,6 @@
29#include "originator.h" 29#include "originator.h"
30#include "vis.h" 30#include "vis.h"
31#include "unicast.h" 31#include "unicast.h"
32#include "bat_ogm.h"
33 32
34void slide_own_bcast_window(struct hard_iface *hard_iface) 33void slide_own_bcast_window(struct hard_iface *hard_iface)
35{ 34{
@@ -248,6 +247,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
248 247
249int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) 248int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
250{ 249{
250 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
251 struct ethhdr *ethhdr; 251 struct ethhdr *ethhdr;
252 252
253 /* drop packet if it has not necessary minimum size */ 253 /* drop packet if it has not necessary minimum size */
@@ -272,7 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
272 if (skb_linearize(skb) < 0) 272 if (skb_linearize(skb) < 0)
273 return NET_RX_DROP; 273 return NET_RX_DROP;
274 274
275 bat_ogm_receive(hard_iface, skb); 275 bat_priv->bat_algo_ops->bat_ogm_receive(hard_iface, skb);
276 276
277 kfree_skb(skb); 277 kfree_skb(skb);
278 return NET_RX_SUCCESS; 278 return NET_RX_SUCCESS;
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index b00a0f537b4e..019337e3eafb 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -28,7 +28,6 @@
28#include "vis.h" 28#include "vis.h"
29#include "gateway_common.h" 29#include "gateway_common.h"
30#include "originator.h" 30#include "originator.h"
31#include "bat_ogm.h"
32 31
33static void send_outstanding_bcast_packet(struct work_struct *work); 32static void send_outstanding_bcast_packet(struct work_struct *work);
34 33
@@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
168 if (primary_if) 167 if (primary_if)
169 hardif_free_ref(primary_if); 168 hardif_free_ref(primary_if);
170 169
171 bat_ogm_schedule(hard_iface, tt_num_changes); 170 bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface, tt_num_changes);
172} 171}
173 172
174static void forw_packet_free(struct forw_packet *forw_packet) 173static void forw_packet_free(struct forw_packet *forw_packet)
@@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
318 if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) 317 if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING)
319 goto out; 318 goto out;
320 319
321 bat_ogm_emit(forw_packet); 320 bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet);
322 321
323 /** 322 /**
324 * we have to have at least one packet in the queue 323 * we have to have at least one packet in the queue
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index d21ff2cf668e..650ce5fb1192 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -348,6 +348,20 @@ struct softif_neigh {
348struct bat_algo_ops { 348struct bat_algo_ops {
349 struct hlist_node list; 349 struct hlist_node list;
350 char *name; 350 char *name;
351 /* init OGM when hard-interface is enabled */
352 void (*bat_ogm_init)(struct hard_iface *hard_iface);
353 /* init primary OGM when primary interface is selected */
354 void (*bat_ogm_init_primary)(struct hard_iface *hard_iface);
355 /* init mac addresses of the OGM belonging to this hard-interface */
356 void (*bat_ogm_update_mac)(struct hard_iface *hard_iface);
357 /* prepare a new outgoing OGM for the send queue */
358 void (*bat_ogm_schedule)(struct hard_iface *hard_iface,
359 int tt_num_changes);
360 /* send scheduled OGM */
361 void (*bat_ogm_emit)(struct forw_packet *forw_packet);
362 /* receive incoming OGM */
363 void (*bat_ogm_receive)(struct hard_iface *if_incoming,
364 struct sk_buff *skb);
351}; 365};
352 366
353#endif /* _NET_BATMAN_ADV_TYPES_H_ */ 367#endif /* _NET_BATMAN_ADV_TYPES_H_ */