[ECOS] Problem with obtaining sockaddr from recvfrom()
jerzy dyrda
jerzy.dyrda@kontron.pl
Thu Oct 11 12:26:00 GMT 2007
Hello all,
> > Not sure if this is your problem, but I have
> > #if defined(__ECOS)
> > addr.sin_len = sizeof(addr);
> > #endif
> >
> > in code that I use.
>
> This is quite possibly the source of the problem.
>
> The standard test program:
> .../net/common/current/tests/udp_lo_test.c
> does a recvfrom() and successfully prints the source address,
> so we're pretty sure that the system [calls] work properly.
>
> Try looking at the test/example programs.
Thanks a lot for hints and suggestions.
The case was missing of initialization addr_len with length of structure
before calling recvfrom() i.e.
/* remote_addr_len == 0 */
ret = recvfrom(fd, &rmcp_packet_raw, IPMI_BUF_SIZE, 0,
&remote_addr, &remote_addr_len);
and as I suppose recvfrom() treat remote_addr as structure with zero length
buffer :(
It's done in the standard test program udp_lo_test.c
c_len = sizeof(c_addr);
^^^^^^^^^^^^^^
if ((len = recvfrom(s_source, data_buf, sizeof(data_buf),0,
(struct sockaddr *)&c_addr,&c_len)) < 0 ) {
CYG_TEST_FAIL_FINISH("I/O error");
}
Best regards,
jerzy
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list