This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
IP configuration
- From: "raghuram" <rram at globaledgesoft dot com>
- To: "Ecos-Discuss \(E-mail\)" <ecos-discuss at sources dot redhat dot com>
- Date: Mon, 11 Oct 2004 11:09:09 +0530
- Subject: [ECOS] IP configuration
> Hello,
> I am running eCOS on a WLAN board with ARM9 processor. I wanted to run a
> client-server application with client application on a linux host ( IP
> address 172.16.6.20)and server application on the WLAN board connected
> through a cross-cable.
> I am also running GoAhead web server on the board. Now using the webserver
I
> am able to configure IP address, Subnet Mask, default Gateway address as
per
> my requirements. The default IP address of the board (Factory setting) is
> 192.168.0.10
>
> 1.0 .First I tried changing the IP address in line with my local LAN
> (172.16.6.10). Made the board as host in my LAN. I could browse the
> webserver from any host in my LAN.
>
> 2.0 Then I connect my linux host and the board through cross-cable. I
loaded
> the image with server application on board and linux host running client
> application.
> Now I faced some problem in "bind" system call. When I used the IP
address
> of the board (172.16.6.10) to the sockaddr structure, I got an error bind
> failing and saying "Can't assign the requested IP address". Following is
the
> piece of code for your reference which resulted in this error.
>
> --------------------------------------------------------------------------
--
> --------------------------------------------------------------------------
--
> -------------
>
> struct sockaddr_in local;
>
> local.sin_family = AF_INET;
> local.sin_len = sizeof(local);
> local.sin_port = htons(7734);
> local.sin_addr.s_addr = inet_addr("172.16.6.10"); //bp->bp_siaddr;
> if(bind(s, (struct sockaddr *) &local, sizeof(local)) < 0) {
> printf("bind error");
> }
>
> --------------------------------------------------------------------------
--
> --------------------------------------------------------------------------
--
> -------------
> Then I replaced "inet_addr("172.16.6.10")" with "INADDR_ANY" and I
problem
> never occured. I could then run my client-server application smoothly.
> Question is why was I getting this error in the first case?
>
> 3.0 Now I wanted to run the client application on the board and server on
my
> linux host. But the "connect" system fails when connecting to linux
machine
> saying "No route to host".
> WHen I looked into the net.h file I found the following configuration.
>
> #define CYGHWR_NET_DRIVER_ETH0_ADDRS_IP 192.168.0.2
> #define CYGHWR_NET_DRIVER_ETH0_ADDRS_NETMASK 255.255.255.0
> #define CYGHWR_NET_DRIVER_ETH0_ADDRS_BROADCAST 192.168.0.255
> #define CYGHWR_NET_DRIVER_ETH0_ADDRS_GATEWAY 192.168.0.101
> #define CYGHWR_NET_DRIVER_ETH0_ADDRS_SERVER 192.168.0.101
>
> But when I check the IP address of the server or client the remain as I
had
> configured them.
> Following is the code snipped for connect system call I had used..
> --------------------------------------------------------------------------
--
> -----------------
> host.sin_family = AF_INET;
> host.sin_len = sizeof(host);
> host.sin_addr.s_addr= inet_addr("172.16.6.20"); //bp->bp_siaddr;
> inet_addr("192.168.0.3");
> host.sin_port = htons (7734); //sent->s_port; // Network order
already
> if (connect(s, (struct sockaddr *)&host, sizeof(host)) < 0) {
> printf("connect errno");
> --------------------------------------------------------------------------
--
> -----------------
> Actually in the example client application the s_addr member of
sockaddr_in
> was
>
> host.sin_addr.s_addr= bp->bp_siaddr;
>
> I changed it to suite my server IP address as above.(host.sin_addr.s_addr=
> inet_addr("172.16.6.20")
>
> Later I checked the value in bp->bp_siaddr. It was 192.168.0.101. This was
> getting filled during init_all_network_interfaces().
> When I changed the IP address of linux host to 192.168.0.101 and that of
> board to 192.168.0.2 and ran the client server application I had not
> problems.
>
> Why is this happening? Any pointers please. Hope I am clear in explaining
my
> problem.
> Regards,
> Raghuram.P.
>
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss