예제 #1
0
파일: testmmap.c 프로젝트: nkwilson/netmap
void
do_if()
{
	struct netmap_if *nifp;
	unsigned int i;

	nifp = get_if();

	printf("name       %s\n", nifp->ni_name);
	printf("version    %u\n", nifp->ni_version);
	printf("flags      %x", nifp->ni_flags);
	if (nifp->ni_flags) {
		printf(" [");
		if (nifp->ni_flags & NI_PRIV_MEM) {
			printf(" PRIV_MEM");
		}
		printf(" ]");
	}
	printf("\n");
	printf("tx_rings   %u\n", nifp->ni_tx_rings);
	printf("rx_rings   %u\n", nifp->ni_rx_rings);
	printf("bufs_head  %u\n", nifp->ni_bufs_head);
	for (i = 0; i < 5; i++)
		printf("spare1[%d]  %u\n", i, nifp->ni_spare1[i]);
	for (i = 0; i < (nifp->ni_tx_rings + nifp->ni_rx_rings + 2); i++)
		printf("ring_ofs[%d] %ld\n", i, nifp->ring_ofs[i]);
}
예제 #2
0
int
status_addr6(struct in6_addr* addr6, int prefix_len, char* prov_ifname)
{
	char* if_name = get_if(addr6, &prefix_len, prov_ifname);
	if (NULL == if_name) {
		return OCF_NOT_RUNNING;
	}
	return OCF_SUCCESS;
}
예제 #3
0
int
advt_addr6(struct in6_addr* addr6, int prefix_len, char* prov_ifname)
{
	/* First, we need to find a proper device to assign the address */
	char*	if_name = get_if(addr6, &prefix_len, prov_ifname);
	int	i;
	if (NULL == if_name) {
		cl_log(LOG_ERR, "no valid mechanisms");
		return OCF_ERR_GENERIC;
	}
	/* Send unsolicited advertisement packet to neighbor */
	for (i = 0; i < UA_REPEAT_COUNT; i++) {
		send_ua(addr6, if_name);
		sleep(1);
	}
	return OCF_SUCCESS;
}
예제 #4
0
static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
{
        struct net_device *net;
	struct dmx_demux *demux;
	struct dvb_net_priv *priv;
	int result;
	int if_num;
 
	if ((if_num = get_if(dvbnet)) < 0)
		return -EINVAL;

	net = &dvbnet->device[if_num];
	demux = dvbnet->demux;
	
	memset(net, 0, sizeof(struct net_device));

	memcpy(net->name, "dvb0_0", 7);
	net->name[3]   = dvbnet->dvbdev->adapter->num + '0';
	net->name[5]   = if_num + '0';
	net->addr_len  		= 6;
	memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
	net->next      = NULL;
	net->init      = dvb_net_init_dev;

	if (!(net->priv = kmalloc(sizeof(struct dvb_net_priv), GFP_KERNEL)))
		return -ENOMEM;
	
	priv = net->priv;
	memset(priv, 0, sizeof(struct dvb_net_priv));
	priv->demux = demux;
        priv->pid = pid;
	priv->rx_mode = RX_MODE_UNI;

	INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
	INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);

        net->base_addr = pid;
                
	if ((result = register_netdev(net)) < 0) {
		return result;
	}

        return if_num;
}
예제 #5
0
파일: testmmap.c 프로젝트: nkwilson/netmap
struct netmap_ring *
get_ring()
{
	struct netmap_if *nifp;
	char *arg;
	unsigned int ringid;

	/* defaults */
	ringid = 0;

	/* first arg: ring number */
	arg = nextarg();
	if (!arg)
		goto doit;
	ringid = strtoul(arg, NULL, 0);
doit:
	nifp = get_if();
	return NETMAP_TXRING(nifp, ringid);
}
예제 #6
0
static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
{
        struct net_device *net;
	struct dvb_net_priv *priv;
	int result;
	int if_num;
 
	if ((if_num = get_if(dvbnet)) < 0)
		return -EINVAL;

	net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
			   dvb_net_setup);
	if (!net)
		return -ENOMEM;
	
	sprintf(net->name, "dvb%d_%d", dvbnet->dvbdev->adapter->num, if_num);

	net->addr_len  		= 6;
	memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);

	dvbnet->device[if_num] = net;
	
	priv = net->priv;
        priv->demux = dvbnet->demux;
        priv->pid = pid;
	priv->rx_mode = RX_MODE_UNI;

	INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
	INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);

        net->base_addr = pid;
                
	if ((result = register_netdev(net)) < 0) {
		kfree(net);
		return result;
	}

        return if_num;
}
예제 #7
0
int
stop_addr6(struct in6_addr* addr6, int prefix_len, char* prov_ifname)
{
	char* if_name;
	if(OCF_NOT_RUNNING == status_addr6(addr6,prefix_len,prov_ifname)) {
		return OCF_SUCCESS;
	}

	if_name = get_if(addr6, &prefix_len, prov_ifname);

	if (NULL == if_name) {
		cl_log(LOG_ERR, "no valid mechanisms.");
		/* I think this should be a success exit according to LSB. */
		return OCF_ERR_GENERIC;
	}

	/* Unassign the address */
	if (0 != unassign_addr6(addr6, prefix_len, if_name)) {
		cl_log(LOG_ERR, "failed to assign the address to %s", if_name);
		return OCF_ERR_GENERIC;
	}

	return OCF_SUCCESS;
}
예제 #8
0
/* Interface existance check by interface name. */
struct interface * if_lookup_by_name (const char *name)
{
	return get_if ((void *)name, GET_IF_BY_NAME);
}
예제 #9
0
/* Interface existance check by index. */
struct interface * if_lookup_by_index (unsigned int idx)
{
	return get_if ((void *)idx, GET_IF_BY_IFINDEX);
}
예제 #10
0
파일: act.c 프로젝트: CTSRD-CHERI/cherios
act_t * act_register(reg_frame_t *frame, queue_t *queue, const char *name,
							status_e create_in_status, act_control_t *parent, size_t base) {
	(void)parent;
	KERNEL_TRACE("act", "Registering activation %s", name);
	if(kernel_next_act >= MAX_ACTIVATIONS) {
		kernel_panic("no act slot");
	}

	act_t * act = kernel_acts + kernel_next_act;

	act->image_base = base;

	//TODO bit of a hack. the kernel needs to know what namespace service to use
	if(kernel_next_act == namespace_num_namespace) {
		KERNEL_TRACE("act", "found namespace");
		ns_ref = act_create_sealed_ref(act);
	}

#ifndef __LITE__
	/* set name */
	kernel_assert(ACT_NAME_MAX_LEN > 0);
	int name_len = 0;
	if(VCAP(name, 1, VCAP_R)) {
		name_len = imin(cheri_getlen(name), ACT_NAME_MAX_LEN-1);
	}
	for(int i = 0; i < name_len; i++) {
		char c = name[i];
		act->name[i] = c; /* todo: sanitize the name if we do not trust it */
	}
	act->name[name_len] = '\0';
#endif

	/* set status */
	act->status = create_in_status;

/*Some "documentation" for the interface between the kernel and activation start                                        *
* These fields are setup by the caller of act_register                                                                  *
*                                                                                                                       *
* a0    : user GP argument (goes to main)                                                                               *
* c3    : user Cap argument (goes to main)                                                                              *
*                                                                                                                       *
* These fields are setup by act_register itself. Although the queue is an argument to the function                      *
*                                                                                                                       *
* c21   : self control reference                                                 										*
* c23   : namespace reference (may be null for init and namespace)                                                      *
* c24   : kernel interface table                                                                                        *
* c25   : queue                                                                                                        */

	/* set namespace */
	frame->cf_c21 	= (capability)act_create_sealed_ctrl_ref(act);
	frame->cf_c23	= (capability)ns_ref;
	frame->cf_c24	= (capability)get_if();
	frame->cf_c25	= (capability)queue;

	/* set queue */
	msg_queue_init(act, queue);

	/* set expected sequence to not expecting */
	act->sync_state.sync_token = 0;
	act->sync_state.sync_condition = 0;

	/* set scheduling status */
	sched_create(act);

	/*update next_act */
	kernel_next_act++;
	KERNEL_TRACE("register", "image base of %s is %lx", act->name, act->image_base);
	KERNEL_TRACE("act", "%s OK! ", __func__);
	return act;
}