How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by CDP » Tue, 05 Jul 2005 22:27:56



Hello Groups,

  I am a newbie to this groups and I am struggling with a problem and I
need your help in this regard.

 I have  lwip ( low weight ip) tcp/ip stack and tftp (client & server
tftp-hpa-0.40) source .Both are compiling well on linux with out any
problem. The tftp source is also working good when I installed it on my
linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
files.

I need to get a tftp/udp/ip stack for an embedded system to upgrade the
firmware of a chip. So the problem is I want to tell my tftp source I
have with me to use lwip tcp/ip stack instead of the tcp/ip stack that
comes from linux . Some how I should be able to do the getting and
putting of files from/to a remote host using this lwip tcp/ip stack and
not the stack that comes from linux.So for this I need to tell my tftp
source to use lwip ..right? Please tell me how can I accomplish this ?
The lwip user forum did not give me the information what I want...But
one guy told me that I can make use of the LD_PRELOAD environment
variable to do this .is this right? and I also heard that I need to
make some modifications to the linux kernel and recompile it as tcp/ip
stack is a part of kernel ..if this is so...? Please tell me the
detailed procedure how can I do this , as I need this at any case for
my work . I would be thankful for any kind of suggestions ..

Regards
CDP

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by aetu » Wed, 06 Jul 2005 01:55:44


If you want reprogram the low level of ip stack you must see
man 7 packet

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by David Schwart » Wed, 06 Jul 2005 08:58:42



Quote:> I have  lwip ( low weight ip) tcp/ip stack and tftp (client & server
> tftp-hpa-0.40) source .Both are compiling well on linux with out any
> problem. The tftp source is also working good when I installed it on my
> linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
> files.

    You haven't defined your problem precisely enough for any Linux folks to
help you. You'll have to talk to the lwip folks.

    DS

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by CDP » Wed, 06 Jul 2005 17:22:04





>     You haven't defined your problem precisely enough for any Linux folks to
> help you.

The problem is I want to make my tftp source I have with me to use lwip
and not the tcp/ip stack that comes from Linux under linux . The tftp
source is my application layer .This application layer should use
udp/ip protocols of lwip under linux , Hope you got my problem by now .

    The tftp is a simple protocol to get and put files to/from a remote
server.I installed my tftp source on Redhat Linux PC , and its getting
and putting files from/to a remote host using the default tcp/ip stack
from Linux
without any problem.So instead of the default tcp/ip stack from linux
it should use lwip under linux , So how can I make this under linux ???

    For this I was told that I must do some modifications in the linux
kernel and recompile it ...is this the exact soultion to do this, if
this is, please tell me the detailed procedure to do this..?

Quote:>  You'll have to talk to the lwip folks.

>     DS

   I asked the lwip folks and I had posted my question in  the lwip
user forum , only one guy answered me that I sould use LD_PRELOAD
environment variable of Linux to do this ...

 I am herewith giving the reply , he had given me , please see below

 First, build the library.  Second set LD_PRELOAD to the path of the
library.  Third, run tftp.  That's it.

The above is the reply he had given me

   So please adivce me in this issue , I guess its a linux specific
question , If you guys want me to post any code my tftp source I can do
that , its nothing but tftp-hpa-0.40.I need help in this desperatley.

Regards
CDP

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by Wille » Wed, 06 Jul 2005 18:36:50


)    I asked the lwip folks and I had posted my question in  the lwip
) user forum , only one guy answered me that I sould use LD_PRELOAD
) environment variable of Linux to do this ...
)
)  I am herewith giving the reply , he had given me , please see below
)
)  First, build the library.  Second set LD_PRELOAD to the path of the
) library.  Third, run tftp.  That's it.
)
) The above is the reply he had given me

Have you actually tried doing what this guy said ?
If you set LD_PRELOAD to point to a library, that will be loaded
and any functions in there replace the 'standard' functions.

I would also assume that the lwip source has detailed instructions
how to use it in your applications.

SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by CDP » Wed, 06 Jul 2005 19:50:37




> )    I asked the lwip folks and I had posted my question in  the lwip
> ) user forum , only one guy answered me that I sould use LD_PRELOAD
> ) environment variable of Linux to do this ...
> )
> )  I am herewith giving the reply , he had given me , please see below
> )
> )  First, build the library.  Second set LD_PRELOAD to the path of the
> ) library.  Third, run tftp.  That's it.
> )
> ) The above is the reply he had given me

> Have you actually tried doing what this guy said ?
> If you set LD_PRELOAD to point to a library, that will be loaded
> and any functions in there replace the 'standard' functions.

     I tried it , by setting the LD_PRELOAD  environement variable to
the path of the shared library of lwip I have with me , which I already
compiled on my linux system. By setting it I started my tftp
application , but I did not observe any change... its like ,its using
the normal tcp/ip stack from linux , but not lwip. If the standard
functions are replaced with this , I should observe some change
..right? But I did nt ..How can I set it actually whether the standard
functions are  replaced..?What about the idea of kernel modifications
and recompiling ..Do you guys have any idea in my problem..?

Quote:

> I would also assume that the lwip source has detailed instructions
> how to use it in your applications.

   The guys in lwip forum , do more with a kind protocol related
things, and if post something related to linux kernel ..or something of
my problem,I guess they can not reply, because I tried it
already.Regarding the documentation lwip , I had a glance at it already
and I did not find useful information..

- Show quoted text -

Quote:

> SaSW, Willem
> --
> Disclaimer: I am in no way responsible for any of the statements
>             made in the above text. For all I know I might be
>             drugged or something..
>             No I'm not paranoid. You all think I'm paranoid, don't you !
> #EOT

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by J Jackso » Wed, 06 Jul 2005 20:23:38



: Hello Groups,

:   I am a newbie to this groups and I am struggling with a problem and I
: need your help in this regard.

:  I have  lwip ( low weight ip) tcp/ip stack and tftp (client & server
: tftp-hpa-0.40) source .Both are compiling well on linux with out any
: problem. The tftp source is also working good when I installed it on my
: linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
: files.

: I need to get a tftp/udp/ip stack for an embedded system to upgrade the
: firmware of a chip.

I'm guessing that your embedded system will not have a Linux kernel
and that you are wanting to build a tftp server as a dedicated application
in an embedded device? If this is a the case then this isn't a linux
problem and you have lots of other problems.

If you did have the Linux kernel in the embedded device you'd use it's
tcp/ip stack, and using lwip wouldn't be an issue.

I think maybe people are just confused by what it is you are trying to do.

: So the problem is I want to tell my tftp source I
: have with me to use lwip tcp/ip stack instead of the tcp/ip stack that
: comes from linux . Some how I should be able to do the getting and
: putting of files from/to a remote host using this lwip tcp/ip stack and
: not the stack that comes from linux.So for this I need to tell my tftp
: source to use lwip ..right? Please tell me how can I accomplish this ?
: The lwip user forum did not give me the information what I want...But
: one guy told me that I can make use of the LD_PRELOAD environment
: variable to do this .is this right? and I also heard that I need to
: make some modifications to the linux kernel and recompile it as tcp/ip
: stack is a part of kernel ..if this is so...? Please tell me the
: detailed procedure how can I do this , as I need this at any case for
: my work . I would be thankful for any kind of suggestions ..

: Regards
: CDP

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by CDP » Wed, 06 Jul 2005 20:44:48




> : Hello Groups,

> :   I am a newbie to this groups and I am struggling with a problem and I
> : need your help in this regard.

> :  I have  lwip ( low weight ip) tcp/ip stack and tftp (client & server
> : tftp-hpa-0.40) source .Both are compiling well on linux with out any
> : problem. The tftp source is also working good when I installed it on my
> : linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
> : files.

> : I need to get a tftp/udp/ip stack for an embedded system to upgrade the
> : firmware of a chip.

> I'm guessing that your embedded system will not have a Linux kernel
> and that you are wanting to build a tftp server as a dedicated application
> in an embedded device? If this is a the case then this isn't a linux
> problem and you have lots of other problems.

> If you did have the Linux kernel in the embedded device you'd use it's
> tcp/ip stack, and using lwip wouldn't be an issue.

> I think maybe people are just confused by what it is you are trying to do.

Hi Jackson,

   Yes your are right , the embedded system do not have a linux kernel
and it has a third party rtos , which is very small and it is only
menat for scheduling.This doesn't have to do anything with what I asked
..?

   The reason why I am using Linux is basically , as a test environment
to test my tftp application combined with lwip .If I can tell my tftp
application to use lwip instead of tcp/ip stack from linux , then I can
test my lwip stack as well as tftp application (ofcourse on linux ).
This is what I am trying to do. I guess there is no confusion by now.
If it works fine then the tftp/udp/ip stack is ready for actual
implementation.

   As I am using linux now on my PC , so what do you think would be the
way to solve my problem ..? Hope you got my problem  by now ...saying
oit in raw words again , tftp application should use lwip for all its
transfers... on linux

  Please advice me if you have any idea..?

Regards
CDP

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by John-Paul Stewar » Thu, 07 Jul 2005 00:06:43



>      I tried it , by setting the LD_PRELOAD  environement variable to
> the path of the shared library of lwip I have with me , which I already
> compiled on my linux system. By setting it I started my tftp
> application , but I did not observe any change... its like ,its using
> the normal tcp/ip stack from linux , but not lwip. If the standard
> functions are replaced with this , I should observe some change
> ..right?

I don't quite know what you'd expect to observe.  TCP/IP stacks don't
typically display a lot of output on screen telling you what is going
on.  What did *you* expect to see?  Why did you expect that?  (E.g., did
the makers of the alternate stack tell you "expect to see X happen"?)

It's possible that the lack of observed difference means the alternate
stack was running just fine.  There might only be observable differences
when things go wrong, if one stack is meant to be a drop-in replacement
for the other.

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by CDP » Thu, 07 Jul 2005 01:44:08




> >      I tried it , by setting the LD_PRELOAD  environement variable to
> > the path of the shared library of lwip I have with me , which I already
> > compiled on my linux system. By setting it I started my tftp
> > application , but I did not observe any change... its like ,its using
> > the normal tcp/ip stack from linux , but not lwip. If the standard
> > functions are replaced with this , I should observe some change
> > ..right?

> I don't quite know what you'd expect to observe.  TCP/IP stacks don't
> typically display a lot of output on screen telling you what is going
> on.  What did *you* expect to see?  Why did you expect that?  (E.g., did
> the makers of the alternate stack tell you "expect to see X happen"?)

> It's possible that the lack of observed difference means the alternate
> stack was running just fine.  There might only be observable differences
> when things go wrong, if one stack is meant to be a drop-in replacement
> for the other.

  Hi John,

     The makers of alternate tcp/ip stack (lwip) did not mention
anything to happen after the replacement.So do you think  that the
alternate stack is working fine with my tftp application? I can not
even see a single difference b/w the linux tcp/ip stack and lwip , may
be I might have done wrong with my LD_PRELOAD environment variable . I
cross checked the LD_PRELOAD environment variable , its set to the path
of shared library gen erated by means of compiling the stack. Do you
know any other means of cross checking ?  whether what I have done is
right?

  One more thing is do you have any idea about kernel modification and
recompilation for this problem.., I mean stack replacement problem
under linux ..?

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by yong.. » Thu, 07 Jul 2005 04:38:38



> ..right? But I did nt ..How can I set it actually whether the standard
> functions are  replaced..?What about the idea of kernel modifications

Perhaps by ltrace the program execution, or strace for open(2) calls?

Yong Huang

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by g.. » Thu, 07 Jul 2005 04:52:46




>> >      I tried it , by setting the LD_PRELOAD  environement variable to
>> > the path of the shared library of lwip I have with me , which I already
>> > compiled on my linux system. By setting it I started my tftp
>> > application , but I did not observe any change... its like ,its using
>> > the normal tcp/ip stack from linux , but not lwip. If the standard
>> > functions are replaced with this , I should observe some change
>> > ..right?

>> I don't quite know what you'd expect to observe.  TCP/IP stacks don't
>> typically display a lot of output on screen telling you what is going
>> on.  What did *you* expect to see?  Why did you expect that?  (E.g., did
>> the makers of the alternate stack tell you "expect to see X happen"?)

>> It's possible that the lack of observed difference means the alternate
>> stack was running just fine.  There might only be observable differences
>> when things go wrong, if one stack is meant to be a drop-in replacement
>> for the other.

>  Hi John,

>     The makers of alternate tcp/ip stack (lwip) did not mention
>anything to happen after the replacement.So do you think  that the
>alternate stack is working fine with my tftp application? I can not
>even see a single difference b/w the linux tcp/ip stack and lwip , may
>be I might have done wrong with my LD_PRELOAD environment variable . I
>cross checked the LD_PRELOAD environment variable , its set to the path
>of shared library gen erated by means of compiling the stack. Do you
>know any other means of cross checking ?  whether what I have done is
>right?

Just a shot in the dark ... can you do netstats or sockstats that show
the packets that used to use the default tcp/ip stack don't use it any
more?

--gregbo
gds at best dot com

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by Nix » Thu, 07 Jul 2005 06:53:13


On 5 Jul 2005, CDP stated:

Quote:>      The makers of alternate tcp/ip stack (lwip) did not mention
> anything to happen after the replacement.So do you think  that the
> alternate stack is working fine with my tftp application? I can not
> even see a single difference b/w the linux tcp/ip stack and lwip , may
> be I might have done wrong with my LD_PRELOAD environment variable . I
> cross checked the LD_PRELOAD environment variable , its set to the path
> of shared library gen erated by means of compiling the stack. Do you
> know any other means of cross checking ?  whether what I have done is
> right?

Well, you could stick some debugging fprintf()s into the library and
see if they are printed.

Quote:>   One more thing is do you have any idea about kernel modification and
> recompilation for this problem.., I mean stack replacement problem
> under linux ..?

Unless the lwip stack was written to fit into the Linux kernel
networking layer, you'll pretty much have to rewrite it --- and the
TCP/IP stack isn't exactly easily replaceable, except with something
that satisfies the same internal interface contracts and locking
rules (many of which aren't documented).

It's *possible*, of course, but extremely difficult, and definitely not
worth it for a test run!

(But if you *did* replace the kernel's TCP/IP stack, it's likely that
nothing would need to be recompiled. At least, if you did it properly.)

--
`But of course, GR is the very best relativity for the masses.'
 --- Wayne Throop

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by John-Paul Stewar » Thu, 07 Jul 2005 07:35:23





>>>     I tried it , by setting the LD_PRELOAD  environement variable to
>>>the path of the shared library of lwip I have with me , which I already
>>>compiled on my linux system. By setting it I started my tftp
>>>application , but I did not observe any change... its like ,its using
>>>the normal tcp/ip stack from linux , but not lwip. If the standard
>>>functions are replaced with this , I should observe some change
>>>..right?

>>I don't quite know what you'd expect to observe.  TCP/IP stacks don't
>>typically display a lot of output on screen telling you what is going
>>on.  What did *you* expect to see?  Why did you expect that?  (E.g., did
>>the makers of the alternate stack tell you "expect to see X happen"?)

>>It's possible that the lack of observed difference means the alternate
>>stack was running just fine.  There might only be observable differences
>>when things go wrong, if one stack is meant to be a drop-in replacement
>>for the other.

>   Hi John,

>      The makers of alternate tcp/ip stack (lwip) did not mention
> anything to happen after the replacement.So do you think  that the
> alternate stack is working fine with my tftp application?

The tests so far are inconclusive.  You can't determine one way or the
other at the moment.  Since they don't tell you to expect certain
differences, that *might* indicate that are no differences to observe.

Quote:> I can not
> even see a single difference b/w the linux tcp/ip stack and lwip , may

If lwip is supposed to be a drop-in replacement, I would suggest that
you *shouldn't* see any difference.  Which is why I said the tests so
far have been inconclusive.  Point is, do *not* assume there is anything
wrong when you don't see a difference.

Another poster suggested using strace to watch to see if the library is
being opened.  That sounds like a very good idea to me.  (I wish I'd
thought to suggest it, myself!)  Try (from a Bash prompt):

export LD_PRELOAD=/path/to/lwip
strace -eopen yourprogram

You should see a line resembling:

open("/path/to/lwip", O_RDONLY) = 3

which would indicate that the library was opened successfully.

 
 
 

How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

Post by Jonathan Bartlet » Thu, 07 Jul 2005 20:37:58


Quote:>      I tried it , by setting the LD_PRELOAD  environement variable to
> the path of the shared library of lwip I have with me , which I already
> compiled on my linux system.

Did you export LD_PRELOAD?  Please give the exact commands used to set
LD_PRELOAD.  If you don't export it, the new program won't see it.

Quote:> By setting it I started my tftp
> application , but I did not observe any change...

Are you supposed to?

To see if the library is loaded, do a ps to grab the PID of the process,
and then check in

/proc/WHATEVERYOURPIDIS/maps

And see if the library is listed there.  If it is, it's linked in.

However, looking on the lwip site, I don't see any indications of a
Linux port, so I'm not sure whether or not any of this actually works.
But give it a try.

Also, I would include more information when making inquiries.  For
example, letting everyone know exactly what commands you are using, what
the names of the files are, what you have tried, and what you expected
the results to be.

 > its like ,its using
 > the normal tcp/ip stack from linux , but not lwip.

How can you tell this?  From what I can tell, there really shouldn't be
any visible differences, except that for large loads you can handle more
with less RAM.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017

 
 
 

1. Packets from bottom of TCP/IP stack direct to application bypassing stack

Hello Everyone

I am working on a ADSL modem and have the following situation that I
would like to have some advice on.

I need to filter out some packages in the lower level of the network
stack. There are 2 types of packages: [eth | ppp | ip | udp] and [eth
| ip | udp], the data in these packages are the same and they can be
identified with the first 16 bits in the UDP data.

I have manage to catch these packages in the /net/core/dev.c file and
function netif_rx(...) with the 16 bit ID so I have the packages.

Now for my question: How do I in an easy way get these packages
directly to my application without using the network stack. I need
BOTH of these packages to reach there and if I use socket the one with
PPP get thrown away somewhere and that is not so good.

I know this is not a very specific question and a little vague but
some advice and pointers would be appreciated.

Regards
Andreas

2. Driver for CASIO QV-10A required

3. Advice requested: Porting Linux TCP/IP stack to application space

4. Trouble with Apache Cookies

5. DDE to TCP/IP Comm Driver via TCP/IP Avail,DDE2TCP,Custom Drivers Avail

6. RedHat and NEC 860 printer

7. tcp / ip stack and ip forwarding questions

8. router/gateway question

9. linux tcp/ip stack as a module...insmod problems

10. Need help convincing my company Linux TCP/IP stack is safe.

11. Linux Firewall and TCP/IP-Stack

12. Linux TCP/IP stack guidance

13. [Q}Linux TCP/IP stack routing...