mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-10 06:44:18 +00:00
PPP: Add option to skip FCS table
Option PPP_FCS_TABLE is created which controls if PPPoS FCS calculation should be done against precalculated table or by using a short algorithm. Default value is 1, keeps old behaviour. Setting it to 0 saves around 0.5 kB flash.
This commit is contained in:
parent
ba0c619844
commit
11a3057e8e
@ -1703,6 +1703,13 @@
|
|||||||
|
|
||||||
#if PPP_SUPPORT
|
#if PPP_SUPPORT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation
|
||||||
|
*/
|
||||||
|
#ifndef PPP_FCS_TABLE
|
||||||
|
#define PPP_FCS_TABLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PAP_SUPPORT==1: Support PAP.
|
* PAP_SUPPORT==1: Support PAP.
|
||||||
*/
|
*/
|
||||||
|
@ -750,9 +750,9 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if PPPOS_SUPPORT
|
#if PPPOS_SUPPORT
|
||||||
|
#if PPP_FCS_TABLE
|
||||||
/*
|
/*
|
||||||
* FCS lookup table as calculated by genfcstab.
|
* FCS lookup table as calculated by genfcstab.
|
||||||
* @todo: smaller, slower implementation for lower memory footprint?
|
|
||||||
*/
|
*/
|
||||||
static const u_short fcstab[256] = {
|
static const u_short fcstab[256] = {
|
||||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||||
@ -788,6 +788,19 @@ static const u_short fcstab[256] = {
|
|||||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||||
};
|
};
|
||||||
|
#else /* PPP_FCS_TABLE */
|
||||||
|
/* The HDLC polynomial: X**0 + X**5 + X**12 + X**16 (0x8408) */
|
||||||
|
#define PPP_FCS_POLYNOMIAL 0x8408
|
||||||
|
u16_t ppp_get_fcs(u8_t byte) {
|
||||||
|
unsigned int octet;
|
||||||
|
int bit;
|
||||||
|
octet = byte;
|
||||||
|
for (bit = 8; bit-- > 0; ) {
|
||||||
|
octet = (octet & 0x01) ? ((octet >> 1) ^ PPP_FCS_POLYNOMIAL) : (octet >> 1);
|
||||||
|
}
|
||||||
|
return octet & 0xffff;
|
||||||
|
}
|
||||||
|
#endif /* PPP_FCS_TABLE */
|
||||||
|
|
||||||
/* PPP's Asynchronous-Control-Character-Map. The mask array is used
|
/* PPP's Asynchronous-Control-Character-Map. The mask array is used
|
||||||
* to select the specific bit for a character. */
|
* to select the specific bit for a character. */
|
||||||
|
@ -127,7 +127,12 @@
|
|||||||
*/
|
*/
|
||||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||||
|
#if PPP_FCS_TABLE
|
||||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||||
|
#else
|
||||||
|
u16_t ppp_get_fcs(u8_t byte);
|
||||||
|
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ ppp_get_fcs(((fcs) ^ (c)) & 0xff))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A 32-bit unsigned integral type.
|
* A 32-bit unsigned integral type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user