diff options
Diffstat (limited to 'net/batman-adv/unicast.h')
-rw-r--r-- | net/batman-adv/unicast.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h index e32b7867a9a4..e7211c279201 100644 --- a/net/batman-adv/unicast.h +++ b/net/batman-adv/unicast.h | |||
@@ -22,6 +22,8 @@ | |||
22 | #ifndef _NET_BATMAN_ADV_UNICAST_H_ | 22 | #ifndef _NET_BATMAN_ADV_UNICAST_H_ |
23 | #define _NET_BATMAN_ADV_UNICAST_H_ | 23 | #define _NET_BATMAN_ADV_UNICAST_H_ |
24 | 24 | ||
25 | #include "packet.h" | ||
26 | |||
25 | #define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */ | 27 | #define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */ |
26 | #define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ | 28 | #define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ |
27 | 29 | ||
@@ -32,4 +34,25 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv); | |||
32 | int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, | 34 | int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, |
33 | struct batman_if *batman_if, uint8_t dstaddr[]); | 35 | struct batman_if *batman_if, uint8_t dstaddr[]); |
34 | 36 | ||
37 | static inline int frag_can_reassemble(struct sk_buff *skb, int mtu) | ||
38 | { | ||
39 | struct unicast_frag_packet *unicast_packet; | ||
40 | int uneven_correction = 0; | ||
41 | unsigned int merged_size; | ||
42 | |||
43 | unicast_packet = (struct unicast_frag_packet *)skb->data; | ||
44 | |||
45 | if (unicast_packet->flags & UNI_FRAG_LARGETAIL) { | ||
46 | if (unicast_packet->flags & UNI_FRAG_HEAD) | ||
47 | uneven_correction = 1; | ||
48 | else | ||
49 | uneven_correction = -1; | ||
50 | } | ||
51 | |||
52 | merged_size = (skb->len - sizeof(struct unicast_frag_packet)) * 2; | ||
53 | merged_size += sizeof(struct unicast_packet) + uneven_correction; | ||
54 | |||
55 | return merged_size <= mtu; | ||
56 | } | ||
57 | |||
35 | #endif /* _NET_BATMAN_ADV_UNICAST_H_ */ | 58 | #endif /* _NET_BATMAN_ADV_UNICAST_H_ */ |