Problem in adding additional heade

Shiva Raman Pandey shiva@sasken.com
Fri, 12 Oct 2001 10:35:42 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_00C7_01C15309.A4D94CC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Friends,
My actual requirement is to insert my own header between Ethernet header =
and
IP header to all the packets generated at this machine and  remove the =
same
from all the packets meant for this machine.
So Packets leaving from this machine will look like(assume my header is
BlueTooth header)
Ethernet header -- BT header --IPheader--TCP/UDP/ICMP header
I tried to using Netfilter to solve my purpose, but found that I cant =
get the
packet directly from ethernet. Even the very first hook PRE_ROUTING also =
gives
from IP layer only.
So if I add my BT header before IP header, IP layer will not accept the =
packet
when I will call 'set_verdict'.
So I changed my design :(, to do some dirty work like add the copy of IP
header before BT header again.
Now it will look like
IP header--BT header--IP header--TCP/UDP/ICMP header
and at the recieving end it will remove the IP header--BT header leaving =
the
remaining packet starting with IP header.

For example, say ping command, packet length =3D 84 bytes, IP header =
length =3D 20
bytes, ICMP header length =3D 8bytes and my BT header length =3D 5 bytes
so I made the new packet of length 20+5+20+(84-20) =3D 109 bytes and =
called the
function set_verdict, with data_len =3D 109, and this 109 bytes long =
payload.
Now at the recieving machine I should get the 109 bytes long packet, but =
in
fact IP_QUEUE is giving the packet of 84 bytes only, that are in fact =
first 84
bytes of the 109 bytes long packet.
Note - I have not touched the checksum fields.

So, my questions are :
1) When I am sending 109 bytes, why I am getting only 84 bytes?
2) I tried changing the payload[3] (ie, packet length field) to 109, in =
that
case the packet never reaches the destination, why?
3) Is this problem due to checksum?
4) Is there any way using netfilter, I can get the packet from ethernet
directly, that will suit my actual design? or any other easy way?
5) How can I verify that the sending machine is actually sending 109 =
bytes(I
mean not reducing it to 84)?

Please send me your suggestions to  find out the solution for this =
problem

Thanks alot.
Regards
Shiva Raman Pandey
Research Associate, Computer Science -R&D
Sasken Communication Technologies Limited
Bangalore, India

------=_NextPart_000_00C7_01C15309.A4D94CC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello Friends,<BR>My actual requirement =
is to=20
insert my own header between Ethernet header and<BR>IP header to all the =
packets=20
generated at this machine and&nbsp; remove the same<BR>from all the =
packets=20
meant for this machine.<BR>So Packets leaving from this machine will =
look=20
like(assume my header is<BR>BlueTooth header)<BR>Ethernet header -- BT =
header=20
--IPheader--TCP/UDP/ICMP header<BR>I tried to using Netfilter to solve =
my=20
purpose, but found that I cant get the<BR>packet directly from ethernet. =
Even=20
the very first hook PRE_ROUTING also gives<BR>from IP layer only.<BR>So =
if I add=20
my BT header before IP header, IP layer will not accept the =
packet<BR>when I=20
will call 'set_verdict'.<BR>So I changed my design :(, to do some dirty =
work=20
like add the copy of IP<BR>header before BT header again.<BR>Now it will =
look=20
like<BR>IP header--BT header--IP header--TCP/UDP/ICMP header<BR>and at =
the=20
recieving end it will remove the IP header--BT header leaving =
the<BR>remaining=20
packet starting with IP header.<BR><BR>For example, say ping command, =
packet=20
length =3D 84 bytes, IP header length =3D 20<BR>bytes, ICMP header =
length =3D 8bytes=20
and my BT header length =3D 5 bytes<BR>so I made the new packet of =
length=20
20+5+20+(84-20) =3D 109 bytes and called the<BR>function set_verdict, =
with=20
data_len =3D 109, and this 109 bytes long payload.<BR>Now at the =
recieving machine=20
I should get the 109 bytes long packet, but in<BR>fact IP_QUEUE is =
giving the=20
packet of 84 bytes only, that are in fact first 84<BR>bytes of the 109 =
bytes=20
long packet.<BR>Note - I have not touched the checksum =
fields.<BR><BR>So, my=20
questions are :<BR>1) When I am sending 109 bytes, why I am getting only =
84=20
bytes?<BR>2) I tried changing the payload[3] (ie, packet length field) =
to 109,=20
in that<BR>case the packet never reaches the destination, why?<BR>3) Is =
this=20
problem due to checksum?<BR>4) Is there any way using netfilter, I can =
get the=20
packet from ethernet<BR>directly, that will suit my actual design? or =
any other=20
easy way?<BR>5) How can I verify that the sending machine is actually =
sending=20
109 bytes(I<BR>mean not reducing it to 84)?<BR><BR>Please send me your=20
suggestions to&nbsp; find out the solution for this =
problem<BR><BR>Thanks=20
alot.<BR>Regards<BR>Shiva Raman Pandey<BR>Research Associate, Computer =
Science=20
-R&amp;D<BR>Sasken Communication Technologies Limited<BR>Bangalore,=20
India</FONT></DIV></BODY></HTML>

------=_NextPart_000_00C7_01C15309.A4D94CC0--