1e3cf00d0SUpinder Malhi /* 2e3cf00d0SUpinder Malhi * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. 3e3cf00d0SUpinder Malhi * 43805eadeSJeff Squyres * This software is available to you under a choice of one of two 53805eadeSJeff Squyres * licenses. You may choose to be licensed under the terms of the GNU 63805eadeSJeff Squyres * General Public License (GPL) Version 2, available from the file 73805eadeSJeff Squyres * COPYING in the main directory of this source tree, or the 83805eadeSJeff Squyres * BSD license below: 93805eadeSJeff Squyres * 103805eadeSJeff Squyres * Redistribution and use in source and binary forms, with or 113805eadeSJeff Squyres * without modification, are permitted provided that the following 123805eadeSJeff Squyres * conditions are met: 133805eadeSJeff Squyres * 143805eadeSJeff Squyres * - Redistributions of source code must retain the above 153805eadeSJeff Squyres * copyright notice, this list of conditions and the following 163805eadeSJeff Squyres * disclaimer. 173805eadeSJeff Squyres * 183805eadeSJeff Squyres * - Redistributions in binary form must reproduce the above 193805eadeSJeff Squyres * copyright notice, this list of conditions and the following 203805eadeSJeff Squyres * disclaimer in the documentation and/or other materials 213805eadeSJeff Squyres * provided with the distribution. 22e3cf00d0SUpinder Malhi * 23e3cf00d0SUpinder Malhi * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24e3cf00d0SUpinder Malhi * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25e3cf00d0SUpinder Malhi * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26e3cf00d0SUpinder Malhi * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27e3cf00d0SUpinder Malhi * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28e3cf00d0SUpinder Malhi * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29e3cf00d0SUpinder Malhi * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30e3cf00d0SUpinder Malhi * SOFTWARE. 31e3cf00d0SUpinder Malhi * 32e3cf00d0SUpinder Malhi */ 33e3cf00d0SUpinder Malhi 34e3cf00d0SUpinder Malhi #ifndef USNIC_CMN_UTIL_H 35e3cf00d0SUpinder Malhi #define USNIC_CMN_UTIL_H 36e3cf00d0SUpinder Malhi 37*4d6f2859SYuval Shaia #include <net/addrconf.h> 38*4d6f2859SYuval Shaia 39e3cf00d0SUpinder Malhi static inline void 404942c0b4SUpinder Malhi usnic_mac_ip_to_gid(const char *const mac, const __be32 inaddr, char *raw_gid) 41c7845bcaSUpinder Malhi { 42c7845bcaSUpinder Malhi raw_gid[0] = 0xfe; 43c7845bcaSUpinder Malhi raw_gid[1] = 0x80; 44c7845bcaSUpinder Malhi memset(&raw_gid[2], 0, 2); 45c7845bcaSUpinder Malhi memcpy(&raw_gid[4], &inaddr, 4); 46*4d6f2859SYuval Shaia addrconf_addr_eui48(&raw_gid[8], mac); 47c7845bcaSUpinder Malhi } 48c7845bcaSUpinder Malhi 49e3cf00d0SUpinder Malhi #endif /* USNIC_COMMON_UTIL_H */ 50