LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-14-2009, 12:24 PM   #1
the_ionic
LQ Newbie
 
Registered: Oct 2009
Posts: 5

Rep: Reputation: 0
Ip4 in IP6 encapsulator/decapsulator and raw socket


Hi all,

I try to implement an IPv4 in IPv6 encapsulator/decapsulator on my own. I know that ip4ip6 tunnel exists in Linux but I need to do it for some special features
So in order to do that, I use libipq (which is quite obsolete I know).
The principle is the following:

Code:
IPv4/IPv6                    IPv4/IPv6
Host A     --------------->  Host B
@IPv4A                       @IPv4B
@IPv6A                       @IPv6B


Host A pings host B in IPv4 (ping @IPv4B).
With libipq, I encapsulate the V4 ping in V6 which gives the following packet: [@IPv6A @IPv6B][@IPv4A @IPv4B][ICMPv4].
Host B receives the IPv4 in IPv6 ping. I decapsulate the IPv6 header with libipq. It gives me the following IPv4 echo request: [@IPv4A @IPv4B][ICMPv4].
Then with a raw socket where sin->addr is set to @IPv4B, I "send" the IPv4 echo request in order to have the right echo reply.
The kernel produces me an echo reply but it's where the problem begins. The echo reply has as source addr @IPv4B which is logical but also @IPv4B as destination address wereas I'm waiting @IPv4A to reply to the ping. I dont understand why. I think it has something to deal with the fact that the IPv4 echo reply is "generated locally" when I decaspulate the IPv6 header but I dont get it... Note also that I just decapsulate/encapsulate the header, I never manipulate src or dst address.
The problem come I think from the raw socket and the question could be:
Is it possible to generate a packet locally and to reply to another host?
I try raw socket with PF_INET (so I don't have to handle L2 layer), but also with AF_PACKET (so I fill the L2 header with the right value) but wathever I try, it is still not working...
If you have any tips for solving that, that would be great.

Thank you,
cheers.

Tanguy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
raw socket/ip packet help shouup Programming 14 04-24-2006 04:54 PM
Help with raw socket programming tuxfood Programming 2 07-25-2005 01:17 PM
Raw Socket Programing djgerbavore Programming 2 08-18-2004 12:58 PM
Using Raw Socket for UDP myself_rajat Linux - Networking 0 05-17-2004 03:35 AM
Socket Raw linuxanswer Programming 1 04-01-2004 09:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration