2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Ethernet output for IPv6. Uses ND tables for link-layer addressing.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Copyright (c) 2010 Inico Technologies Ltd.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * All rights reserved.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Redistribution and use in source and binary forms, with or without modification,
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * are permitted provided that the following conditions are met:
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * 1. Redistributions of source code must retain the above copyright notice,
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * this list of conditions and the following disclaimer.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * 2. Redistributions in binary form must reproduce the above copyright notice,
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * this list of conditions and the following disclaimer in the documentation
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * and/or other materials provided with the distribution.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * 3. The name of the author may not be used to endorse or promote products
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * derived from this software without specific prior written permission.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * OF SUCH DAMAGE.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * This file is part of the lwIP TCP/IP stack.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Author: Ivan Delamer <delamer@inicotech.com>
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Please coordinate changes and requests with Ivan Delamer
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * <delamer@inicotech.com>
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync/** The ethernet address */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync/** Ethernet header */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Send an IPv6 packet on the network using netif->linkoutput
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * The ethernet header is filled in before sending.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @params netif the lwIP network interface on which to send the packet
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @params p the packet to send, p->payload pointing to the (uninitialized) ethernet header
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @params src the source MAC address to be copied into the ethernet header
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @params dst the destination MAC address to be copied into the ethernet header
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @return ERR_OK if the packet was sent, any other err_t on failure
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsyncethip6_send(struct netif *netif, struct pbuf *p, struct eth_addr *src, struct eth_addr *dst)
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync struct eth_hdr *ethhdr = (struct eth_hdr *)p->payload;
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync LWIP_ASSERT("netif->hwaddr_len must be 6 for ethip6!",
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("ethip6_send: sending packet %p\n", (void *)p));
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* send the packet */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * Resolve and fill-in Ethernet address header for outgoing IPv6 packet.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * For IPv6 multicast, corresponding Ethernet addresses
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * are selected and the packet is transmitted on the link.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * For unicast addresses, ...
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @TODO anycast addresses
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @param netif The lwIP network interface which the IP packet will be sent on.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @param q The pbuf(s) containing the IP packet to be sent.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * @param ip6addr The IP address of the packet destination.
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * - ERR_RTE No route to destination (no gateway to external networks),
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync * or the return type of either etharp_query() or etharp_send_ip().
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsyncethip6_output(struct netif *netif, struct pbuf *q, ip6_addr_t *ip6addr)
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* make room for Ethernet header - should not fail */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* bail out */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync ("etharp_output: could not allocate room for header.\n"));
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* multicast destination IP address? */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Hash IP multicast address to MAC address.*/
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Send out. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync return ethip6_send(netif, q, (struct eth_addr*)(netif->hwaddr), &dest);
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* We have a unicast destination IP address */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* TODO anycast? */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Get next hop record. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync if (i < 0) {
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* failed to get a next hop neighbor record. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Now that we have a destination record, send or queue the packet. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Switch to delay state. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME;
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* TODO should we send or queue if PROBE? send for now, to let unicast NS pass. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* Send out. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync return ethip6_send(netif, q, (struct eth_addr*)(netif->hwaddr), &dest);
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync /* We should queue packet on this interface. */
2e848e79ccf2e4285250a0af98ddb9eb28864878vboxsync#endif /* LWIP_IPV6 && LWIP_ETHERNET */