Ejemplo n.º 1
0
int selected_interface(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    kernel_pid_t ifs = get_first_interface();

    printf("Using interface: %d\n", ifs);

    return 0;
}
Ejemplo n.º 2
0
void options_set_defaults() {
    char *s;
    /* Should go through the list of interfaces, and find the first one which
     * is up and is not lo or dummy*. */
    options.interface = get_first_interface();
    if (!options.interface)
        options.interface = "eth0";

    options.filtercode = NULL;
    options.netfilter = 0;
    inet_aton("10.0.1.0", &options.netfilternet);
    inet_aton("255.255.255.0", &options.netfiltermask);
    options.dnsresolution = 1;
    options.portresolution = 1;
#ifdef NEED_PROMISCUOUS_FOR_OUTGOING
    options.promiscuous = 1;
    options.promiscuous_but_choosy = 1;
#else
    options.promiscuous = 0;
    options.promiscuous_but_choosy = 0;
#endif
    options.showbars = 1;
    options.showports = OPTION_PORTS_OFF;
    options.aggregate_src = 0;
    options.aggregate_dest = 0;
    options.paused = 0;
    options.showhelp = 0;
    options.bandwidth_in_bytes = 0;
    options.sort = OPTION_SORT_DIV2;
    options.screenfilter = NULL;
    options.freezeorder = 0;
    options.linedisplay = OPTION_LINEDISPLAY_TWO_LINE;
    options.screen_offset = 0;
    options.show_totals = 0;
    options.max_bandwidth = 0; /* auto */
    options.log_scale = 0;
    options.bar_interval = 1;

    /* Figure out the name for the config file */
    s = getenv("HOME");
    if(s != NULL) {
        int i = strlen(s) + 9 + 1;
        options.config_file = xmalloc(i);
        snprintf(options.config_file,i,"%s/.iftoprc",s);
    }
    else {
        options.config_file = xstrdup("iftoprc");
    }
    options.config_file_specified = 0;
    
}
Ejemplo n.º 3
0
int main(void)
{

    puts("Smart Environment Actor Application");

    // initialize RNG
    random_init(time(NULL));

    // Message Queue for receiving potentially fast incoming networking packets
    msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);

    // Initialize GPIO
    gpio_init(LEDRED_PIN, GPIO_OUT);
    gpio_init(LEDYELLOW_PIN, GPIO_OUT);
    gpio_init(LEDGREEN_PIN, GPIO_OUT);

    iface_pid = get_first_interface();

    if (iface_pid < 0) {
        puts("Unable to find an interface to use for wireless communication");
        return 1;
    }

    if (!rpl_init(iface_pid)) {
        puts("error: unable to initialize RPL");
        return 1;
    }

    puts("Joining multicast group on addr " MULTICAST_ADDR);

    add_multicast_address(MULTICAST_ADDR, iface_pid);

    puts("Launching coap server");
    thread_create(_rcv_stack_buf, THREAD_STACKSIZE_DEFAULT, THREAD_PRIORITY_MAIN - 1, 0, _coap_server_thread, NULL , "_coap_server_thread");

    // Taken from the hello world example!
    printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
    printf("This board features a(n) %s MCU.\n", RIOT_MCU);

    char line_buf[SHELL_DEFAULT_BUFSIZE];
    shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

    return 0;
}
Ejemplo n.º 4
0
/* ARGSUSED */
int
main(int argc, char *argv[])
{
	char *root, *interface, *strategy, dummy;
	long len;

	root = interface = strategy = NULL;
	program = argv[0];

	root = get_root_fstype();

	/*
	 * If diskless, perhaps boot properties were used to configure
	 * the interface.
	 */
	if ((strcmp(root, "nfs") == 0) && boot_properties_present()) {
		strategy = "bootprops";

		interface = get_first_interface();
		if (interface == NULL) {
			(void) fprintf(stderr,
			    "%s: cannot identify root interface.\n", program);
			return (2);
		}

		(void) printf("%s %s %s\n", root, interface, strategy);
		return (0);
	}

	/*
	 * Handle the simple case where diskless dhcp tells us everything
	 * we need to know.
	 */
	if ((len = sysinfo(SI_DHCP_CACHE, &dummy, sizeof (dummy))) > 1) {
		/* interface is first thing in cache. */
		strategy = "dhcp";
		interface = alloca(len);
		(void) sysinfo(SI_DHCP_CACHE, interface, len);
		(void) printf("%s %s %s\n", root, interface, strategy);
		return (0);
	}

	/*
	 * We're not "nfs dhcp", "nfs none" is impossible, and we don't handle
	 * "ufs rarp" (consumers are coded to deal with this reality), so
	 * there are three possible situations:
	 *
	 *	1. We're "ufs dhcp" if there are any interfaces which have
	 *	   obtained their addresses through DHCP.  That is, if there
	 *	   are any IFF_UP and non-IFF_VIRTUAL interfaces also have
	 *	   IFF_DHCPRUNNING set.
	 *
	 *	2. We're "ufs none" if our filesystem is local and there
	 *	   are no interfaces which have obtained their addresses
	 *	   through DHCP.
	 *
	 *	3. We're "nfs rarp" if our filesystem is remote and there's
	 *	   at least IFF_UP non-IFF_VIRTUAL interface (which there
	 *	   *must* be, since we're running over NFS somehow), then
	 *	   it must be RARP since SI_DHCP_CACHE call above failed.
	 *	   It's too bad there isn't an IFF_RARPRUNNING flag.
	 */

	interface = get_first_interface();

	if (check_dhcp_running(interface))
		strategy = "dhcp";

	if (strcmp(root, "nfs") == 0 || strcmp(root, "cachefs") == 0) {
		if (interface == NULL) {
			(void) fprintf(stderr,
			    "%s: cannot identify root interface.\n", program);
			return (2);
		}
		if (strategy == NULL)
			strategy = "rarp";	/*  must be rarp/bootparams */
	} else {
		if (interface == NULL || strategy == NULL)
			interface = strategy = "none";
	}

	(void) printf("%s %s %s\n", root, interface, strategy);
	return (0);
}