zoukankan      html  css  js  c++  java
  • kernel随机生成MAC地址的接口

    /**  * eth_random_addr - Generate software assigned random Ethernet address  

    * @addr: Pointer to a six-byte array containing the Ethernet address  *  

    * Generate a random Ethernet address (MAC) that is not multicast  

    * and has the local assigned bit set.  */

    static inline void eth_random_addr(u8 *addr)

    {  

      get_random_bytes(addr, ETH_ALEN);  

      addr[0] &= 0xfe; /* clear multicast bit */  

      addr[0] |= 0x02; /* set local assignment bit (IEEE802) */

    }

    #define random_ether_addr(addr) eth_random_addr(addr)

    /**
     * eth_hw_addr_random - Generate software assigned random Ethernet and
     * set device flag
     * @dev: pointer to net_device structure
     *
     * Generate a random Ethernet address (MAC) to be used by a net device
     * and set addr_assign_type so the state can be read by sysfs and be
     * used by userspace.
     */
    static inline void eth_hw_addr_random(struct net_device *dev)
    {
     dev->addr_assign_type = NET_ADDR_RANDOM;
     eth_random_addr(dev->dev_addr);
    }

  • 相关阅读:
    oracle操作。
    python 多行对应元素求和
    matplotlib 画饼图
    ggplot2 图例及分页参数
    python(3)跳过第一行(多行)读入数据
    seqtk抽取测序数据
    数据库命令补全工具mycli
    取色网站
    perl 转置矩阵
    python 调用系统软件
  • 原文地址:https://www.cnblogs.com/zxc2man/p/6760603.html
Copyright © 2011-2022 走看看