Changeset 1542
- Timestamp:
- 01/09/10 15:44:01 (7 months ago)
- Location:
- trunk/batman-adv-kernelland
- Files:
-
- 3 modified
-
gateway_client.c (modified) (3 diffs)
-
gateway_client.h (modified) (2 diffs)
-
soft-interface.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/batman-adv-kernelland/gateway_client.c
r1540 r1542 21 21 #include "gateway_client.h" 22 22 #include "gateway_common.h" 23 #include <linux/ip.h> 24 #include <linux/udp.h> 23 25 24 26 LIST_HEAD(gw_list); … … 27 29 atomic_t gw_clnt_class; 28 30 static struct gw_node *curr_gateway; 31 32 void *gw_get_selected(void) 33 { 34 struct gw_node *curr_gateway_tmp = NULL; 35 36 spin_lock(&curr_gw_lock); 37 curr_gateway_tmp = curr_gateway; 38 spin_unlock(&curr_gw_lock); 39 40 if (!curr_gateway_tmp) 41 return NULL; 42 43 return curr_gateway_tmp->orig_node; 44 } 29 45 30 46 void gw_deselect(void) … … 334 350 return bytes_written; 335 351 } 352 353 bool gw_is_target(struct sk_buff *skb) 354 { 355 struct ethhdr *ethhdr; 356 struct iphdr *iphdr; 357 struct udphdr *udphdr; 358 359 if (atomic_read(&gw_mode) != GW_MODE_CLIENT) 360 return false; 361 362 if (!curr_gateway) 363 return false; 364 365 ethhdr = (struct ethhdr *)skb->data; 366 if (ntohs(ethhdr->h_proto) != ETH_P_IP) 367 return false; 368 369 iphdr = (struct iphdr *)(skb->data + ETH_HLEN); 370 371 if (iphdr->protocol != IPPROTO_UDP) 372 return false; 373 374 udphdr = (struct udphdr *)(skb->data + ETH_HLEN + (iphdr->ihl * 4)); 375 376 if (ntohs(udphdr->dest) != 67) 377 return false; 378 379 return true; 380 } -
trunk/batman-adv-kernelland/gateway_client.h
r1540 r1542 22 22 void gw_deselect(void); 23 23 void gw_election(void); 24 void *gw_get_selected(void); 24 25 void gw_check_election(struct orig_node *orig_node); 25 26 void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags); … … 28 29 void gw_node_list_free(void); 29 30 int gw_client_fill_buffer_text(unsigned char *buff, int buff_len); 31 bool gw_is_target(struct sk_buff *skb); -
trunk/batman-adv-kernelland/soft-interface.c
r1527 r1542 27 27 #include "types.h" 28 28 #include "hash.h" 29 #include "gateway_client.h" 29 30 #include <linux/ethtool.h> 30 31 #include <linux/etherdevice.h> … … 182 183 int data_len = skb->len; 183 184 unsigned long flags; 185 bool bcast_dst = false, do_bcast = true; 184 186 185 187 if (atomic_read(&module_state) != MODULE_ACTIVE) … … 190 192 hna_local_add(ethhdr->h_source); 191 193 194 if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) 195 bcast_dst = true; 196 197 if ((bcast_dst) && gw_is_target(skb)) 198 do_bcast = false; 199 192 200 /* ethernet packet should be broadcasted */ 193 if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) { 194 201 if (bcast_dst && do_bcast) { 195 202 if (my_skb_push(skb, sizeof(struct bcast_packet)) < 0) 196 203 goto dropped; … … 220 227 } else { 221 228 spin_lock_irqsave(&orig_hash_lock, flags); 229 222 230 /* get routing information */ 223 orig_node = ((struct orig_node *)hash_find(orig_hash, 231 if (bcast_dst) 232 orig_node = (struct orig_node *)gw_get_selected(); 233 else 234 orig_node = ((struct orig_node *)hash_find(orig_hash, 224 235 ethhdr->h_dest)); 225 236
