netif setup for IPv6 traffic (static /128 address assignment)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

netif setup for IPv6 traffic (static /128 address assignment)

josephjah
Hello, I'm trying to assign a static /128 address to a netif but I think I'm
doing something wrong. I'm using 2.0.3 (also tested latest mater). I can see
packets are being correctly received but when ethip6_output() is called it
can't seem to find the proper interface to send out on. I've stepped through
the code for a bit and it seems like it can't get what it needs from the ND6
module, almost as if there are no destination cache/hints. Does my
initialization code look sane? Do I need to set additional flags or enable a
module of some sort? Thanks in advance guys.

// For instance, I want to assign: fde4:da74:55b2:b9ee:6a99:930f:26b9:2df0

static ip6_addr_t ipaddr;
memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
lwipdev->mtu = MY_MTU;
lwipdev->name[0] = 'l';
lwipdev->name[1] = '0'+lwipInterfacesCount;
lwipdev->hwaddr_len = 6;
lwipdev->linkoutput = lwip_eth_tx;
lwipdev->ip6_autoconfig_enabled = 1;
mac.copyTo(lwipdev->hwaddr, lwipdev->hwaddr_len);
netif_add(lwipdev, NULL, NULL, NULL, NULL, tapif_init, ethernet_input);
lwipdev->state = this;
netif_create_ip6_linklocal_address(lwipdev, 1);
s8_t idx = 1;
netif_add_ip6_address(lwipdev, &ipaddr, &idx);
netif_set_default(lwipdev);
netif_set_up(lwipdev);
netif_set_link_up(lwipdev);
netif_ip6_addr_set_state(lwipdev, 1, IP6_ADDR_TENTATIVE);
lwipdev->output_ip6 = ethip6_output;



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: netif setup for IPv6 traffic (static /128 address assignment)

goldsimon@gmx.de
On 25.07.2018 08:01, josephjah wrote:

> Hello, I'm trying to assign a static /128 address to a netif but I think I'm
> doing something wrong. I'm using 2.0.3 (also tested latest mater). I can see
> packets are being correctly received but when ethip6_output() is called it
> can't seem to find the proper interface to send out on. I've stepped through
> the code for a bit and it seems like it can't get what it needs from the ND6
> module, almost as if there are no destination cache/hints. Does my
> initialization code look sane? Do I need to set additional flags or enable a
> module of some sort? Thanks in advance guys.
>
> // For instance, I want to assign: fde4:da74:55b2:b9ee:6a99:930f:26b9:2df0
>
> static ip6_addr_t ipaddr;
> memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
> lwipdev->mtu = MY_MTU;
> lwipdev->name[0] = 'l';
> lwipdev->name[1] = '0'+lwipInterfacesCount;
> lwipdev->hwaddr_len = 6;
> lwipdev->linkoutput = lwip_eth_tx;
> lwipdev->ip6_autoconfig_enabled = 1;
> mac.copyTo(lwipdev->hwaddr, lwipdev->hwaddr_len);
> netif_add(lwipdev, NULL, NULL, NULL, NULL, tapif_init, ethernet_input);
> lwipdev->state = this;
> netif_create_ip6_linklocal_address(lwipdev, 1);
> s8_t idx = 1;
> netif_add_ip6_address(lwipdev, &ipaddr, &idx);
> netif_set_default(lwipdev);
> netif_set_up(lwipdev);
> netif_set_link_up(lwipdev);
> netif_ip6_addr_set_state(lwipdev, 1, IP6_ADDR_TENTATIVE);
> lwipdev->output_ip6 = ethip6_output;

This code is totally not standard. You're mixing up responsibilities.
However, I don't have an example of what you're trying to do right now.
Does 'netif_ip6_addr_set()' not do what you want?


Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: netif setup for IPv6 traffic (static /128 address assignment)

josephjah
Thanks for responding. I've tried using netif_ip6_addr_set() per your
suggestion but while it sets the address correctly for the netif, it doesn't
seem to take me any closer to an operational state. I'm just not sure where
to find a good example to follow. Can you clarify "mixing responsibilities"?
Here's a snippet which might be closer to standard usage (but still exhibits
the same problem).

Am I doing something out of order? or does lwIP not support assigning a
static ipv6 address of this form?

Thanks.

static err_t netif_init(struct netif *netif)
{
        netif->hwaddr_len = 6;
        netif->name[0]    = 'l';
        netif->name[1]    = '0'+lwipInterfacesCount;
        netif->linkoutput = lwip_eth_tx;
        netif->output     = etharp_output;
        netif->output_ip6 = ethip6_output;
        netif->mtu        = MY_MTU;
        netif->flags      = NETIF_FLAG_BROADCAST
                | NETIF_FLAG_ETHARP
                | NETIF_FLAG_ETHERNET
                | NETIF_FLAG_IGMP
                | NETIF_FLAG_MLD6
                | NETIF_FLAG_LINK_UP
                | NETIF_FLAG_UP;
        _mac.copyTo(netif->hwaddr, netif->hwaddr_len);
        netif->hwaddr_len = sizeof(netif->hwaddr);
        return ERR_OK;
}

void setup(...) {
        static ip6_addr_t ipaddr;
        memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
        netif_add(&netif, NULL, NULL, NULL, NULL, netif_init, ethernet_input);
        netif.state = this;
        s8_t idx = 1;
        netif_ip6_addr_set(&netif, 1, &ipaddr);
        netif_set_status_callback(&netif, netif_status_callback);
        netif_set_default(&netif);
        netif_set_up(&netif);
        netif_set_link_up(&netif);
}



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: netif setup for IPv6 traffic (static /128 address assignment)

goldsimon@gmx.de
I must say I've never tried. I have only tested slaac an link local addresses so far. At which point does it reject using your address?

Simon


Am 25. Juli 2018 21:32:03 MESZ schrieb josephjah <[hidden email]>:
Thanks for responding. I've tried using netif_ip6_addr_set() per your
suggestion but while it sets the address correctly for the netif, it doesn't
seem to take me any closer to an operational state. I'm just not sure where
to find a good example to follow. Can you clarify "mixing responsibilities"?
Here's a snippet which might be closer to standard usage (but still exhibits
the same problem).

Am I doing something out of order? or does lwIP not support assigning a
static ipv6 address of this form?

Thanks.

static err_t netif_init(struct netif *netif)
{
netif->hwaddr_len = 6;
netif->name[0] = 'l';
netif->name[1] = '0'+lwipInterfacesCount;
netif->linkoutput = lwip_eth_tx;
netif->output = etharp_output;
netif->output_ip6 = ethip6_output;
netif->mtu = MY_MTU;
netif->flags = NETIF_FLAG_BROADCAST
| NETIF_FLAG_ETHARP
| NETIF_FLAG_ETHERNET
| NETIF_FLAG_IGMP
| NETIF_FLAG_MLD6
| NETIF_FLAG_LINK_UP
| NETIF_FLAG_UP;
_mac.copyTo(netif->hwaddr, netif->hwaddr_len);
netif->hwaddr_len = sizeof(netif->hwaddr);
return ERR_OK;
}

void setup(...) {
static ip6_addr_t ipaddr;
memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
netif_add(&netif, NULL, NULL, NULL, NULL, netif_init, ethernet_input);
netif.state = this;
s8_t idx = 1;
netif_ip6_addr_set(&netif, 1, &ipaddr);
netif_set_status_callback(&netif, netif_status_callback);
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
}



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html



lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: netif setup for IPv6 traffic (static /128 address assignment)

josephjah
Upon closer inspection it might have been a copy/paste error on my part.

I am using it in TCP/IP thread mode in this case and after replacing
ethernet_input with tcpip_input in the following line:

netif_add(&netif, NULL, NULL, NULL, NULL, netif_init_6, tcpip_input);

It works as intended now.

I do appreciate your time, Simon. Thanks.



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users