"Fossies" - the Fresh Open Source Software archive 
Member "open-fcoe/usr/common/libfc/src/fc/fc_wwn_from_wwn.c" of archive open-fcoe.tar.gz:
/*
* Copyright(c) 2007 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Maintained at www.Open-FCoE.org
*/
#include "net_types.h"
#include "sa_log.h"
#include "sa_assert.h"
#include "fc_types.h"
/*
* Convert 48-bit IEEE OUI to 64-bit FC WWN.
*/
fc_wwn_t fc_wwn_from_wwn(fc_wwn_t wwn, u_int scheme, u_int port)
{
u_int64_t mac;
u_int64_t vend;
switch (wwn >> 60) { /* get OUI and vendor-specified field */
case 0:
case 1:
mac = wwn & ((1ULL << 48) - 1);
vend = port;
break;
case 2:
ASSERT(port < 0x1000);
mac = wwn & ((1ULL << 48) - 1);
vend = ((wwn >> 48) + port) & 0xfff;
break;
default:
ASSERT_NOTREACHED;
mac = vend = 0;
break;
}
wwn = fc_wwn_from_mac(mac, scheme, vend);
return wwn;
}