How to explicitly set IP6 header version = 6 in outgoing packets

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

How to explicitly set IP6 header version = 6 in outgoing packets

Mohsin
Hi,

I'm implementing IPv6 in my ethernet device.

Can anyone please tell me how to explicitly set IP6 header version of the outgoing packets to be 6 just before sending the packet. i. e.  just before calling BeginPacketSend();

Because in my case, IP6 header version remains 0 only for all outgoing packets of my device and hence packets are not received at my PC. So I want to set it to 6 explicitly.

Any help would be highly appreciated.

Regards,
Mohsin
Reply | Threaded
Open this post in threaded view
|

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Sergio R. Caprile
$ grep -R BeginPacketSend lwip/*
$

What are you talking about, Willis ?
Are we talking lwIP here ?


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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Ivan Delamer-2
In reply to this post by Mohsin
This is already done in ethip6_send().

Are you sure you've set this?

   netif->output_ip6 = ethip6_output;

Also, is the pbuf_header() call in ethip6_output() failing? have you
set PBUF_LINK_HLEN to 14 or 16 ?

Ivan




> Date: Tue, 18 Nov 2014 11:57:55 -0700 (MST)
> From: mfkexpress <[hidden email]>
> To: [hidden email]
> Subject: [lwip-users] How to explicitly set IP6 header version = 6 in
> outgoing packets
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> Hi,
>
> I'm implementing IPv6 in my ethernet device.
>
> Can anyone please tell me how to explicitly set IP6 header version of
> the
> outgoing packets to be 6 just before sending the packet. i. e.  just
> before
> calling BeginPacketSend();
>
> Because in my case, IP6 header version remains 0 only for all outgoing
> packets of my device and hence packets are not received at my PC. So I
> want
> to set it to 6 explicitly.
>
> Any help would be highly appreciated.
>
> Regards,
> Mohsin


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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Mohsin
Yes, I've set netif->output_ip6 = ethip6_output and PBUF_LINK_HLEN = 14.

Also IP6H_VTCFL_SET(ip6hdr, 6, tc, 0); is being called in ip6_output_if() but just below this line when I checked condition:

             if (IP6H_V(ip6hdr) != 6)  {
             Uart_Puts("IP6 Header Version is not 6\n");
             }

I got above line printed on my output log which means it is not set to 6 and also it remains "00" in outgoing packets.

Any help please...

Regards,
Mohsin

Reply | Threaded
Open this post in threaded view
|

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Ivan Delamer-2
In reply to this post by Mohsin
The header is now probably pointing at the Ethernet header, not the
IPv6 header.

That is how it should be.

Check if byte at offset 14 has first nibble set to 6. Remember it is
not the first byte that is 6. It is the first nibble of the byte.

Cheers
Ivan


> Date: Sat, 22 Nov 2014 06:08:02 -0700 (MST)
> From: mfkexpress <[hidden email]>
> To: [hidden email]
> Subject: Re: [lwip-users] How to explicitly set IP6 header version = 6
> in outgoing packets
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> Yes, I've set netif->output_ip6 = ethip6_output and PBUF_LINK_HLEN =
> 14.
>
> Also IP6H_VTCFL_SET(ip6hdr, 6, tc, 0); is being called in
> ip6_output_if()
> but just below this line when I checked condition:
>
>              if (IP6H_V(ip6hdr) != 6)  {
>              Uart_Puts("IP6 Header Version is not 6\n");
>              }
>
> I got above line printed on my output log which means it is not set to
> 6 and
> also it remains "00" in outgoing packets.
>
> Any help please...
>
> Regards,
> Mohsin


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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Mohsin
No... even first nibble at offset 14 is also not 6.
Below I've quoted outgoing packet generated from my device for your reference which has IP6H_V=0.

    q->payload  33 33 FF 12 32 24 00 00
                      21 12 32 24 86 DD 00 00
                      00 00 00 20 3A FF 00 00
                      00 00 00 00 00 00 00 00
                      00 00 00 00 00 00 FF 02
                      00 00 00 00 00 00 00 00
                      00 01 FF 12 32 24 87 00
                      A1 7B 00 00 00 00 FE 80
                      00 00 00 00 00 00 02 00
                      21 FF FE 12 32 24 01 01
                      00 00 21 12 32 24

I think the highlighted field of above packet should be "60".

How can I explicitly set it's first nibble to "6" without calling IP6H_VTCFL_SET() just before writing it to Tx FIFO?
Ivan Delamer-2 wrote
The header is now probably pointing at the Ethernet header, not the
IPv6 header.

That is how it should be.

Check if byte at offset 14 has first nibble set to 6. Remember it is
not the first byte that is 6. It is the first nibble of the byte.

Cheers
Ivan


> Date: Sat, 22 Nov 2014 06:08:02 -0700 (MST)
> From: mfkexpress <[hidden email]>
> To: [hidden email]
> Subject: Re: [lwip-users] How to explicitly set IP6 header version = 6
> in outgoing packets
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> Yes, I've set netif->output_ip6 = ethip6_output and PBUF_LINK_HLEN =
> 14.
>
> Also IP6H_VTCFL_SET(ip6hdr, 6, tc, 0); is being called in
> ip6_output_if()
> but just below this line when I checked condition:
>
>              if (IP6H_V(ip6hdr) != 6)  {
>              Uart_Puts("IP6 Header Version is not 6\n");
>              }
>
> I got above line printed on my output log which means it is not set to
> 6 and
> also it remains "00" in outgoing packets.
>
> Any help please...
>
> Regards,
> Mohsin


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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

goldsimon@gmx.de
mfkexpress wrote:
> [..]
> I think the highlighted field of above packet should be "60".
>
> How can I explicitly set it's first nibble to "6" without calling
> IP6H_VTCFL_SET() just before writing it to Tx FIFO?

As Ivan already said, you can't do that yourself. The byte should be correctly set by lwIP. If it's not, there's a bug either in your port or in lwIP. And you'd be *much* better off finding that bug and fixing it instead of re-setting some bits to some value at some point...


Simon

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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Mohsin
This post was updated on .

Hi,

I think there is a bug related to setting ip6 header version in IP6H_VTCFL_SET() function.
Because this function do not set the header version to 6 which I found by debugging into my code.

So what I did was I first ORed ip6hdr->_v_tc_fl with 0x6 and then left shifted it 28 bits which I have implemented as follows:

              IP6H_VTCFL_SET(ip6hdr, 6, tc, 0);
              ip6hdr->_v_tc_fl = htonl(ip6hdr->_v_tc_fl | (0x6));
        ip6hdr->_v_tc_fl = htonl((ip6hdr->_v_tc_fl) << 28);

With above settings, now my outgoing packet has IP6H_V = 6 and as we just want Traffic Class (tc) and FLow Label (fl) to be "0" at the moment.

Is it proper approach?
As atleast with above settings, packets sent from my device are being received on my PC which initially were not.

Also one issue that I face is  pinging with my target's IP6 address gives me "General Failure" error.
Any help for this error please...

Thanks & Regards,
Mohsin
Simon Goldschmidt wrote
mfkexpress wrote:
> [..]
> I think the highlighted field of above packet should be "60".
>
> How can I explicitly set it's first nibble to "6" without calling
> IP6H_VTCFL_SET() just before writing it to Tx FIFO?

As Ivan already said, you can't do that yourself. The byte should be correctly set by lwIP. If it's not, there's a bug either in your port or in lwIP. And you'd be *much* better off finding that bug and fixing it instead of re-setting some bits to some value at some point...


Simon

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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

goldsimon@gmx.de
mfkexpress wrote:
> I think there is a bug related to setting ip6 header version in IP6H_VTCFL_SET() function.
> Because this function do not set the header version to 6 which I found by debugging into my code.
> [..]
> IP6H_VTCFL_SET(ip6hdr, 6, tc, 0);
> ip6hdr->_v_tc_fl = htonl(ip6hdr->_v_tc_fl | (0x6));
> ip6hdr->_v_tc_fl = htonl((ip6hdr->_v_tc_fl) << 28);
> [..]
> Is it proper approach?

Doesn't seem like the proper approach, no.

Could you try this instead:

#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))

Maybe your compiler has problems with shifting the constant '6' left by 28... Which platform were you using again?


Simon

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

Re: How to explicitly set IP6 header version = 6 in outgoing packets

Mohsin
This post was updated on .
Simon Goldschmidt wrote
mfkexpress wrote:
> I think there is a bug related to setting ip6 header version in IP6H_VTCFL_SET() function.
> Because this function do not set the header version to 6 which I found by debugging into my code.
> [..]
> IP6H_VTCFL_SET(ip6hdr, 6, tc, 0);
> ip6hdr->_v_tc_fl = htonl(ip6hdr->_v_tc_fl | (0x6));
> ip6hdr->_v_tc_fl = htonl((ip6hdr->_v_tc_fl) << 28);
> [..]
> Is it proper approach?

Doesn't seem like the proper approach, no.

Could you try this instead:

#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))

Maybe your compiler has problems with shifting the constant '6' left by 28... Which platform were you using again?


Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Thank you sooo much Simon...
This really worked for me. I was such a fool that I didn't consider typecasting.
I'm using windows 32-bit platform.

But one problem is why I can't ping to my device?
Though some NS, NA packets are getting Tx/Rx from my device to PC, I get "General failure" message in reply whenever I'm pinging IP6 address of my device.
Please help me for that. It would be highly appreciated.

Thanks & Regards,
Mohsin