コード例 #1
0
ファイル: br_device.c プロジェクト: nhanh0/hah
static int br_dev_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
	unsigned long args[4];
	unsigned long *data;

	if (cmd != SIOCDEVPRIVATE)
		return -EOPNOTSUPP;

	data = (unsigned long *)rq->ifr_data;
	if (copy_from_user(args, data, 4*sizeof(unsigned long)))
		return -EFAULT;

	return br_ioctl(dev->priv, args[0], args[1], args[2], args[3]);
}
コード例 #2
0
ファイル: acfg_br.c プロジェクト: KHATEEBNSIT/AP
a_status_t acfg_get_br_list()
{
    int i, err;
    int ifindices[32];
    int num, br_socket_fd;
    struct bridge *br;
    struct port *p;

    br_socket_fd = socket(AF_INET, SOCK_STREAM, 0);
    if (br_socket_fd  < 0) {
        return A_STATUS_FAILED;
    }
    num = br_ioctl(br_socket_fd, BRCTL_GET_BRIDGES, 
            (unsigned long) ifindices, 32);
    if (num < 0) {
        return A_STATUS_FAILED;
    }
    for (i = 0; i < num; i++) {

        br = malloc(sizeof(struct bridge));
        memset(br, 0, sizeof(struct bridge));
        br->ifindex = ifindices[i];
        br->firstport = NULL;
        if (if_indextoname(br->ifindex, br->ifname) == NULL) {
            return A_STATUS_FAILED;
        }

        br->next = bridge_list;
        bridge_list = br;
        if ((err = br_make_port_list(br, br_socket_fd)) != 0) {
            return A_STATUS_FAILED;
        }

    }
    br = bridge_list;
    acfg_print("num br = %d\n", num);	
    for (i = 0; i < num; i++) {
        acfg_print("br = %s\n", br->ifname);
        p = br->firstport;
        while (p != NULL) {
            acfg_print("Ii = %s\n", p->ifname);
            p = p->next;
        }		
        br = br->next;		
    }
    return A_STATUS_OK;
}
コード例 #3
0
ファイル: libbridge_init.c プロジェクト: TKr/Wive-ng-rt8186
int br_make_bridge_list()
{
	int err;
	int i;
	int ifindices[32];
	int num;

	num = br_ioctl(BRCTL_GET_BRIDGES, (unsigned long)ifindices, 32);
	if (num < 0)
		return errno;

	bridge_list = NULL;
	for (i=0;i<num;i++) {
		struct bridge *br;

		br = malloc(sizeof(struct bridge));
		memset(br, 0, sizeof(struct bridge));
		br->ifindex = ifindices[i];
		br->firstport = NULL;
		br->next = bridge_list;
		bridge_list = br;
		if ((err = br_read_info(br)) != 0)
			goto error_out;
		if ((err = br_make_port_list(br)) != 0)
			goto error_out;
	}

	return 0;

 error_out:
	while (bridge_list != NULL) {
		struct bridge *nxt;

		nxt = bridge_list->next;
		br_nuke_bridge(bridge_list);
		bridge_list = nxt;
	}

	return err;
}
コード例 #4
0
int br_make_bridge_list()
{
	int i;
	int err;
	int ifindices[1024];
	int num;

	num = br_ioctl(BRCTL_GET_BRIDGES, (unsigned long)ifindices, 1024);
	if (num < 0)
		return errno;

	bridge_list = NULL;
	for (i=0;i<num;i++) {
		struct bridge *br;
		br = br_create_bridge_by_index(ifindices[i]);
		if (!br) {
			goto error_out;
		}

		br->next = bridge_list;
		bridge_list = br;
	}

	return 0;

 error_out:
	while (bridge_list != NULL) {
		struct bridge *nxt;

		nxt = bridge_list->next;
		br_nuke_bridge(bridge_list);
		bridge_list = nxt;
	}

	return err;
}