aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/eth_media.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-10-07 15:19:11 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-12-27 11:33:36 -0500
commit3d749a6a26b0811b4b2bb4ec2c47cd630a6bbf88 (patch)
tree57616bd9e10a70b9146cb46ccd8905ee2a75475d /net/tipc/eth_media.c
parent4d163a326fa4868cce1bb75dd95855d40e5497c6 (diff)
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 <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/eth_media.c')
-rw-r--r--net/tipc/eth_media.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index ebba0fcd937e..3b75c0d656d9 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -54,18 +54,24 @@ struct eth_bearer {
54 struct packet_type tipc_packet_type; 54 struct packet_type tipc_packet_type;
55}; 55};
56 56
57static struct media eth_media_info;
57static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; 58static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
58static int eth_started; 59static int eth_started;
59static struct notifier_block notifier; 60static struct notifier_block notifier;
60 61
61/** 62/**
62 * eth_media_addr_set - initialize Ethernet media address structure 63 * eth_media_addr_set - initialize Ethernet media address structure
64 *
65 * Media-dependent "value" field stores MAC address in first 6 bytes
66 * and zeroes out the remaining bytes.
63 */ 67 */
64 68
65static void eth_media_addr_set(struct tipc_media_addr *a, char *mac) 69static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
66{ 70{
67 a->type = htonl(TIPC_MEDIA_TYPE_ETH); 71 memcpy(a->value, mac, ETH_ALEN);
68 memcpy(&a->dev_addr.eth_addr, mac, ETH_ALEN); 72 memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
73 a->media_id = TIPC_MEDIA_TYPE_ETH;
74 a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN);
69} 75}
70 76
71/** 77/**
@@ -94,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
94 100
95 skb_reset_network_header(clone); 101 skb_reset_network_header(clone);
96 clone->dev = dev; 102 clone->dev = dev;
97 dev_hard_header(clone, dev, ETH_P_TIPC, &dest->dev_addr.eth_addr, 103 dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
98 dev->dev_addr, clone->len); 104 dev->dev_addr, clone->len);
99 dev_queue_xmit(clone); 105 dev_queue_xmit(clone);
100 return 0; 106 return 0;
@@ -256,12 +262,10 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
256 262
257static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) 263static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
258{ 264{
259 unchar *addr = (unchar *)&a->dev_addr;
260
261 if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ 265 if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
262 return 1; 266 return 1;
263 267
264 sprintf(str_buf, "%pM", addr); 268 sprintf(str_buf, "%pM", a->value);
265 return 0; 269 return 0;
266} 270}
267 271
@@ -293,7 +297,7 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
293{ 297{
294 memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE); 298 memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE);
295 msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH; 299 msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
296 memcpy(msg_area + ETH_ADDR_OFFSET, a->dev_addr.eth_addr, ETH_ALEN); 300 memcpy(msg_area + ETH_ADDR_OFFSET, a->value, ETH_ALEN);
297 return 0; 301 return 0;
298} 302}
299 303
@@ -322,8 +326,8 @@ static struct media eth_media_info = {
322 .str2addr = eth_str2addr, 326 .str2addr = eth_str2addr,
323 .addr2msg = eth_addr2msg, 327 .addr2msg = eth_addr2msg,
324 .msg2addr = eth_msg2addr, 328 .msg2addr = eth_msg2addr,
325 .bcast_addr = { htonl(TIPC_MEDIA_TYPE_ETH), 329 .bcast_addr = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
326 { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } }, 330 TIPC_MEDIA_TYPE_ETH, 1 },
327 .priority = TIPC_DEF_LINK_PRI, 331 .priority = TIPC_DEF_LINK_PRI,
328 .tolerance = TIPC_DEF_LINK_TOL, 332 .tolerance = TIPC_DEF_LINK_TOL,
329 .window = TIPC_DEF_LINK_WIN, 333 .window = TIPC_DEF_LINK_WIN,