示例#1
0
/**
 * Call ppp_close() inside the tcpip_thread context.
 */
static err_t
pppapi_do_ppp_close(struct tcpip_api_call_data *m)
{
  /* cast through void* to silence alignment warnings. 
   * We know it works because the structs have been instantiated as struct pppapi_msg */
  struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m;

  return ppp_close(msg->msg.ppp, msg->msg.msg.close.nocarrier);
}
示例#2
0
int
ppp_pstn_testing (PSTN_SET * settings)
{
  char buffer[64];
  pppondial_pstn_a ("9172233");
  ppp_options_pstn_a ("visiontek", "ippco123");
  ppp_pstn_a ("9172233", "visiontek", "ippco123", "0.0.0.0", "0.0.0.0",
	      "255.255.255.0");


  //  pppdial_pstn(settings->dialno);
  //  ppp_options(settings->username,settings->password);
  //  ppp_on_dial(settings->dialno);
  lk_dispclr ();
  lk_disptext (2, 0, "Connecting PPP", 0);
  lk_disptext (3, 0, "pls wait...", 0);
  if (ppp_open () < 0)
    {
      lk_dispclr ();
      lk_disptext (2, 0, "ISP Connection", 0);
      lk_disptext (3, 0, "Failed", 0);
      lk_disptext (5, 0, "Press any key", 0);
    }
  else
    {
      get_pstnip ();
      ppp_close ();
      lk_dispclr ();
      lk_disptext (2, 2, "PPP CONN. SUCCESS", 0);
      lk_disptext (3, 0, "WITH", 0);
      lk_disptext (3, 6, pstn_ip, 0);
      lk_disptext (5, 3, "Press any key", 0);
    }
  lk_getkey ();
  return 0;
}
示例#3
0
/**
 * Call ppp_close() inside the tcpip_thread context.
 */
static void
pppapi_do_ppp_close(struct pppapi_msg_msg *msg)
{
  msg->err = ppp_close(msg->ppp, msg->msg.close.nocarrier);
  TCPIP_PPPAPI_ACK(msg);
}
示例#4
0
/**
 * Call ppp_close() inside the tcpip_thread context.
 */
static void pppapi_do_ppp_close(struct pppapi_msg_msg *msg) {
  msg->err = ppp_close(msg->ppp);
  TCPIP_PPPAPI_ACK(msg);
}
示例#5
0
void
main_thread_entry(cyg_addrword_t p)
{
    CYG_TEST_INFO("Initializing lwIP");
    cyg_lwip_simple_init();

    test_state = TEST_CHAT_INIT;
    req_state = REQ_DNS_INIT;

    while (1) {
        cyg_lwip_simple_poll();
        switch (test_state) {
        case TEST_INITIAL:
            diag_printf("INFO:<Starting test run (%d/%d)>\n", run, NUM_RUNS);
            test_state = TEST_CHAT_INIT;
            break;
        case TEST_CHAT_INIT:
            CYG_TEST_INFO("Initializing chat");
            sd = sio_open(SIO_DEV_PPPOS);
            if (!sd)
                CYG_TEST_FAIL_FINISH("Cannot open serial");
            chat = chat_new(sd, chat_items, CHAT_TIMEOUT, chat_cb, chat_send_cb, NULL);
            if (!chat)
                CYG_TEST_FAIL_FINISH("Cannot allocate chat");
            test_state = TEST_CHAT_RUN;
            break;
        case TEST_CHAT_RUN:
            chat_poll(chat);
            break;
        case TEST_CHAT_FINISH:
            chat_free(chat);
            if (chat_ok)
                test_state = TEST_PPP_INIT;
            else
                test_state = TEST_NEXT_RUN;
            break;
        case TEST_PPP_INIT:
            CYG_TEST_INFO("Initializing PPP");
            if (ppp_init() != ERR_OK)
                CYG_TEST_FAIL_FINISH("Cannot initialize PPP");
            pd = ppp_open_serial(sd, ppp_status_cb, (void *) pd);
            if (pd < 0)
                CYG_TEST_FAIL_FINISH("Cannot open PPP over serial");
            ppp_set_auth(PPPAUTHTYPE_ANY, CYGDAT_NET_LWIP_PPP_TEST_USERNAME,
                                          CYGDAT_NET_LWIP_PPP_TEST_PASSWORD);
            test_state = TEST_PPP_INIT_WAIT;
            break;
        case TEST_PPP_INIT_WAIT:
            ppp_poll(pd);
            break;
        case TEST_PPP_UP:
            ppp_poll(pd);
            handle_req_state();
            break;
        case TEST_PPP_CLOSE:
            ppp_close(pd);
            test_state = TEST_PPP_CLOSE_WAIT;
            break;
        case TEST_PPP_CLOSE_WAIT:
            ppp_poll(pd);
            if (!ppp_is_open(pd))
                // Escape from data mode
                sio_write(sd, (u8_t *) "+++", 3);
                cyg_thread_delay(200);
                test_state = TEST_NEXT_RUN;
            break;
        case TEST_NEXT_RUN:
            if (run < NUM_RUNS) {
                run++;
                test_state = TEST_INITIAL;
            } else {
                test_state = TEST_FINISH;
            }
            break;
        case TEST_FINISH:
            test_state = TEST_CHAT_INIT;
            diag_printf("INFO:<Test done (%d/%d) successful runs\n",
                        success, NUM_RUNS);
            break;
        }
        cyg_thread_yield();
    }
}
示例#6
0
/* This is somewhat different to other ports: we have a main loop here:
 * a dedicated task that waits for packets to arrive. This would normally be
 * done from interrupt context with embedded hardware, but we don't get an
 * interrupt in windows for that :-) */
static void
main_loop(void)
{
#if !NO_SYS
  err_t err;
  sys_sem_t init_sem;
#endif /* NO_SYS */
#if USE_PPP
#if !USE_ETHERNET
  int count;
  u8_t rxbuf[1024];
#endif
  volatile int callClosePpp = 0;
#endif /* USE_PPP */

  /* initialize lwIP stack, network interfaces and applications */
#if NO_SYS
  lwip_init();
  test_init(NULL);
#else /* NO_SYS */
  err = sys_sem_new(&init_sem, 0);
  LWIP_ASSERT("failed to create init_sem", err == ERR_OK);
  tcpip_init(test_init, &init_sem);
  /* we have to wait for initialization to finish before
   * calling update_adapter()! */
  sys_sem_wait(&init_sem);
  sys_sem_free(&init_sem);
#endif /* NO_SYS */

#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
  netconn_thread_init();
#endif

  /* MAIN LOOP for driver update (and timers if NO_SYS) */
  while (!_kbhit()) {
#if NO_SYS
    /* handle timers (already done in tcpip.c when NO_SYS=0) */
    sys_check_timeouts();
#endif /* NO_SYS */

#if USE_ETHERNET
#if !PCAPIF_RX_USE_THREAD
    /* check for packets and link status*/
    pcapif_poll(&netif);
    /* When pcapif_poll comes back, there are not packets, so sleep to
       prevent 100% CPU load. Don't do this in an embedded system since it
       increases latency! */
    sys_msleep(1);
#else /* !PCAPIF_RX_USE_THREAD */
    sys_msleep(50);
#endif /* !PCAPIF_RX_USE_THREAD */
#else /* USE_ETHERNET */
    /* try to read characters from serial line and pass them to PPPoS */
    count = sio_read(ppp_sio, (u8_t*)rxbuf, 1024);
    if(count > 0) {
      pppos_input(ppp, rxbuf, count);
    } else {
      /* nothing received, give other tasks a chance to run */
      sys_msleep(1);
    }

#endif /* USE_ETHERNET */
#if USE_SLIPIF
    slipif_poll(&slipif1);
#if USE_SLIPIF > 1
    slipif_poll(&slipif2);
#endif /* USE_SLIPIF > 1 */
#endif /* USE_SLIPIF */
#if ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING
    /* check for loopback packets on all netifs */
    netif_poll_all();
#endif /* ENABLE_LOOPBACK && !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#if USE_PPP
    {
    int do_hup = 0;
    if(do_hup) {
      ppp_close(ppp, 1);
      do_hup = 0;
    }
    }
    if(callClosePpp && ppp) {
      /* make sure to disconnect PPP before stopping the program... */
      callClosePpp = 0;
#if NO_SYS
      ppp_close(ppp, 0);
#else
      pppapi_close(ppp, 0);
#endif
      ppp = NULL;
    }
#endif /* USE_PPP */
  }

#if USE_PPP
    if(ppp) {
      u32_t started;
      printf("Closing PPP connection...\n");
      /* make sure to disconnect PPP before stopping the program... */
#if NO_SYS
      ppp_close(ppp, 0);
#else
      pppapi_close(ppp, 0);
#endif
      ppp = NULL;
      /* Wait for some time to let PPP finish... */
      started = sys_now();
      do
      {
#if USE_ETHERNET && !PCAPIF_RX_USE_THREAD
        pcapif_poll(&netif);
#else /* USE_ETHERNET && !PCAPIF_RX_USE_THREAD */
        sys_msleep(50);
#endif /* USE_ETHERNET && !PCAPIF_RX_USE_THREAD */
        /* @todo: need a better check here: only wait until PPP is down */
      } while(sys_now() - started < 5000);
    }
#endif /* USE_PPP */
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
  netconn_thread_cleanup();
#endif
#if USE_ETHERNET
  /* release the pcap library... */
  pcapif_shutdown(&netif);
#endif /* USE_ETHERNET */
}