[En-Nut-Discussion] Newbie question: TCP Client
Przemyslaw Rudy
prudy at audiotech.pl
Sat Oct 29 22:36:28 CEST 2005
Interesting
In the httpd example I replaced:
-----
NutDhcpIfConfig()
-----
with:
-----
NutNetIfConfig("eth0", mac, ip_addr, ip_mask)
NutIpRouteAdd(0, 0, my_gate, &DEV_ETHER)
-----
Then having a router between the nut board and a PC, the web server
cannot be contacted.
Why? Because the route has not been actually added!
Building with WinAVR I got the following:
-----
warning: implicit declaration of function `NutIpRouteAdd'
-----
but that’s fine as the proper function will be linked anyway.
Then I added this to the httpserv.c:
-----
#include <net/route.h>
-----
or just this is enough:
-----
extern int NutIpRouteAdd(u_long ip, u_long mask, u_long gate, NUTDEVICE
* dev);
-----
and everything works now.
Assuming, if there is no explicit function declaration while compiling
the c source the default function argument types are used instead.
Below are lst outputs:
good (with declaration/include)
---
call NutNetIfConfig
mov __tmp_reg__,r31
ldi r31,lo8(devEth0)
mov r12,r31
ldi r31,hi8(devEth0)
mov r13,r31
mov r31,__tmp_reg__
ldd r14,Y+11
ldd r15,Y+12
ldd r16,Y+13
ldd r17,Y+14
ldi r18,lo8(0)
ldi r19,hi8(0)
ldi r20,hlo8(0)
ldi r21,hhi8(0)
movw r24,r20
movw r22,r18
call NutIpRouteAdd
---
bad (no include/declaration)
---
call NutNetIfConfig
ldi r16,lo8(devEth0)
ldi r17,hi8(devEth0)
ldd r18,Y+11
ldd r19,Y+12
ldd r20,Y+13
ldd r21,Y+14
ldi r22,lo8(0)
ldi r23,hi8(0)
movw r24,r22
call NutIpRouteAdd
---
More information about the En-Nut-Discussion
mailing list