From 78f030724671c70b209308502ab0e5f507301365 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 23 Oct 2011 17:38:23 +0200 Subject: [PATCH] Slipif: fixed IPv6 support --- src/netif/slipif.c | 47 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/netif/slipif.c b/src/netif/slipif.c index c7daa3b3..137ba89d 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -108,11 +108,10 @@ struct slipif_priv { * * @param netif the lwip network interface structure for this slipif * @param p the pbuf chaing packet to send - * @param ipaddr the ip address to send the packet to (not used for slipif) * @return always returns ERR_OK since the serial layer does not provide return values */ -err_t -slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) +static err_t +slipif_output(struct netif *netif, struct pbuf *p) { struct slipif_priv *priv; struct pbuf *q; @@ -123,8 +122,6 @@ slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); LWIP_ASSERT("p != NULL", (p != NULL)); - LWIP_UNUSED_ARG(ipaddr); - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_output(%"U16_F"): sending %"U16_F" bytes\n", (u16_t)netif->num, p->tot_len)); priv = netif->state; @@ -158,6 +155,42 @@ slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) return ERR_OK; } +/** + * Send a pbuf doing the necessary SLIP encapsulation + * + * Uses the serial layer's sio_send() + * + * @param netif the lwip network interface structure for this slipif + * @param p the pbuf chaing packet to send + * @param ipaddr the ip address to send the packet to (not used for slipif) + * @return always returns ERR_OK since the serial layer does not provide return values + */ +static err_t +slipif_output_v4(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) +{ + LWIP_UNUSED_ARG(ipaddr); + return slipif_output(netif, p); +} + +#if LWIP_IPV6 +/** + * Send a pbuf doing the necessary SLIP encapsulation + * + * Uses the serial layer's sio_send() + * + * @param netif the lwip network interface structure for this slipif + * @param p the pbuf chaing packet to send + * @param ipaddr the ip address to send the packet to (not used for slipif) + * @return always returns ERR_OK since the serial layer does not provide return values + */ +static err_t +slipif_output_v6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) +{ + LWIP_UNUSED_ARG(ipaddr); + return slipif_output(netif, p); +} +#endif /* LWIP_IPV6 */ + /** * Handle the incoming SLIP stream character by character * @@ -330,9 +363,9 @@ slipif_init(struct netif *netif) netif->name[0] = 's'; netif->name[1] = 'l'; - netif->output = slipif_output; + netif->output = slipif_output_v4; #if LWIP_IPV6 - netif->output_ip6 = slipif_output; + netif->output_ip6 = slipif_output_v6; #endif /* LWIP_IPV6 */ netif->mtu = SLIP_MAX_SIZE; netif->flags |= NETIF_FLAG_POINTTOPOINT;