registering a network device

in my driver i’m trying to register the network device using network ddk api’s .
During the call to reg i get an error of operation not permitted.
So how to resolve this error or what is the source for this error.

my code is as follows.

int net_device_reg(usb_to_eth_t *drv, io_net_self_t *ion, void *dll_hdl)
{
int ret,errno;
printf(“call to register net device\n”);

if(net_device_config(drv) != EOK)
	perror("could not configure device\n");
else
{	
	ret= drv->ion->reg(dll_hdl, &usb_to_eth_entry, &drv->reg_hdl, &drv->cell, &drv->lan_no);
	printf("error no: %d\n",errno);
	printf("\nreturn val %d\n",ret);
	if(ret < 0)
	{
		perror("the error is:\n");
		return -1;
	}
	else
	{
	//	printf("net device registered\n");
		printf("interface returned: %d\n ",drv->lan_no);
		printf("cell no: %d\n ",drv->cell);
		printf("interface allocated: %d\n ",drv->cfg.lan);
		return 0;
	}
}
return 0;

}

Priyanka,

I’ve never used the network DDK but this sounds like your program doesn’t have the right privileges.

Even if you are running as root some I/O operations specifically must make a ThreadCtrl() call in order to access hardware/memory.

The documentation for the net_device_reg() call should mention this.

Tim

Are you running as root?

yes i’m running as root.
i also tried using Thread_ctl but of no use.

int net_device_reg(usb_to_eth_t *drv, io_net_self_t *ion, void *dll_hdl)
{
int ret,errno,ret1;
printf(“call to register net device\n”);

if(net_device_config(drv) != EOK)
	perror("could not configure device\n");
else
{	
	ret1=ThreadCtl(_NTO_TCTL_IO, 0);
	printf("thread ctl ret= %d",ret1);
	ret = drv->ion->reg(dll_hdl, &usb_to_eth_entry, &drv->reg_hdl, &drv->cell, &drv->lan_no);
	printf("error no: %d\n",errno);
	printf("\nreturn val %d\n",ret);
	if(ret < 0)
	{
		perror("the error is:\n");
		return -1;
	}
	else
	{
	//	printf("net device registered\n");
		printf("interface returned: %d\n ",drv->lan_no);
		printf("cell no: %d\n ",drv->cell);
		printf("interface allocated: %d\n ",drv->cfg.lan);
		return 0;
	}
}
return 0;

}

It gave the same error.