Hi,
Thanks for your information. From your information, I've trace back the data and from here the function returns back -1:-
INT8 tcp_mapsocket (struct ip_frame* ipframe, struct tcp_frame* tcpframe)
{
struct tcb* soc;
UINT8 i;
/* Check if there is already connection on */
for( i=0; i < NO_OF_TCPSOCKETS; i++) {
soc = &tcp_socket[i]; /* Get socket */
if(soc->state == TCP_STATE_LISTENING)
continue; /* No match */
if(soc->remport != tcpframe->sport)
continue;
if(soc->locport != tcpframe->dport)
continue;
if(soc->rem_ip != ipframe->sip)
continue;
/* There is connection on already */
TCP_DEBUGOUT("Active connection socket found\r\n");
return(i);
}
/* Allocate listening one if SYN packet (Connection Request) */
TCP_DEBUGOUT("No active connection, checking if SYN packet\r\n");
/* Is it SYN? */
if( (tcpframe->hlen_flags & TCP_FLAG_SYN) == 0 )
return(-1);
if( tcpframe->hlen_flags & TCP_FLAG_ACK )
return(-1);
if( tcpframe->hlen_flags & TCP_FLAG_RESET )
return(-1);
if( tcpframe->hlen_flags & TCP_FLAG_FIN )
return(-1);
TCP_DEBUGOUT("Trying to allocate listening one for SYN packet\r\n");
/* Search listening sockets */
for( i=0; i < NO_OF_TCPSOCKETS; i++) {
soc = &tcp_socket[i]; /* Get socket */
if(soc->state != TCP_STATE_LISTENING)
continue;
if(soc->locport != tcpframe->dport)
continue;
/* Bind it */
soc->rem_ip = ipframe->sip;
soc->remport = tcpframe->sport;
TCP_DEBUGOUT("Allocated new socket\r\n");
return(i);
}
return(-1);
}
From what I've study from the source code, the program was jump out of the loop after the RED line. When I put the breakpoint on the RED line, I found out the value of soc->locport and tcpframe->dport are not same, and I don't know why the program jump out from the loop and maybe there is somewhere wrong on the setting.
Can you show me how to set the setting so that the program can connect using the TCP connection, because I still study the devices? Thanks.
Regards
kahjoo