/*
* Calculate a new fcs given the current fcs and the new data.
*/
__u16 pppfcs16(fcs, cp, len)
register __u16 fcs;
register unsigned char *cp;
register int len;
{
while (len--)
fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
return (fcs);
}/*
* generate CRC16
*/
__u16 gen_fcs16(unsigned char *cp, int len)
{
__u16 fcs; /* add on output */
fcs = pppfcs16(PPP_INITFCS, cp, len);
fcs ^= 0xffff; /* complement */ return fcs;
/*
cp[len] = (fcs & 0x00ff); // least significant byte first
cp[len+1] = ((fcs >> 8) & 0x00ff);
*/
}/*
* check received data block
*/
__u16 chk_fcs16(unsigned char *cp, int len)
{
__u16 fcs; fcs = pppfcs16(PPP_INITFCS, cp, len);
return fcs;/*
if (fcs == PPP_GOODFCS)
return SUCCESS;
*/
}
* Calculate a new fcs given the current fcs and the new data.
*/
__u16 pppfcs16(fcs, cp, len)
register __u16 fcs;
register unsigned char *cp;
register int len;
{
while (len--)
fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
return (fcs);
}/*
* generate CRC16
*/
__u16 gen_fcs16(unsigned char *cp, int len)
{
__u16 fcs; /* add on output */
fcs = pppfcs16(PPP_INITFCS, cp, len);
fcs ^= 0xffff; /* complement */ return fcs;
/*
cp[len] = (fcs & 0x00ff); // least significant byte first
cp[len+1] = ((fcs >> 8) & 0x00ff);
*/
}/*
* check received data block
*/
__u16 chk_fcs16(unsigned char *cp, int len)
{
__u16 fcs; fcs = pppfcs16(PPP_INITFCS, cp, len);
return fcs;/*
if (fcs == PPP_GOODFCS)
return SUCCESS;
*/
}
cp : PByte;
len : integer ) : Word ;
begin
pppfcs16 := fcs;
while (len > 0) do
begin
fcs := fcs shr 8;
fcs := fcs xor fcstab[(fcs xor cp^) and $ff];
Inc(cp, 1);
Dec(len);
end;
pppfcs16 := fcs;
end;function gen_fcs16(cp : PByte; len : integer) : Word;
var
fcs : Word;begin
fcs := pppfcs16(PPP_INITFCS, cp, len);
fcs := fcs xor $ffff;
Result := fcs;
end;function chk_fcs16(cp : PByte; len : integer) : Word;
var
fcs : Word;
begin
fcs := pppfcs16(PPP_INITFCS, cp, len);
Result := fcs;
end;