Skip to content

Commit

Permalink
[TIPC]: endianness annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Al Viro authored and David S. Miller committed Dec 3, 2006
1 parent d54a81d commit 3e6c8cd
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 52 deletions.
32 changes: 16 additions & 16 deletions include/linux/tipc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,34 @@


struct tipc_node_info {
__u32 addr; /* network address of node */
__u32 up; /* 0=down, 1= up */
__be32 addr; /* network address of node */
__be32 up; /* 0=down, 1= up */
};

struct tipc_link_info {
__u32 dest; /* network address of peer node */
__u32 up; /* 0=down, 1=up */
__be32 dest; /* network address of peer node */
__be32 up; /* 0=down, 1=up */
char str[TIPC_MAX_LINK_NAME]; /* link name */
};

struct tipc_bearer_config {
__u32 priority; /* Range [1,31]. Override per link */
__u32 detect_scope;
__be32 priority; /* Range [1,31]. Override per link */
__be32 detect_scope;
char name[TIPC_MAX_BEARER_NAME];
};

struct tipc_link_config {
__u32 value;
__be32 value;
char name[TIPC_MAX_LINK_NAME];
};

#define TIPC_NTQ_ALLTYPES 0x80000000

struct tipc_name_table_query {
__u32 depth; /* 1:type, 2:+name info, 3:+port info, 4+:+debug info */
__u32 type; /* {t,l,u} info ignored if high bit of "depth" is set */
__u32 lowbound; /* (i.e. displays all entries of name table) */
__u32 upbound;
__be32 depth; /* 1:type, 2:+name info, 3:+port info, 4+:+debug info */
__be32 type; /* {t,l,u} info ignored if high bit of "depth" is set */
__be32 lowbound; /* (i.e. displays all entries of name table) */
__be32 upbound;
};

/*
Expand Down Expand Up @@ -262,8 +262,8 @@ struct tipc_route_info {
*/

struct tlv_desc {
__u16 tlv_len; /* TLV length (descriptor + value) */
__u16 tlv_type; /* TLV identifier */
__be16 tlv_len; /* TLV length (descriptor + value) */
__be16 tlv_type; /* TLV identifier */
};

#define TLV_ALIGNTO 4
Expand Down Expand Up @@ -377,9 +377,9 @@ struct tipc_genlmsghdr {

struct tipc_cfg_msg_hdr
{
__u32 tcm_len; /* Message length (including header) */
__u16 tcm_type; /* Command type */
__u16 tcm_flags; /* Additional flags */
__be32 tcm_len; /* Message length (including header) */
__be16 tcm_type; /* Command type */
__be16 tcm_flags; /* Additional flags */
char tcm_reserved[8]; /* Unused */
};

Expand Down
2 changes: 1 addition & 1 deletion include/net/tipc/tipc_bearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/

struct tipc_media_addr {
__u32 type; /* bearer type (network byte order) */
__be32 type; /* bearer type (network byte order) */
union {
__u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */
#if 0
Expand Down
2 changes: 1 addition & 1 deletion include/net/tipc/tipc_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#ifdef __KERNEL__

struct tipc_msg {
u32 hdr[15];
__be32 hdr[15];
};


Expand Down
32 changes: 11 additions & 21 deletions net/tipc/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value)
{
struct sk_buff *buf;
u32 value_net;
__be32 value_net;

buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value)));
if (buf) {
Expand Down Expand Up @@ -284,8 +284,7 @@ static struct sk_buff *cfg_set_own_addr(void)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

addr = *(u32 *)TLV_DATA(req_tlv_area);
addr = ntohl(addr);
addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (addr == tipc_own_addr)
return tipc_cfg_reply_none();
if (!tipc_addr_node_valid(addr))
Expand Down Expand Up @@ -319,8 +318,7 @@ static struct sk_buff *cfg_set_remote_mng(void)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
tipc_remote_management = (value != 0);
return tipc_cfg_reply_none();
}
Expand All @@ -332,8 +330,7 @@ static struct sk_buff *cfg_set_max_publications(void)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != delimit(value, 1, 65535))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (max publications must be 1-65535)");
Expand All @@ -348,8 +345,7 @@ static struct sk_buff *cfg_set_max_subscriptions(void)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != delimit(value, 1, 65535))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (max subscriptions must be 1-65535");
Expand All @@ -363,8 +359,7 @@ static struct sk_buff *cfg_set_max_ports(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value == tipc_max_ports)
return tipc_cfg_reply_none();
if (value != delimit(value, 127, 65535))
Expand All @@ -383,8 +378,7 @@ static struct sk_buff *cfg_set_max_zones(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value == tipc_max_zones)
return tipc_cfg_reply_none();
if (value != delimit(value, 1, 255))
Expand All @@ -403,8 +397,7 @@ static struct sk_buff *cfg_set_max_clusters(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != delimit(value, 1, 1))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (max clusters fixed at 1)");
Expand All @@ -417,8 +410,7 @@ static struct sk_buff *cfg_set_max_nodes(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value == tipc_max_nodes)
return tipc_cfg_reply_none();
if (value != delimit(value, 8, 2047))
Expand All @@ -437,8 +429,7 @@ static struct sk_buff *cfg_set_max_slaves(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != 0)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (max secondary nodes fixed at 0)");
Expand All @@ -451,8 +442,7 @@ static struct sk_buff *cfg_set_netid(void)

if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value == tipc_net_id)
return tipc_cfg_reply_none();
if (value != delimit(value, 1, 9999))
Expand Down
3 changes: 1 addition & 2 deletions net/tipc/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

value = *(u32 *)TLV_DATA(req_tlv_area);
value = ntohl(value);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != delimit(value, 0, 32768))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)");
Expand Down
10 changes: 5 additions & 5 deletions net/tipc/name_distr.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
*/

struct distr_item {
u32 type;
u32 lower;
u32 upper;
u32 ref;
u32 key;
__be32 type;
__be32 lower;
__be32 upper;
__be32 ref;
__be32 key;
};

/**
Expand Down
9 changes: 3 additions & 6 deletions net/tipc/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

domain = *(u32 *)TLV_DATA(req_tlv_area);
domain = ntohl(domain);
domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (!tipc_addr_domain_valid(domain))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network address)");
Expand Down Expand Up @@ -642,8 +641,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

domain = *(u32 *)TLV_DATA(req_tlv_area);
domain = ntohl(domain);
domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (!tipc_addr_domain_valid(domain))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network address)");
Expand All @@ -664,8 +662,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)

/* Add TLV for broadcast link */

link_info.dest = tipc_own_addr & 0xfffff00;
link_info.dest = htonl(link_info.dest);
link_info.dest = htonl(tipc_own_addr & 0xfffff00);
link_info.up = htonl(1);
sprintf(link_info.str, tipc_bclink_name);
tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
Expand Down

0 comments on commit 3e6c8cd

Please sign in to comment.