Hi, I’m trying to get the TCP data length of a TCP/IP packet, but it’s always returning 4 for me, even if the TCP data comes empty.
Can anyone check what’s wrong with my code?
if (ntohs(pEtherHeader.h_proto)=ETH_P_IP) then begin
pIPHeader:=TIPHeaderPtr(Integer(pEtherHeader)+SizeOf(TEtherHeader));
if (pIPHeader.Protocol = IPPROTO_TCP) then begin
pTcpHeader:=TTCPHeaderPtr(Integer(pIPHeader) + (pIPHeader.VerLen and $F) * 4);
TcpDataLen:=sizeof(TIpHeader)-sizeof(TTCPHeader);
pTcpData:=POINTER(INTEGER(pTcpHeader)+sizeof(TTCPHeader));
end;
end;