Home > Back-end >  About TCP packet header bag end processing
About TCP packet header bag end processing

Time:10-05

 # include 
#include
#include

# define PACKET_TCP_ID_HEAD "B8C1
"# define PACKET_TCP_ID_TAIL "76 b7"

Unsigned char Packet_Filter_TCP (unsigned char Packet [])
{
Unsigned char num=0;

Unsigned char * p=Packet;
Char * Head=NULL;
Char * Tail=NULL;

Head=memchr (p, B, sizeof (p));
Sscanf (Head, % 4 "s", the Head);

If (STRCMP (Head, PACKET_TCP_ID_HEAD)==0)
{
Printf (" found the baotou \ n ");
Tail=memchr (p, '7', sizeof (p));
Sscanf (Tail, "% 4 s", Tail).
If (STRCMP (Tail, PACKET_TCP_ID_TAIL)==0)
{
Printf (" found the package tail \ n ");
num++;
}
The else
Return 0;
}
The else
Return 0;

return num;
}

Int main ()
{
int num;
Unsigned char Packedt []="B8C176B71827063516376B7B8C11827063516376B7B8C11827063516376B7";
Num=Packet_Filter_TCP (Packedt);
Printf (" transfer % d a packet ", num);

Return 0;
}

CodePudding user response:

What problem, didn't see

CodePudding user response:

CodePudding user response:

Comments section has the function and the algorithm writes very understand ah
  • Related