TCP Grammar header check in MQX4.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TCP Grammar header check in MQX4.1

591 Views
wulinweng
Contributor II

Dear Support:

As we know, the tcp/ip stack in mqx4.1 has check the TCP Grammar Header in function TCP_Process_packet() in Tcp.c.

the tcp header include:

/*  Header of a TCP packet
 */
typedef struct tcp_header {              /* see RFC sec.3.1 */

   unsigned char    source_port[2];   /* source TCP port number */
   unsigned char    dest_port[2];     /* destination TCP port number */
   unsigned char    seq[4];           /* of 1st data octet or 1st-1 if (flags & SYN)*/
   unsigned char    ack[4];           /* valid if (flags & ACK) */
   unsigned char    flags[2];         /* see flags values above */
   unsigned char    window[2];        /* nb of bytes recipient of packet can send */
   unsigned char    checksum[2];      /* (see RFC) */
   unsigned char    urgent[2];        /* offset from seq, valid if (flags & URG) */
                              /* then follow options in 4-byte multiples, */
                              /* then data  */

} TCP_HEADER, * TCP_HEADER_PTR; /* 20 bytes */

the processing of the received packet is just check the flags in the source code like below:

   if ( ((flags & SYN) && (flags & FIN)) ||
        (flags == FIN) ||
        (flags == 0) ) {
      TCP_PP_DROP;
   }

my question is if the other data in the structure of tcp header is not valid, and the processing is not do the checking, can it be something wrong happen?

If I want to do the all tcp header data check? how can I to do it?

BR,

0 Kudos
1 Reply

343 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Wulin:

In RTCS, there is a TCP header checksum.    that is,  "  unsigned char    checksum[2];      /* (see RFC) */", this checksum is calculated only for the header bytes. The result of summing the entire IP header, including checksum, should be zero if there is no corruption.  At each hop, the checksum is recalculated and the packet will be discarded upon checksum mismatch.

This checksum is calculated by hardware.

Two configuration options are defined in rtcs/include/rtcscfg.h. You may override the settings from the user_config.h user configuration file

pastedImage_1.png

pastedImage_2.png

Regards

Daniel

0 Kudos