Commit 6f229d76 authored by Al Viro's avatar Al Viro Committed by David S. Miller

[SYNCPPP]: Endianness and 64bit fixes.

	* trivial annotations
	* long != 32bit, use __be32
	* wrong endianness in sending CISCO_ADDR_REPLY
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98eb5683
...@@ -107,24 +107,24 @@ ...@@ -107,24 +107,24 @@
struct ppp_header { struct ppp_header {
u8 address; u8 address;
u8 control; u8 control;
u16 protocol; __be16 protocol;
}; };
#define PPP_HEADER_LEN sizeof (struct ppp_header) #define PPP_HEADER_LEN sizeof (struct ppp_header)
struct lcp_header { struct lcp_header {
u8 type; u8 type;
u8 ident; u8 ident;
u16 len; __be16 len;
}; };
#define LCP_HEADER_LEN sizeof (struct lcp_header) #define LCP_HEADER_LEN sizeof (struct lcp_header)
struct cisco_packet { struct cisco_packet {
u32 type; __be32 type;
u32 par1; __be32 par1;
u32 par2; __be32 par2;
u16 rel; __be16 rel;
u16 time0; __be16 time0;
u16 time1; __be16 time1;
}; };
#define CISCO_PACKET_LEN 18 #define CISCO_PACKET_LEN 18
#define CISCO_BIG_PACKET_LEN 20 #define CISCO_BIG_PACKET_LEN 20
...@@ -139,7 +139,7 @@ static struct sk_buff_head tx_queue; ...@@ -139,7 +139,7 @@ static struct sk_buff_head tx_queue;
static void sppp_keepalive (unsigned long dummy); static void sppp_keepalive (unsigned long dummy);
static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type, static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type,
u8 ident, u16 len, void *data); u8 ident, u16 len, void *data);
static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2); static void sppp_cisco_send (struct sppp *sp, int type, u32 par1, u32 par2);
static void sppp_lcp_input (struct sppp *sp, struct sk_buff *m); static void sppp_lcp_input (struct sppp *sp, struct sk_buff *m);
static void sppp_cisco_input (struct sppp *sp, struct sk_buff *m); static void sppp_cisco_input (struct sppp *sp, struct sk_buff *m);
static void sppp_ipcp_input (struct sppp *sp, struct sk_buff *m); static void sppp_ipcp_input (struct sppp *sp, struct sk_buff *m);
...@@ -447,7 +447,7 @@ static void sppp_keepalive (unsigned long dummy) ...@@ -447,7 +447,7 @@ static void sppp_keepalive (unsigned long dummy)
sppp_cisco_send (sp, CISCO_KEEPALIVE_REQ, ++sp->pp_seq, sppp_cisco_send (sp, CISCO_KEEPALIVE_REQ, ++sp->pp_seq,
sp->pp_rseq); sp->pp_rseq);
else if (sp->lcp.state == LCP_STATE_OPENED) { else if (sp->lcp.state == LCP_STATE_OPENED) {
long nmagic = htonl (sp->lcp.magic); __be32 nmagic = htonl (sp->lcp.magic);
sp->lcp.echoid = ++sp->pp_seq; sp->lcp.echoid = ++sp->pp_seq;
sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REQ, sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REQ,
sp->lcp.echoid, 4, &nmagic); sp->lcp.echoid, 4, &nmagic);
...@@ -667,7 +667,7 @@ badreq: ...@@ -667,7 +667,7 @@ badreq:
dev->name, len); dev->name, len);
break; break;
} }
if (ntohl (*(long*)(h+1)) == sp->lcp.magic) { if (ntohl (*(__be32*)(h+1)) == sp->lcp.magic) {
/* Line loopback mode detected. */ /* Line loopback mode detected. */
printk (KERN_WARNING "%s: loopback\n", dev->name); printk (KERN_WARNING "%s: loopback\n", dev->name);
if_down (dev); if_down (dev);
...@@ -680,7 +680,7 @@ badreq: ...@@ -680,7 +680,7 @@ badreq:
sppp_lcp_open (sp); sppp_lcp_open (sp);
break; break;
} }
*(long*)(h+1) = htonl (sp->lcp.magic); *(__be32 *)(h+1) = htonl (sp->lcp.magic);
sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REPLY, h->ident, len-4, h+1); sppp_cp_send (sp, PPP_LCP, LCP_ECHO_REPLY, h->ident, len-4, h+1);
break; break;
case LCP_ECHO_REPLY: case LCP_ECHO_REPLY:
...@@ -692,7 +692,7 @@ badreq: ...@@ -692,7 +692,7 @@ badreq:
dev->name, len); dev->name, len);
break; break;
} }
if (ntohl (*(long*)(h+1)) != sp->lcp.magic) if (ntohl(*(__be32 *)(h+1)) != sp->lcp.magic)
sp->pp_alivecnt = 0; sp->pp_alivecnt = 0;
break; break;
} }
...@@ -765,7 +765,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) ...@@ -765,7 +765,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
{ {
struct in_device *in_dev; struct in_device *in_dev;
struct in_ifaddr *ifa; struct in_ifaddr *ifa;
__be32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */ __be32 addr = 0, mask = htonl(~0U); /* FIXME: is the mask correct? */
#ifdef CONFIG_INET #ifdef CONFIG_INET
rcu_read_lock(); rcu_read_lock();
if ((in_dev = __in_dev_get_rcu(dev)) != NULL) if ((in_dev = __in_dev_get_rcu(dev)) != NULL)
...@@ -782,8 +782,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) ...@@ -782,8 +782,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
} }
rcu_read_unlock(); rcu_read_unlock();
#endif #endif
/* I hope both addr and mask are in the net order */ sppp_cisco_send (sp, CISCO_ADDR_REPLY, ntohl(addr), ntohl(mask));
sppp_cisco_send (sp, CISCO_ADDR_REPLY, addr, mask);
break; break;
} }
} }
...@@ -844,7 +843,7 @@ static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type, ...@@ -844,7 +843,7 @@ static void sppp_cp_send (struct sppp *sp, u16 proto, u8 type,
* Send Cisco keepalive packet. * Send Cisco keepalive packet.
*/ */
static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2) static void sppp_cisco_send (struct sppp *sp, int type, u32 par1, u32 par2)
{ {
struct ppp_header *h; struct ppp_header *h;
struct cisco_packet *ch; struct cisco_packet *ch;
...@@ -868,7 +867,7 @@ static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2) ...@@ -868,7 +867,7 @@ static void sppp_cisco_send (struct sppp *sp, int type, long par1, long par2)
ch->type = htonl (type); ch->type = htonl (type);
ch->par1 = htonl (par1); ch->par1 = htonl (par1);
ch->par2 = htonl (par2); ch->par2 = htonl (par2);
ch->rel = -1; ch->rel = htons(0xffff);
ch->time0 = htons ((u16) (t >> 16)); ch->time0 = htons ((u16) (t >> 16));
ch->time1 = htons ((u16) t); ch->time1 = htons ((u16) t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment