[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE : RE : [lwip-users] Weird behavior of lwIP with C functions
From: |
Frédéric BERNON |
Subject: |
RE : RE : [lwip-users] Weird behavior of lwIP with C functions |
Date: |
Wed, 11 Jul 2007 09:08:30 +0200 |
>Isnt it a socket api
function?
netbuf_copy_partial is more a netconn
api,than a socket one (but in current code, socket layer is based on netconn
layer). But it's just to show you how to process a pbuf (where data can be in
several blocks). So, don't use it directly, but look how it's implemented to do
the same thing.
>I am only taking the data of the first
current pbuf received
Be carefull, the "first current pbuf
received" can be a chain: by example, if your port use a 128bytes pool size, and
you receive a full packet (saying, 1500 bytes), the pbuf you will receive will
be a pbuf chain of 12 "blocks" (~1500/128). More, if you only want to read the
first pbuf of the chain, don't use "tot_len" (the total pbuf chain size), but
"len" (the pbuf node size).
> more longer than 10 chars
so I guess it shouldn't cause the software to crash
But with any "string" function (like
sprintf), you HAVE TO alloc one byte more for the zero-terminal...
>regarding sprintf, is memcpy
better?
Of course!!!
====================================
Frédéric
BERNON
HYMATOM SA
Chef de projet informatique
Microsoft
Certified Professional
Tél. : +33
(0)4-67-87-61-10
Fax. : +33
(0)4-67-70-85-44
Email : address@hiddenr
Web Site : http://www.hymatom.fr
====================================
P
Avant
d'imprimer, penser à l'environnement
Hi
Frederic,
Thank you for your quick reply,
Well, I was wondering
about the netbuf_copy_partial function you talked to me about. Isnt it a
socket api function? I am using the raw api and well, I can see what you mean
when you say that there is a chain of pbuf when data is received and I am only
taking the data of the first current pbuf received. You re right saying it
could be handled better, still the command line I am sending to Virtex II are
no more longer than 10 chars so I guess it shouldn't cause the software to
crash. Besides I debugged the code by removing some
parts and see how the
server behaves. No problem appears to come before i check the commandType
variable with a strncpy, then in this if, it starts behaving
weirdly.
Anyway, regarding sprintf, is memcpy better?
Thanks
again,
Antoine.
Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et
bénéficiez de 2 Go de stockage ! Windows Live
Hotmail
Frédéric BERNON.vcf
Description: Frédéric BERNON.vcf
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE : RE : [lwip-users] Weird behavior of lwIP with C functions,
Frédéric BERNON <=