I have checked with a router which reply with a RST packet when we try to 
connect to a port which is not up.
 
Starting lwIP, loopback interface IP is 127.0.0.1
Starting lwIP, local interface IP is 192.168.1.249
 0: \Device\NPF_GenericDialupAdapter
 1: \Device\NPF_{E0F42C25-0F0D-43B3-94DF-74D3B575B0A8}
MAC: 00:15:F2:4C:D0:59
err=-5, conn->pcb.tcp!=NULL
connected error==-1 [0]
close now
 
In this case, err_tcp will receive a -5 (ERR_RST), but only once. So, the tcp 
state machine is good (there is no retry inside core code).
 
BTW: I just fix a small error in err_strerr[] table. I suggest we could use a 
xmacro like for memp_std.h to avoid this kind of errors in the future.
 
 
  
====================================
Frédéric BERNON 
HYMATOM SA 
Chef de projet informatique 
Microsoft Certified Professional 
Tél. : +33 (0)4-67-87-61-10 
Fax. : +33 (0)4-67-70-85-44 
Email : [EMAIL PROTECTED] 
Web Site : http://www.hymatom.fr <http://www.hymatom.fr/>  
====================================
P Avant d'imprimer, penser à l'environnement
 

        -----Message d'origine-----
        De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Frédéric 
BERNON
        Envoyé : mercredi 12 décembre 2007 08:29
        À : Mailing list for lwIP users
        Objet : Re: RE : [lwip-users] Receiving RSTs
        
        
        I did this test with last CVS HEAD (with a Vista workstation):
         
        static void
        tcp_connect_thread(void *arg)
        {
        int sock;
        struct sockaddr_in local;
        struct sockaddr_in to;
        int iResult;
        u32_t server_address;
         
        /* initialize server address */
        server_address = inet_addr("192.168.0.1");/*my pc*/
        /* if we got a valid server address... */
        if (server_address!=0) {
        /* create new socket */
        sock = socket( AF_INET, SOCK_STREAM, 0);
        if (sock>=0) {
        /* prepare local address */
        memset(&local, 0, sizeof(local));
        local.sin_family = AF_INET;
        local.sin_port = htons(INADDR_ANY);
        local.sin_addr.s_addr = htonl(INADDR_ANY);
        /* bind to local address */
        if (bind( sock, (struct sockaddr *)&local, sizeof(local))==0) {
        /* prepare server address */
        memset(&to, 0, sizeof(to));
        to.sin_family = AF_INET;
        to.sin_port = htons(62345);/* a port which is not opened*/
        to.sin_addr.s_addr = server_address;
         
        /* connect to server */
        if ((iResult=connect( sock, (struct sockaddr *)&to, sizeof(to)))>=0) {
        printf("connected success==%i [%i]\n", iResult, errno);
        } else {
        printf("connected error==%i [%i]\n", iResult, errno);
        }
        /* sleep */
        sys_msleep(60000);/*let the time to see if any other packet is 
received*/
        printf("close now\n");
         
        }
        /* close the socket */
        closesocket(sock);
        }
        }
        }
         
        I got :
         
        
        Starting lwIP, loopback interface IP is 127.0.0.1
        Starting lwIP, local interface IP is 192.168.0.2
         0: \Device\NPF_{A6293F5E-B3DF-4E8D-8D01-C65870EEDD1E}
         1: \Device\NPF_{2DA42D7E-7436-40CD-901E-5D73107798B0}
        MAC: 00:18:F3:E3:8D:8D
        err_tcp==-4
        connected error==-1 [0]
        close now
        
        -4 = ERR_ABRT
         
        What I can said is the PC never send any RST packet (checked with 
wireshark). Of course, perhaps it's different with another pc OS.
         
        But in all cases, in err_tcp, we set to NULL conn->pcb.tcp. So, we 
can't reuse the pcb. The only solution seems to close the socket and reopen it. 
If on RST, we receive any error, perhaps we could add a line like: 

        static void

        err_tcp(void *arg, err_t err)

        {

        struct netconn *conn;

        conn = arg;

        LWIP_ASSERT("conn != NULL", (conn != NULL));

        if (conn->pcb.tcp == NULL) return; /*<<<<<<<<<<<<<<<<<<<<<<<<<<*/

        conn->pcb.tcp = NULL;

        conn->err = err;

         
        ----- Original Message ----- 
        From: "Jonathan Larmour" <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
        To: "Mailing list for lwIP users" <[email protected] 
<mailto:[email protected]> >
        Sent: Tuesday, December 11, 2007 11:45 PM
        Subject: Re: RE : [lwip-users] Receiving RSTs
        
        
        > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  wrote:
        >> Jonathan Larmour wrote:
        >> 
        >>> I wonder from what Aparna says:
        >>>
        >>>  
        >>>
        >>>>>         When the Windows server is not up, the PC responds with a 
RST
        >>>>>         for a received SYN. The connect() API returns an error, 
and the
        >>>>>         client retries connect() after every few seconds.
        >>>>>       
        >>>
        >>>
        >>> whether he/she is not closing the socket before calling connect 
again?
        >>>
        >>> Maybe the netconn API needs to explicitly disallow connects if 
        >>> conn->err is
        >>> set?
        >>>
        >>> Either way, if the socket isn't being closed, Aparna needs to fix 
        >>> his/her code.
        >>>   
        >> 
        >> Normally, the socket API allows calling connect for a second time 
(when 
        >> the first call fails and the socket is not already connected).
        > 
        > Oh yes, of course you are right. Aparna's code should be valid for a 
BSD 
        > sockets API, sorry.
        > 
        >> LwIP 
        >> might not allow this, in which case we can argue if there is 
        >> documentation missing or an assert (or a code change)...
        > 
        > I think in the short term, disallowing based on non-zero conn->err 
would 
        > be best. This could be solved, but probably only when we have the 
richer 
        > set of synchronisation primitives we've been thinking about elsewhere.
        > 
        > Jifl
        > -- 
        > eCosCentric Limited      http://www.eCosCentric.com/ 
<http://www.eCosCentric.com/>      The eCos experts
        > Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 
245571
        > Registered in England and Wales: Reg No 4422071.
        > ------["The best things in life aren't things."]------      
Opinions==mine
        > 
        > 
        > _______________________________________________
        > lwip-users mailing list
        > [email protected] <mailto:[email protected]> 
        > http://lists.nongnu.org/mailman/listinfo/lwip-users 
<http://lists.nongnu.org/mailman/listinfo/lwip-users> 
        > 

<<image001.jpg>>

<<image002.jpg>>

BEGIN:VCARD
VERSION:2.1
N:BERNON;Frédéric;;M.
FN:Frédéric BERNON
ORG:HYMATOM SA;Recherche et Développement
TITLE:Chef de projet informatique
TEL;WORK;VOICE:04-67-87-61-10
TEL;WORK;FAX:04-67-70-85-44
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;23;Zone Industrielle=0D=0A175 rue de Massacan;VENDARGUES;;34740;FRANCE;
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:23=0D=0AZone Industrielle=0D=0A175 rue de Massacan=0D=0AVENDARGUES 34740=0D=
=0AFrance
URL;WORK:http://www.hymatom.fr
ROLE:Chef de projet informatique
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
REV:20020404T083210Z
END:VCARD
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to