[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] udp checksum error
From: |
Jonathan Larmour |
Subject: |
Re: [lwip-users] udp checksum error |
Date: |
Thu, 17 Jan 2008 11:05:38 +0000 |
User-agent: |
Thunderbird 1.5.0.12 (X11/20070530) |
Muhamad Ikhwan Ismail wrote:
> I am using the socket API sending some dummy
> packets to a UDP echo server I setup on the other node. The sending went
> well except for I am having UDP checksum error.
See comments below.
> void test_udp_socket(void){
> int socket_index;
>
> SCB_PTR suspend_udp; //semaphore used to suspend the thread
> suspend_udp = create_sema(1);
>
> socket_index = lwip_socket(AF_INET,SOCK_DGRAM,0x00);
>
> /*now get a sockaddr structure corresponding to socket domain AF_INET */
> struct sockaddr_in* endpoint = (struct
> sockaddr_in*)mallocx(sizeof(struct sockaddr));
At this point you should probably memset the contents of sockaddr_in to 0
(unless your mallocx does .
> (endpoint)->sin_family = AF_INET;
> (endpoint)->sin_port = (htons(7));
> struct ip_addr server_ip;
> IP4_ADDR(&server_ip,169,254,36,145);
> (endpoint)->sin_addr.s_addr = server_ip.addr;
> int addrlen = (endpoint)->sin_len = sizeof((endpoint)->sin_addr.s_addr);
The above line is wrong. You need addrlen to be sizeof(endpoint).
NB, there's no need to set sin_len - it exists only for compatibility with
other stacks, and isn't even part of the POSIX standard any more.
Jifl
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine