Fixed serious bug which causes RNDIS task to end when non-data message are sent via RNDIS interface
This commit is contained in:
parent
f13ec95efa
commit
b6e76a4947
3 changed files with 32 additions and 16 deletions
|
@ -115,6 +115,8 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
uint8_t bytecounter, headercounter;
|
uint8_t bytecounter, headercounter;
|
||||||
uint16_t i, dataoffset;
|
uint16_t i, dataoffset;
|
||||||
|
clock_time_t timediff;
|
||||||
|
clock_time_t thetime;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
|
@ -212,11 +214,19 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
//Also mark the USB as "in use"
|
//Also mark the USB as "in use"
|
||||||
|
|
||||||
//This is done as "flood control" by only allowing one IP packet per time limit
|
//This is done as "flood control" by only allowing one IP packet per time limit
|
||||||
clock_time_t timediff = clock_time() - flood_timer.start;
|
thetime = clock_time();
|
||||||
|
|
||||||
|
timediff = thetime - flood_timer.start;
|
||||||
|
|
||||||
|
//Oops, timer wrapped! Just ignore it for now
|
||||||
|
if (thetime < flood_timer.start) {
|
||||||
|
timediff = flood_timer.interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//If timer not yet expired
|
//If timer not yet expired
|
||||||
if (timediff < flood_timer.interval) {
|
//if (timediff < flood_timer.interval) {
|
||||||
|
if (!timer_expired(&flood_timer)) {
|
||||||
//Wait until timer expiers
|
//Wait until timer expiers
|
||||||
usb_busy = 1;
|
usb_busy = 1;
|
||||||
etimer_set(&et, flood_timer.interval - timediff);
|
etimer_set(&et, flood_timer.interval - timediff);
|
||||||
|
@ -227,6 +237,7 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
usb_busy = 0;
|
usb_busy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Restart flood timer
|
//Restart flood timer
|
||||||
timer_restart(&flood_timer);
|
timer_restart(&flood_timer);
|
||||||
|
|
||||||
|
@ -236,10 +247,12 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
//Try and read the header in
|
//Try and read the header in
|
||||||
headercounter = sizeof(rndis_data_packet_t);
|
headercounter = sizeof(rndis_data_packet_t);
|
||||||
|
|
||||||
|
uint8_t fail = 0;
|
||||||
|
|
||||||
//Hmm.. what's going on here
|
//Hmm.. what's going on here
|
||||||
if (bytecounter < headercounter) {
|
if (bytecounter < headercounter) {
|
||||||
Usb_ack_receive_out();
|
Usb_ack_receive_out();
|
||||||
break;
|
fail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -253,17 +266,17 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
//This is no good. Probably lost syncronization... just drop it for now
|
//This is no good. Probably lost syncronization... just drop it for now
|
||||||
if(PBUF->MessageType != REMOTE_NDIS_PACKET_MSG) {
|
if(PBUF->MessageType != REMOTE_NDIS_PACKET_MSG) {
|
||||||
Usb_ack_receive_out();
|
Usb_ack_receive_out();
|
||||||
break;
|
fail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//802.3 does not have OOB data, and we don't care about per-packet data
|
||||||
|
//so that just leave regular packet data...
|
||||||
|
if (PBUF->DataLength && (fail == 0)) {
|
||||||
|
|
||||||
//Looks like we've got a live one
|
//Looks like we've got a live one
|
||||||
rx_start_led();
|
rx_start_led();
|
||||||
|
|
||||||
|
|
||||||
//802.3 does not have OOB data, and we don't care about per-packet data
|
|
||||||
//so that just leave regular packet data...
|
|
||||||
if (PBUF->DataLength) {
|
|
||||||
|
|
||||||
//Get offset
|
//Get offset
|
||||||
dataoffset = PBUF->DataOffset;
|
dataoffset = PBUF->DataOffset;
|
||||||
|
|
||||||
|
@ -323,6 +336,7 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
uip_len = PBUF->DataLength; //uip_len includes LLH_LEN
|
uip_len = PBUF->DataLength; //uip_len includes LLH_LEN
|
||||||
mac_ethernetToLowpan(uip_buf);
|
mac_ethernetToLowpan(uip_buf);
|
||||||
|
|
||||||
|
|
||||||
} //if (PBUF->DataLength)
|
} //if (PBUF->DataLength)
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,7 +359,7 @@ PROCESS_THREAD(rndis_process, ev, data_proc)
|
||||||
/**
|
/**
|
||||||
\brief Send data over RNDIS interface, data is in uipbuf and length is uiplen
|
\brief Send data over RNDIS interface, data is in uipbuf and length is uiplen
|
||||||
*/
|
*/
|
||||||
uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen)
|
uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen, uint8_t led)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -390,8 +404,10 @@ uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen)
|
||||||
while(!Is_usb_write_enabled());
|
while(!Is_usb_write_enabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (led) {
|
||||||
tx_end_led();
|
tx_end_led();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Usb_send_in();
|
Usb_send_in();
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
//_____ D E C L A R A T I O N S ____________________________________________
|
//_____ D E C L A R A T I O N S ____________________________________________
|
||||||
|
|
||||||
|
|
||||||
uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen);
|
uint8_t rndis_send(uint8_t * senddata, uint16_t sendlen, uint8_t led);
|
||||||
void sof_action(void);
|
void sof_action(void);
|
||||||
void rx_start_led(void);
|
void rx_start_led(void);
|
||||||
void tx_end_led(void);
|
void tx_end_led(void);
|
||||||
|
|
|
@ -342,7 +342,7 @@ void mac_LowpanToEthernet(void)
|
||||||
|
|
||||||
uip_len += UIP_LLH_LEN;
|
uip_len += UIP_LLH_LEN;
|
||||||
|
|
||||||
rndis_send(uip_buf, uip_len);
|
rndis_send(uip_buf, uip_len, 1);
|
||||||
rndis_stat.rxok++;
|
rndis_stat.rxok++;
|
||||||
uip_len = 0;
|
uip_len = 0;
|
||||||
}
|
}
|
||||||
|
@ -779,7 +779,7 @@ void mac_logTXtoEthernet(frame_create_params_t *p,frame_result_t *frame_result)
|
||||||
|
|
||||||
sendlen += UIP_LLH_LEN;
|
sendlen += UIP_LLH_LEN;
|
||||||
|
|
||||||
rndis_send(raw_buf, sendlen);
|
rndis_send(raw_buf, sendlen, 0);
|
||||||
rndis_stat.rxok++;
|
rndis_stat.rxok++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -832,7 +832,7 @@ void mac_802154raw(const struct mac_driver *r)
|
||||||
|
|
||||||
sendlen += UIP_LLH_LEN;
|
sendlen += UIP_LLH_LEN;
|
||||||
|
|
||||||
rndis_send(raw_buf, sendlen);
|
rndis_send(raw_buf, sendlen, 1);
|
||||||
rndis_stat.rxok++;
|
rndis_stat.rxok++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue