コード例 #1
0
ファイル: rose_route.c プロジェクト: kzlin129/tt-gpl
/*
 *	Delete a loopback node.
 */
void rose_del_loopback_node(rose_address *address)
{
    struct rose_node *rose_node;

    spin_lock_bh(&rose_node_list_lock);

    rose_node = rose_node_list;
    while (rose_node != NULL) {
        if ((rose_node->mask == 10) &&
                (rosecmpm(address, &rose_node->address, 10) == 0) &&
                rose_node->loopback)
            break;
        rose_node = rose_node->next;
    }

    if (rose_node == NULL)
        goto out;

    rose_remove_node(rose_node);

    rose_loopback_neigh->count--;

out:
    spin_unlock_bh(&rose_node_list_lock);
}
コード例 #2
0
ファイル: rose_route.c プロジェクト: kzlin129/tt-gpl
/*
 *	Clear all nodes and neighbours out, except for neighbours with
 *	active connections going through them.
 *  Do not clear loopback neighbour and nodes.
 */
static int rose_clear_routes(void)
{
    struct rose_neigh *s, *rose_neigh;
    struct rose_node  *t, *rose_node;

    spin_lock_bh(&rose_node_list_lock);
    spin_lock_bh(&rose_neigh_list_lock);

    rose_neigh = rose_neigh_list;
    rose_node  = rose_node_list;

    while (rose_node != NULL) {
        t         = rose_node;
        rose_node = rose_node->next;
        if (!t->loopback)
            rose_remove_node(t);
    }

    while (rose_neigh != NULL) {
        s          = rose_neigh;
        rose_neigh = rose_neigh->next;

        if (s->use == 0 && !s->loopback) {
            s->count = 0;
            rose_remove_neigh(s);
        }
    }

    spin_unlock_bh(&rose_neigh_list_lock);
    spin_unlock_bh(&rose_node_list_lock);

    return 0;
}
コード例 #3
0
ファイル: rose_route.c プロジェクト: shattered/linux-m68k
/*
 *	"Delete" a node. Strictly speaking remove a route to a node. The node
 *	is only deleted if no routes are left to it.
 */
static int rose_del_node(struct rose_route_struct *rose_route, struct device *dev)
{
	struct rose_node  *rose_node;
	struct rose_neigh *rose_neigh;
	struct rose_route_struct dummy_route;
	int i;

	for (rose_node = rose_node_list; rose_node != NULL; rose_node = rose_node->next)
		if ((rose_node->mask == rose_route->mask) && (rosecmpm(&rose_route->address, &rose_node->address, rose_route->mask) == 0))
			break;

	if (rose_node == NULL) return -EINVAL;

	for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next)
		if (ax25cmp(&rose_route->neighbour, &rose_neigh->callsign) == 0 && rose_neigh->dev == dev)
			break;

	if (rose_neigh == NULL) return -EINVAL;

	for (i = 0; i < rose_node->count; i++) {
		if (rose_node->neighbour[i] == rose_neigh) {
			rose_neigh->count--;

			if (rose_neigh->count == 0) {
				/* Add a dummy node to keep the neighbourg still visible */
				dummy_route = *rose_route;
				dummy_route.mask = 10;
				memset(&dummy_route.address, 0, sizeof(rose_address));
				rose_add_node(&dummy_route, dev);
			}
			/* if (rose_neigh->count == 0 && rose_neigh->use == 0) {
				rose_remove_neigh(rose_neigh);
			} */

			rose_node->count--;

			if (rose_node->count == 0) {
				rose_remove_node(rose_node);
			} else {
				switch (i) {
					case 0:
						rose_node->neighbour[0] = rose_node->neighbour[1];
					case 1:
						rose_node->neighbour[1] = rose_node->neighbour[2];
					case 2:
						break;
				}
			}

			return 0;
		}
	}

	return -EINVAL;
}
コード例 #4
0
ファイル: rose_route.c プロジェクト: dmgerman/original
/*
 *	Delete a loopback node.
 */
void rose_del_loopback_node(rose_address *address)
{
	struct rose_node *rose_node;

	for (rose_node = rose_node_list; rose_node != NULL; rose_node = rose_node->next)
		if ((rose_node->mask == 10) && (rosecmpm(address, &rose_node->address, 10) == 0) && rose_node->loopback)
			break;

	if (rose_node == NULL) return;

	rose_remove_node(rose_node);

	rose_loopback_neigh->count--;
}
コード例 #5
0
ファイル: rose_route.c プロジェクト: dmgerman/original
/*
 *	"Delete" a node. Strictly speaking remove a route to a node. The node
 *	is only deleted if no routes are left to it.
 */
static int rose_del_node(struct rose_route_struct *rose_route, struct net_device *dev)
{
	struct rose_node  *rose_node;
	struct rose_neigh *rose_neigh;
	int i;

	for (rose_node = rose_node_list; rose_node != NULL; rose_node = rose_node->next)
		if ((rose_node->mask == rose_route->mask) && (rosecmpm(&rose_route->address, &rose_node->address, rose_route->mask) == 0))
			break;

	if (rose_node == NULL) return -EINVAL;

	if (rose_node->loopback) return -EINVAL;

	for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next)
		if (ax25cmp(&rose_route->neighbour, &rose_neigh->callsign) == 0 && rose_neigh->dev == dev)
			break;

	if (rose_neigh == NULL) return -EINVAL;

	for (i = 0; i < rose_node->count; i++) {
		if (rose_node->neighbour[i] == rose_neigh) {
			rose_neigh->count--;

			if (rose_neigh->count == 0 && rose_neigh->use == 0)
				rose_remove_neigh(rose_neigh);

			rose_node->count--;

			if (rose_node->count == 0) {
				rose_remove_node(rose_node);
			} else {
				switch (i) {
					case 0:
						rose_node->neighbour[0] = rose_node->neighbour[1];
					case 1:
						rose_node->neighbour[1] = rose_node->neighbour[2];
					case 2:
						break;
				}
			}

			return 0;
		}
	}

	return -EINVAL;
}
コード例 #6
0
ファイル: rose_route.c プロジェクト: kzlin129/tt-gpl
/*
 *	A device has been removed. Remove its routes and neighbours.
 */
void rose_rt_device_down(struct net_device *dev)
{
    struct rose_neigh *s, *rose_neigh;
    struct rose_node  *t, *rose_node;
    int i;

    spin_lock_bh(&rose_node_list_lock);
    spin_lock_bh(&rose_neigh_list_lock);
    rose_neigh = rose_neigh_list;
    while (rose_neigh != NULL) {
        s          = rose_neigh;
        rose_neigh = rose_neigh->next;

        if (s->dev != dev)
            continue;

        rose_node = rose_node_list;

        while (rose_node != NULL) {
            t         = rose_node;
            rose_node = rose_node->next;

            for (i = 0; i < t->count; i++) {
                if (t->neighbour[i] != s)
                    continue;

                t->count--;

                switch (i) {
                case 0:
                    t->neighbour[0] = t->neighbour[1];
                case 1:
                    t->neighbour[1] = t->neighbour[2];
                case 2:
                    break;
                }
            }

            if (t->count <= 0)
                rose_remove_node(t);
        }

        rose_remove_neigh(s);
    }
    spin_unlock_bh(&rose_neigh_list_lock);
    spin_unlock_bh(&rose_node_list_lock);
}
コード例 #7
0
ファイル: rose_route.c プロジェクト: shattered/linux-m68k
/*
 *	A device has been removed. Remove its routes and neighbours.
 */
void rose_rt_device_down(struct device *dev)
{
	struct rose_neigh *s, *rose_neigh = rose_neigh_list;
	struct rose_node  *t, *rose_node;
	int i;

	while (rose_neigh != NULL) {
		s          = rose_neigh;
		rose_neigh = rose_neigh->next;

		if (s->dev == dev) {
			rose_node = rose_node_list;

			while (rose_node != NULL) {
				t         = rose_node;
				rose_node = rose_node->next;

				for (i = 0; i < t->count; i++) {
					if (t->neighbour[i] == s) {
						t->count--;

						switch (i) {
							case 0:
								t->neighbour[0] = t->neighbour[1];
							case 1:
								t->neighbour[1] = t->neighbour[2];
							case 2:
								break;
						}
					}
				}

				if (t->count <= 0)
					rose_remove_node(t);
			}

			rose_remove_neigh(s);
		}
	}
}
コード例 #8
0
ファイル: rose_route.c プロジェクト: shattered/linux-m68k
/*
 *	Clear all nodes and neighbours out, except for neighbours with
 *	active connections going through them.
 */
static int rose_clear_routes(void)
{
	struct rose_neigh *s, *rose_neigh = rose_neigh_list;
	struct rose_node  *t, *rose_node  = rose_node_list;

	while (rose_node != NULL) {
		t         = rose_node;
		rose_node = rose_node->next;

		rose_remove_node(t);
	}

	while (rose_neigh != NULL) {
		s          = rose_neigh;
		rose_neigh = rose_neigh->next;

		s->count = 0;

		if (s->use == 0)
			rose_remove_neigh(s);
	}

	return 0;
}
コード例 #9
0
ファイル: rose_route.c プロジェクト: kzlin129/tt-gpl
/*
 *	"Delete" a node. Strictly speaking remove a route to a node. The node
 *	is only deleted if no routes are left to it.
 */
static int rose_del_node(struct rose_route_struct *rose_route,
                         struct net_device *dev)
{
    struct rose_node  *rose_node;
    struct rose_neigh *rose_neigh;
    int i, err = 0;

    spin_lock_bh(&rose_node_list_lock);
    spin_lock_bh(&rose_neigh_list_lock);

    rose_node = rose_node_list;
    while (rose_node != NULL) {
        if ((rose_node->mask == rose_route->mask) &&
                (rosecmpm(&rose_route->address, &rose_node->address,
                          rose_route->mask) == 0))
            break;
        rose_node = rose_node->next;
    }

    if (rose_node == NULL || rose_node->loopback) {
        err = -EINVAL;
        goto out;
    }

    rose_neigh = rose_neigh_list;
    while (rose_neigh != NULL) {
        if (ax25cmp(&rose_route->neighbour, &rose_neigh->callsign) == 0
                && rose_neigh->dev == dev)
            break;
        rose_neigh = rose_neigh->next;
    }

    if (rose_neigh == NULL) {
        err = -EINVAL;
        goto out;
    }

    for (i = 0; i < rose_node->count; i++) {
        if (rose_node->neighbour[i] == rose_neigh) {
            rose_neigh->count--;

            if (rose_neigh->count == 0 && rose_neigh->use == 0)
                rose_remove_neigh(rose_neigh);

            rose_node->count--;

            if (rose_node->count == 0) {
                rose_remove_node(rose_node);
            } else {
                switch (i) {
                case 0:
                    rose_node->neighbour[0] =
                        rose_node->neighbour[1];
                case 1:
                    rose_node->neighbour[1] =
                        rose_node->neighbour[2];
                case 2:
                    break;
                }
            }
            goto out;
        }
    }
    err = -EINVAL;

out:
    spin_unlock_bh(&rose_neigh_list_lock);
    spin_unlock_bh(&rose_node_list_lock);

    return err;
}