How do I set the Protocol field in an Ipv4 header to 41 in windows?

133 Views Asked by At

Background

For my windows project I create RFC7217 ip global unicast addresses. Using Winsock2 and Microsoft's IpHelper functions these addresses get entered into the PC's local tables, then bind'ed to eventually become listening sockets. From another PC I can connect to these listening end points.

Problem

The ISPs do not, however, do Ipv6 very well, if at all. Enter Hurricane Electric with their free tunneling router service complete with /48 prefixes (read: a ton of possible Ipv6 addresses). But I have to get my address end points into their tunnel, programmatically.

Question

Which brings me to my question. I can see that a possible solution for my project, is to write encapsulation and decapsulation functions described in RFC4213 called 6in4. My problem is, however, I haven't figured out how to get my fully formed 6in4 datagram in my SOCKADDR_IN structure so it can be turned into a listening or connecting socket. I don't see header fields like Protocol and Payload Length, which have to be set for the Ipv4 datagram with its Ipv6 contents to work. Maybe there is another set of iphelpers or even more primitive functions that let me set header fields? If so, I haven't found them.

EDIT1

Typical config statements for a Hurricane Electric tunnel for Windows:

netsh interface teredo set state disabled
netsh interface ipv6 add v6v4tunnel interface=IP6Tunnel localaddress=mmm.mmm.mmm.mmm remoteaddress=216.66.22.2
netsh interface ipv6 add address interface=IP6Tunnel address=2001:jjj:kkk:lll::2
netsh interface ipv6 add route prefix=::/0 interface=IP6Tunnel nexthop=2001:jjj:kkk:lll::1
0

There are 0 best solutions below