diff options
author | Chia-chi Yeh <chiachi@android.com> | 2009-06-13 02:29:04 +0800 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2009-06-13 02:29:04 +0800 |
commit | 7620ea508ae5fc623da4fc8ded8c8e10e65196b3 (patch) | |
tree | f6e72c632ac5754746fdb62f9b5bafe9e002267b /drivers/net | |
parent | 23e089f0f32898a924e37c8a5f6a533f4d07324b (diff) |
net: Fix a bitmask in PPPoPNS and rename constants in PPPoPNS and PPPoLAC.
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/pppolac.c | 26 | ||||
-rw-r--r-- | drivers/net/pppopns.c | 15 |
2 files changed, 21 insertions, 20 deletions
diff --git a/drivers/net/pppolac.c b/drivers/net/pppolac.c index 8843a9d30911..893a65264aba 100644 --- a/drivers/net/pppolac.c +++ b/drivers/net/pppolac.c @@ -32,12 +32,12 @@ #include <linux/ppp_channel.h> #include <net/tcp_states.h> -#define L2TP_CONTROL_MASK 0x80 -#define L2TP_VERSION_MASK 0x0F +#define L2TP_CONTROL_BIT 0x80 +#define L2TP_LENGTH_BIT 0x40 +#define L2TP_SEQUENCE_BIT 0x08 +#define L2TP_OFFSET_BIT 0x02 #define L2TP_VERSION 0x02 -#define L2TP_LENGTH_MASK 0x40 -#define L2TP_OFFSET_MASK 0x02 -#define L2TP_SEQUENCE_MASK 0x08 +#define L2TP_VERSION_MASK 0x0F #define PPP_ADDR 0xFF #define PPP_CTRL 0x03 @@ -63,7 +63,7 @@ static int pppolac_recv(struct sock *sk_udp, struct sk_buff *skb) goto drop; /* Put it back if it is a control packet. */ - if (skb->data[sizeof(struct udphdr)] & L2TP_CONTROL_MASK) + if (skb->data[sizeof(struct udphdr)] & L2TP_CONTROL_BIT) return 1; /* Now the packet is ours. Skip UDP header. */ @@ -76,20 +76,20 @@ static int pppolac_recv(struct sock *sk_udp, struct sk_buff *skb) ptr = &skb->data[2]; /* Check the length if it is present. */ - if (bits & L2TP_LENGTH_MASK) { + if (bits & L2TP_LENGTH_BIT) { if ((ptr[0] << 8 | ptr[1]) != skb->len) goto drop; ptr += 2; } /* Skip all fields including optional ones. */ - if (!skb_pull(skb, 6 + (bits & L2TP_SEQUENCE_MASK ? 4 : 0) + - (bits & L2TP_LENGTH_MASK ? 2 : 0) + - (bits & L2TP_OFFSET_MASK ? 2 : 0))) + if (!skb_pull(skb, 6 + (bits & L2TP_SEQUENCE_BIT ? 4 : 0) + + (bits & L2TP_LENGTH_BIT ? 2 : 0) + + (bits & L2TP_OFFSET_BIT ? 2 : 0))) goto drop; /* Skip the offset padding if it is present. */ - if (bits & L2TP_OFFSET_MASK && + if (bits & L2TP_OFFSET_BIT && !skb_pull(skb, skb->data[-2] << 8 | skb->data[-1])) goto drop; @@ -113,7 +113,7 @@ static int pppolac_recv(struct sock *sk_udp, struct sk_buff *skb) /* Check the sequence if it is present. According to RFC 2661 page 10 * and 43, the only thing to do is updating opt->sequencing. */ - opt->sequencing = bits & L2TP_SEQUENCE_MASK; + opt->sequencing = bits & L2TP_SEQUENCE_BIT; /* Skip PPP address and control if they are present. */ if (skb->len >= 2 && skb->data[0] == PPP_ADDR && @@ -153,7 +153,7 @@ static int pppolac_xmit(struct ppp_channel *chan, struct sk_buff *skb) /* Install L2TP header. */ if (opt->sequencing) { skb_push(skb, 10); - skb->data[0] = L2TP_SEQUENCE_MASK; + skb->data[0] = L2TP_SEQUENCE_BIT; skb->data[6] = opt->sequence >> 8; skb->data[7] = opt->sequence; skb->data[8] = 0; diff --git a/drivers/net/pppopns.c b/drivers/net/pppopns.c index 8885eba8968e..1fb19dc2e0bd 100644 --- a/drivers/net/pppopns.c +++ b/drivers/net/pppopns.c @@ -33,9 +33,10 @@ #define GRE_HEADER_SIZE 8 -#define PPTP_GRE_MASK htons(0x2001) -#define PPTP_GRE_SEQ_MASK htons(0x1000) -#define PPTP_GRE_ACK_MASK htons(0x0080) +#define PPTP_GRE_BITS htons(0x2001) +#define PPTP_GRE_BITS_MASK htons(0xEF7F) +#define PPTP_GRE_SEQ_BIT htons(0x1000) +#define PPTP_GRE_ACK_BIT htons(0x0080) #define PPTP_GRE_TYPE htons(0x880B) #define PPP_ADDR 0xFF @@ -78,13 +79,13 @@ static void pppopns_recv(struct sock *sk_raw, int length) /* Check the header. */ hdr = (struct header *)skb->data; if (hdr->type != PPTP_GRE_TYPE || hdr->call != opt->local || - (hdr->bits & PPTP_GRE_MASK) != PPTP_GRE_MASK) + (hdr->bits & PPTP_GRE_BITS_MASK) != PPTP_GRE_BITS) goto drop; /* Skip all fields including optional ones. */ if (!skb_pull(skb, GRE_HEADER_SIZE + - (hdr->bits & PPTP_GRE_SEQ_MASK ? 4 : 0) + - (hdr->bits & PPTP_GRE_ACK_MASK ? 4 : 0))) + (hdr->bits & PPTP_GRE_SEQ_BIT ? 4 : 0) + + (hdr->bits & PPTP_GRE_ACK_BIT ? 4 : 0))) goto drop; /* Check the length. */ @@ -130,7 +131,7 @@ static int pppopns_xmit(struct ppp_channel *chan, struct sk_buff *skb) /* Install PPTP GRE header. */ hdr = (struct header *)skb_push(skb, 12); - hdr->bits = PPTP_GRE_MASK | PPTP_GRE_SEQ_MASK; + hdr->bits = PPTP_GRE_BITS | PPTP_GRE_SEQ_BIT; hdr->type = PPTP_GRE_TYPE; hdr->length = htons(length); hdr->call = opt->remote; |