Commit c4ea94ab authored by Steven Whitehouse's avatar Steven Whitehouse Committed by David S. Miller

[DECnet]: Endian annotation and fixes for DECnet.

The typedef for dn_address has been removed in favour of using __le16
or __u16 directly as appropriate. All the DECnet header files are
updated accordingly.

The byte ordering of dn_eth2dn() and dn_dn2eth() are both changed
since just about all their callers wanted network order rather than
host order, so the conversion is now done in the functions themselves.

Several missed endianess conversions have been picked up during the
conversion process. The nh_gw field in struct dn_fib_info has been
changed from a 32 bit field to 16 bits as it ought to be.

One or two cases of using htons rather than dn_htons in the routing
code have been found and fixed.

There are still a few warnings to fix, but this patch deals with the
important cases.
Signed-off-by: default avatarSteven Whitehouse <steve@chygwyn.com>
Signed-off-by: default avatarPatrick Caulfield <patrick@tykepenguin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2c7946a7
...@@ -71,17 +71,17 @@ ...@@ -71,17 +71,17 @@
struct dn_naddr struct dn_naddr
{ {
unsigned short a_len; __le16 a_len;
unsigned char a_addr[DN_MAXADDL]; __u8 a_addr[DN_MAXADDL]; /* Two bytes little endian */
}; };
struct sockaddr_dn struct sockaddr_dn
{ {
unsigned short sdn_family; __u16 sdn_family;
unsigned char sdn_flags; __u8 sdn_flags;
unsigned char sdn_objnum; __u8 sdn_objnum;
unsigned short sdn_objnamel; __le16 sdn_objnamel;
unsigned char sdn_objname[DN_MAXOBJL]; __u8 sdn_objname[DN_MAXOBJL];
struct dn_naddr sdn_add; struct dn_naddr sdn_add;
}; };
#define sdn_nodeaddrl sdn_add.a_len /* Node address length */ #define sdn_nodeaddrl sdn_add.a_len /* Node address length */
...@@ -93,38 +93,38 @@ struct sockaddr_dn ...@@ -93,38 +93,38 @@ struct sockaddr_dn
* DECnet set/get DSO_CONDATA, DSO_DISDATA (optional data) structure * DECnet set/get DSO_CONDATA, DSO_DISDATA (optional data) structure
*/ */
struct optdata_dn { struct optdata_dn {
unsigned short opt_status; /* Extended status return */ __le16 opt_status; /* Extended status return */
#define opt_sts opt_status #define opt_sts opt_status
unsigned short opt_optl; /* Length of user data */ __le16 opt_optl; /* Length of user data */
unsigned char opt_data[16]; /* User data */ __u8 opt_data[16]; /* User data */
}; };
struct accessdata_dn struct accessdata_dn
{ {
unsigned char acc_accl; __u8 acc_accl;
unsigned char acc_acc[DN_MAXACCL]; __u8 acc_acc[DN_MAXACCL];
unsigned char acc_passl; __u8 acc_passl;
unsigned char acc_pass[DN_MAXACCL]; __u8 acc_pass[DN_MAXACCL];
unsigned char acc_userl; __u8 acc_userl;
unsigned char acc_user[DN_MAXACCL]; __u8 acc_user[DN_MAXACCL];
}; };
/* /*
* DECnet logical link information structure * DECnet logical link information structure
*/ */
struct linkinfo_dn { struct linkinfo_dn {
unsigned short idn_segsize; /* Segment size for link */ __le16 idn_segsize; /* Segment size for link */
unsigned char idn_linkstate; /* Logical link state */ __u8 idn_linkstate; /* Logical link state */
}; };
/* /*
* Ethernet address format (for DECnet) * Ethernet address format (for DECnet)
*/ */
union etheraddress { union etheraddress {
unsigned char dne_addr[6]; /* Full ethernet address */ __u8 dne_addr[6]; /* Full ethernet address */
struct { struct {
unsigned char dne_hiord[4]; /* DECnet HIORD prefix */ __u8 dne_hiord[4]; /* DECnet HIORD prefix */
unsigned char dne_nodeaddr[2]; /* DECnet node address */ __u8 dne_nodeaddr[2]; /* DECnet node address */
} dne_remote; } dne_remote;
}; };
...@@ -133,7 +133,7 @@ union etheraddress { ...@@ -133,7 +133,7 @@ union etheraddress {
* DECnet physical socket address format * DECnet physical socket address format
*/ */
struct dn_addr { struct dn_addr {
unsigned short dna_family; /* AF_DECnet */ __le16 dna_family; /* AF_DECnet */
union etheraddress dna_netaddr; /* DECnet ethernet address */ union etheraddress dna_netaddr; /* DECnet ethernet address */
}; };
......
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
#include <net/tcp.h> #include <net/tcp.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
typedef unsigned short dn_address; #define dn_ntohs(x) le16_to_cpu(x)
#define dn_htons(x) cpu_to_le16(x)
#define dn_ntohs(x) le16_to_cpu((unsigned short)(x))
#define dn_htons(x) cpu_to_le16((unsigned short)(x))
struct dn_scp /* Session Control Port */ struct dn_scp /* Session Control Port */
{ {
...@@ -31,36 +29,36 @@ struct dn_scp /* Session Control Port */ ...@@ -31,36 +29,36 @@ struct dn_scp /* Session Control Port */
#define DN_CL 15 /* Closed */ #define DN_CL 15 /* Closed */
#define DN_CN 16 /* Closed Notification */ #define DN_CN 16 /* Closed Notification */
unsigned short addrloc; __le16 addrloc;
unsigned short addrrem; __le16 addrrem;
unsigned short numdat; __u16 numdat;
unsigned short numoth; __u16 numoth;
unsigned short numoth_rcv; __u16 numoth_rcv;
unsigned short numdat_rcv; __u16 numdat_rcv;
unsigned short ackxmt_dat; __u16 ackxmt_dat;
unsigned short ackxmt_oth; __u16 ackxmt_oth;
unsigned short ackrcv_dat; __u16 ackrcv_dat;
unsigned short ackrcv_oth; __u16 ackrcv_oth;
unsigned char flowrem_sw; __u8 flowrem_sw;
unsigned char flowloc_sw; __u8 flowloc_sw;
#define DN_SEND 2 #define DN_SEND 2
#define DN_DONTSEND 1 #define DN_DONTSEND 1
#define DN_NOCHANGE 0 #define DN_NOCHANGE 0
unsigned short flowrem_dat; __u16 flowrem_dat;
unsigned short flowrem_oth; __u16 flowrem_oth;
unsigned short flowloc_dat; __u16 flowloc_dat;
unsigned short flowloc_oth; __u16 flowloc_oth;
unsigned char services_rem; __u8 services_rem;
unsigned char services_loc; __u8 services_loc;
unsigned char info_rem; __u8 info_rem;
unsigned char info_loc; __u8 info_loc;
unsigned short segsize_rem; __u16 segsize_rem;
unsigned short segsize_loc; __u16 segsize_loc;
unsigned char nonagle; __u8 nonagle;
unsigned char multi_ireq; __u8 multi_ireq;
unsigned char accept_mode; __u8 accept_mode;
unsigned long seg_total; /* Running total of current segment */ unsigned long seg_total; /* Running total of current segment */
struct optdata_dn conndata_in; struct optdata_dn conndata_in;
...@@ -160,40 +158,41 @@ static inline struct dn_scp *DN_SK(struct sock *sk) ...@@ -160,40 +158,41 @@ static inline struct dn_scp *DN_SK(struct sock *sk)
*/ */
#define DN_SKB_CB(skb) ((struct dn_skb_cb *)(skb)->cb) #define DN_SKB_CB(skb) ((struct dn_skb_cb *)(skb)->cb)
struct dn_skb_cb { struct dn_skb_cb {
unsigned short dst; __le16 dst;
unsigned short src; __le16 src;
unsigned short hops; __u16 hops;
unsigned short dst_port; __le16 dst_port;
unsigned short src_port; __le16 src_port;
unsigned char services; __u8 services;
unsigned char info; __u8 info;
unsigned char rt_flags; __u8 rt_flags;
unsigned char nsp_flags; __u8 nsp_flags;
unsigned short segsize; __u16 segsize;
unsigned short segnum; __u16 segnum;
unsigned short xmit_count; __u16 xmit_count;
unsigned long stamp; unsigned long stamp;
int iif; int iif;
}; };
static inline dn_address dn_eth2dn(unsigned char *ethaddr) static inline __le16 dn_eth2dn(unsigned char *ethaddr)
{ {
return ethaddr[4] | (ethaddr[5] << 8); return dn_htons(ethaddr[4] | (ethaddr[5] << 8));
} }
static inline dn_address dn_saddr2dn(struct sockaddr_dn *saddr) static inline __le16 dn_saddr2dn(struct sockaddr_dn *saddr)
{ {
return *(dn_address *)saddr->sdn_nodeaddr; return *(__le16 *)saddr->sdn_nodeaddr;
} }
static inline void dn_dn2eth(unsigned char *ethaddr, dn_address addr) static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
{ {
__u16 a = dn_ntohs(addr);
ethaddr[0] = 0xAA; ethaddr[0] = 0xAA;
ethaddr[1] = 0x00; ethaddr[1] = 0x00;
ethaddr[2] = 0x04; ethaddr[2] = 0x04;
ethaddr[3] = 0x00; ethaddr[3] = 0x00;
ethaddr[4] = (unsigned char)(addr & 0xff); ethaddr[4] = (__u8)(a & 0xff);
ethaddr[5] = (unsigned char)(addr >> 8); ethaddr[5] = (__u8)(a >> 8);
} }
static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp)
...@@ -202,7 +201,7 @@ static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) ...@@ -202,7 +201,7 @@ static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp)
fl->uli_u.dnports.dport = scp->addrrem; fl->uli_u.dnports.dport = scp->addrrem;
fl->uli_u.dnports.objnum = scp->addr.sdn_objnum; fl->uli_u.dnports.objnum = scp->addr.sdn_objnum;
if (fl->uli_u.dnports.objnum == 0) { if (fl->uli_u.dnports.objnum == 0) {
fl->uli_u.dnports.objnamel = scp->addr.sdn_objnamel; fl->uli_u.dnports.objnamel = (__u8)dn_ntohs(scp->addr.sdn_objnamel);
memcpy(fl->uli_u.dnports.objname, scp->addr.sdn_objname, 16); memcpy(fl->uli_u.dnports.objname, scp->addr.sdn_objname, 16);
} }
} }
...@@ -217,7 +216,7 @@ extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); ...@@ -217,7 +216,7 @@ extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
extern struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr); extern struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr);
extern struct sock *dn_find_by_skb(struct sk_buff *skb); extern struct sock *dn_find_by_skb(struct sk_buff *skb);
#define DN_ASCBUF_LEN 9 #define DN_ASCBUF_LEN 9
extern char *dn_addr2asc(dn_address, char *); extern char *dn_addr2asc(__u16, char *);
extern int dn_destroy_timer(struct sock *sk); extern int dn_destroy_timer(struct sock *sk);
extern int dn_sockaddr2username(struct sockaddr_dn *addr, unsigned char *buf, unsigned char type); extern int dn_sockaddr2username(struct sockaddr_dn *addr, unsigned char *buf, unsigned char type);
...@@ -226,7 +225,7 @@ extern int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn ...@@ -226,7 +225,7 @@ extern int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn
extern void dn_start_slow_timer(struct sock *sk); extern void dn_start_slow_timer(struct sock *sk);
extern void dn_stop_slow_timer(struct sock *sk); extern void dn_stop_slow_timer(struct sock *sk);
extern dn_address decnet_address; extern __le16 decnet_address;
extern int decnet_debug_level; extern int decnet_debug_level;
extern int decnet_time_wait; extern int decnet_time_wait;
extern int decnet_dn_count; extern int decnet_dn_count;
......
...@@ -7,11 +7,11 @@ struct dn_dev; ...@@ -7,11 +7,11 @@ struct dn_dev;
struct dn_ifaddr { struct dn_ifaddr {
struct dn_ifaddr *ifa_next; struct dn_ifaddr *ifa_next;
struct dn_dev *ifa_dev; struct dn_dev *ifa_dev;
dn_address ifa_local; __le16 ifa_local;
dn_address ifa_address; __le16 ifa_address;
unsigned char ifa_flags; __u8 ifa_flags;
unsigned char ifa_scope; __u8 ifa_scope;
char ifa_label[IFNAMSIZ]; char ifa_label[IFNAMSIZ];
}; };
#define DN_DEV_S_RU 0 /* Run - working normally */ #define DN_DEV_S_RU 0 /* Run - working normally */
...@@ -91,7 +91,7 @@ struct dn_dev { ...@@ -91,7 +91,7 @@ struct dn_dev {
struct timer_list timer; struct timer_list timer;
unsigned long t3; unsigned long t3;
struct neigh_parms *neigh_parms; struct neigh_parms *neigh_parms;
unsigned char addr[ETH_ALEN]; __u8 addr[ETH_ALEN];
struct neighbour *router; /* Default router on circuit */ struct neighbour *router; /* Default router on circuit */
struct neighbour *peer; /* Peer on pointopoint links */ struct neighbour *peer; /* Peer on pointopoint links */
unsigned long uptime; /* Time device went up in jiffies */ unsigned long uptime; /* Time device went up in jiffies */
...@@ -99,56 +99,56 @@ struct dn_dev { ...@@ -99,56 +99,56 @@ struct dn_dev {
struct dn_short_packet struct dn_short_packet
{ {
unsigned char msgflg; __u8 msgflg;
unsigned short dstnode; __le16 dstnode;
unsigned short srcnode; __le16 srcnode;
unsigned char forward; __u8 forward;
} __attribute__((packed)); } __attribute__((packed));
struct dn_long_packet struct dn_long_packet
{ {
unsigned char msgflg; __u8 msgflg;
unsigned char d_area; __u8 d_area;
unsigned char d_subarea; __u8 d_subarea;
unsigned char d_id[6]; __u8 d_id[6];
unsigned char s_area; __u8 s_area;
unsigned char s_subarea; __u8 s_subarea;
unsigned char s_id[6]; __u8 s_id[6];
unsigned char nl2; __u8 nl2;
unsigned char visit_ct; __u8 visit_ct;
unsigned char s_class; __u8 s_class;
unsigned char pt; __u8 pt;
} __attribute__((packed)); } __attribute__((packed));
/*------------------------- DRP - Routing messages ---------------------*/ /*------------------------- DRP - Routing messages ---------------------*/
struct endnode_hello_message struct endnode_hello_message
{ {
unsigned char msgflg; __u8 msgflg;
unsigned char tiver[3]; __u8 tiver[3];
unsigned char id[6]; __u8 id[6];
unsigned char iinfo; __u8 iinfo;
unsigned short blksize; __le16 blksize;
unsigned char area; __u8 area;
unsigned char seed[8]; __u8 seed[8];
unsigned char neighbor[6]; __u8 neighbor[6];
unsigned short timer; __le16 timer;
unsigned char mpd; __u8 mpd;
unsigned char datalen; __u8 datalen;
unsigned char data[2]; __u8 data[2];
} __attribute__((packed)); } __attribute__((packed));
struct rtnode_hello_message struct rtnode_hello_message
{ {
unsigned char msgflg; __u8 msgflg;
unsigned char tiver[3]; __u8 tiver[3];
unsigned char id[6]; __u8 id[6];
unsigned char iinfo; __u8 iinfo;
unsigned short blksize; __le16 blksize;
unsigned char priority; __u8 priority;
unsigned char area; __u8 area;
unsigned short timer; __le16 timer;
unsigned char mpd; __u8 mpd;
} __attribute__((packed)); } __attribute__((packed));
...@@ -169,12 +169,12 @@ extern void dn_dev_down(struct net_device *); ...@@ -169,12 +169,12 @@ extern void dn_dev_down(struct net_device *);
extern int dn_dev_set_default(struct net_device *dev, int force); extern int dn_dev_set_default(struct net_device *dev, int force);
extern struct net_device *dn_dev_get_default(void); extern struct net_device *dn_dev_get_default(void);
extern int dn_dev_bind_default(dn_address *addr); extern int dn_dev_bind_default(__le16 *addr);
extern int register_dnaddr_notifier(struct notifier_block *nb); extern int register_dnaddr_notifier(struct notifier_block *nb);
extern int unregister_dnaddr_notifier(struct notifier_block *nb); extern int unregister_dnaddr_notifier(struct notifier_block *nb);
static inline int dn_dev_islocal(struct net_device *dev, dn_address addr) static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
{ {
struct dn_dev *dn_db = dev->dn_ptr; struct dn_dev *dn_db = dev->dn_ptr;
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
......
...@@ -37,7 +37,7 @@ struct dn_fib_nh { ...@@ -37,7 +37,7 @@ struct dn_fib_nh {
int nh_weight; int nh_weight;
int nh_power; int nh_power;
int nh_oif; int nh_oif;
u32 nh_gw; __le16 nh_gw;
}; };
struct dn_fib_info { struct dn_fib_info {
...@@ -48,7 +48,7 @@ struct dn_fib_info { ...@@ -48,7 +48,7 @@ struct dn_fib_info {
int fib_dead; int fib_dead;
unsigned fib_flags; unsigned fib_flags;
int fib_protocol; int fib_protocol;
dn_address fib_prefsrc; __le16 fib_prefsrc;
__u32 fib_priority; __u32 fib_priority;
__u32 fib_metrics[RTAX_MAX]; __u32 fib_metrics[RTAX_MAX];
#define dn_fib_mtu fib_metrics[RTAX_MTU-1] #define dn_fib_mtu fib_metrics[RTAX_MTU-1]
...@@ -71,15 +71,15 @@ struct dn_fib_info { ...@@ -71,15 +71,15 @@ struct dn_fib_info {
#define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif) #define DN_FIB_RES_OIF(res) (DN_FIB_RES_NH(res).nh_oif)
typedef struct { typedef struct {
u16 datum; __le16 datum;
} dn_fib_key_t; } dn_fib_key_t;
typedef struct { typedef struct {
u16 datum; __le16 datum;
} dn_fib_hash_t; } dn_fib_hash_t;
typedef struct { typedef struct {
u16 datum; __u16 datum;
} dn_fib_idx_t; } dn_fib_idx_t;
struct dn_fib_node { struct dn_fib_node {
...@@ -126,11 +126,11 @@ extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, ...@@ -126,11 +126,11 @@ extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
const struct flowi *fl, const struct flowi *fl,
struct dn_fib_res *res); struct dn_fib_res *res);
extern void dn_fib_release_info(struct dn_fib_info *fi); extern void dn_fib_release_info(struct dn_fib_info *fi);
extern u16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type);
extern void dn_fib_flush(void); extern void dn_fib_flush(void);
extern void dn_fib_select_multipath(const struct flowi *fl, extern void dn_fib_select_multipath(const struct flowi *fl,
struct dn_fib_res *res); struct dn_fib_res *res);
extern int dn_fib_sync_down(dn_address local, struct net_device *dev, extern int dn_fib_sync_down(__le16 local, struct net_device *dev,
int force); int force);
extern int dn_fib_sync_up(struct net_device *dev); extern int dn_fib_sync_up(struct net_device *dev);
...@@ -148,8 +148,8 @@ extern void dn_fib_table_cleanup(void); ...@@ -148,8 +148,8 @@ extern void dn_fib_table_cleanup(void);
extern void dn_fib_rules_init(void); extern void dn_fib_rules_init(void);
extern void dn_fib_rules_cleanup(void); extern void dn_fib_rules_cleanup(void);
extern void dn_fib_rule_put(struct dn_fib_rule *); extern void dn_fib_rule_put(struct dn_fib_rule *);
extern __u16 dn_fib_rules_policy(__u16 saddr, struct dn_fib_res *res, unsigned *flags); extern __le16 dn_fib_rules_policy(__le16 saddr, struct dn_fib_res *res, unsigned *flags);
extern unsigned dnet_addr_type(__u16 addr); extern unsigned dnet_addr_type(__le16 addr);
extern int dn_fib_lookup(const struct flowi *fl, struct dn_fib_res *res); extern int dn_fib_lookup(const struct flowi *fl, struct dn_fib_res *res);
/* /*
...@@ -194,10 +194,10 @@ extern struct dn_fib_table *dn_fib_tables[]; ...@@ -194,10 +194,10 @@ extern struct dn_fib_table *dn_fib_tables[];
#endif /* CONFIG_DECNET_ROUTER */ #endif /* CONFIG_DECNET_ROUTER */
static inline u16 dnet_make_mask(int n) static inline __le16 dnet_make_mask(int n)
{ {
if (n) if (n)
return htons(~((1<<(16-n))-1)); return dn_htons(~((1<<(16-n))-1));
return 0; return 0;
} }
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
*/ */
struct dn_neigh { struct dn_neigh {
struct neighbour n; struct neighbour n;
dn_address addr; __le16 addr;
unsigned long flags; unsigned long flags;
#define DN_NDFLAG_R1 0x0001 /* Router L1 */ #define DN_NDFLAG_R1 0x0001 /* Router L1 */
#define DN_NDFLAG_R2 0x0002 /* Router L2 */ #define DN_NDFLAG_R2 0x0002 /* Router L2 */
#define DN_NDFLAG_P3 0x0004 /* Phase III Node */ #define DN_NDFLAG_P3 0x0004 /* Phase III Node */
unsigned long blksize; unsigned long blksize;
unsigned char priority; __u8 priority;
}; };
extern void dn_neigh_init(void); extern void dn_neigh_init(void);
......
...@@ -72,77 +72,77 @@ extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int nobl ...@@ -72,77 +72,77 @@ extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int nobl
struct nsp_data_seg_msg struct nsp_data_seg_msg
{ {
unsigned char msgflg; __u8 msgflg;
unsigned short dstaddr; __le16 dstaddr;
unsigned short srcaddr; __le16 srcaddr;
} __attribute__((packed)); } __attribute__((packed));
struct nsp_data_opt_msg struct nsp_data_opt_msg
{ {
unsigned short acknum; __le16 acknum;
unsigned short segnum; __le16 segnum;
unsigned short lsflgs; __le16 lsflgs;
} __attribute__((packed)); } __attribute__((packed));
struct nsp_data_opt_msg1 struct nsp_data_opt_msg1
{ {
unsigned short acknum; __le16 acknum;
unsigned short segnum; __le16 segnum;
} __attribute__((packed)); } __attribute__((packed));
/* Acknowledgment Message (data/other data) */ /* Acknowledgment Message (data/other data) */
struct nsp_data_ack_msg struct nsp_data_ack_msg
{ {
unsigned char msgflg; __u8 msgflg;
unsigned short dstaddr; __le16 dstaddr;
unsigned short srcaddr; __le16 srcaddr;
unsigned short acknum; __le16 acknum;
} __attribute__((packed)); } __attribute__((packed));
/* Connect Acknowledgment Message */ /* Connect Acknowledgment Message */
struct nsp_conn_ack_msg struct nsp_conn_ack_msg
{ {
unsigned char msgflg; __u8 msgflg;
unsigned short dstaddr; __le16 dstaddr;
} __attribute__((packed)); } __attribute__((packed));
/* Connect Initiate/Retransmit Initiate/Connect Confirm */ /* Connect Initiate/Retransmit Initiate/Connect Confirm */
struct nsp_conn_init_msg struct nsp_conn_init_msg
{ {
unsigned char msgflg; __u8 msgflg;
#define NSP_CI 0x18 /* Connect Initiate */ #define NSP_CI 0x18 /* Connect Initiate */
#define NSP_RCI 0x68 /* Retrans. Conn Init */ #define NSP_RCI 0x68 /* Retrans. Conn Init */
unsigned short dstaddr; __le16 dstaddr;
unsigned short srcaddr; __le16 srcaddr;
unsigned char services; __u8 services;
#define NSP_FC_NONE 0x00 /* Flow Control None */ #define NSP_FC_NONE 0x00 /* Flow Control None */
#define NSP_FC_SRC 0x04 /* Seg Req. Count */ #define NSP_FC_SRC 0x04 /* Seg Req. Count */
#define NSP_FC_SCMC 0x08 /* Sess. Control Mess */ #define NSP_FC_SCMC 0x08 /* Sess. Control Mess */
#define NSP_FC_MASK 0x0c /* FC type mask */ #define NSP_FC_MASK 0x0c /* FC type mask */
unsigned char info; __u8 info;
unsigned short segsize; __le16 segsize;
} __attribute__((packed)); } __attribute__((packed));
/* Disconnect Initiate/Disconnect Confirm */ /* Disconnect Initiate/Disconnect Confirm */
struct nsp_disconn_init_msg struct nsp_disconn_init_msg
{ {
unsigned char msgflg; __u8 msgflg;
unsigned short dstaddr; __le16 dstaddr;
unsigned short srcaddr; __le16 srcaddr;
unsigned short reason; __le16 reason;
} __attribute__((packed)); } __attribute__((packed));
struct srcobj_fmt struct srcobj_fmt
{ {
char format; __u8 format;
unsigned char task; __u8 task;
unsigned short grpcode; __le16 grpcode;
unsigned short usrcode; __le16 usrcode;
char dlen; __u8 dlen;
} __attribute__((packed)); } __attribute__((packed));
/* /*
...@@ -150,7 +150,7 @@ struct srcobj_fmt ...@@ -150,7 +150,7 @@ struct srcobj_fmt
* numbers used in NSP. Similar in operation to the functions * numbers used in NSP. Similar in operation to the functions
* of the same name in TCP. * of the same name in TCP.
*/ */
static __inline__ int dn_before(unsigned short seq1, unsigned short seq2) static __inline__ int dn_before(__u16 seq1, __u16 seq2)
{ {
seq1 &= 0x0fff; seq1 &= 0x0fff;
seq2 &= 0x0fff; seq2 &= 0x0fff;
...@@ -159,7 +159,7 @@ static __inline__ int dn_before(unsigned short seq1, unsigned short seq2) ...@@ -159,7 +159,7 @@ static __inline__ int dn_before(unsigned short seq1, unsigned short seq2)
} }
static __inline__ int dn_after(unsigned short seq1, unsigned short seq2) static __inline__ int dn_after(__u16 seq1, __u16 seq2)
{ {
seq1 &= 0x0fff; seq1 &= 0x0fff;
seq2 &= 0x0fff; seq2 &= 0x0fff;
...@@ -167,23 +167,23 @@ static __inline__ int dn_after(unsigned short seq1, unsigned short seq2) ...@@ -167,23 +167,23 @@ static __inline__ int dn_after(unsigned short seq1, unsigned short seq2)
return (int)((seq2 - seq1) & 0x0fff) > 2048; return (int)((seq2 - seq1) & 0x0fff) > 2048;
} }
static __inline__ int dn_equal(unsigned short seq1, unsigned short seq2) static __inline__ int dn_equal(__u16 seq1, __u16 seq2)
{ {
return ((seq1 ^ seq2) & 0x0fff) == 0; return ((seq1 ^ seq2) & 0x0fff) == 0;
} }
static __inline__ int dn_before_or_equal(unsigned short seq1, unsigned short seq2) static __inline__ int dn_before_or_equal(__u16 seq1, __u16 seq2)
{ {
return (dn_before(seq1, seq2) || dn_equal(seq1, seq2)); return (dn_before(seq1, seq2) || dn_equal(seq1, seq2));
} }
static __inline__ void seq_add(unsigned short *seq, unsigned short off) static __inline__ void seq_add(__u16 *seq, __u16 off)
{ {
(*seq) += off; (*seq) += off;
(*seq) &= 0x0fff; (*seq) &= 0x0fff;
} }
static __inline__ int seq_next(unsigned short seq1, unsigned short seq2) static __inline__ int seq_next(__u16 seq1, __u16 seq2)
{ {
return dn_equal(seq1 + 1, seq2); return dn_equal(seq1 + 1, seq2);
} }
...@@ -191,7 +191,7 @@ static __inline__ int seq_next(unsigned short seq1, unsigned short seq2) ...@@ -191,7 +191,7 @@ static __inline__ int seq_next(unsigned short seq1, unsigned short seq2)
/* /*
* Can we delay the ack ? * Can we delay the ack ?
*/ */
static __inline__ int sendack(unsigned short seq) static __inline__ int sendack(__u16 seq)
{ {
return (int)((seq & 0x1000) ? 0 : 1); return (int)((seq & 0x1000) ? 0 : 1);
} }
......
...@@ -71,12 +71,12 @@ struct dn_route { ...@@ -71,12 +71,12 @@ struct dn_route {
struct dn_route *rt_next; struct dn_route *rt_next;
} u; } u;
__u16 rt_saddr; __le16 rt_saddr;
__u16 rt_daddr; __le16 rt_daddr;
__u16 rt_gateway; __le16 rt_gateway;
__u16 rt_local_src; /* Source used for forwarding packets */ __le16 rt_local_src; /* Source used for forwarding packets */
__u16 rt_src_map; __le16 rt_src_map;
__u16 rt_dst_map; __le16 rt_dst_map;
unsigned rt_flags; unsigned rt_flags;
unsigned rt_type; unsigned rt_type;
......
...@@ -30,8 +30,8 @@ struct flowi { ...@@ -30,8 +30,8 @@ struct flowi {
} ip6_u; } ip6_u;
struct { struct {
__u16 daddr; __le16 daddr;
__u16 saddr; __le16 saddr;
__u32 fwmark; __u32 fwmark;
__u8 scope; __u8 scope;
} dn_u; } dn_u;
...@@ -64,8 +64,8 @@ struct flowi { ...@@ -64,8 +64,8 @@ struct flowi {
} icmpt; } icmpt;
struct { struct {
__u16 sport; __le16 sport;
__u16 dport; __le16 dport;
__u8 objnum; __u8 objnum;
__u8 objnamel; /* Not 16 bits since max val is 16 */ __u8 objnamel; /* Not 16 bits since max val is 16 */
__u8 objname[16]; /* Not zero terminated */ __u8 objname[16]; /* Not zero terminated */
......
...@@ -172,7 +172,7 @@ static struct hlist_head *dn_find_list(struct sock *sk) ...@@ -172,7 +172,7 @@ static struct hlist_head *dn_find_list(struct sock *sk)
/* /*
* Valid ports are those greater than zero and not already in use. * Valid ports are those greater than zero and not already in use.
*/ */
static int check_port(unsigned short port) static int check_port(__le16 port)
{ {
struct sock *sk; struct sock *sk;
struct hlist_node *node; struct hlist_node *node;
...@@ -661,7 +661,7 @@ static void dn_destroy_sock(struct sock *sk) ...@@ -661,7 +661,7 @@ static void dn_destroy_sock(struct sock *sk)
} }
} }
char *dn_addr2asc(dn_address addr, char *buf) char *dn_addr2asc(__u16 addr, char *buf)
{ {
unsigned short node, area; unsigned short node, area;
...@@ -801,7 +801,7 @@ static int dn_auto_bind(struct socket *sock) ...@@ -801,7 +801,7 @@ static int dn_auto_bind(struct socket *sock)
/* End of compatibility stuff */ /* End of compatibility stuff */
scp->addr.sdn_add.a_len = dn_htons(2); scp->addr.sdn_add.a_len = dn_htons(2);
rv = dn_dev_bind_default((dn_address *)scp->addr.sdn_add.a_addr); rv = dn_dev_bind_default((__le16 *)scp->addr.sdn_add.a_addr);
if (rv == 0) { if (rv == 0) {
rv = dn_hash_sock(sk); rv = dn_hash_sock(sk);
if (rv) if (rv)
...@@ -1021,7 +1021,7 @@ static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt) ...@@ -1021,7 +1021,7 @@ static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt)
opt->opt_optl = *ptr++; opt->opt_optl = *ptr++;
opt->opt_status = 0; opt->opt_status = 0;
memcpy(opt->opt_data, ptr, opt->opt_optl); memcpy(opt->opt_data, ptr, opt->opt_optl);
skb_pull(skb, opt->opt_optl + 1); skb_pull(skb, dn_ntohs(opt->opt_optl) + 1);
} }
...@@ -1121,8 +1121,8 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -1121,8 +1121,8 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
skb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->addr), &type)); skb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->addr), &type));
skb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->peer), &type)); skb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->peer), &type));
*(dn_address *)(DN_SK(newsk)->peer.sdn_add.a_addr) = cb->src; *(__le16 *)(DN_SK(newsk)->peer.sdn_add.a_addr) = cb->src;
*(dn_address *)(DN_SK(newsk)->addr.sdn_add.a_addr) = cb->dst; *(__le16 *)(DN_SK(newsk)->addr.sdn_add.a_addr) = cb->dst;
menuver = *skb->data; menuver = *skb->data;
skb_pull(skb, 1); skb_pull(skb, 1);
...@@ -1365,7 +1365,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us ...@@ -1365,7 +1365,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
if (optlen != sizeof(struct optdata_dn)) if (optlen != sizeof(struct optdata_dn))
return -EINVAL; return -EINVAL;
if (u.opt.opt_optl > 16) if (dn_ntohs(u.opt.opt_optl) > 16)
return -EINVAL; return -EINVAL;
memcpy(&scp->conndata_out, &u.opt, optlen); memcpy(&scp->conndata_out, &u.opt, optlen);
...@@ -1378,7 +1378,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us ...@@ -1378,7 +1378,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
if (optlen != sizeof(struct optdata_dn)) if (optlen != sizeof(struct optdata_dn))
return -EINVAL; return -EINVAL;
if (u.opt.opt_optl > 16) if (dn_ntohs(u.opt.opt_optl) > 16)
return -EINVAL; return -EINVAL;
memcpy(&scp->discdata_out, &u.opt, optlen); memcpy(&scp->discdata_out, &u.opt, optlen);
......
...@@ -64,7 +64,7 @@ extern struct neigh_table dn_neigh_table; ...@@ -64,7 +64,7 @@ extern struct neigh_table dn_neigh_table;
/* /*
* decnet_address is kept in network order. * decnet_address is kept in network order.
*/ */
dn_address decnet_address = 0; __le16 decnet_address = 0;
static DEFINE_RWLOCK(dndev_lock); static DEFINE_RWLOCK(dndev_lock);
static struct net_device *decnet_default_device; static struct net_device *decnet_default_device;
...@@ -439,7 +439,7 @@ static void dn_dev_del_ifa(struct dn_dev *dn_db, struct dn_ifaddr **ifap, int de ...@@ -439,7 +439,7 @@ static void dn_dev_del_ifa(struct dn_dev *dn_db, struct dn_ifaddr **ifap, int de
*ifap = ifa1->ifa_next; *ifap = ifa1->ifa_next;
if (dn_db->dev->type == ARPHRD_ETHER) { if (dn_db->dev->type == ARPHRD_ETHER) {
if (ifa1->ifa_local != dn_htons(dn_eth2dn(dev->dev_addr))) { if (ifa1->ifa_local != dn_eth2dn(dev->dev_addr)) {
dn_dn2eth(mac_addr, ifa1->ifa_local); dn_dn2eth(mac_addr, ifa1->ifa_local);
dev_mc_delete(dev, mac_addr, ETH_ALEN, 0); dev_mc_delete(dev, mac_addr, ETH_ALEN, 0);
} }
...@@ -470,7 +470,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa) ...@@ -470,7 +470,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
} }
if (dev->type == ARPHRD_ETHER) { if (dev->type == ARPHRD_ETHER) {
if (ifa->ifa_local != dn_htons(dn_eth2dn(dev->dev_addr))) { if (ifa->ifa_local != dn_eth2dn(dev->dev_addr)) {
dn_dn2eth(mac_addr, ifa->ifa_local); dn_dn2eth(mac_addr, ifa->ifa_local);
dev_mc_add(dev, mac_addr, ETH_ALEN, 0); dev_mc_add(dev, mac_addr, ETH_ALEN, 0);
dev_mc_upload(dev); dev_mc_upload(dev);
...@@ -561,7 +561,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg) ...@@ -561,7 +561,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
switch(cmd) { switch(cmd) {
case SIOCGIFADDR: case SIOCGIFADDR:
*((dn_address *)sdn->sdn_nodeaddr) = ifa->ifa_local; *((__le16 *)sdn->sdn_nodeaddr) = ifa->ifa_local;
goto rarok; goto rarok;
case SIOCSIFADDR: case SIOCSIFADDR:
...@@ -804,7 +804,7 @@ static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -804,7 +804,7 @@ static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
return skb->len; return skb->len;
} }
static int dn_dev_get_first(struct net_device *dev, dn_address *addr) static int dn_dev_get_first(struct net_device *dev, __le16 *addr)
{ {
struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
...@@ -830,7 +830,7 @@ static int dn_dev_get_first(struct net_device *dev, dn_address *addr) ...@@ -830,7 +830,7 @@ static int dn_dev_get_first(struct net_device *dev, dn_address *addr)
* a sensible default. Eventually the routing code will take care of all the * a sensible default. Eventually the routing code will take care of all the
* nasties for us I hope. * nasties for us I hope.
*/ */
int dn_dev_bind_default(dn_address *addr) int dn_dev_bind_default(__le16 *addr)
{ {
struct net_device *dev; struct net_device *dev;
int rv; int rv;
...@@ -853,7 +853,7 @@ static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -853,7 +853,7 @@ static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
{ {
struct endnode_hello_message *msg; struct endnode_hello_message *msg;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
unsigned short int *pktlen; __le16 *pktlen;
struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL) if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
...@@ -882,7 +882,7 @@ static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -882,7 +882,7 @@ static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
msg->datalen = 0x02; msg->datalen = 0x02;
memset(msg->data, 0xAA, 2); memset(msg->data, 0xAA, 2);
pktlen = (unsigned short *)skb_push(skb,2); pktlen = (__le16 *)skb_push(skb,2);
*pktlen = dn_htons(skb->len - 2); *pktlen = dn_htons(skb->len - 2);
skb->nh.raw = skb->data; skb->nh.raw = skb->data;
...@@ -926,7 +926,7 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -926,7 +926,7 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa)
size_t size; size_t size;
unsigned char *ptr; unsigned char *ptr;
unsigned char *i1, *i2; unsigned char *i1, *i2;
unsigned short *pktlen; __le16 *pktlen;
char *src; char *src;
if (mtu2blksize(dev) < (26 + 7)) if (mtu2blksize(dev) < (26 + 7))
...@@ -955,11 +955,11 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -955,11 +955,11 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa)
ptr += ETH_ALEN; ptr += ETH_ALEN;
*ptr++ = dn_db->parms.forwarding == 1 ? *ptr++ = dn_db->parms.forwarding == 1 ?
DN_RT_INFO_L1RT : DN_RT_INFO_L2RT; DN_RT_INFO_L1RT : DN_RT_INFO_L2RT;
*((unsigned short *)ptr) = dn_htons(mtu2blksize(dev)); *((__le16 *)ptr) = dn_htons(mtu2blksize(dev));
ptr += 2; ptr += 2;
*ptr++ = dn_db->parms.priority; /* Priority */ *ptr++ = dn_db->parms.priority; /* Priority */
*ptr++ = 0; /* Area: Reserved */ *ptr++ = 0; /* Area: Reserved */
*((unsigned short *)ptr) = dn_htons((unsigned short)dn_db->parms.t3); *((__le16 *)ptr) = dn_htons((unsigned short)dn_db->parms.t3);
ptr += 2; ptr += 2;
*ptr++ = 0; /* MPD: Reserved */ *ptr++ = 0; /* MPD: Reserved */
i1 = ptr++; i1 = ptr++;
...@@ -974,7 +974,7 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -974,7 +974,7 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa)
skb_trim(skb, (27 + *i2)); skb_trim(skb, (27 + *i2));
pktlen = (unsigned short *)skb_push(skb, 2); pktlen = (__le16 *)skb_push(skb, 2);
*pktlen = dn_htons(skb->len - 2); *pktlen = dn_htons(skb->len - 2);
skb->nh.raw = skb->data; skb->nh.raw = skb->data;
...@@ -1016,7 +1016,7 @@ static void dn_send_ptp_hello(struct net_device *dev, struct dn_ifaddr *ifa) ...@@ -1016,7 +1016,7 @@ static void dn_send_ptp_hello(struct net_device *dev, struct dn_ifaddr *ifa)
ptr = skb_put(skb, 2 + 4 + tdlen); ptr = skb_put(skb, 2 + 4 + tdlen);
*ptr++ = DN_RT_PKT_HELO; *ptr++ = DN_RT_PKT_HELO;
*((dn_address *)ptr) = ifa->ifa_local; *((__le16 *)ptr) = ifa->ifa_local;
ptr += 2; ptr += 2;
*ptr++ = tdlen; *ptr++ = tdlen;
...@@ -1150,7 +1150,7 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err) ...@@ -1150,7 +1150,7 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
void dn_dev_up(struct net_device *dev) void dn_dev_up(struct net_device *dev)
{ {
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
dn_address addr = decnet_address; __le16 addr = decnet_address;
int maybe_default = 0; int maybe_default = 0;
struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
...@@ -1173,7 +1173,7 @@ void dn_dev_up(struct net_device *dev) ...@@ -1173,7 +1173,7 @@ void dn_dev_up(struct net_device *dev)
if (dev->type == ARPHRD_ETHER) { if (dev->type == ARPHRD_ETHER) {
if (memcmp(dev->dev_addr, dn_hiord, 4) != 0) if (memcmp(dev->dev_addr, dn_hiord, 4) != 0)
return; return;
addr = dn_htons(dn_eth2dn(dev->dev_addr)); addr = dn_eth2dn(dev->dev_addr);
maybe_default = 1; maybe_default = 1;
} }
...@@ -1385,8 +1385,8 @@ static int dn_dev_seq_show(struct seq_file *seq, void *v) ...@@ -1385,8 +1385,8 @@ static int dn_dev_seq_show(struct seq_file *seq, void *v)
mtu2blksize(dev), mtu2blksize(dev),
dn_db->parms.priority, dn_db->parms.priority,
dn_db->parms.state, dn_db->parms.name, dn_db->parms.state, dn_db->parms.name,
dn_db->router ? dn_addr2asc(dn_ntohs(*(dn_address *)dn_db->router->primary_key), router_buf) : "", dn_db->router ? dn_addr2asc(dn_ntohs(*(__le16 *)dn_db->router->primary_key), router_buf) : "",
dn_db->peer ? dn_addr2asc(dn_ntohs(*(dn_address *)dn_db->peer->primary_key), peer_buf) : ""); dn_db->peer ? dn_addr2asc(dn_ntohs(*(__le16 *)dn_db->peer->primary_key), peer_buf) : "");
} }
return 0; return 0;
} }
......
...@@ -143,11 +143,11 @@ static inline struct dn_fib_info *dn_fib_find_info(const struct dn_fib_info *nfi ...@@ -143,11 +143,11 @@ static inline struct dn_fib_info *dn_fib_find_info(const struct dn_fib_info *nfi
return NULL; return NULL;
} }
u16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type) __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type)
{ {
while(RTA_OK(attr,attrlen)) { while(RTA_OK(attr,attrlen)) {
if (attr->rta_type == type) if (attr->rta_type == type)
return *(u16*)RTA_DATA(attr); return *(__le16*)RTA_DATA(attr);
attr = RTA_NEXT(attr, attrlen); attr = RTA_NEXT(attr, attrlen);
} }
...@@ -565,7 +565,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -565,7 +565,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
return skb->len; return skb->len;
} }
static void fib_magic(int cmd, int type, __u16 dst, int dst_len, struct dn_ifaddr *ifa) static void fib_magic(int cmd, int type, __le16 dst, int dst_len, struct dn_ifaddr *ifa)
{ {
struct dn_fib_table *tb; struct dn_fib_table *tb;
struct { struct {
...@@ -684,7 +684,7 @@ static int dn_fib_dnaddr_event(struct notifier_block *this, unsigned long event, ...@@ -684,7 +684,7 @@ static int dn_fib_dnaddr_event(struct notifier_block *this, unsigned long event,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
int dn_fib_sync_down(dn_address local, struct net_device *dev, int force) int dn_fib_sync_down(__le16 local, struct net_device *dev, int force)
{ {
int ret = 0; int ret = 0;
int scope = RT_SCOPE_NOWHERE; int scope = RT_SCOPE_NOWHERE;
......
...@@ -95,7 +95,7 @@ static struct neigh_ops dn_phase3_ops = { ...@@ -95,7 +95,7 @@ static struct neigh_ops dn_phase3_ops = {
struct neigh_table dn_neigh_table = { struct neigh_table dn_neigh_table = {
.family = PF_DECnet, .family = PF_DECnet,
.entry_size = sizeof(struct dn_neigh), .entry_size = sizeof(struct dn_neigh),
.key_len = sizeof(dn_address), .key_len = sizeof(__le16),
.hash = dn_neigh_hash, .hash = dn_neigh_hash,
.constructor = dn_neigh_construct, .constructor = dn_neigh_construct,
.id = "dn_neigh_cache", .id = "dn_neigh_cache",
...@@ -123,7 +123,7 @@ struct neigh_table dn_neigh_table = { ...@@ -123,7 +123,7 @@ struct neigh_table dn_neigh_table = {
static u32 dn_neigh_hash(const void *pkey, const struct net_device *dev) static u32 dn_neigh_hash(const void *pkey, const struct net_device *dev)
{ {
return jhash_2words(*(dn_address *)pkey, 0, dn_neigh_table.hash_rnd); return jhash_2words(*(__u16 *)pkey, 0, dn_neigh_table.hash_rnd);
} }
static int dn_neigh_construct(struct neighbour *neigh) static int dn_neigh_construct(struct neighbour *neigh)
...@@ -249,14 +249,14 @@ static int dn_long_output(struct sk_buff *skb) ...@@ -249,14 +249,14 @@ static int dn_long_output(struct sk_buff *skb)
data = skb_push(skb, sizeof(struct dn_long_packet) + 3); data = skb_push(skb, sizeof(struct dn_long_packet) + 3);
lp = (struct dn_long_packet *)(data+3); lp = (struct dn_long_packet *)(data+3);
*((unsigned short *)data) = dn_htons(skb->len - 2); *((__le16 *)data) = dn_htons(skb->len - 2);
*(data + 2) = 1 | DN_RT_F_PF; /* Padding */ *(data + 2) = 1 | DN_RT_F_PF; /* Padding */
lp->msgflg = DN_RT_PKT_LONG|(cb->rt_flags&(DN_RT_F_IE|DN_RT_F_RQR|DN_RT_F_RTS)); lp->msgflg = DN_RT_PKT_LONG|(cb->rt_flags&(DN_RT_F_IE|DN_RT_F_RQR|DN_RT_F_RTS));
lp->d_area = lp->d_subarea = 0; lp->d_area = lp->d_subarea = 0;
dn_dn2eth(lp->d_id, dn_ntohs(cb->dst)); dn_dn2eth(lp->d_id, cb->dst);
lp->s_area = lp->s_subarea = 0; lp->s_area = lp->s_subarea = 0;
dn_dn2eth(lp->s_id, dn_ntohs(cb->src)); dn_dn2eth(lp->s_id, cb->src);
lp->nl2 = 0; lp->nl2 = 0;
lp->visit_ct = cb->hops & 0x3f; lp->visit_ct = cb->hops & 0x3f;
lp->s_class = 0; lp->s_class = 0;
...@@ -293,7 +293,7 @@ static int dn_short_output(struct sk_buff *skb) ...@@ -293,7 +293,7 @@ static int dn_short_output(struct sk_buff *skb)
} }
data = skb_push(skb, sizeof(struct dn_short_packet) + 2); data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
*((unsigned short *)data) = dn_htons(skb->len - 2); *((__le16 *)data) = dn_htons(skb->len - 2);
sp = (struct dn_short_packet *)(data+2); sp = (struct dn_short_packet *)(data+2);
sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS)); sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS));
...@@ -335,7 +335,7 @@ static int dn_phase3_output(struct sk_buff *skb) ...@@ -335,7 +335,7 @@ static int dn_phase3_output(struct sk_buff *skb)
} }
data = skb_push(skb, sizeof(struct dn_short_packet) + 2); data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
*((unsigned short *)data) = dn_htons(skb->len - 2); *((__le16 *)data) = dn_htons(skb->len - 2);
sp = (struct dn_short_packet *)(data + 2); sp = (struct dn_short_packet *)(data + 2);
sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS)); sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS));
...@@ -373,9 +373,9 @@ int dn_neigh_router_hello(struct sk_buff *skb) ...@@ -373,9 +373,9 @@ int dn_neigh_router_hello(struct sk_buff *skb)
struct neighbour *neigh; struct neighbour *neigh;
struct dn_neigh *dn; struct dn_neigh *dn;
struct dn_dev *dn_db; struct dn_dev *dn_db;
dn_address src; __le16 src;
src = dn_htons(dn_eth2dn(msg->id)); src = dn_eth2dn(msg->id);
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1);
...@@ -409,7 +409,7 @@ int dn_neigh_router_hello(struct sk_buff *skb) ...@@ -409,7 +409,7 @@ int dn_neigh_router_hello(struct sk_buff *skb)
} }
/* Only use routers in our area */ /* Only use routers in our area */
if ((dn_ntohs(src)>>10) == dn_ntohs((decnet_address)>>10)) { if ((dn_ntohs(src)>>10) == (dn_ntohs((decnet_address))>>10)) {
if (!dn_db->router) { if (!dn_db->router) {
dn_db->router = neigh_clone(neigh); dn_db->router = neigh_clone(neigh);
} else { } else {
...@@ -433,9 +433,9 @@ int dn_neigh_endnode_hello(struct sk_buff *skb) ...@@ -433,9 +433,9 @@ int dn_neigh_endnode_hello(struct sk_buff *skb)
struct endnode_hello_message *msg = (struct endnode_hello_message *)skb->data; struct endnode_hello_message *msg = (struct endnode_hello_message *)skb->data;
struct neighbour *neigh; struct neighbour *neigh;
struct dn_neigh *dn; struct dn_neigh *dn;
dn_address src; __le16 src;
src = dn_htons(dn_eth2dn(msg->id)); src = dn_eth2dn(msg->id);
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1);
......
...@@ -85,7 +85,7 @@ static void dn_log_martian(struct sk_buff *skb, const char *msg) ...@@ -85,7 +85,7 @@ static void dn_log_martian(struct sk_buff *skb, const char *msg)
if (decnet_log_martians && net_ratelimit()) { if (decnet_log_martians && net_ratelimit()) {
char *devname = skb->dev ? skb->dev->name : "???"; char *devname = skb->dev ? skb->dev->name : "???";
struct dn_skb_cb *cb = DN_SKB_CB(skb); struct dn_skb_cb *cb = DN_SKB_CB(skb);
printk(KERN_INFO "DECnet: Martian packet (%s) dev=%s src=0x%04hx dst=0x%04hx srcport=0x%04hx dstport=0x%04hx\n", msg, devname, cb->src, cb->dst, cb->src_port, cb->dst_port); printk(KERN_INFO "DECnet: Martian packet (%s) dev=%s src=0x%04hx dst=0x%04hx srcport=0x%04hx dstport=0x%04hx\n", msg, devname, dn_ntohs(cb->src), dn_ntohs(cb->dst), dn_ntohs(cb->src_port), dn_ntohs(cb->dst_port));
} }
} }
...@@ -128,7 +128,7 @@ static void dn_ack(struct sock *sk, struct sk_buff *skb, unsigned short ack) ...@@ -128,7 +128,7 @@ static void dn_ack(struct sock *sk, struct sk_buff *skb, unsigned short ack)
*/ */
static int dn_process_ack(struct sock *sk, struct sk_buff *skb, int oth) static int dn_process_ack(struct sock *sk, struct sk_buff *skb, int oth)
{ {
unsigned short *ptr = (unsigned short *)skb->data; __le16 *ptr = (__le16 *)skb->data;
int len = 0; int len = 0;
unsigned short ack; unsigned short ack;
...@@ -346,7 +346,7 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb) ...@@ -346,7 +346,7 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
ptr = skb->data; ptr = skb->data;
cb->services = *ptr++; cb->services = *ptr++;
cb->info = *ptr++; cb->info = *ptr++;
cb->segsize = dn_ntohs(*(__u16 *)ptr); cb->segsize = dn_ntohs(*(__le16 *)ptr);
if ((scp->state == DN_CI) || (scp->state == DN_CD)) { if ((scp->state == DN_CI) || (scp->state == DN_CD)) {
scp->persist = 0; scp->persist = 0;
...@@ -363,7 +363,7 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb) ...@@ -363,7 +363,7 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
if (skb->len > 0) { if (skb->len > 0) {
unsigned char dlen = *skb->data; unsigned char dlen = *skb->data;
if ((dlen <= 16) && (dlen <= skb->len)) { if ((dlen <= 16) && (dlen <= skb->len)) {
scp->conndata_in.opt_optl = dlen; scp->conndata_in.opt_optl = dn_htons((__u16)dlen);
memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen); memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen);
} }
} }
...@@ -397,17 +397,17 @@ static void dn_nsp_disc_init(struct sock *sk, struct sk_buff *skb) ...@@ -397,17 +397,17 @@ static void dn_nsp_disc_init(struct sock *sk, struct sk_buff *skb)
if (skb->len < 2) if (skb->len < 2)
goto out; goto out;
reason = dn_ntohs(*(__u16 *)skb->data); reason = dn_ntohs(*(__le16 *)skb->data);
skb_pull(skb, 2); skb_pull(skb, 2);
scp->discdata_in.opt_status = reason; scp->discdata_in.opt_status = dn_htons(reason);
scp->discdata_in.opt_optl = 0; scp->discdata_in.opt_optl = 0;
memset(scp->discdata_in.opt_data, 0, 16); memset(scp->discdata_in.opt_data, 0, 16);
if (skb->len > 0) { if (skb->len > 0) {
unsigned char dlen = *skb->data; unsigned char dlen = *skb->data;
if ((dlen <= 16) && (dlen <= skb->len)) { if ((dlen <= 16) && (dlen <= skb->len)) {
scp->discdata_in.opt_optl = dlen; scp->discdata_in.opt_optl = dn_htons((__u16)dlen);
memcpy(scp->discdata_in.opt_data, skb->data + 1, dlen); memcpy(scp->discdata_in.opt_data, skb->data + 1, dlen);
} }
} }
...@@ -464,7 +464,7 @@ static void dn_nsp_disc_conf(struct sock *sk, struct sk_buff *skb) ...@@ -464,7 +464,7 @@ static void dn_nsp_disc_conf(struct sock *sk, struct sk_buff *skb)
if (skb->len != 2) if (skb->len != 2)
goto out; goto out;
reason = dn_ntohs(*(__u16 *)skb->data); reason = dn_ntohs(*(__le16 *)skb->data);
sk->sk_state = TCP_CLOSE; sk->sk_state = TCP_CLOSE;
...@@ -513,7 +513,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb) ...@@ -513,7 +513,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
if (skb->len != 4) if (skb->len != 4)
goto out; goto out;
segnum = dn_ntohs(*(__u16 *)ptr); segnum = dn_ntohs(*(__le16 *)ptr);
ptr += 2; ptr += 2;
lsflags = *(unsigned char *)ptr++; lsflags = *(unsigned char *)ptr++;
fcval = *ptr; fcval = *ptr;
...@@ -621,7 +621,7 @@ static void dn_nsp_otherdata(struct sock *sk, struct sk_buff *skb) ...@@ -621,7 +621,7 @@ static void dn_nsp_otherdata(struct sock *sk, struct sk_buff *skb)
if (skb->len < 2) if (skb->len < 2)
goto out; goto out;
cb->segnum = segnum = dn_ntohs(*(__u16 *)skb->data); cb->segnum = segnum = dn_ntohs(*(__le16 *)skb->data);
skb_pull(skb, 2); skb_pull(skb, 2);
if (seq_next(scp->numoth_rcv, segnum)) { if (seq_next(scp->numoth_rcv, segnum)) {
...@@ -649,7 +649,7 @@ static void dn_nsp_data(struct sock *sk, struct sk_buff *skb) ...@@ -649,7 +649,7 @@ static void dn_nsp_data(struct sock *sk, struct sk_buff *skb)
if (skb->len < 2) if (skb->len < 2)
goto out; goto out;
cb->segnum = segnum = dn_ntohs(*(__u16 *)skb->data); cb->segnum = segnum = dn_ntohs(*(__le16 *)skb->data);
skb_pull(skb, 2); skb_pull(skb, 2);
if (seq_next(scp->numdat_rcv, segnum)) { if (seq_next(scp->numdat_rcv, segnum)) {
...@@ -760,7 +760,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb) ...@@ -760,7 +760,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb)
/* /*
* Grab the destination address. * Grab the destination address.
*/ */
cb->dst_port = *(unsigned short *)ptr; cb->dst_port = *(__le16 *)ptr;
cb->src_port = 0; cb->src_port = 0;
ptr += 2; ptr += 2;
...@@ -768,7 +768,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb) ...@@ -768,7 +768,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb)
* If not a connack, grab the source address too. * If not a connack, grab the source address too.
*/ */
if (pskb_may_pull(skb, 5)) { if (pskb_may_pull(skb, 5)) {
cb->src_port = *(unsigned short *)ptr; cb->src_port = *(__le16 *)ptr;
ptr += 2; ptr += 2;
skb_pull(skb, 5); skb_pull(skb, 5);
} }
...@@ -778,7 +778,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb) ...@@ -778,7 +778,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb)
* Swap src & dst and look up in the normal way. * Swap src & dst and look up in the normal way.
*/ */
if (unlikely(cb->rt_flags & DN_RT_F_RTS)) { if (unlikely(cb->rt_flags & DN_RT_F_RTS)) {
unsigned short tmp = cb->dst_port; __le16 tmp = cb->dst_port;
cb->dst_port = cb->src_port; cb->dst_port = cb->src_port;
cb->src_port = tmp; cb->src_port = tmp;
tmp = cb->dst; tmp = cb->dst;
......
...@@ -287,26 +287,26 @@ int dn_nsp_xmit_timeout(struct sock *sk) ...@@ -287,26 +287,26 @@ int dn_nsp_xmit_timeout(struct sock *sk)
return 0; return 0;
} }
static inline unsigned char *dn_mk_common_header(struct dn_scp *scp, struct sk_buff *skb, unsigned char msgflag, int len) static inline __le16 *dn_mk_common_header(struct dn_scp *scp, struct sk_buff *skb, unsigned char msgflag, int len)
{ {
unsigned char *ptr = skb_push(skb, len); unsigned char *ptr = skb_push(skb, len);
BUG_ON(len < 5); BUG_ON(len < 5);
*ptr++ = msgflag; *ptr++ = msgflag;
*((unsigned short *)ptr) = scp->addrrem; *((__le16 *)ptr) = scp->addrrem;
ptr += 2; ptr += 2;
*((unsigned short *)ptr) = scp->addrloc; *((__le16 *)ptr) = scp->addrloc;
ptr += 2; ptr += 2;
return ptr; return (__le16 __force *)ptr;
} }
static unsigned short *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, unsigned char msgflag, int hlen, int other) static __le16 *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, unsigned char msgflag, int hlen, int other)
{ {
struct dn_scp *scp = DN_SK(sk); struct dn_scp *scp = DN_SK(sk);
unsigned short acknum = scp->numdat_rcv & 0x0FFF; unsigned short acknum = scp->numdat_rcv & 0x0FFF;
unsigned short ackcrs = scp->numoth_rcv & 0x0FFF; unsigned short ackcrs = scp->numoth_rcv & 0x0FFF;
unsigned short *ptr; __le16 *ptr;
BUG_ON(hlen < 9); BUG_ON(hlen < 9);
...@@ -325,7 +325,7 @@ static unsigned short *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, un ...@@ -325,7 +325,7 @@ static unsigned short *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, un
/* Set "cross subchannel" bit in ackcrs */ /* Set "cross subchannel" bit in ackcrs */
ackcrs |= 0x2000; ackcrs |= 0x2000;
ptr = (unsigned short *)dn_mk_common_header(scp, skb, msgflag, hlen); ptr = (__le16 *)dn_mk_common_header(scp, skb, msgflag, hlen);
*ptr++ = dn_htons(acknum); *ptr++ = dn_htons(acknum);
*ptr++ = dn_htons(ackcrs); *ptr++ = dn_htons(ackcrs);
...@@ -333,11 +333,11 @@ static unsigned short *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, un ...@@ -333,11 +333,11 @@ static unsigned short *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, un
return ptr; return ptr;
} }
static unsigned short *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *skb, int oth) static __le16 *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *skb, int oth)
{ {
struct dn_scp *scp = DN_SK(sk); struct dn_scp *scp = DN_SK(sk);
struct dn_skb_cb *cb = DN_SKB_CB(skb); struct dn_skb_cb *cb = DN_SKB_CB(skb);
unsigned short *ptr = dn_mk_ack_header(sk, skb, cb->nsp_flags, 11, oth); __le16 *ptr = dn_mk_ack_header(sk, skb, cb->nsp_flags, 11, oth);
if (unlikely(oth)) { if (unlikely(oth)) {
cb->segnum = scp->numoth; cb->segnum = scp->numoth;
...@@ -524,9 +524,9 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp) ...@@ -524,9 +524,9 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
struct dn_scp *scp = DN_SK(sk); struct dn_scp *scp = DN_SK(sk);
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct nsp_conn_init_msg *msg; struct nsp_conn_init_msg *msg;
unsigned char len = scp->conndata_out.opt_optl; __u8 len = (__u8)dn_ntohs(scp->conndata_out.opt_optl);
if ((skb = dn_alloc_skb(sk, 50 + scp->conndata_out.opt_optl, gfp)) == NULL) if ((skb = dn_alloc_skb(sk, 50 + dn_ntohs(scp->conndata_out.opt_optl), gfp)) == NULL)
return; return;
msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg)); msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
...@@ -553,7 +553,7 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp) ...@@ -553,7 +553,7 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
unsigned short reason, gfp_t gfp, unsigned short reason, gfp_t gfp,
struct dst_entry *dst, struct dst_entry *dst,
int ddl, unsigned char *dd, __u16 rem, __u16 loc) int ddl, unsigned char *dd, __le16 rem, __le16 loc)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
int size = 7 + ddl + ((msgflg == NSP_DISCINIT) ? 1 : 0); int size = 7 + ddl + ((msgflg == NSP_DISCINIT) ? 1 : 0);
...@@ -561,7 +561,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, ...@@ -561,7 +561,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
if ((dst == NULL) || (rem == 0)) { if ((dst == NULL) || (rem == 0)) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_DEBUG "DECnet: dn_nsp_do_disc: BUG! Please report this to SteveW@ACM.org rem=%u dst=%p\n", (unsigned)rem, dst); printk(KERN_DEBUG "DECnet: dn_nsp_do_disc: BUG! Please report this to SteveW@ACM.org rem=%u dst=%p\n", dn_ntohs(rem), dst);
return; return;
} }
...@@ -570,11 +570,11 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, ...@@ -570,11 +570,11 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
msg = skb_put(skb, size); msg = skb_put(skb, size);
*msg++ = msgflg; *msg++ = msgflg;
*(__u16 *)msg = rem; *(__le16 *)msg = rem;
msg += 2; msg += 2;
*(__u16 *)msg = loc; *(__le16 *)msg = loc;
msg += 2; msg += 2;
*(__u16 *)msg = dn_htons(reason); *(__le16 *)msg = dn_htons(reason);
msg += 2; msg += 2;
if (msgflg == NSP_DISCINIT) if (msgflg == NSP_DISCINIT)
*msg++ = ddl; *msg++ = ddl;
...@@ -600,10 +600,10 @@ void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, ...@@ -600,10 +600,10 @@ void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg,
int ddl = 0; int ddl = 0;
if (msgflg == NSP_DISCINIT) if (msgflg == NSP_DISCINIT)
ddl = scp->discdata_out.opt_optl; ddl = dn_ntohs(scp->discdata_out.opt_optl);
if (reason == 0) if (reason == 0)
reason = scp->discdata_out.opt_status; reason = dn_ntohs(scp->discdata_out.opt_status);
dn_nsp_do_disc(sk, msgflg, reason, gfp, sk->sk_dst_cache, ddl, dn_nsp_do_disc(sk, msgflg, reason, gfp, sk->sk_dst_cache, ddl,
scp->discdata_out.opt_data, scp->addrrem, scp->addrloc); scp->discdata_out.opt_data, scp->addrrem, scp->addrloc);
...@@ -708,7 +708,7 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg) ...@@ -708,7 +708,7 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
if (aux > 0) if (aux > 0)
memcpy(skb_put(skb, aux), scp->accessdata.acc_acc, aux); memcpy(skb_put(skb, aux), scp->accessdata.acc_acc, aux);
aux = scp->conndata_out.opt_optl; aux = (__u8)dn_ntohs(scp->conndata_out.opt_optl);
*skb_put(skb, 1) = aux; *skb_put(skb, 1) = aux;
if (aux > 0) if (aux > 0)
memcpy(skb_put(skb,aux), scp->conndata_out.opt_data, aux); memcpy(skb_put(skb,aux), scp->conndata_out.opt_data, aux);
......
...@@ -133,9 +133,9 @@ static struct dst_ops dn_dst_ops = { ...@@ -133,9 +133,9 @@ static struct dst_ops dn_dst_ops = {
.entries = ATOMIC_INIT(0), .entries = ATOMIC_INIT(0),
}; };
static __inline__ unsigned dn_hash(unsigned short src, unsigned short dst) static __inline__ unsigned dn_hash(__le16 src, __le16 dst)
{ {
unsigned short tmp = src ^ dst; __u16 tmp = (__u16 __force)(src ^ dst);
tmp ^= (tmp >> 3); tmp ^= (tmp >> 3);
tmp ^= (tmp >> 5); tmp ^= (tmp >> 5);
tmp ^= (tmp >> 10); tmp ^= (tmp >> 10);
...@@ -379,9 +379,9 @@ static int dn_return_short(struct sk_buff *skb) ...@@ -379,9 +379,9 @@ static int dn_return_short(struct sk_buff *skb)
{ {
struct dn_skb_cb *cb; struct dn_skb_cb *cb;
unsigned char *ptr; unsigned char *ptr;
dn_address *src; __le16 *src;
dn_address *dst; __le16 *dst;
dn_address tmp; __le16 tmp;
/* Add back headers */ /* Add back headers */
skb_push(skb, skb->data - skb->nh.raw); skb_push(skb, skb->data - skb->nh.raw);
...@@ -394,9 +394,9 @@ static int dn_return_short(struct sk_buff *skb) ...@@ -394,9 +394,9 @@ static int dn_return_short(struct sk_buff *skb)
ptr = skb->data + 2; ptr = skb->data + 2;
*ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS; *ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS;
dst = (dn_address *)ptr; dst = (__le16 *)ptr;
ptr += 2; ptr += 2;
src = (dn_address *)ptr; src = (__le16 *)ptr;
ptr += 2; ptr += 2;
*ptr = 0; /* Zero hop count */ *ptr = 0; /* Zero hop count */
...@@ -475,7 +475,8 @@ static int dn_route_rx_packet(struct sk_buff *skb) ...@@ -475,7 +475,8 @@ static int dn_route_rx_packet(struct sk_buff *skb)
struct dn_skb_cb *cb = DN_SKB_CB(skb); struct dn_skb_cb *cb = DN_SKB_CB(skb);
printk(KERN_DEBUG printk(KERN_DEBUG
"DECnet: dn_route_rx_packet: rt_flags=0x%02x dev=%s len=%d src=0x%04hx dst=0x%04hx err=%d type=%d\n", "DECnet: dn_route_rx_packet: rt_flags=0x%02x dev=%s len=%d src=0x%04hx dst=0x%04hx err=%d type=%d\n",
(int)cb->rt_flags, devname, skb->len, cb->src, cb->dst, (int)cb->rt_flags, devname, skb->len,
dn_ntohs(cb->src), dn_ntohs(cb->dst),
err, skb->pkt_type); err, skb->pkt_type);
} }
...@@ -505,7 +506,7 @@ static int dn_route_rx_long(struct sk_buff *skb) ...@@ -505,7 +506,7 @@ static int dn_route_rx_long(struct sk_buff *skb)
/* Destination info */ /* Destination info */
ptr += 2; ptr += 2;
cb->dst = dn_htons(dn_eth2dn(ptr)); cb->dst = dn_eth2dn(ptr);
if (memcmp(ptr, dn_hiord_addr, 4) != 0) if (memcmp(ptr, dn_hiord_addr, 4) != 0)
goto drop_it; goto drop_it;
ptr += 6; ptr += 6;
...@@ -513,7 +514,7 @@ static int dn_route_rx_long(struct sk_buff *skb) ...@@ -513,7 +514,7 @@ static int dn_route_rx_long(struct sk_buff *skb)
/* Source info */ /* Source info */
ptr += 2; ptr += 2;
cb->src = dn_htons(dn_eth2dn(ptr)); cb->src = dn_eth2dn(ptr);
if (memcmp(ptr, dn_hiord_addr, 4) != 0) if (memcmp(ptr, dn_hiord_addr, 4) != 0)
goto drop_it; goto drop_it;
ptr += 6; ptr += 6;
...@@ -541,9 +542,9 @@ static int dn_route_rx_short(struct sk_buff *skb) ...@@ -541,9 +542,9 @@ static int dn_route_rx_short(struct sk_buff *skb)
skb_pull(skb, 5); skb_pull(skb, 5);
skb->h.raw = skb->data; skb->h.raw = skb->data;
cb->dst = *(dn_address *)ptr; cb->dst = *(__le16 *)ptr;
ptr += 2; ptr += 2;
cb->src = *(dn_address *)ptr; cb->src = *(__le16 *)ptr;
ptr += 2; ptr += 2;
cb->hops = *ptr & 0x3f; cb->hops = *ptr & 0x3f;
...@@ -575,7 +576,7 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type ...@@ -575,7 +576,7 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
{ {
struct dn_skb_cb *cb; struct dn_skb_cb *cb;
unsigned char flags = 0; unsigned char flags = 0;
__u16 len = dn_ntohs(*(__u16 *)skb->data); __u16 len = dn_ntohs(*(__le16 *)skb->data);
struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr; struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr;
unsigned char padlen = 0; unsigned char padlen = 0;
...@@ -782,7 +783,7 @@ static int dn_rt_bug(struct sk_buff *skb) ...@@ -782,7 +783,7 @@ static int dn_rt_bug(struct sk_buff *skb)
struct dn_skb_cb *cb = DN_SKB_CB(skb); struct dn_skb_cb *cb = DN_SKB_CB(skb);
printk(KERN_DEBUG "dn_rt_bug: skb from:%04x to:%04x\n", printk(KERN_DEBUG "dn_rt_bug: skb from:%04x to:%04x\n",
cb->src, cb->dst); dn_ntohs(cb->src), dn_ntohs(cb->dst));
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -823,7 +824,7 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res) ...@@ -823,7 +824,7 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
return 0; return 0;
} }
static inline int dn_match_addr(__u16 addr1, __u16 addr2) static inline int dn_match_addr(__le16 addr1, __le16 addr2)
{ {
__u16 tmp = dn_ntohs(addr1) ^ dn_ntohs(addr2); __u16 tmp = dn_ntohs(addr1) ^ dn_ntohs(addr2);
int match = 16; int match = 16;
...@@ -834,9 +835,9 @@ static inline int dn_match_addr(__u16 addr1, __u16 addr2) ...@@ -834,9 +835,9 @@ static inline int dn_match_addr(__u16 addr1, __u16 addr2)
return match; return match;
} }
static __u16 dnet_select_source(const struct net_device *dev, __u16 daddr, int scope) static __le16 dnet_select_source(const struct net_device *dev, __le16 daddr, int scope)
{ {
__u16 saddr = 0; __le16 saddr = 0;
struct dn_dev *dn_db = dev->dn_ptr; struct dn_dev *dn_db = dev->dn_ptr;
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
int best_match = 0; int best_match = 0;
...@@ -861,14 +862,14 @@ static __u16 dnet_select_source(const struct net_device *dev, __u16 daddr, int s ...@@ -861,14 +862,14 @@ static __u16 dnet_select_source(const struct net_device *dev, __u16 daddr, int s
return saddr; return saddr;
} }
static inline __u16 __dn_fib_res_prefsrc(struct dn_fib_res *res) static inline __le16 __dn_fib_res_prefsrc(struct dn_fib_res *res)
{ {
return dnet_select_source(DN_FIB_RES_DEV(*res), DN_FIB_RES_GW(*res), res->scope); return dnet_select_source(DN_FIB_RES_DEV(*res), DN_FIB_RES_GW(*res), res->scope);
} }
static inline __u16 dn_fib_rules_map_destination(__u16 daddr, struct dn_fib_res *res) static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_res *res)
{ {
__u16 mask = dnet_make_mask(res->prefixlen); __le16 mask = dnet_make_mask(res->prefixlen);
return (daddr&~mask)|res->fi->fib_nh->nh_gw; return (daddr&~mask)|res->fi->fib_nh->nh_gw;
} }
...@@ -892,12 +893,13 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old ...@@ -892,12 +893,13 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
struct dn_fib_res res = { .fi = NULL, .type = RTN_UNICAST }; struct dn_fib_res res = { .fi = NULL, .type = RTN_UNICAST };
int err; int err;
int free_res = 0; int free_res = 0;
__u16 gateway = 0; __le16 gateway = 0;
if (decnet_debug_level & 16) if (decnet_debug_level & 16)
printk(KERN_DEBUG printk(KERN_DEBUG
"dn_route_output_slow: dst=%04x src=%04x mark=%d" "dn_route_output_slow: dst=%04x src=%04x mark=%d"
" iif=%d oif=%d\n", oldflp->fld_dst, oldflp->fld_src, " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
dn_ntohs(oldflp->fld_src),
oldflp->fld_fwmark, loopback_dev.ifindex, oldflp->oif); oldflp->fld_fwmark, loopback_dev.ifindex, oldflp->oif);
/* If we have an output interface, verify its a DECnet device */ /* If we have an output interface, verify its a DECnet device */
...@@ -961,8 +963,9 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old ...@@ -961,8 +963,9 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
if (decnet_debug_level & 16) if (decnet_debug_level & 16)
printk(KERN_DEBUG printk(KERN_DEBUG
"dn_route_output_slow: initial checks complete." "dn_route_output_slow: initial checks complete."
" dst=%o4x src=%04x oif=%d try_hard=%d\n", fl.fld_dst, " dst=%o4x src=%04x oif=%d try_hard=%d\n",
fl.fld_src, fl.oif, try_hard); dn_ntohs(fl.fld_dst), dn_ntohs(fl.fld_src),
fl.oif, try_hard);
/* /*
* N.B. If the kernel is compiled without router support then * N.B. If the kernel is compiled without router support then
...@@ -1218,8 +1221,8 @@ static int dn_route_input_slow(struct sk_buff *skb) ...@@ -1218,8 +1221,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
struct neighbour *neigh = NULL; struct neighbour *neigh = NULL;
unsigned hash; unsigned hash;
int flags = 0; int flags = 0;
__u16 gateway = 0; __le16 gateway = 0;
__u16 local_src = 0; __le16 local_src = 0;
struct flowi fl = { .nl_u = { .dn_u = struct flowi fl = { .nl_u = { .dn_u =
{ .daddr = cb->dst, { .daddr = cb->dst,
.saddr = cb->src, .saddr = cb->src,
...@@ -1266,7 +1269,7 @@ static int dn_route_input_slow(struct sk_buff *skb) ...@@ -1266,7 +1269,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
res.type = RTN_LOCAL; res.type = RTN_LOCAL;
flags |= RTCF_DIRECTSRC; flags |= RTCF_DIRECTSRC;
} else { } else {
__u16 src_map = fl.fld_src; __le16 src_map = fl.fld_src;
free_res = 1; free_res = 1;
out_dev = DN_FIB_RES_DEV(res); out_dev = DN_FIB_RES_DEV(res);
......
...@@ -46,11 +46,11 @@ struct dn_fib_rule ...@@ -46,11 +46,11 @@ struct dn_fib_rule
unsigned char r_action; unsigned char r_action;
unsigned char r_dst_len; unsigned char r_dst_len;
unsigned char r_src_len; unsigned char r_src_len;
dn_address r_src; __le16 r_src;
dn_address r_srcmask; __le16 r_srcmask;
dn_address r_dst; __le16 r_dst;
dn_address r_dstmask; __le16 r_dstmask;
dn_address r_srcmap; __le16 r_srcmap;
u8 r_flags; u8 r_flags;
#ifdef CONFIG_DECNET_ROUTE_FWMARK #ifdef CONFIG_DECNET_ROUTE_FWMARK
u32 r_fwmark; u32 r_fwmark;
...@@ -208,8 +208,8 @@ int dn_fib_lookup(const struct flowi *flp, struct dn_fib_res *res) ...@@ -208,8 +208,8 @@ int dn_fib_lookup(const struct flowi *flp, struct dn_fib_res *res)
{ {
struct dn_fib_rule *r, *policy; struct dn_fib_rule *r, *policy;
struct dn_fib_table *tb; struct dn_fib_table *tb;
dn_address saddr = flp->fld_src; __le16 saddr = flp->fld_src;
dn_address daddr = flp->fld_dst; __le16 daddr = flp->fld_dst;
int err; int err;
read_lock(&dn_fib_rules_lock); read_lock(&dn_fib_rules_lock);
...@@ -259,7 +259,7 @@ int dn_fib_lookup(const struct flowi *flp, struct dn_fib_res *res) ...@@ -259,7 +259,7 @@ int dn_fib_lookup(const struct flowi *flp, struct dn_fib_res *res)
return -ESRCH; return -ESRCH;
} }
unsigned dnet_addr_type(__u16 addr) unsigned dnet_addr_type(__le16 addr)
{ {
struct flowi fl = { .nl_u = { .dn_u = { .daddr = addr } } }; struct flowi fl = { .nl_u = { .dn_u = { .daddr = addr } } };
struct dn_fib_res res; struct dn_fib_res res;
...@@ -277,7 +277,7 @@ unsigned dnet_addr_type(__u16 addr) ...@@ -277,7 +277,7 @@ unsigned dnet_addr_type(__u16 addr)
return ret; return ret;
} }
__u16 dn_fib_rules_policy(__u16 saddr, struct dn_fib_res *res, unsigned *flags) __le16 dn_fib_rules_policy(__le16 saddr, struct dn_fib_res *res, unsigned *flags)
{ {
struct dn_fib_rule *r = res->r; struct dn_fib_rule *r = res->r;
......
...@@ -46,7 +46,7 @@ struct dn_zone ...@@ -46,7 +46,7 @@ struct dn_zone
u32 dz_hashmask; u32 dz_hashmask;
#define DZ_HASHMASK(dz) ((dz)->dz_hashmask) #define DZ_HASHMASK(dz) ((dz)->dz_hashmask)
int dz_order; int dz_order;
u16 dz_mask; __le16 dz_mask;
#define DZ_MASK(dz) ((dz)->dz_mask) #define DZ_MASK(dz) ((dz)->dz_mask)
}; };
...@@ -84,14 +84,14 @@ static int dn_fib_hash_zombies; ...@@ -84,14 +84,14 @@ static int dn_fib_hash_zombies;
static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz) static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz)
{ {
u16 h = ntohs(key.datum)>>(16 - dz->dz_order); u16 h = dn_ntohs(key.datum)>>(16 - dz->dz_order);
h ^= (h >> 10); h ^= (h >> 10);
h ^= (h >> 6); h ^= (h >> 6);
h &= DZ_HASHMASK(dz); h &= DZ_HASHMASK(dz);
return *(dn_fib_idx_t *)&h; return *(dn_fib_idx_t *)&h;
} }
static inline dn_fib_key_t dz_key(u16 dst, struct dn_zone *dz) static inline dn_fib_key_t dz_key(__le16 dst, struct dn_zone *dz)
{ {
dn_fib_key_t k; dn_fib_key_t k;
k.datum = dst & DZ_MASK(dz); k.datum = dst & DZ_MASK(dz);
...@@ -250,7 +250,7 @@ static int dn_fib_nh_match(struct rtmsg *r, struct nlmsghdr *nlh, struct dn_kern ...@@ -250,7 +250,7 @@ static int dn_fib_nh_match(struct rtmsg *r, struct nlmsghdr *nlh, struct dn_kern
for_nexthops(fi) { for_nexthops(fi) {
int attrlen = nhlen - sizeof(struct rtnexthop); int attrlen = nhlen - sizeof(struct rtnexthop);
dn_address gw; __le16 gw;
if (attrlen < 0 || (nhlen -= nhp->rtnh_len) < 0) if (attrlen < 0 || (nhlen -= nhp->rtnh_len) < 0)
return -EINVAL; return -EINVAL;
...@@ -457,7 +457,7 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct ...@@ -457,7 +457,7 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
dz_key_0(key); dz_key_0(key);
if (rta->rta_dst) { if (rta->rta_dst) {
dn_address dst; __le16 dst;
memcpy(&dst, rta->rta_dst, 2); memcpy(&dst, rta->rta_dst, 2);
if (dst & ~DZ_MASK(dz)) if (dst & ~DZ_MASK(dz))
return -EINVAL; return -EINVAL;
...@@ -593,7 +593,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct ...@@ -593,7 +593,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
dz_key_0(key); dz_key_0(key);
if (rta->rta_dst) { if (rta->rta_dst) {
dn_address dst; __le16 dst;
memcpy(&dst, rta->rta_dst, 2); memcpy(&dst, rta->rta_dst, 2);
if (dst & ~DZ_MASK(dz)) if (dst & ~DZ_MASK(dz))
return -EINVAL; return -EINVAL;
......
...@@ -86,9 +86,9 @@ static void strip_it(char *str) ...@@ -86,9 +86,9 @@ static void strip_it(char *str)
* Simple routine to parse an ascii DECnet address * Simple routine to parse an ascii DECnet address
* into a network order address. * into a network order address.
*/ */
static int parse_addr(dn_address *addr, char *str) static int parse_addr(__le16 *addr, char *str)
{ {
dn_address area, node; __u16 area, node;
while(*str && !ISNUM(*str)) str++; while(*str && !ISNUM(*str)) str++;
...@@ -139,7 +139,7 @@ static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen ...@@ -139,7 +139,7 @@ static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen
void **context) void **context)
{ {
size_t len; size_t len;
dn_address addr; __le16 addr;
if (oldval && oldlenp) { if (oldval && oldlenp) {
if (get_user(len, oldlenp)) if (get_user(len, oldlenp))
...@@ -147,14 +147,14 @@ static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen ...@@ -147,14 +147,14 @@ static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen
if (len) { if (len) {
if (len != sizeof(unsigned short)) if (len != sizeof(unsigned short))
return -EINVAL; return -EINVAL;
if (put_user(decnet_address, (unsigned short __user *)oldval)) if (put_user(decnet_address, (__le16 __user *)oldval))
return -EFAULT; return -EFAULT;
} }
} }
if (newval && newlen) { if (newval && newlen) {
if (newlen != sizeof(unsigned short)) if (newlen != sizeof(unsigned short))
return -EINVAL; return -EINVAL;
if (get_user(addr, (unsigned short __user *)newval)) if (get_user(addr, (__le16 __user *)newval))
return -EFAULT; return -EFAULT;
dn_dev_devices_off(); dn_dev_devices_off();
...@@ -173,7 +173,7 @@ static int dn_node_address_handler(ctl_table *table, int write, ...@@ -173,7 +173,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
{ {
char addr[DN_ASCBUF_LEN]; char addr[DN_ASCBUF_LEN];
size_t len; size_t len;
dn_address dnaddr; __le16 dnaddr;
if (!*lenp || (*ppos && !write)) { if (!*lenp || (*ppos && !write)) {
*lenp = 0; *lenp = 0;
......
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