* [ECOS] Problem Establishing socket Connection
@ 2003-11-10 18:15 kevin_lemay
2003-11-10 19:34 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: kevin_lemay @ 2003-11-10 18:15 UTC (permalink / raw)
To: ecos-discuss
I am trying to port some working vxWorks code over the eCos. This includes some standard BSD socket connections.
I am encountering a problem within eCos. It has decided that I am trying to establish a network connection to a multicast socket, which is not the case.
We are attempting to connect to 130.30.174.109 (x821eae6d), port 5678.
I am using the CVS version of eCos as of Friday on an i386 platform.
The error occurs in tcp_usrrec.c at line 341
336 /*
337 * Must disallow TCP ``connections'' to multicast addresses.
338 */
339 sinp = (struct sockaddr_in *)nam;
- 340 if (sinp->sin_family == AF_INET
- 341 && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
- 342 error = EAFNOSUPPORT;
- 343 goto out;
344 }
(gdb) p nam
$2 = (struct sockaddr *) 0x185ba0
(gdb) x/16w nam
0x185ba0 <main_stack+6816>: 0x2e160200 0x6dae1e82 0x00000000 0x00000000
0x185bb0 <main_stack+6832>: 0x00000000 0x00000000 0x00000000 0x00000000
0x185bc0 <main_stack+6848>: 0x00000002 0x11110000 0x00185be8 0x001349e0
0x185bd0 <main_stack+6864>: 0x00173dd1 0x0000162e 0x52725c78 0x00000004
(gdb)
The code that attempts to connect is:
int rc;
struct sockaddr_in servAddr;
int socketId;
/* Server side */
bzero(&servAddr, sizeof(servAddr));
servAddr.sin_family = AF_INET;
inet_aton(srvIpAddress, &servAddr.sin_addr);
servAddr.sin_port = htons(port);
/* create socket */
socketId = socket(AF_INET, SOCK_STREAM, 0);
if (socketId < 0)
{
return( -1 );
}
/* connect to server */
rc = connect(socketId, (struct sockaddr *) &servAddr,
sizeof(servAddr));
if (rc<0)
{
close(socketId);
socketId = 0;
return(-1);
}
return(socketId);
Debug Console Output:
0x0000ccf8 in ?? () at
/opt/ecos/ecos_cvs/ecos/packages/net/common/current/src/getserv.c:60
Loading section .text, size 0x69799 lma 0x108000
Loading section .rodata, size 0xa7ab lma 0x1717a0
Loading section .data, size 0x1bb0 lma 0x17bf50
Start address 0x108000, load size 482036
Transfer rate: 192814 bits/sec, 319 bytes/write.
[cyg_net_init] Init: mbinit(0x00000000)
[cyg_net_init] Init: cyg_net_init_devs(0x00000000)
Init device 'i82559_eth0'
[cyg_net_init] Init: loopattach(0x00000000)
[cyg_net_init] Init: ifinit(0x00000000)
[cyg_net_init] Init: domaininit(0x00000000)
[cyg_net_init] Init: cyg_net_add_domain(0x0017d300)
New domain internet at 0x00000000
[cyg_net_init] Init: cyg_net_add_domain(0x0017cc40)
New domain route at 0x00000000
[cyg_net_init] Init: call_route_init(0x00000000)
[cyg_net_init] Done
[New Thread 4]
[Switching to Thread 4]
Breakpoint 5, main () at osmain.c:78
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x0013ed40 in walkPciCreatePorts at
osmain.c:451
2 breakpoint keep y 0x0013d394 in openSocket at
/home/klemay/prj/TestbaseV2/c/oslib.c:81
3 breakpoint keep y 0x0014259e in bsd_connect at
/opt/ecos/ecos_cvs/ecos/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c:267
5 breakpoint keep y 0x0013e92d in main at osmain.c:78
breakpoint already hit 1 time
(gdb) c
Continuing.
BOOTP[eth0] op: REQUEST
htype: Ethernet
hlen: 6
hops: 0
xid: 0xa1d2024b
secs: 0
flags: 0x80
hw_addr: 00:02:b3:1f:02:4b
client IP: 0.0.0.0
my IP: 130.30.173.222
server IP: 156.140.232.41
gateway IP: 130.30.172.1
options:
DHCP message: 3 REQUEST
DHCP server id: 156.140.232.41
DHCP time 51: 604800
DHCP time 58: 302400
DHCP time 59: 529200
subnet mask: 255.255.252.0
gateway: 130.30.172.1
domain server: 156.140.238.22, 156.140.232.41
domain name: rose.agilent.com.
IP broadcast: 255.255.255.255
Unknown option: 2c/44.8: 130 29 152 23 130 29 154 21
Unknown option: 2e/46.1: 8
host name: rg-dhcp7.
DHCP option: 37/55.9: 54 51 58 59 1 3 6 15 28
DHCP option: 39/57.2: 576
DHCP requested ip: 130.30.173.222
Any help would be appreciated.
Kevin Lemay
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] Problem Establishing socket Connection
2003-11-10 18:15 [ECOS] Problem Establishing socket Connection kevin_lemay
@ 2003-11-10 19:34 ` Andrew Lunn
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2003-11-10 19:34 UTC (permalink / raw)
To: kevin_lemay; +Cc: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]
On Mon, Nov 10, 2003 at 11:12:30AM -0700, kevin_lemay@agilent.com wrote:
> I am trying to port some working vxWorks code over the eCos. This
> includes some standard BSD socket connections.
> I am encountering a problem within eCos. It has decided that I am
> trying to establish a network connection to a multicast socket,
> which is not the case.
>
> We are attempting to connect to 130.30.174.109 (x821eae6d), port 5678.
>
> I am using the CVS version of eCos as of Friday on an i386 platform.
It always a good idea to post a complete (none)working test
case. Something we can just compile and run. It saves us time messing
turning your code fragment into something useful.
I've attached what i used to test this.
>
> The error occurs in tcp_usrrec.c at line 341
>
>
> 336 /*
> 337 * Must disallow TCP ``connections'' to multicast addresses.
> 338 */
> 339 sinp = (struct sockaddr_in *)nam;
> - 340 if (sinp->sin_family == AF_INET
> - 341 && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
> - 342 error = EAFNOSUPPORT;
> - 343 goto out;
> 344 }
I get another error. EINVAL. I didn't track it down, but these seems
much more reasonable to me than EAFNOSUPPORT.
Please try to reproduce your problem either using my code, or build a
complete test case which demonstrates the problem.
Thanks
Andrew
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 2118 bytes --]
#include <network.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <cyg/infra/testcase.h>
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
static char stack[STACK_SIZE];
static cyg_thread thread_data;
static cyg_handle_t thread_handle;
int yourtest(void)
{
int rc;
struct sockaddr_in servAddr;
int socketId;
char * srvIpAddress = "130.30.174.109";
int port = 5297;
/* Server side */
bzero(&servAddr, sizeof(servAddr));
servAddr.sin_family = AF_INET;
inet_aton(srvIpAddress, &servAddr.sin_addr);
servAddr.sin_port = htons(port);
/* create socket */
socketId = socket(AF_INET, SOCK_STREAM, 0);
if (socketId < 0)
{
return( -1 );
}
/* connect to server */
rc = connect(socketId, (struct sockaddr *) &servAddr, sizeof(servAddr));
if (rc<0)
{
close(socketId);
socketId = 0;
perror("connect");
return(-1);
}
return(socketId);
}
void myfunc(cyg_addrword_t data)
{
init_all_network_interfaces();
yourtest();
}
void
cyg_start(void)
{
CYG_TEST_INIT();
cyg_thread_create(3, // Priority
myfunc, // entry
0, // entry parameter
"Test program", // Name
&stack[0], // Stack
STACK_SIZE, // Size
&thread_handle, // Handle
&thread_data // Thread data structure
);
cyg_thread_resume(thread_handle); // Start it
cyg_scheduler_start();
}
[-- Attachment #3: Type: text/plain, Size: 146 bytes --]
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [ECOS] Problem Establishing socket Connection
@ 2003-11-10 20:11 kevin_lemay
0 siblings, 0 replies; 3+ messages in thread
From: kevin_lemay @ 2003-11-10 20:11 UTC (permalink / raw)
To: andrew; +Cc: ecos-discuss
Andrew,
You are right... I should have made the code stub.
It turns out that the FreeBSD stack requires you to fill out the sa_len field of the server address. Your code sample runs with this modification.
I will go back to my code and see if that fixes my problem....
Thanks,
Kevin
-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch]
Sent: Monday, November 10, 2003 11:35 AM
To: kevin_lemay@agilent.com
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Problem Establishing socket Connection
On Mon, Nov 10, 2003 at 11:12:30AM -0700, kevin_lemay@agilent.com wrote:
> I am trying to port some working vxWorks code over the eCos. This
> includes some standard BSD socket connections.
> I am encountering a problem within eCos. It has decided that I am
> trying to establish a network connection to a multicast socket,
> which is not the case.
>
> We are attempting to connect to 130.30.174.109 (x821eae6d), port 5678.
>
> I am using the CVS version of eCos as of Friday on an i386 platform.
It always a good idea to post a complete (none)working test
case. Something we can just compile and run. It saves us time messing
turning your code fragment into something useful.
I've attached what i used to test this.
>
> The error occurs in tcp_usrrec.c at line 341
>
>
> 336 /*
> 337 * Must disallow TCP ``connections'' to multicast addresses.
> 338 */
> 339 sinp = (struct sockaddr_in *)nam;
> - 340 if (sinp->sin_family == AF_INET
> - 341 && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
> - 342 error = EAFNOSUPPORT;
> - 343 goto out;
> 344 }
I get another error. EINVAL. I didn't track it down, but these seems
much more reasonable to me than EAFNOSUPPORT.
Please try to reproduce your problem either using my code, or build a
complete test case which demonstrates the problem.
Thanks
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-11-10 20:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-10 18:15 [ECOS] Problem Establishing socket Connection kevin_lemay
2003-11-10 19:34 ` Andrew Lunn
2003-11-10 20:11 kevin_lemay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).