Skip to content

Commit d76a436

Browse files
Erik Hugnedavem330
authored andcommitted
tipc: make media address offset a common define
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91e2eb5 commit d76a436

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

net/tipc/bearer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*/
5353
#define TIPC_MEDIA_INFO_SIZE 32
5454
#define TIPC_MEDIA_TYPE_OFFSET 3
55+
#define TIPC_MEDIA_ADDR_OFFSET 4
5556

5657
/*
5758
* Identifiers of supported TIPC media types

net/tipc/eth_media.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "core.h"
3838
#include "bearer.h"
3939

40-
#define ETH_ADDR_OFFSET 4 /* MAC addr position inside address field */
41-
4240
/* Convert Ethernet address (media address format) to string */
4341
static int tipc_eth_addr2str(struct tipc_media_addr *addr,
4442
char *strbuf, int bufsz)
@@ -55,7 +53,7 @@ static int tipc_eth_addr2msg(char *msg, struct tipc_media_addr *addr)
5553
{
5654
memset(msg, 0, TIPC_MEDIA_INFO_SIZE);
5755
msg[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
58-
memcpy(msg + ETH_ADDR_OFFSET, addr->value, ETH_ALEN);
56+
memcpy(msg + TIPC_MEDIA_ADDR_OFFSET, addr->value, ETH_ALEN);
5957
return 0;
6058
}
6159

@@ -79,7 +77,7 @@ static int tipc_eth_msg2addr(struct tipc_bearer *b,
7977
char *msg)
8078
{
8179
/* Skip past preamble: */
82-
msg += ETH_ADDR_OFFSET;
80+
msg += TIPC_MEDIA_ADDR_OFFSET;
8381
return tipc_eth_raw2addr(b, addr, msg);
8482
}
8583

0 commit comments

Comments
 (0)