- if(c->protocol_minor >= 2)
- return sptps_receive_data(&c->sptps, bufp, inlen);
+ /* Are we receiving a SPTPS packet? */
+
+ if(c->sptpslen) {
+ int len = MIN(inlen, c->sptpslen - c->inbuf.len);
+ buffer_add(&c->inbuf, bufp, len);
+
+ char *sptpspacket = buffer_read(&c->inbuf, c->sptpslen);
+
+ if(!sptpspacket) {
+ return true;
+ }
+
+ if(!receive_tcppacket_sptps(c, sptpspacket, c->sptpslen)) {
+ return false;
+ }
+
+ c->sptpslen = 0;
+
+ bufp += len;
+ inlen -= len;
+ continue;
+ }
+
+ if(c->protocol_minor >= 2) {
+ int len = sptps_receive_data(&c->sptps, bufp, inlen);
+
+ if(!len) {
+ return false;
+ }
+
+ bufp += len;
+ inlen -= len;
+ continue;
+ }