コード例 #1
0
static void addrconf_dev_config(struct device *dev)
{
    struct in6_addr addr;
    struct inet6_dev    * idev;

    if (dev->type != ARPHRD_ETHER) {
        /* Alas, we support only Ethernet autoconfiguration. */
        return;
    }

    idev = addrconf_add_dev(dev);
    if (idev == NULL)
        return;

#ifdef CONFIG_IPV6_EUI64
    memset(&addr, 0, sizeof(struct in6_addr));

    addr.s6_addr[0] = 0xFE;
    addr.s6_addr[1] = 0x80;

    if (ipv6_generate_eui64(addr.s6_addr + 8, dev) == 0)
        addrconf_add_linklocal(idev, &addr);
#endif

#ifndef CONFIG_IPV6_NO_PB
    memset(&addr, 0, sizeof(struct in6_addr));

    addr.s6_addr[0] = 0xFE;
    addr.s6_addr[1] = 0x80;

    memcpy(addr.s6_addr + (sizeof(struct in6_addr) - dev->addr_len),
           dev->dev_addr, dev->addr_len);
    addrconf_add_linklocal(idev, &addr);
#endif
}
コード例 #2
0
ファイル: addrconf.c プロジェクト: hugh712/Jollen
static void addrconf_dev_config(struct net_device *dev)
{
	struct in6_addr addr;
	struct inet6_dev    * idev;

	ASSERT_RTNL();

	if ((dev->type != ARPHRD_ETHER) && 
	    (dev->type != ARPHRD_FDDI) &&
	    (dev->type != ARPHRD_IEEE802_TR)) {
		/* Alas, we support only Ethernet autoconfiguration. */
		return;
	}

	idev = addrconf_add_dev(dev);
	if (idev == NULL)
		return;

	memset(&addr, 0, sizeof(struct in6_addr));

	addr.s6_addr[0] = 0xFE;
	addr.s6_addr[1] = 0x80;

	if (ipv6_generate_eui64(addr.s6_addr + 8, dev) == 0)
		addrconf_add_linklocal(idev, &addr);
}
コード例 #3
0
ファイル: core.c プロジェクト: AK101111/linux
static int lowpan_event(struct notifier_block *unused,
			unsigned long event, void *ptr)
{
	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
	struct inet6_dev *idev;
	struct in6_addr addr;
	int i;

	if (dev->type != ARPHRD_6LOWPAN)
		return NOTIFY_DONE;

	idev = __in6_dev_get(dev);
	if (!idev)
		return NOTIFY_DONE;

	switch (event) {
	case NETDEV_UP:
	case NETDEV_CHANGE:
		/* (802.15.4 6LoWPAN short address slaac handling */
		if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154) &&
		    addrconf_ifid_802154_6lowpan(addr.s6_addr + 8, dev) == 0) {
			__ipv6_addr_set_half(&addr.s6_addr32[0],
					     htonl(0xFE800000), 0);
			addrconf_add_linklocal(idev, &addr, 0);
		}
		break;
	case NETDEV_DOWN:
		for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
			clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE,
				  &lowpan_dev(dev)->ctx.table[i].flags);
		break;
	default:
		return NOTIFY_DONE;
	}

	return NOTIFY_OK;
}