CodePudding user response:
I usually use the collection to simulate this typeTIP_HEAD_TEST=the packed record
In case the integer of
0: (VersionLength: the set of 0.. 7);
1: (VerLen: Byte);
end;
Var
IPHEAD: TIP_HEAD_TEST;
The begin
IPHEAD. VerLen:=$4.//set the IPV4, at the same time, the length of the qing dynasty 0
IPHEAD. VerLen:=$4 or (nLen SHL 4);//set length and IPV4, at the same time can also be SHL 3, here there seems to be a variable bit
IPHEAD. VersionLength:=IPHEAD. VersionLength + [2];//only the bit position 1, 2 is set IPV4, other unchanged
.