PPP, removed useless padding in bitfields

Most of them were wrong actually. We have to use unsigned int because
C90 only allows int types for bitfields, so we are stuck to 32-bit
bitfields in most cases.
This commit is contained in:
Sylvain Rochet 2015-04-21 22:43:53 +02:00
parent 632de523de
commit 5989c1883e
7 changed files with 2 additions and 57 deletions

View File

@ -127,21 +127,14 @@ typedef struct ccp_options {
unsigned int deflate :1; /* do Deflate? */
unsigned int deflate_correct :1; /* use correct code for deflate? */
unsigned int deflate_draft :1; /* use draft RFC code for deflate? */
#else /* DEFLATE_SUPPORT */
unsigned int :3; /* 3 bit of padding */
#endif /* DEFLATE_SUPPORT */
#if BSDCOMPRESS_SUPPORT
unsigned int bsd_compress :1; /* do BSD Compress? */
#else /* BSDCOMPRESS_SUPPORT */
unsigned int :1; /* 1 bit of padding */
#endif /* BSDCOMPRESS_SUPPORT */
#if PREDICTOR_SUPPORT
unsigned int predictor_1 :1; /* do Predictor-1? */
unsigned int predictor_2 :1; /* do Predictor-2? */
#else /* PREDICTOR_SUPPORT */
unsigned int :2; /* 2 bit of padding */
#endif /* PREDICTOR_SUPPORT */
unsigned int :2; /* 2 bit of padding to round out to 8 bits */
#if MPPE_SUPPORT
u8_t mppe; /* MPPE bitfield */

View File

@ -94,18 +94,13 @@ typedef struct ipcp_options {
unsigned int neg_vj :1; /* Van Jacobson Compression? */
unsigned int old_vj :1; /* use old (short) form of VJ option? */
unsigned int cflag :1;
#else
unsigned int :3; /* 3 bits of padding */
#endif /* VJ_SUPPORT */
unsigned int accept_local :1; /* accept peer's value for ouraddr */
unsigned int accept_remote :1; /* accept peer's value for hisaddr */
#if LWIP_DNS
unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */
unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */
#else
unsigned int :2; /* 2 bits of padding */
#endif /* LWIP_DNS */
unsigned int :6; /* 6 bits of padding to round out to 16 bits */
u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
#if LWIP_DNS

View File

@ -170,7 +170,7 @@ typedef struct ipv6cp_options {
#ifdef IPV6CP_COMP
unsigned int neg_vj :1; /* Van Jacobson Compression? */
#endif /* IPV6CP_COMP */
unsigned int :2; /* 2 bit of padding to round out to 8 bits */
#ifdef IPV6CP_COMP
u_short vj_protocol; /* protocol value to use in VJ option */
#endif /* IPV6CP_COMP */

View File

@ -113,35 +113,26 @@ typedef struct lcp_options {
unsigned int neg_asyncmap :1; /* Negotiate the async map? */
#if PAP_SUPPORT
unsigned int neg_upap :1; /* Ask for UPAP authentication? */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
unsigned int neg_chap :1; /* Ask for CHAP authentication? */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* CHAP_SUPPORT */
#if EAP_SUPPORT
unsigned int neg_eap :1; /* Ask for EAP authentication? */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* EAP_SUPPORT */
unsigned int neg_magicnumber :1; /* Ask for magic number? */
unsigned int neg_pcompression :1; /* HDLC Protocol Field Compression? */
unsigned int neg_accompression :1; /* HDLC Address/Control Field Compression? */
#if LQR_SUPPORT
unsigned int neg_lqr :1; /* Negotiate use of Link Quality Reports */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* LQR_SUPPORT */
unsigned int neg_cbcp :1; /* Negotiate use of CBCP */
#ifdef HAVE_MULTILINK
unsigned int neg_mrru :1; /* negotiate multilink MRRU */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* HAVE_MULTILINK */
unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */
unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */
u16_t mru; /* Value of MRU */
#ifdef HAVE_MULTILINK
u16_t mrru; /* Value of MRRU, and multilink enable */

View File

@ -164,7 +164,6 @@ typedef struct ppp_mppe_state {
u16_t sanity_errors; /* take down LCP if too many */
unsigned int stateful :1; /* stateful mode flag */
unsigned int discard :1; /* stateful mode packet loss flag */
unsigned int :6; /* 6 bit of padding to round out to 8 bits */
} ppp_mppe_state;
void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key);

View File

@ -200,63 +200,42 @@ typedef struct ppp_settings_s {
#if PPP_SERVER && PPP_AUTH_SUPPORT
unsigned int auth_required :1; /* Peer is required to authenticate */
unsigned int null_login :1; /* Username of "" and a password of "" are acceptable */
#else
unsigned int :2; /* 2 bits of padding */
#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
#if PPP_REMOTENAME
unsigned int explicit_remote :1; /* remote_name specified with remotename opt */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* PPP_REMOTENAME */
#if PAP_SUPPORT
unsigned int refuse_pap :1; /* Don't proceed auth. with PAP */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
unsigned int refuse_chap :1; /* Don't proceed auth. with CHAP */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* CHAP_SUPPORT */
#if MSCHAP_SUPPORT
unsigned int refuse_mschap :1; /* Don't proceed auth. with MS-CHAP */
unsigned int refuse_mschap_v2 :1; /* Don't proceed auth. with MS-CHAPv2 */
#else
unsigned int :2; /* 2 bits of padding */
#endif /* MSCHAP_SUPPORT */
#if EAP_SUPPORT
unsigned int refuse_eap :1; /* Don't proceed auth. with EAP */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* EAP_SUPPORT */
#if LWIP_DNS
unsigned int usepeerdns :1; /* Ask peer for DNS adds */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* LWIP_DNS */
unsigned int persist :1; /* Persist mode, always try to open the connection */
#if PRINTPKT_SUPPORT
unsigned int hide_password :1; /* Hide password in dumped packets */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* PRINTPKT_SUPPORT */
unsigned int noremoteip :1; /* Let him have no IP address */
unsigned int lax_recv :1; /* accept control chars in asyncmap */
unsigned int noendpoint :1; /* don't send/accept endpoint discriminator */
#if PPP_LCP_ADAPTIVE
unsigned int lcp_echo_adaptive :1; /* request echo only if the link was idle */
#else
unsigned int :1; /* 1 bit of padding */
#endif /* PPP_LCP_ADAPTIVE */
#if MPPE_SUPPORT
unsigned int require_mppe :1; /* Require MPPE (Microsoft Point to Point Encryption) */
unsigned int refuse_mppe_40 :1; /* Allow MPPE 40-bit mode? */
unsigned int refuse_mppe_128 :1; /* Allow MPPE 128-bit mode? */
unsigned int refuse_mppe_stateful :1; /* Allow MPPE stateful mode? */
#else /* MPPE_SUPPORT */
unsigned int :4; /* 2 bit of padding */
#endif /* MPPE_SUPPORT */
unsigned int :5; /* 7 bit of padding to round out to 24 bits */
u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */
@ -360,34 +339,23 @@ struct ppp_pcb_s {
#if 0 /* UNUSED - PROXY ARP */
unsigned int proxy_arp_set :1; /* Have created proxy arp entry */
#endif /* UNUSED - PROXY ARP */
#else /* PPP_IPV4_SUPPORT */
unsigned int :3; /* 3 bit of padding */
#endif /* PPP_IPV4_SUPPORT */
#if PPP_IPV6_SUPPORT
unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */
unsigned int if6_up :1; /* True when the IPv6 interface is up. */
#else
unsigned int :2; /* 2 bit of padding */
#endif /* PPP_IPV6_SUPPORT */
unsigned int lcp_echo_timer_running :1; /* set if a timer is running */
#if VJ_SUPPORT
unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */
#else /* VJ_SUPPORT */
unsigned int :1; /* 1 bit of padding */
#endif /* VJ_SUPPORT */
#if CCP_SUPPORT
unsigned int ccp_all_rejected :1; /* we rejected all peer's options */
unsigned int ccp_is_open :1; /* true when CCP is open (currently negotiating) */
unsigned int ccp_is_up :1; /* true when CCP is up (ready to handle data packets) */
#else /* CCP_SUPPORT */
unsigned int :3; /* 3 bits of padding */
#endif /* CCP_SUPPORT */
#if MPPE_SUPPORT
unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */
#else /* MPPE_SUPPORT */
unsigned int :1; /* 1 bit of padding */
#endif /* MPPE_SUPPORT */
unsigned int :5; /* 5 bits of padding to round out to 16 bits */
#if PPP_AUTH_SUPPORT
/* auth data */

View File

@ -81,7 +81,6 @@ struct pppos_pcb_s {
unsigned int open :1; /* Set if PPPoS is open */
unsigned int pcomp :1; /* Does peer accept protocol compression? */
unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
unsigned int :5; /* 5 bits of padding to round out to 8 bits */
/* PPPoS rx */
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */