6lowpan: set and use mac_len for mac header length

Set the mac header length while creating the 802.15.4 mac header.

Drop the function for recalculate mac header length in upper layers
which was static and works for intra pan communication only.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: clean lowpan netdev setup

This patch replaces a redundant open-coded calculation
with the already defined MAC802154_FRAME_HARD_HEADER_LEN.

Also replace a magic number with the already defined
IEEE802154_MFR_SIZE.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: remove several copies of sk_buff

The current implementation does many copies of the sk_buff for
increasing headroom which are not necessary.

This patch increases the headroom in the maclayer for a worst case
scenario of (sizeof(struct ipv6hdr) + sizeof(struct udphdr)).

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix fragmentation on sending side

This patch fixes the fragmentation on sending side according to rfc4944.

Also add improvemnt to use the full payload of a PDU which calculate the
nearest divided to 8 payload length for the fragmentation datagram
offset attribute.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: allow to skip bytes in lowpan_fetch_skb

This will add support to skip bytes from skb with the lowpan_fetch_skb
function.

This is necessary for upcomming patches.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix fragmentation on receiving side

This patch fixes the fragmentation of receiving 6lowpan packets.
The current fragmentation isn't rfc4944 compatible.

Add support for fragmentation frame match with source and destination
addresses, instead of using tag id of fragmentation header only.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix udp nullpointer dereferencing

Sometimes a nullpointer dereferencing occurs because a wrong pointer
arithmetic in udp_uncompression.

This patch changes "**(hc06_ptr + 3)" to the right one "*(*hc06_ptr +
3)". Dereferencing like "**(hc06_ptr + 3)" works in a random case only.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix udp compress ordering

In case ((ntohs(uh->source) & LOWPAN_NHC_UDP_8BIT_MASK) the order of
uncompression is wrong. It's always first source port then destionation
port as second.

See:
http://tools.ietf.org/html/rfc6282#section-4.3.3

"Fields carried in-line (in part or in whole) appear in the same order
as they do in the UDP header format"

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix udp byte ordering

The incomming udp header in lowpan_compress_udp_header function is
already in network byte order.

Everytime we read this values for source and destination port we need
to convert this value to host byte order.

In the outcomming header we need to set this value in  networkbyteorder
so the upcomming process have it in the right order.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: add udp warning for elided checksum

Bit 5 of "UDP LOWPAN_NHC Format" indicate that the checksum can be elided.
The host need to calculate the udp checksum afterwards but this isn't
supported right now.

See:
http://tools.ietf.org/html/rfc6282#section-4.3.3
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: udp use lowpan_fetch_skb function

Cleanup the lowpan_uncompress_udp_header function to use the
lowpan_fetch_skb function.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: udp use subtraction on both conditions

Cleanup code to handle both calculation in the same way.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: udp remove unecessary break

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: fix fragmentation race condition

If the timer expire on fragmentation handling we need to hold the
flist_lock spinlock while accessing fraglist.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
6lowpan: use try_to_del_timer_sync instead del_timer_sync

This is a race condition fix if the timer expire on when the last frame
is arrived otherwise we cleanup the list entry twice.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>