Beispiel #1
0
void start(void) 
{
	mos_node_id_set(6);
	transportInit(false);
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);

	mos_thread_new (appSend, 384, PRIORITY_NORMAL);
}
/* The start function is automatically called by the operating system,
   for single-threaded applications, treat start() like main(). for multi-
   threaded applications, start each thread in the start() function.*/
void start(void)
{
  /* must start the net thread */
   net_init();

   mos_thread_new(mos_command_daemon, MOS_COMMANDER_STACK_SIZE,
		  PRIORITY_NORMAL);

  /* Initialize the MST backend */
   mst_proto_init();

   uint8_t myaddr = mos_node_id_get();
   
   net_ioctl(MST_PROTO_ID, SET_ADDR, (uint8_t)myaddr);
   net_ioctl(MST_PROTO_ID, SET_DTB, 20);

   //This is the basic app thread
   mos_thread_new(recv, 128, PRIORITY_NORMAL);
   mos_thread_new(send, 128, PRIORITY_NORMAL);
}
void m_thread() {
    dvdrp_filter_list *pred;
    int8_t ret;
    dvdrp_constraint_list *clist_ptr;
    printf("Hello from DV/DRP test recv!\n");

    net_init();
    dvdrp_init();

    //turn down the power to make it easy to test multihop
    com_ioctl(IFACE_RADIO, CC1000_TX_POWER, 1);

    
    ret = net_proto_set(DVDRP_PROTO_ID);
    if(ret == NET_PROTO_INVALID) {
	printf("Invalid proto\n");
    }

    net_event_register(1, recv);

    pred = pool_malloc(&filter_pool);
    pred->next = NULL;

    clist_ptr = pool_malloc(&constraint_pool);
    clist_ptr->name = TEMP_VALUE;
    clist_ptr->value = 0;
    clist_ptr->compare_type = DVDRP_COMPARE_GT;
    pred->constraints = clist_ptr;

    clist_ptr = pool_malloc(&constraint_pool);
    clist_ptr->name = LIGHT_VALUE;
    clist_ptr->value = 150;
    clist_ptr->compare_type = DVDRP_COMPARE_GT;
    clist_ptr->next = NULL;

    pred->constraints->next = clist_ptr;

    net_ioctl(DVDRP_PROTO_ID, DVDRP_IOCTL_SETPRED, pred, 0);

    mos_led_toggle(2);
    
    printf("Waiting for mesgs.\n\n");
}
Beispiel #4
0
void start(void) {
	mos_node_id_set(1);
	
	is_base = false;
	
	// Initialize net layer
	net_init();
		   
	// Start the CTP backends 
	ctp_proto_init();
	
	// Wait a while till the routing is possibly established      
	mos_mdelay(10);
	
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);
	printf("Running net layer and CTP backend... \n");
	
	// transportInit(true);
}
Beispiel #5
0
void start(void) {
	uint16_t power = 31;
	uint8_t retVal = 0;
	
	mos_node_id_set(NODE_ID);
	transportInit(false);
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);
	// net_ioctl(CTP_PROTO_ID, CTP_SET_POWER, power);
	
	// Sleep for 30 sec to allow CTP++ routing to stabilize
	mos_thread_sleep(30000);
	
	printf("Starting appSend thread... \n");
	retVal = mos_thread_new(appSend, 384, PRIORITY_NORMAL);
	if (retVal != THREAD_OK) {
		printf("mos_thread_new retval = %d \n", retVal);
	}
	
	printf("_end = %d \n", (int)&_end);
}
Beispiel #6
0
void start(void) {
	mos_node_id_set(4);
	
	is_base = false;
	
	// Initialize net layer
	net_init();
		   
	// Start the CTP backends 
	ctp_proto_init();
	
	// Wait a while till the routing is possibly established      
	mos_mdelay(10);
	
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);
	com_ioctl_IFACE_RADIO (CC2420_TX_POWER, 30); //set the tx power from 0 (min) to 31 (max)  
	cc2420_set_channel(26);
	printf("Running net layer and CTP backend... \n");
	
	// transportInit(true);
}
Beispiel #7
0
/*
 * Handle the IOCTL system call for the NET devices.  This basically
 * means I/O control for the SOCKET layer (future expansions could be
 * a variable number of socket table entries, et al), and for the more
 * general protocols like ARP.  The latter currently lives in the INET
 * module, so we have to get ugly a tiny little bit.  Later... -FvK
 */
static int
net_fioctl(struct inode *inode, struct file *file,
	   unsigned int cmd, unsigned long arg)
{
  extern int arp_ioctl(unsigned int, void *);

  /* Dispatch on the minor device. */
  switch(MINOR(inode->i_rdev)) {
	case 0:		/* NET (SOCKET) */
		DPRINTF((net_debug, "NET: SOCKET level I/O control request.\n"));
		return(net_ioctl(cmd, arg));
#ifdef CONFIG_INET
	case 1:		/* ARP */
		DPRINTF((net_debug, "NET: ARP level I/O control request.\n"));
		return(arp_ioctl(cmd, (void *) arg));
#endif
	default:
		return(-ENODEV);
  }
  /*NOTREACHED*/
  return(-EINVAL);
}
Beispiel #8
0
static int
dvbdev_ioctl(struct dvb_device *dvbdev, int num,
             struct file *file,	unsigned int cmd, unsigned long arg)
{
	struct dvb_struct *dvb=(struct dvb_struct *) dvbdev->priv;
	//void *parg=(void *)arg;
	int type=num2type(dvb, num);

	switch (type) {
	case DVB_DEVICE_VIDEO_0:
		return video_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_AUDIO_0:
		return audio_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_FRONTEND_0:
		return frontend_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_SEC_0:
		return sec_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_DEMUX_0:
		return demux_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_DVR_0:
		return DmxDevDVRIoctl(&dvb->dmxdev, file, cmd, arg);

	case DVB_DEVICE_CA_0:
		return ca_ioctl(dvbdev, file, cmd, arg);

	case DVB_DEVICE_NET_0:
		return net_ioctl(dvbdev, file, cmd, arg);

	default:
		return -EOPNOTSUPP;
	}
	return 0;
}
Beispiel #9
0
/*
====================
NET_Socket
====================
*/
int NET_Socket (char *net_interface, int port)
{
	int newsocket;
	struct sockaddr_in address;
	qboolean _true = true;
	int	i = 1;

// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Switching to the equivalent function (and data structures) in the platform:
	//if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
	if ((newsocket = net_socket (PF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0)
// <<< FIX
	{
		Com_Printf ("ERROR: UDP_OpenSocket: socket: %s\n", NET_ErrorString());
		return 0;
	}

	// make it non-blocking
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Switching to the equivalent function in the platform:
	//if (ioctl (newsocket, FIONBIO, &_true) == -1)
	if (net_ioctl (newsocket, FIONBIO, &_true) < 0)
// <<< FIX
	{
		Com_Printf ("ERROR: UDP_OpenSocket: ioctl FIONBIO: %s\n", NET_ErrorString());
		return 0;
	}

	// make it broadcast capable
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// SO_BROADCAST cannot be applied to sockets in this platform. Letting it pass:
	//if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
	//{
	//	Com_Printf ("ERROR: UDP_OpenSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString());
	//	return 0;
	//}
// <<< FIX

	if (!net_interface || !net_interface[0] || !stricmp(net_interface, "localhost"))
		address.sin_addr.s_addr = INADDR_ANY;
	else
		NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);

	if (port == PORT_ANY)
		address.sin_port = 0;
	else
		address.sin_port = htons((short)port);

	address.sin_family = AF_INET;

// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Do not bind the socket if port == 0 (part 1):
	if(address.sin_port > 0) 
	{
// <<< FIX
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Switching to the equivalent function in the platform:
	//if( bind (newsocket, (void *)&address, sizeof(address)) == -1)
	if( net_bind (newsocket, (void *)&address, sizeof(address)) < 0)
// <<< FIX
	{
		Com_Printf ("ERROR: UDP_OpenSocket: bind: %s\n", NET_ErrorString());
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Switching to the equivalent function in the library:
		//close (newsocket);
		net_close (newsocket);
// <<< FIX
		return 0;
	}
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Do not bind the socket if port == 0 (part 2):
	}
// <<< FIX

	return newsocket;
}