diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2011-07-30 06:33:33 -0400 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2011-09-08 11:39:06 -0400 |
commit | d0b9fd89c2e44693e4c696bc1454fbe623d2e261 (patch) | |
tree | 6705d2901d687505cb62172a9fe26f8f90240bc4 | |
parent | fc9572756418e13e0bffaf2d58f678b907602507 (diff) |
batman-adv: move routing packet initialization into corresponding file
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 37 | ||||
-rw-r--r-- | net/batman-adv/bat_ogm.h | 3 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.c | 38 |
3 files changed, 46 insertions, 32 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 6fa2d465b6cd..468bd5e1f7f5 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -30,6 +30,43 @@ | |||
30 | #include "hard-interface.h" | 30 | #include "hard-interface.h" |
31 | #include "send.h" | 31 | #include "send.h" |
32 | 32 | ||
33 | void bat_ogm_init(struct hard_iface *hard_iface) | ||
34 | { | ||
35 | struct batman_ogm_packet *batman_ogm_packet; | ||
36 | |||
37 | hard_iface->packet_len = BATMAN_OGM_LEN; | ||
38 | hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC); | ||
39 | |||
40 | batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; | ||
41 | batman_ogm_packet->packet_type = BAT_OGM; | ||
42 | batman_ogm_packet->version = COMPAT_VERSION; | ||
43 | batman_ogm_packet->flags = NO_FLAGS; | ||
44 | batman_ogm_packet->ttl = 2; | ||
45 | batman_ogm_packet->tq = TQ_MAX_VALUE; | ||
46 | batman_ogm_packet->tt_num_changes = 0; | ||
47 | batman_ogm_packet->ttvn = 0; | ||
48 | } | ||
49 | |||
50 | void bat_ogm_init_primary(struct hard_iface *hard_iface) | ||
51 | { | ||
52 | struct batman_ogm_packet *batman_ogm_packet; | ||
53 | |||
54 | batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; | ||
55 | batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; | ||
56 | batman_ogm_packet->ttl = TTL; | ||
57 | } | ||
58 | |||
59 | void bat_ogm_update_mac(struct hard_iface *hard_iface) | ||
60 | { | ||
61 | struct batman_ogm_packet *batman_ogm_packet; | ||
62 | |||
63 | batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; | ||
64 | memcpy(batman_ogm_packet->orig, | ||
65 | hard_iface->net_dev->dev_addr, ETH_ALEN); | ||
66 | memcpy(batman_ogm_packet->prev_sender, | ||
67 | hard_iface->net_dev->dev_addr, ETH_ALEN); | ||
68 | } | ||
69 | |||
33 | /* is there another aggregated packet here? */ | 70 | /* is there another aggregated packet here? */ |
34 | static int bat_ogm_aggr_packet(int buff_pos, int packet_len, | 71 | static int bat_ogm_aggr_packet(int buff_pos, int packet_len, |
35 | int tt_num_changes) | 72 | int tt_num_changes) |
diff --git a/net/batman-adv/bat_ogm.h b/net/batman-adv/bat_ogm.h index bdd3d1eb4c20..7809b92500bd 100644 --- a/net/batman-adv/bat_ogm.h +++ b/net/batman-adv/bat_ogm.h | |||
@@ -24,6 +24,9 @@ | |||
24 | 24 | ||
25 | #include "main.h" | 25 | #include "main.h" |
26 | 26 | ||
27 | void bat_ogm_init(struct hard_iface *hard_iface); | ||
28 | void bat_ogm_init_primary(struct hard_iface *hard_iface); | ||
29 | void bat_ogm_update_mac(struct hard_iface *hard_iface); | ||
27 | void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff, | 30 | void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff, |
28 | int packet_len, struct hard_iface *if_incoming); | 31 | int packet_len, struct hard_iface *if_incoming); |
29 | 32 | ||
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index cfee0178ec62..2a1558242845 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -28,6 +28,7 @@ | |||
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" | ||
31 | 32 | ||
32 | #include <linux/if_arp.h> | 33 | #include <linux/if_arp.h> |
33 | 34 | ||
@@ -131,7 +132,6 @@ static void primary_if_select(struct bat_priv *bat_priv, | |||
131 | struct hard_iface *new_hard_iface) | 132 | struct hard_iface *new_hard_iface) |
132 | { | 133 | { |
133 | struct hard_iface *curr_hard_iface; | 134 | struct hard_iface *curr_hard_iface; |
134 | struct batman_ogm_packet *batman_ogm_packet; | ||
135 | 135 | ||
136 | ASSERT_RTNL(); | 136 | ASSERT_RTNL(); |
137 | 137 | ||
@@ -147,11 +147,7 @@ static void primary_if_select(struct bat_priv *bat_priv, | |||
147 | if (!new_hard_iface) | 147 | if (!new_hard_iface) |
148 | return; | 148 | return; |
149 | 149 | ||
150 | batman_ogm_packet = (struct batman_ogm_packet *) | 150 | bat_ogm_init_primary(new_hard_iface); |
151 | (new_hard_iface->packet_buff); | ||
152 | batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; | ||
153 | batman_ogm_packet->ttl = TTL; | ||
154 | |||
155 | primary_if_update_addr(bat_priv); | 151 | primary_if_update_addr(bat_priv); |
156 | } | 152 | } |
157 | 153 | ||
@@ -163,17 +159,6 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface) | |||
163 | return false; | 159 | return false; |
164 | } | 160 | } |
165 | 161 | ||
166 | static void update_mac_addresses(struct hard_iface *hard_iface) | ||
167 | { | ||
168 | struct batman_ogm_packet *batman_ogm_packet; | ||
169 | |||
170 | batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; | ||
171 | memcpy(batman_ogm_packet->orig, | ||
172 | hard_iface->net_dev->dev_addr, ETH_ALEN); | ||
173 | memcpy(batman_ogm_packet->prev_sender, | ||
174 | hard_iface->net_dev->dev_addr, ETH_ALEN); | ||
175 | } | ||
176 | |||
177 | static void check_known_mac_addr(const struct net_device *net_dev) | 162 | static void check_known_mac_addr(const struct net_device *net_dev) |
178 | { | 163 | { |
179 | const struct hard_iface *hard_iface; | 164 | const struct hard_iface *hard_iface; |
@@ -248,7 +233,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) | |||
248 | 233 | ||
249 | bat_priv = netdev_priv(hard_iface->soft_iface); | 234 | bat_priv = netdev_priv(hard_iface->soft_iface); |
250 | 235 | ||
251 | update_mac_addresses(hard_iface); | 236 | bat_ogm_update_mac(hard_iface); |
252 | hard_iface->if_status = IF_TO_BE_ACTIVATED; | 237 | hard_iface->if_status = IF_TO_BE_ACTIVATED; |
253 | 238 | ||
254 | /** | 239 | /** |
@@ -287,7 +272,6 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
287 | const char *iface_name) | 272 | const char *iface_name) |
288 | { | 273 | { |
289 | struct bat_priv *bat_priv; | 274 | struct bat_priv *bat_priv; |
290 | struct batman_ogm_packet *batman_ogm_packet; | ||
291 | struct net_device *soft_iface; | 275 | struct net_device *soft_iface; |
292 | int ret; | 276 | int ret; |
293 | 277 | ||
@@ -322,8 +306,8 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
322 | 306 | ||
323 | hard_iface->soft_iface = soft_iface; | 307 | hard_iface->soft_iface = soft_iface; |
324 | bat_priv = netdev_priv(hard_iface->soft_iface); | 308 | bat_priv = netdev_priv(hard_iface->soft_iface); |
325 | hard_iface->packet_len = BATMAN_OGM_LEN; | 309 | |
326 | hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC); | 310 | bat_ogm_init(hard_iface); |
327 | 311 | ||
328 | if (!hard_iface->packet_buff) { | 312 | if (!hard_iface->packet_buff) { |
329 | bat_err(hard_iface->soft_iface, "Can't add interface packet " | 313 | bat_err(hard_iface->soft_iface, "Can't add interface packet " |
@@ -332,16 +316,6 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
332 | goto err; | 316 | goto err; |
333 | } | 317 | } |
334 | 318 | ||
335 | batman_ogm_packet = (struct batman_ogm_packet *) | ||
336 | (hard_iface->packet_buff); | ||
337 | batman_ogm_packet->packet_type = BAT_OGM; | ||
338 | batman_ogm_packet->version = COMPAT_VERSION; | ||
339 | batman_ogm_packet->flags = NO_FLAGS; | ||
340 | batman_ogm_packet->ttl = 2; | ||
341 | batman_ogm_packet->tq = TQ_MAX_VALUE; | ||
342 | batman_ogm_packet->tt_num_changes = 0; | ||
343 | batman_ogm_packet->ttvn = 0; | ||
344 | |||
345 | hard_iface->if_num = bat_priv->num_ifaces; | 319 | hard_iface->if_num = bat_priv->num_ifaces; |
346 | bat_priv->num_ifaces++; | 320 | bat_priv->num_ifaces++; |
347 | hard_iface->if_status = IF_INACTIVE; | 321 | hard_iface->if_status = IF_INACTIVE; |
@@ -556,7 +530,7 @@ static int hard_if_event(struct notifier_block *this, | |||
556 | goto hardif_put; | 530 | goto hardif_put; |
557 | 531 | ||
558 | check_known_mac_addr(hard_iface->net_dev); | 532 | check_known_mac_addr(hard_iface->net_dev); |
559 | update_mac_addresses(hard_iface); | 533 | bat_ogm_update_mac(hard_iface); |
560 | 534 | ||
561 | bat_priv = netdev_priv(hard_iface->soft_iface); | 535 | bat_priv = netdev_priv(hard_iface->soft_iface); |
562 | primary_if = primary_if_get_selected(bat_priv); | 536 | primary_if = primary_if_get_selected(bat_priv); |