コード例 #1
0
PROCESS_THREAD(ctk_conio_service_process, ev, data) {
  PROCESS_BEGIN();

  s_ctk_draw_init();
  ctk_restore();

  SERVICE_REGISTER(ctk_conio_service);

  while(ev != PROCESS_EVENT_SERVICE_REMOVED &&
	ev != PROCESS_EVENT_EXIT) {
    PROCESS_WAIT_EVENT();
  }

  SERVICE_REMOVE(ctk_conio_service);
  
  PROCESS_END();
}
コード例 #2
0
/*--------------------------------------------------------------------------*/
EK_EVENTHANDLER(eventhandler, ev, data)
{
  EK_EVENTHANDLER_ARGS(ev, data);
  
  switch(ev) {
  case EK_EVENT_INIT:
  case EK_EVENT_REPLACE:
    s_ctk_draw_init();
    ctk_restore();
    break;
  case EK_EVENT_REQUEST_REPLACE:
    VIC.ctrl1 = 0x1b;  /* $D011 */
    VIC.addr  = 0x17;  /* $D018 */
    VIC.ctrl2 = 0xc8;  /* $D016 */
    CIA2.pra  = 0x03;  /* $DD00 */
    ek_replace((struct ek_proc *)data, NULL);
    LOADER_UNLOAD();
    break;    
  }
}
コード例 #3
0
ファイル: contiki-main.c プロジェクト: PorterNan/RPLSecurity
/*-----------------------------------------------------------------------------------*/
int
main(void)
{
    process_init();

    procinit_init();

#ifdef PLATFORM_BUILD
    program_handler_add(&directory_dsc, "Directory",   1);
    program_handler_add(&www_dsc,       "Web browser", 1);
#endif /* PLATFORM_BUILD */

    autostart_start(autostart_processes);

#if !UIP_CONF_IPV6
    {
        uip_ipaddr_t addr;
        uip_ipaddr(&addr, 192,168,0,111);
        uip_sethostaddr(&addr);
        log_message("IP Address:  ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 255,255,255,0);
        uip_setnetmask(&addr);
        log_message("Subnet Mask: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        uip_setdraddr(&addr);
        log_message("Def. Router: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        resolv_conf(&addr);
        log_message("DNS Server:  ", inet_ntoa(*(struct in_addr*)&addr));
    }

#else /* UIP_CONF_IPV6 */

#if !UIP_CONF_IPV6_RPL
#ifdef HARD_CODED_ADDRESS
    uip_ipaddr_t ipaddr;
    uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
    if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
#if UIP_CONF_ROUTER
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
#else /* UIP_CONF_ROUTER */
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
#endif /* UIP_CONF_ROUTER */
#if !UIP_CONF_IPV6_RPL
        uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
        uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif
    }
#endif /* HARD_CODED_ADDRESS */
#endif
#endif

    while(1) {

        process_run();

        etimer_request_poll();

        /* Allow user-mode APC to execute. */
        SleepEx(10, TRUE);

#ifdef PLATFORM_BUILD
        if(console_resize()) {
            ctk_restore();
        }
#endif /* PLATFORM_BUILD */
    }
}
コード例 #4
0
ファイル: www.c プロジェクト: 21moons/contiki
/* www_process():
 *
 * The program's signal dispatcher function. Is called whenever a signal arrives.
 */
PROCESS_THREAD(www_process, ev, data)
{
    static struct ctk_widget *w;
#if WWW_CONF_WITH_WGET
    static char *argptr;
#endif /* WWW_CONF_WITH_WGET */

    w = (struct ctk_widget *)data;

    PROCESS_BEGIN();

    /* Create the main window. */
    memset(webpage, 0, sizeof(webpage));
    ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
                   WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
    make_window();
#ifdef WWW_CONF_HOMEPAGE
    strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
#endif /* WWW_CONF_HOMEPAGE */
    CTK_WIDGET_FOCUS(&mainwindow, &urlentry);

#if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC)
#if CTK_CONF_WINDOWS
    /* Create download dialog.*/
    ctk_dialog_new(&wgetdialog, 38, 7);
    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1);
    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2);
    CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton);
    CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton);
#endif /* CTK_CONF_WINDOWS */
#endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */

    ctk_window_open(&mainwindow);

    while(1) {

        PROCESS_WAIT_EVENT();

        if(ev == tcpip_event) {
            webclient_appcall(data);
        } else if(ev == ctk_signal_widget_activate) {
            if(w == (struct ctk_widget *)&gobutton ||
                    w == (struct ctk_widget *)&urlentry) {
                start_loading();
                firsty = 0;
#if WWW_CONF_HISTORY_SIZE > 0
                log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
                memcpy(url, editurl, WWW_CONF_MAX_URLLEN);
                petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN);
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &gobutton);
#if WWW_CONF_HISTORY_SIZE > 0
            } else if(w == (struct ctk_widget *)&backbutton) {
                firsty = 0;
                start_loading();
                --history_last;
                if(history_last > WWW_CONF_HISTORY_SIZE) {
                    history_last = WWW_CONF_HISTORY_SIZE - 1;
                }
                memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
            } else if(w == (struct ctk_widget *)&downbutton) {
                firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
                start_loading();
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
            } else if(w == (struct ctk_widget *)&stopbutton) {
                loading = 0;
                webclient_close();
#if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC)
            } else if(w == (struct ctk_widget *)&wgetnobutton) {
#if CTK_CONF_WINDOWS
                ctk_dialog_close();
#else /* CTK_CONF_WINDOWS */
                clear_page();
#endif /* CTK_CONF_WINDOWS */
            } else if(w == (struct ctk_widget *)&wgetyesbutton) {
#if CTK_CONF_WINDOWS
                ctk_dialog_close();
#else /* CTK_CONF_WINDOWS */
                clear_page();
#endif /* CTK_CONF_WINDOWS */
#if WWW_CONF_WITH_WGET
                quit();
                argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN);
                if(argptr != NULL) {
                    strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
                }
                program_handler_load("wget.prg", argptr);
#else /* WWW_CONF_WITH_WGET */
                petsciiconv_topetscii(url, sizeof(url));
                /* Clear screen */
                ctk_restore();
                WWW_CONF_WGET_EXEC(url);
                redraw_window();
                show_statustext("Cannot exec wget");
#endif /* WWW_CONF_WITH_WGET */
#endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */
#if WWW_CONF_FORMS
            } else {
                /* Assume form widget. */
                struct inputattrib *input = (struct inputattrib *)
                                            (((char *)w) - offsetof(struct inputattrib, widget));
                formsubmit(input->formptr);
#endif /* WWW_CONF_FORMS */
            }
        } else if(ev == ctk_signal_hyperlink_activate) {
            firsty = 0;
#if WWW_CONF_HISTORY_SIZE > 0
            log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
            set_link(w->widget.hyperlink.url);
            show_url();
            open_url();
            start_loading();
            CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
        } else if(ev == ctk_signal_hyperlink_hover) {
            if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) {
                strncpy(statustexturl, w->widget.hyperlink.url,
                        sizeof(statustexturl));
                petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
                show_statustext(statustexturl);
            }
#if UIP_UDP
        } else if(ev == resolv_event_found) {
            /* Either found a hostname, or not. */
            if((char *)data != NULL &&
                    resolv_lookup((char *)data, NULL) == RESOLV_STATUS_CACHED) {
                open_url();
            } else {
                show_statustext("Host not found");
            }
#endif /* UIP_UDP */
        } else if(ev == ctk_signal_window_close ||
                  ev == PROCESS_EVENT_EXIT) {
            quit();
        }
    }
コード例 #5
0
ファイル: contiki-main.c プロジェクト: kerlyn-bsd3/contiki
int
main(int argc, char **argv)
{
    contiki_argc = argc;
    contiki_argv = argv;

    /* The first one or two args are used for wpcap configuration */
    /* so this needs to be "removed" from  contiki_args.          */
    contiki_argc--;
    contiki_argv++;
#ifdef UIP_FALLBACK_INTERFACE
    contiki_argc--;
    contiki_argv++;
#endif

    process_init();

    procinit_init();

#ifdef PLATFORM_BUILD
    program_handler_add(&directory_dsc, "Directory",   1);
    program_handler_add(&www_dsc,       "Web browser", 1);
#endif /* PLATFORM_BUILD */

    autostart_start(autostart_processes);

#if !NETSTACK_CONF_WITH_IPV6
    {
        uip_ipaddr_t addr;
        uip_ipaddr(&addr, 192,168,0,111);
        uip_sethostaddr(&addr);
        log_message("IP Address:  ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 255,255,255,0);
        uip_setnetmask(&addr);
        log_message("Subnet Mask: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        uip_setdraddr(&addr);
        log_message("Def. Router: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME);
        log_message("DNS Server:  ", inet_ntoa(*(struct in_addr*)&addr));
    }

#else /* NETSTACK_CONF_WITH_IPV6 */

#if !UIP_CONF_IPV6_RPL
#ifdef HARD_CODED_ADDRESS
    uip_ipaddr_t ipaddr;
    uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
    if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
#if UIP_CONF_ROUTER
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
#else /* UIP_CONF_ROUTER */
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
#endif /* UIP_CONF_ROUTER */
#if !UIP_CONF_IPV6_RPL
        uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
        uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif
    }
#endif /* HARD_CODED_ADDRESS */
#endif
#endif

    while(1) {

        process_run();

        etimer_request_poll();

        /* Allow user-mode APC to execute. */
        SleepEx(10, TRUE);

#ifdef PLATFORM_BUILD
        if(console_resize()) {
            ctk_restore();
        }
#endif /* PLATFORM_BUILD */
    }
}
コード例 #6
0
ファイル: contiki-main.c プロジェクト: msolters/6lbr
int
main(int argc, char **argv)
{
#if NETSTACK_CONF_WITH_IPV6
#if UIP_CONF_IPV6_RPL
  printf(CONTIKI_VERSION_STRING " started with IPV6, RPL\n");
#else
  printf(CONTIKI_VERSION_STRING " started with IPV6\n");
#endif
#else
  printf(CONTIKI_VERSION_STRING " started\n");
#endif

  /* crappy way of remembering and accessing argc/v */
  contiki_argc = argc;
  contiki_argv = argv;

  /* native under windows is hardcoded to use the first one or two args */
  /* for wpcap configuration so this needs to be "removed" from         */
  /* contiki_args (used by the native-border-router) */
#ifdef __CYGWIN__
  contiki_argc--;
  contiki_argv++;
#ifdef UIP_FALLBACK_INTERFACE
  contiki_argc--;
  contiki_argv++;
#endif
#endif

  process_init();
  process_start(&etimer_process, NULL);
  ctimer_init();
  rtimer_init();

#if WITH_GUI
  process_start(&ctk_process, NULL);
#endif

  set_rime_addr();

  netstack_init();
  printf("MAC %s RDC %s SEC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_LLSEC.name, NETSTACK_NETWORK.name);

#if ! CETIC_6LBR
#if NETSTACK_CONF_WITH_IPV6
  queuebuf_init();

  memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));

  process_start(&tcpip_process, NULL);
#ifdef __CYGWIN__
  process_start(&wpcap_process, NULL);
#endif
  printf("Tentative link-local IPv6 address ");
  {
    uip_ds6_addr_t *lladdr;
    int i;
    lladdr = uip_ds6_get_link_local(-1);
    for(i = 0; i < 7; ++i) {
      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
             lladdr->ipaddr.u8[i * 2 + 1]);
    }
    /* make it hardcoded... */
    lladdr->state = ADDR_AUTOCONF;

    printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
  }
#elif NETSTACK_CONF_WITH_IPV4
  process_start(&tcpip_process, NULL);
#endif
#endif

  serial_line_init();

  autostart_start(autostart_processes);

  /* Make standard output unbuffered. */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);

#if ! CETIC_6LBR
  select_set_callback(STDIN_FILENO, &stdin_fd);
#endif
  while(1) {
    fd_set fdr;
    fd_set fdw;
    int maxfd;
    int i;
    int retval;
    struct timeval tv;

    retval = process_run();

    tv.tv_sec = 0;
    tv.tv_usec = retval ? 1 : SELECT_TIMEOUT;

    FD_ZERO(&fdr);
    FD_ZERO(&fdw);
    maxfd = 0;
    for(i = 0; i <= select_max; i++) {
      if(select_callback[i] != NULL && select_callback[i]->set_fd(&fdr, &fdw)) {
        maxfd = i;
      }
    }

    retval = select(maxfd + 1, &fdr, &fdw, NULL, &tv);
    if(retval < 0) {
      if(errno != EINTR) {
        perror("select");
      }
    } else if(retval > 0) {
      /* timeout => retval == 0 */
      for(i = 0; i <= maxfd; i++) {
        if(select_callback[i] != NULL) {
          select_callback[i]->handle_fd(&fdr, &fdw);
        }
      }
    }

    etimer_request_poll();

#if WITH_GUI
    if(console_resize()) {
       ctk_restore();
    }
#endif /* WITH_GUI */
  }

  return 0;
}