Beispiel #1
0
/*
 *	Manual configuration of address on an interface
 */
static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen)
{
	struct inet6_ifaddr *ifp;
	struct inet6_dev *idev;
	struct net_device *dev;
	int scope;

	ASSERT_RTNL();
	
	if ((dev = __dev_get_by_index(ifindex)) == NULL)
		return -ENODEV;
	
	if (!(dev->flags&IFF_UP))
		return -ENETDOWN;

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

	scope = ipv6_addr_scope(pfx);

	if ((ifp = ipv6_add_addr(idev, pfx, plen, scope, IFA_F_PERMANENT)) != NULL) {
		addrconf_dad_start(ifp);
		in6_ifa_put(ifp);
		return 0;
	}

	return -ENOBUFS;
}
Beispiel #2
0
/*
 *	Manual configuration of address on an interface
 */
static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen)
{
    struct inet6_ifaddr *ifp;
    struct inet6_dev *idev;
    struct device *dev;
    int scope;

    if ((dev = dev_get_by_index(ifindex)) == NULL)
        return -ENODEV;

    if (!(dev->flags&IFF_UP))
        return -ENETDOWN;

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

    scope = ipv6_addr_scope(pfx);

    if ((ifp = ipv6_add_addr(idev, pfx, scope)) == NULL)
        return -ENOMEM;

    ifp->prefix_len = plen;
    ifp->flags |= ADDR_PERMANENT;

    addrconf_dad_start(ifp);
    return 0;
}
Beispiel #3
0
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);
}
Beispiel #4
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
}