From 3d749a6a26b0811b4b2bb4ec2c47cd630a6bbf88 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 7 Oct 2011 15:19:11 -0400 Subject: tipc: Hide media-specific addressing details from generic bearer code Reworks TIPC's media address data structure and associated processing routines to transfer all media-specific details of address conversion to the associated TIPC media adaptation code. TIPC's generic bearer code now only needs to know which media type an address is associated with and whether or not it is a broadcast address, and totally ignores the "value" field that contains the actual media-specific addressing info. These changes eliminate the need for a number of endianness conversion operations and will make it easier for TIPC to support new media types in the future. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bearer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'net/tipc/bearer.c') diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 17652f20a359..aa37261626d6 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -108,7 +108,8 @@ int tipc_register_media(struct media *m_ptr) if (!media_name_valid(m_ptr->name)) goto exit; - if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) + if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) || + !m_ptr->bcast_addr.broadcast) goto exit; if (m_ptr->priority > TIPC_MAX_LINK_PRI) goto exit; @@ -138,20 +139,17 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) { char addr_str[MAX_ADDR_STR]; struct media *m_ptr; - u32 media_type; - media_type = ntohl(a->type); - m_ptr = media_find_id(media_type); + m_ptr = media_find_id(a->media_id); if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); else { - unchar *addr = (unchar *)&a->dev_addr; u32 i; - tipc_printf(pb, "UNKNOWN(%u)", media_type); - for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) - tipc_printf(pb, "-%02x", addr[i]); + tipc_printf(pb, "UNKNOWN(%u)", a->media_id); + for (i = 0; i < sizeof(a->value); i++) + tipc_printf(pb, "-%02x", a->value[i]); } } -- cgit v1.2.3