Skip to content

Commit c722440

Browse files
committed
Add public functions for retrieving the MAC and MTU (paired with
r28344). This commit was SVN r28345. The following SVN revision numbers were found above: r28344 --> e88881c
1 parent e88881c commit c722440

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

opal/util/if.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
13-
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved.
1414
* $COPYRIGHT$
1515
*
1616
* Additional copyrights may follow
@@ -390,6 +390,46 @@ int opal_ifindextomask(int if_index, uint32_t* if_mask, int length)
390390
return OPAL_ERROR;
391391
}
392392

393+
/*
394+
* Lookup the interface by opal_list index and return the
395+
* MAC assigned to the interface.
396+
*/
397+
398+
int btl_usnic_opal_ifindextomac(int if_index, uint8_t mac[6])
399+
{
400+
opal_if_t* intf;
401+
402+
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
403+
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
404+
intf = (opal_if_t*)opal_list_get_next(intf)) {
405+
if (intf->if_index == if_index) {
406+
memcpy(mac, &intf->if_mac, 6);
407+
return OPAL_SUCCESS;
408+
}
409+
}
410+
return OPAL_ERROR;
411+
}
412+
413+
/*
414+
* Lookup the interface by opal_list index and return the
415+
* MTU assigned to the interface.
416+
*/
417+
418+
int btl_usnic_opal_ifindextomtu(int if_index, int *if_mtu)
419+
{
420+
opal_if_t* intf;
421+
422+
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
423+
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
424+
intf = (opal_if_t*)opal_list_get_next(intf)) {
425+
if (intf->if_index == if_index) {
426+
*if_mtu = intf->if_mtu;
427+
return OPAL_SUCCESS;
428+
}
429+
}
430+
return OPAL_ERROR;
431+
}
432+
393433
/*
394434
* Lookup the interface by opal_list index and return the
395435
* flags assigned to the interface.

opal/util/if.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
1313
* reserved.
1414
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
15+
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
1516
* $COPYRIGHT$
1617
*
1718
* Additional copyrights may follow
@@ -154,6 +155,22 @@ OPAL_DECLSPEC int opal_ifindextoaddr(int if_index, struct sockaddr*,
154155
*/
155156
OPAL_DECLSPEC int opal_ifindextomask(int if_index, uint32_t*, int);
156157

158+
/**
159+
* Lookup an interface by index and return its MAC address.
160+
*
161+
* @param if_index (IN) Interface index
162+
* @param if_mac (OUT) Interface's MAC address
163+
*/
164+
OPAL_DECLSPEC int btl_usnic_opal_ifindextomac(int if_index, uint8_t if_mac[6]);
165+
166+
/**
167+
* Lookup an interface by index and return its MTU.
168+
*
169+
* @param if_index (IN) Interface index
170+
* @param if_mtu (OUT) Interface's MTU
171+
*/
172+
OPAL_DECLSPEC int btl_usnic_opal_ifindextomtu(int if_index, int *if_mtu);
173+
157174
/**
158175
* Lookup an interface by index and return its flags.
159176
*

0 commit comments

Comments
 (0)