Example #1
0
void
rfm12_process(void)
{
  uip_len = rfm12_rxfinish();
  if (!uip_len)
    return;

#ifdef ROUTER_SUPPORT
#ifdef RFM12_RAW_SUPPORT
  if (rfm12_raw_conn->rport)
  {
    /* rfm12 raw capturing active, forward in udp/ip encapsulated form,
     * thusly don't push to the stack. */
    /* FIXME This way we cannot accept rfm12_raw requests from anything
     * but ethernet.  This shalt be improved somewhen. */
    uip_stack_set_active(STACK_ENC);
    memmove(uip_buf + UIP_IPUDPH_LEN + UIP_LLH_LEN, rfm12_data, uip_len);
    uip_slen = uip_len;
    uip_udp_conn = rfm12_raw_conn;
    uip_process(UIP_UDP_SEND_CONN);
    router_output();

    uip_buf_unlock();
    rfm12_rxstart();
    return;
  }
#endif /* RFM12_RAW_SUPPORT */

  /* uip_input expects the number of bytes including the LLH. */
  uip_len = uip_len + RFM12_BRIDGE_OFFSET + RFM12_LLH_LEN;
#endif /* not ROUTER_SUPPORT */

  rfm12_rxstart();

  router_input(STACK_RFM12);

  if (uip_len == 0)
  {
    uip_buf_unlock();
    return;                     /* The stack didn't generate any data
                                 * that has to be sent back. */
  }

  /* Application has generated output, send it out. */
  router_output();
}
Example #2
0
void
usb_net_periodic(void)
{
  if (usb_rq_len && (usb_rq_index >= usb_rq_len)) {
    /* A packet arrived, put it into uip */
    uip_len = usb_rq_len + UIP_LLH_LEN;
    usb_rq_len = 0;
    router_input (STACK_USB);

    if (uip_len == 0)
      uip_buf_unlock ();	/* The stack didn't generate any data
				   that has to be sent back. */

    else
      router_output ();         /* Application has generated output,
				   send it out. */
  }
}
Example #3
0
void
openvpn_handle_udp (void)
{
  if (uip_udp_conn->lport != HTONS(OPENVPN_PORT))
    return;
  if (!uip_newdata ())
    return;

  /* Overwrite udp connection information (i.e. take from incoming packet). */
  uip_ipaddr_copy(uip_udp_conn->ripaddr, BUF->srcipaddr);
  uip_udp_conn->rport = BUF->srcport;

  if (openvpn_hmac_verify ())
    {
      printf ("HMAC verification failed.\n");
      return;
    }

  if (openvpn_decrypt_and_verify ())
    {
      printf ("decrypt/verify failed.\n");
      return;
    }

  memmove (uip_buf + BASE_LLH_LEN,
	   uip_buf + OPENVPN_TOTAL_LLH_LEN,
	   uip_len - OPENVPN_HMAC_CRYPT_LEN);

  /* ``uip_len'' is the number of payload bytes (including
     hmac/encryption bits), however uip_process expects the number of
     bytes including a LLH of 14 bytes. */
  uip_len = uip_len + BASE_LLH_LEN - OPENVPN_HMAC_CRYPT_LEN;

  printf ("received a correct packet of %d bytes.\n", uip_len - BASE_LLH_LEN);

  /* Push data back into the router. */
  router_input (STACK_OPENVPN);

  if (! uip_len)
    return;			/* Inner stack hasn't created a
				   packet. */
  openvpn_process_out ();
}