Skip to content

Commit

Permalink
tipc: make media address offset a common define
Browse files Browse the repository at this point in the history
With the exception of infiniband media which does not use media
offsets, the media address is always located at offset 4 in the
media info field as defined by the protocol, so we move the
definition to the generic bearer.h

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Erik Hugne authored and David S. Miller committed Feb 27, 2015
1 parent 91e2eb5 commit d76a436
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions net/tipc/bearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*/
#define TIPC_MEDIA_INFO_SIZE 32
#define TIPC_MEDIA_TYPE_OFFSET 3
#define TIPC_MEDIA_ADDR_OFFSET 4

/*
* Identifiers of supported TIPC media types
Expand Down
6 changes: 2 additions & 4 deletions net/tipc/eth_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
#include "core.h"
#include "bearer.h"

#define ETH_ADDR_OFFSET 4 /* MAC addr position inside address field */

/* Convert Ethernet address (media address format) to string */
static int tipc_eth_addr2str(struct tipc_media_addr *addr,
char *strbuf, int bufsz)
Expand All @@ -55,7 +53,7 @@ static int tipc_eth_addr2msg(char *msg, struct tipc_media_addr *addr)
{
memset(msg, 0, TIPC_MEDIA_INFO_SIZE);
msg[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
memcpy(msg + ETH_ADDR_OFFSET, addr->value, ETH_ALEN);
memcpy(msg + TIPC_MEDIA_ADDR_OFFSET, addr->value, ETH_ALEN);
return 0;
}

Expand All @@ -79,7 +77,7 @@ static int tipc_eth_msg2addr(struct tipc_bearer *b,
char *msg)
{
/* Skip past preamble: */
msg += ETH_ADDR_OFFSET;
msg += TIPC_MEDIA_ADDR_OFFSET;
return tipc_eth_raw2addr(b, addr, msg);
}

Expand Down

0 comments on commit d76a436

Please sign in to comment.