Initial net6.h [dnacd]

Has the definition of an IPv6 address and IPv6 header. It may make sense
to separate the v4 support from net.h (or to include this in net.h).

Cc: Kim Phillips <kim.phillips@freescale.com>
Reviewed-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Series-to: uboot, net
Series-prefix: RFC
Series-version: 3
Series-changes: 2
- use __be16/__be32
- add ipv6_addr_v4mapped and ipv6_addr_is_isatap inline functions
Series-changes: 3
- add reviewed-by from Kim Phillips

Cover-letter:
Initial IPv6 support

This series so far covers the introduction of a IP6addr_t and
printing/parsing of addresses. I have a patch for testing these basic
things which I haven't included in this series yet. Is there a unittest
facility for u-boot I should be using?

A few open questions

1) Presumably the majority of the actual V6 code would be included by a
config option (CONFIG_IPV6). How far should I take that? Should the
vsprintf code be conditional?

2) Our current out of tree code parallels net.c and net.h. Should I
continue this for the final version or integrate it into net.[ch].

3) rxhand_f currently takes an IPaddr_t. I haven't looked at the usage
of this yet but to support V6 this may need to be a new union or a void
*.

END
lib/vsprintf.c: add IPv6 compressed format %pI6c [dnacd]

Add support for "human friendly" IPv6 address representations as
specified in
http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00

This code has been adapted from Linux kernel with minimal modification.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Series-changes: 2
 -Add support for printing mapped and ISATAP addresses
lib/net_utils.c: make string_to_ip stricter [dnacd]

Previously values greater than 255 were implicitly truncated. Add some
stricter checking to reject addresses with components >255.

With the input "1234192.168.1.1" the old behaviour would truncate the
address to 192.168.1.1. New behaviour rejects the string outright and
returns 0, which for the purposes of IP addresses can be considered an
error.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Series-changes: 3
 -Fix a what should have been a glaringly obvious omission that cause
  all addresses to be interpreted as 0. Made even stricter so
  that v6 addresses that start with numbers aren't accepted.
lib/net_utils.c: add string_to_ip6 [dnacd]

string_to_ip6 parses an IPv6 address from a string. Parsing v6 addresses
is a bit more complicated than parsing v4 because there are a number of
different formats that can be used.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Series-notes:
I'm sure the parsing can be better and done in less code with only a
single pass but I haven't yet figured it out. The main problem is that
"::" can represent a variable number of contiguous "0000:" so when
parsing "::" we can't tell how many half words to skip.
END

Series-changes: 3
 -return -1 with the input string is null.
common.h: add getenv_IP6addr [dnacd]

Analogous to getenv_IPaddr but for IPv6. This allows the caller to get an
IP6addr_t from an environment variable.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
tsec: enable promiscuous mode for IPv6 [dnacd]

For IPv6 neighbor discovery to operate correctly we need to register for
various multicast groups (because some neighbor discovery packets are
sent to various multicast addresses).

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Currently the multicast support in the tsec driver is conditional on
CONFIG_MCAST_TFTP and tsec_mcast_addr, eth_mcast_join and
eth_device->mcast all disagree on what the prototype for the function to
add a multicast address should be. Instead of tackling this I've taken
the cowards way out and just enabled promiscuous mode which means the
device sees any packet regardless of the destination address.
net: ipv6 support [dnacd]

Adds basic support for IPv6. Neighbor discovery and ping6 are the only
things supported at the moment. Stub code exists for UDP but it is
untested and unlikely to work.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Series-notes:
Now we have something functional. With this you can do something like
'setenv ipaddr6 3ffe::2' and 'ping6 3ffe::1' should work.
I seem to have a problem that when you send a ping6 for a non-existent
address that ends up stuck and the next non-ipv6 net operation tries to
resolve it. I suspect this is because the pending neighbor discovery
information isn't cleaned up properly.
I'm sending this out now because I'll be away at a conference next week
so probably won't have any time to work on this but I did want to say
"hey ping6 works". When I get back I'll start tackling tftp over ipv6.
END

---
This patch is bigger than I'd like it to be but I'm not sure how to
split it up and keep the parts build able. One obvious thing would be to
remove the UDP stub which I'll be updating anyway in order to support
TFTP over IPv6
testing