EmbeddedRelated.com
Forums

Using Static IP mode

Started by Steve January 31, 2005

Gateway is not needed if it’s just your PC and the Rabbit connected to the hub.

 

Yes, the sample static.c is for a web server, but uses a static address and you can use this sample to see if it’s your hardware or firmware that flakey

 

From: Steve Trigero [mailto:s...@yahoo.com]
Sent: Tuesday, February 01, 2005 1:24 PM
To: r...@yahoogroups.com
Subject: RE: [rabbit-semi] Using Static IP mode

 

My IT guys are asking about the gateway setting in the
Rabbit. They seem to think that this is very important
and that if its not set right no packets would be
processed. I've never touched the gateway setting.
Could that be why Static IP mode is not functioning?

Is there a sample Static IP program I can try? I can't
seem to find one. The one example, static.c, is for a
web server.

Steve



At 01:23 PM 2/1/2005, you wrote:

>My IT guys are asking about the gateway setting in the
>Rabbit. They seem to think that this is very important
>and that if its not set right no packets would be
>processed. I've never touched the gateway setting.
>Could that be why Static IP mode is not functioning?
>
>Is there a sample Static IP program I can try? I can't
>seem to find one. The one example, static.c, is for a
>web server.

Gateway does not matter on a lan.

Are you sure the settings are valid? Try defineing:

#define NET_VERBOSE

That should give you info if your params are bad. There is a line:

printf("NET: ifconfig() bad or inappropriate parameter ID: %d\n", ident);

in net.lib. You can look up the ID in the net.lib #defines.

Here's the code from my locateip sample that used either DHCP or static
settibgs (stored in RTData). If RTData.ip_address==0 it used DHCP,
otherwise it uses params stored in the struct.

#define USE_DHCP
#define TCPCONFIG 6

if (!RTData.ip_address)
ifconfig(IF_ETH0,IFS_DHCP,1,IFS_DHCP_TIMEOUT,5,IFS_END);

// init network
//
sock_init();
//
// if IP address is fixed, disable DHCP
// if hardcoded, override sock_init() stuff with ours.
//
if (RTData.ip_address)
{
printf("Load Static IP settings.\r\n");
ifconfig(IF_ETH0,IFS_DHCP,0,IFS_END);
ifconfig(IF_ETH0,IFS_IPADDR,RTData.ip_address,IFS_END);
if (RTData.netmask)
ifconfig(IF_ETH0,IFS_NETMASK,RTData.netmask,IFS_END);
if (RTData.gateway)
ifconfig(IF_ETH0,IFS_ROUTER_SET,RTData.gateway,IFS_END);
}
else
{
printf("Using DHCP.\r\n");
}
ifconfig(IF_ETH0,IFS_UP,IFS_END);

while (ifpending(IF_ETH0)&1)
{
tcp_tick(NULL);
}
//
// FYI show network info
//
pd_getaddress(0,addr);
sprintf(mac_addr,"%02x:%02x:%02x:%02x:%02x:%02x",
addr[0],addr[1],addr[2],
addr[3],addr[4],addr[5]);
printf("MAC addr=%s\n",mac_addr);

----
The full source and the PC application to assign the board IP is in my free
libs located in the URL in my sig.

<Scott>

------
| Scott G. Henion| shenion@shen... |
| Consultant | Stone Mountain, GA |
| SHDesigns | PGP Key 0xE98DDC48 |
| http://www.shdesigns.org/rabbit/ |
------


I tried sample program pingme.c and it works, sort of.
At least the link light on the hub lights up. I tried
pinging it but I get error message "Destination
unreachable". I suspect it has to do with the default
IP address used, 10.10.6.100. My PC is still at
192.168.100.2.

I notice that pingme.c does not call ifconfig(). It
just calls sock_init() and tcp_tick(). Or is there
some code buried in one of the DC libraries that does
this?

Steve

--- Bob Hohentanner <bhohentanner@bhoh...> wrote:

> Gateway is not needed if it's just your PC and the
> Rabbit connected to
> the hub.
>
> Yes, the sample static.c is for a web server, but
> uses a static address
> and you can use this sample to see if it's your
> hardware or firmware
> that flakey
>
> ________________________________
>
> From: Steve Trigero [mailto:seecwriter@seec...]
> Sent: Tuesday, February 01, 2005 1:24 PM
> To: rabbit-semi@rabb...
> Subject: RE: [rabbit-semi] Using Static IP mode
>
> My IT guys are asking about the gateway setting in
> the
> Rabbit. They seem to think that this is very
> important
> and that if its not set right no packets would be
> processed. I've never touched the gateway setting.
> Could that be why Static IP mode is not functioning?
>
> Is there a sample Static IP program I can try? I
> can't
> seem to find one. The one example, static.c, is for
> a
> web server.
>
> Steve > ________________________________
>
> > .
>




The different addresses explain the “destination unreachable” message.

 

What do you TCPCONFIG defined to? It should be 0 if you are going to handle the configuration, otherwise it uses some macros.

 

Bob

 

From: Steve Trigero [mailto:s...@yahoo.com]
Sent: Tuesday, February 01, 2005 2:05 PM
To: r...@yahoogroups.com
Subject: RE: [rabbit-semi] Using Static IP mode

 

I tried sample program pingme.c and it works, sort of.
At least the link light on the hub lights up. I tried
pinging it but I get error message "Destination
unreachable". I suspect it has to do with the default
IP address used, 10.10.6.100. My PC is still at
192.168.100.2.

I notice that pingme.c does not call ifconfig(). It
just calls sock_init() and tcp_tick(). Or is there
some code buried in one of the DC libraries that does
this?

Steve

--- Bob Hohentanner <b...@acromag.com> wrote:

> Gateway is not needed if it's just your PC and the
> Rabbit connected to
> the hub.

> Yes, the sample static.c is for a web server, but
> uses a static address
> and you can use this sample to see if it's your
> hardware or firmware
> that flakey

> ________________________________
>
> From: Steve Trigero [mailto:s...@yahoo.com]
> Sent: Tuesday, February 01, 2005 1:24 PM
> To: r...@yahoogroups.com
> Subject: RE: [rabbit-semi] Using Static IP mode

> My IT guys are asking about the gateway setting in
> the
> Rabbit. They seem to think that this is very
> important
> and that if its not set right no packets would be
> processed. I've never touched the gateway setting.
> Could that be why Static IP mode is not functioning?
>
> Is there a sample Static IP program I can try? I
> can't
> seem to find one. The one example, static.c, is for
> a
> web server.
>
> Steve
>
>
> ________________________________
>
> > .
>




I have TCPCONFIG defined to 0 in my program.

And setting the Rabbit to the right address range
causes ping to work.

So now, why does my program not work? The first
difference I notice is that in my program tcp_tick()
is not called until I get a true value returned from
pd_havelink(). This works for DHCP. Shouldn't it also
work for Static IP?

Steve --- Bob Hohentanner <bhohentanner@bhoh...> wrote:

> The different addresses explain the "destination
> unreachable" message.
>
> What do you TCPCONFIG defined to? It should be 0 if
> you are going to
> handle the configuration, otherwise it uses some
> macros.
>
> Bob
>
> ________________________________
>
> From: Steve Trigero [mailto:seecwriter@seec...]
> Sent: Tuesday, February 01, 2005 2:05 PM
> To: rabbit-semi@rabb...
> Subject: RE: [rabbit-semi] Using Static IP mode
>
> I tried sample program pingme.c and it works, sort
> of.
> At least the link light on the hub lights up. I
> tried
> pinging it but I get error message "Destination
> unreachable". I suspect it has to do with the
> default
> IP address used, 10.10.6.100. My PC is still at
> 192.168.100.2.
>
> I notice that pingme.c does not call ifconfig(). It
> just calls sock_init() and tcp_tick(). Or is there
> some code buried in one of the DC libraries that
> does
> this?
>
> Steve
>
> --- Bob Hohentanner <bhohentanner@bhoh...>
> wrote:
>
> > Gateway is not needed if it's just your PC and the
> > Rabbit connected to
> > the hub.
> >
> > Yes, the sample static.c is for a web server, but
> > uses a static address
> > and you can use this sample to see if it's your
> > hardware or firmware
> > that flakey
> >
> > ________________________________
> >
> > From: Steve Trigero [mailto:seecwriter@seec...]
> > Sent: Tuesday, February 01, 2005 1:24 PM
> > To: rabbit-semi@rabb...
> > Subject: RE: [rabbit-semi] Using Static IP mode
> >
> > My IT guys are asking about the gateway setting in
> > the
> > Rabbit. They seem to think that this is very
> > important
> > and that if its not set right no packets would be
> > processed. I've never touched the gateway setting.
> > Could that be why Static IP mode is not
> functioning?
> >
> > Is there a sample Static IP program I can try? I
> > can't
> > seem to find one. The one example, static.c, is
> for
> > a
> > web server.
> >
> > Steve
> >
> >
> > ________________________________
> >
> > > .
> >
> ________________________________
>
> > .
>




Scott,

In your sample program, if the Rabbit is not connected
to a network what happens when the Rabbit gets to
"while (ifpending(IF_ETH0)&1)"? Does it hang there
until a cable is plugged in?

Steve --- Scott Henion <shenion@shen...> wrote:

> At 01:23 PM 2/1/2005, you wrote:
>
> >My IT guys are asking about the gateway setting in
> the
> >Rabbit. They seem to think that this is very
> important
> >and that if its not set right no packets would be
> >processed. I've never touched the gateway setting.
> >Could that be why Static IP mode is not
> functioning?
> >
> >Is there a sample Static IP program I can try? I
> can't
> >seem to find one. The one example, static.c, is for
> a
> >web server.
>
> Gateway does not matter on a lan.
>
> Are you sure the settings are valid? Try defineing:
>
> #define NET_VERBOSE
>
> That should give you info if your params are bad.
> There is a line:
>
> printf("NET: ifconfig() bad or inappropriate
> parameter ID: %d\n", ident);
>
> in net.lib. You can look up the ID in the net.lib
> #defines.
>
> Here's the code from my locateip sample that used
> either DHCP or static
> settibgs (stored in RTData). If RTData.ip_address==0
> it used DHCP,
> otherwise it uses params stored in the struct.
>
> #define USE_DHCP
> #define TCPCONFIG 6
>
> if (!RTData.ip_address)
ifconfig(IF_ETH0,IFS_DHCP,1,IFS_DHCP_TIMEOUT,5,IFS_END);
>
> // init network
> //
> sock_init();
> //
> // if IP address is fixed, disable DHCP
> // if hardcoded, override sock_init() stuff
> with ours.
> //
> if (RTData.ip_address)
> {
> printf("Load Static IP settings.\r\n");
> ifconfig(IF_ETH0,IFS_DHCP,0,IFS_END);
ifconfig(IF_ETH0,IFS_IPADDR,RTData.ip_address,IFS_END);
> if (RTData.netmask) ifconfig(IF_ETH0,IFS_NETMASK,RTData.netmask,IFS_END);
> if (RTData.gateway) ifconfig(IF_ETH0,IFS_ROUTER_SET,RTData.gateway,IFS_END);
> }
> else
> {
> printf("Using DHCP.\r\n");
> }
> ifconfig(IF_ETH0,IFS_UP,IFS_END);
>
> while (ifpending(IF_ETH0)&1)
> {
> tcp_tick(NULL);
> }
> //
> // FYI show network info
> //
> pd_getaddress(0,addr);
>
> sprintf(mac_addr,"%02x:%02x:%02x:%02x:%02x:%02x",
> addr[0],addr[1],addr[2],
> addr[3],addr[4],addr[5]);
> printf("MAC addr=%s\n",mac_addr);
>
> ----
> The full source and the PC application to assign the
> board IP is in my free
> libs located in the URL in my sig.
>
> <Scott>
>
> ------
> | Scott G. Henion| shenion@shen... |
> | Consultant | Stone Mountain, GA |
> | SHDesigns | PGP Key 0xE98DDC48 |
> | http://www.shdesigns.org/rabbit/ |
> ------




The Gateway setting only applies when the Rabbit needs to talk to
addresses not in its subnet - for example off-site hosts.

When the IP stack encounters an IP address not in the local subnet it
sends the message to the gateway whose job is to get it to the outside
world.

So for many all-my-friends-are-local uses of the rabbit the gateway is
not needed.

As for getting anything to work, until you can get static.c working and
serving it's web page to your PC, you probably aren't ready to try to
diagnose your own code - static.c is (usually) trivial to make work by
simply setting the #defined IP address to something reasonable. Once
static.c works, you'll have proved that you don't have bad cables, or
cables plugged into wrong ports or whatever.


Change the IP address on your PC to 10.10.6.1 and set the netmask to
255.255.255.0.
Reboot the PC. Try the pingme program again and let us know the
results.

Arlen

On Feb 1, 2005, at 11:05 AM, Steve Trigero wrote:

>
> I tried sample program pingme.c and it works, sort of.
> At least the link light on the hub lights up. I tried
> pinging it but I get error message "Destination
> unreachable". I suspect it has to do with the default
> IP address used, 10.10.6.100. My PC is still at
> 192.168.100.2.
>
> I notice that pingme.c does not call ifconfig(). It
> just calls sock_init() and tcp_tick(). Or is there
> some code buried in one of the DC libraries that does
> this?
>
> Steve
>
> --- Bob Hohentanner <bhohentanner@bhoh...> wrote:
>
>> Gateway is not needed if it's just your PC and the
>> Rabbit connected to
>> the hub.
>>
>> Yes, the sample static.c is for a web server, but
>> uses a static address
>> and you can use this sample to see if it's your
>> hardware or firmware
>> that flakey
>>
>> ________________________________
>>
>> From: Steve Trigero [mailto:seecwriter@seec...]
>> Sent: Tuesday, February 01, 2005 1:24 PM
>> To: rabbit-semi@rabb...
>> Subject: RE: [rabbit-semi] Using Static IP mode
>>
>> My IT guys are asking about the gateway setting in
>> the
>> Rabbit. They seem to think that this is very
>> important
>> and that if its not set right no packets would be
>> processed. I've never touched the gateway setting.
>> Could that be why Static IP mode is not functioning?
>>
>> Is there a sample Static IP program I can try? I
>> can't
>> seem to find one. The one example, static.c, is for
>> a
>> web server.
>>
>> Steve
>>
>>
>> ________________________________
>>
>> > .
> >
>
> Yahoo! Groups Links >
>





Changing the address caused pingme to work.

But that doesn't explain why I can't ping my own
program when in Static IP mode. DHCP works fine.

Steve --- Arlen Fletcher <arlenf@arle...> wrote:

> Change the IP address on your PC to 10.10.6.1 and
> set the netmask to
> 255.255.255.0.
> Reboot the PC. Try the pingme program again and let
> us know the
> results.
>
> Arlen
>
> On Feb 1, 2005, at 11:05 AM, Steve Trigero wrote:
>
> >
> > I tried sample program pingme.c and it works, sort
> of.
> > At least the link light on the hub lights up. I
> tried
> > pinging it but I get error message "Destination
> > unreachable". I suspect it has to do with the
> default
> > IP address used, 10.10.6.100. My PC is still at
> > 192.168.100.2.
> >
> > I notice that pingme.c does not call ifconfig().
> It
> > just calls sock_init() and tcp_tick(). Or is there
> > some code buried in one of the DC libraries that
> does
> > this?
> >
> > Steve
> >
> > --- Bob Hohentanner <bhohentanner@bhoh...>
> wrote:
> >
> >> Gateway is not needed if it's just your PC and
> the
> >> Rabbit connected to
> >> the hub.
> >>
> >> Yes, the sample static.c is for a web server, but
> >> uses a static address
> >> and you can use this sample to see if it's your
> >> hardware or firmware
> >> that flakey
> >>
> >> ________________________________
> >>
> >> From: Steve Trigero [mailto:seecwriter@seec...]
> >> Sent: Tuesday, February 01, 2005 1:24 PM
> >> To: rabbit-semi@rabb...
> >> Subject: RE: [rabbit-semi] Using Static IP mode
> >>
> >> My IT guys are asking about the gateway setting
> in
> >> the
> >> Rabbit. They seem to think that this is very
> >> important
> >> and that if its not set right no packets would be
> >> processed. I've never touched the gateway
> setting.
> >> Could that be why Static IP mode is not
> functioning?
> >>
> >> Is there a sample Static IP program I can try? I
> >> can't
> >> seem to find one. The one example, static.c, is
> for
> >> a
> >> web server.
> >>
> >> Steve
> >>
> >>
> >> ________________________________
> >>
> >> > .
> >>
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>




Steve,

 

    Did you get my question about where you have your sock_init relative to the ifconfig calls? You only call sock_init once right?

 

From: Steve Trigero [mailto:s...@yahoo.com]
Sent: Tuesday, February 01, 2005 4:16 PM
To: r...@yahoogroups.com
Subject: Re: [rabbit-semi] Using Static IP mode

 


Changing the address caused pingme to work.

But that doesn't explain why I can't ping my own
program when in Static IP mode. DHCP works fine.

Steve --- Arlen Fletcher <a...@direcway.com> wrote:

> Change the IP address on your PC to 10.10.6.1 and
> set the netmask to
> 255.255.255.0.
> Reboot the PC.  Try the pingme program again and let
> us know the
> results.
>
> Arlen
>
> On Feb 1, 2005, at 11:05 AM, Steve Trigero wrote:
>
> >
> > I tried sample program pingme.c and it works, sort
> of.
> > At least the link light on the hub lights up. I
> tried
> > pinging it but I get error message "Destination
> > unreachable". I suspect it has to do with the
> default
> > IP address used, 10.10.6.100. My PC is still at
> > 192.168.100.2.
> >
> > I notice that pingme.c does not call ifconfig().
> It
> > just calls sock_init() and tcp_tick(). Or is there
> > some code buried in one of the DC libraries that
> does
> > this?
> >
> > Steve
> >
> > --- Bob Hohentanner <b...@acromag.com>
> wrote:
> >
> >> Gateway is not needed if it's just your PC and
> the
> >> Rabbit connected to
> >> the hub.
> >>
> >> Yes, the sample static.c is for a web server, but
> >> uses a static address
> >> and you can use this sample to see if it's your
> >> hardware or firmware
> >> that flakey
> >>
> >> ________________________________
> >>
> >> From: Steve Trigero [mailto:s...@yahoo.com]
> >> Sent: Tuesday, February 01, 2005 1:24 PM
> >> To: r...@yahoogroups.com
> >> Subject: RE: [rabbit-semi] Using Static IP mode
> >>
> >> My IT guys are asking about the gateway setting
> in
> >> the
> >> Rabbit. They seem to think that this is very
> >> important
> >> and that if its not set right no packets would be
> >> processed. I've never touched the gateway
> setting.
> >> Could that be why Static IP mode is not
> functioning?
> >>
> >> Is there a sample Static IP program I can try? I
> >> can't
> >> seem to find one. The one example, static.c, is
> for
> >> a
> >> web server.
> >>
> >> Steve
> >>
> >>
> >> ________________________________
> >>
> >> > .
> >>
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>