static void handle_fd(fd_set *rset, fd_set *wset) { /* Optional delay between outgoing packets */ /* Base delay times number of 6lowpan fragments to be sent */ /* delaymsec = 10; */ if(delaymsec) { struct timeval tv; int dmsec; gettimeofday(&tv, NULL); dmsec=(tv.tv_sec-delaystartsec)*1000+tv.tv_usec/1000-delaystartmsec; if(dmsec<0) delaymsec=0; if(dmsec>delaymsec) delaymsec=0; } if(delaymsec==0) { int size; if(FD_ISSET(tunfd, rset)) { size = tun_input(&uip_buf[UIP_LLH_LEN], sizeof(uip_buf)); /* printf("TUN data incoming read:%d\n", size); */ uip_len = size; tcpip_input(); if(slip_config_basedelay) { struct timeval tv; gettimeofday(&tv, NULL) ; delaymsec=slip_config_basedelay; delaystartsec =tv.tv_sec; delaystartmsec=tv.tv_usec/1000; } } } }
static void handle_fd(fd_set * rset, fd_set * wset) { /* Optional delay between outgoing packets */ /* Base delay times number of 6lowpan fragments to be sent */ /* delaymsec = 10; */ if(delaymsec) { struct timeval tv; int dmsec; gettimeofday(&tv, NULL); dmsec = (tv.tv_sec - delaystartsec) * 1000 + tv.tv_usec / 1000 - delaystartmsec; if(dmsec < 0) delaymsec = 0; if(dmsec > delaymsec) delaymsec = 0; } if(delaymsec == 0) { int size; if(FD_ISSET(tunfd, rset)) { size = tun_input(tmp_tap_buf, sizeof(tmp_tap_buf)); printf("TUN data incoming read:%d\n", size); if(ethernet_has_fcs) { //Remove extra data from packet capture uip_len = size - ETHERNET_LLH_LEN - 4; } else { uip_len = size - ETHERNET_LLH_LEN; } memcpy(ll_header, tmp_tap_buf, ETHERNET_LLH_LEN); memcpy(uip_buf, tmp_tap_buf + ETHERNET_LLH_LEN, uip_len); eth_input(); if(slip_config_basedelay) { struct timeval tv; gettimeofday(&tv, NULL); delaymsec = slip_config_basedelay; delaystartsec = tv.tv_sec; delaystartmsec = tv.tv_usec / 1000; } } } }
static void handle_fd(fd_set * rset, fd_set * wset) { /* Optional delay between outgoing packets */ /* Base delay times number of 6lowpan fragments to be sent */ /* delaymsec = 10; */ if(delaymsec) { struct timeval tv; int dmsec; gettimeofday(&tv, NULL); dmsec = (tv.tv_sec - delaystartsec) * 1000 + tv.tv_usec / 1000 - delaystartmsec; if(dmsec < 0) delaymsec = 0; if(dmsec > delaymsec) delaymsec = 0; } if(delaymsec == 0) { int size; if(FD_ISSET(tunfd, rset)) { size = tun_input(ethernet_tmp_buf, ETHERNET_TMP_BUF_SIZE); eth_drv_input(ethernet_tmp_buf, size); if(slip_config_basedelay) { struct timeval tv; gettimeofday(&tv, NULL); delaymsec = slip_config_basedelay; delaystartsec = tv.tv_sec; delaystartmsec = tv.tv_usec / 1000; } } } }