Ejemplo n.º 1
0
int brctl_main(int argc, char **argv)
{
    if (argc == 1) {
        fprintf(stderr, "try to be professional!\n");
        return -1;
    }
    br_init();
    if (!strcmp(argv[1], "addif")) {
        if (ifexists(argv[3]))
            br_add_interface(argv[2], argv[3]);
    }
    if (!strcmp(argv[1], "delif")) {
        if (ifexists(argv[3]))
            br_del_interface(argv[2], argv[3]);
    }
    if (!strcmp(argv[1], "addbr")) {
        br_add_bridge(argv[2]);
    }
    if (!strcmp(argv[1], "stp")) {
        br_set_stp_state(argv[2], atoi(argv[3]));
    }
    if (!strcmp(argv[1], "delbr")) {
        if (!ifexists(argv[2]))
            return -1;
        br_del_bridge(argv[2]);
    }
    if (!strcmp(argv[1], "show")) {
        br_cmd_show();
    }
    br_shutdown();
}
Ejemplo n.º 2
0
static int br_ioctl_deviceless(unsigned int cmd,
			       unsigned long arg0,
			       unsigned long arg1)
{
	switch (cmd)
	{
	case BRCTL_GET_VERSION:
		return BRCTL_VERSION;

	case BRCTL_GET_BRIDGES:
	{
		int i;
		int indices[64];

		for (i=0;i<64;i++)
			indices[i] = 0;

		if (arg1 > 64)
			arg1 = 64;
		arg1 = br_get_bridge_ifindices(indices, arg1);
		if (copy_to_user((void *)arg0, indices, arg1*sizeof(int)))
			return -EFAULT;

		return arg1;
	}

	case BRCTL_ADD_BRIDGE:
	case BRCTL_DEL_BRIDGE:
	{
		char buf[IFNAMSIZ];

		if (copy_from_user(buf, (void *)arg0, IFNAMSIZ))
			return -EFAULT;

		buf[IFNAMSIZ-1] = 0;

		if (cmd == BRCTL_ADD_BRIDGE)
			return br_add_bridge(buf);

		return br_del_bridge(buf);
	}
	}

	return -EOPNOTSUPP;
}
Ejemplo n.º 3
0
void br_cmd_delbr(struct bridge *br, char *brname, char *arg1)
{
	int err;

	if ((err = br_del_bridge(brname)) == 0)
		return;

	switch (err) {
	case ENXIO:
		fprintf(stderr, "bridge %s doesn't exist; can't delete it\n", brname);
		break;

	case EBUSY:
		fprintf(stderr, "bridge %s is still up; can't delete it\n", brname);
		break;

	default:
		perror("br_del_bridge");
		break;
	}
}
Ejemplo n.º 4
0
static int br_cmd_delbr(int argc, char*const* argv)
{
	int err;

	switch (err = br_del_bridge(argv[1])){
	case 0:
		return 0;

	case ENXIO:
		fprintf(stderr, "bridge %s doesn't exist; can't delete it\n",
			argv[1]);
		return 1;

	case EBUSY:
		fprintf(stderr, "bridge %s is still up; can't delete it\n",
			argv[1]);
		return 1;

	default:
		fprintf(stderr, "can't delete bridge %s: %s\n",
			argv[1], strerror(err));
		return 1;
	}
}
Ejemplo n.º 5
0
static int br_ioctl_deviceless(unsigned int cmd,
			       unsigned long arg0,
			       unsigned long arg1)
{
	switch (cmd)
	{
	case BRCTL_GET_VERSION:
		return BRCTL_VERSION;

	case BRCTL_GET_BRIDGES:
	{
		int i;
		int indices[64];

		for (i=0;i<64;i++)
			indices[i] = 0;

		if (arg1 > 64)
			arg1 = 64;
		arg1 = br_get_bridge_ifindices(indices, arg1);
		if (copy_to_user((void *)arg0, indices, arg1*sizeof(int)))
			return -EFAULT;

		return arg1;
	}

	case BRCTL_ADD_BRIDGE:
	case BRCTL_DEL_BRIDGE:
	{
		char buf[IFNAMSIZ];

		if (copy_from_user(buf, (void *)arg0, IFNAMSIZ))
			return -EFAULT;

		buf[IFNAMSIZ-1] = 0;

		if (cmd == BRCTL_ADD_BRIDGE)
			return br_add_bridge(buf);

		return br_del_bridge(buf);
	}
#ifdef CONFIG_RTK_MESH
	//by brian, dynamic portal enable
	case BRCTL_SET_MESH_PATHSELPID:
		return br_set_meshpathsel_pid(arg0);

	case BRCTL_GET_PORTSTAT:
		{
		struct net_bridge *br;
	
		br = find_br_by_name("br0");
		if (br == NULL)
			return -1;
		else	
			return br->eth0_received;
		}
#endif
	}

	return -EOPNOTSUPP;
}