|
|
@ -119,7 +119,7 @@ buf_bufto(register struct psock_buf *buf, u8_t endmarker,
|
|
|
|
++buf->ptr;
|
|
|
|
++buf->ptr;
|
|
|
|
--*datalen;
|
|
|
|
--*datalen;
|
|
|
|
--buf->left;
|
|
|
|
--buf->left;
|
|
|
|
|
|
|
|
|
|
|
|
if(c == endmarker) {
|
|
|
|
if(c == endmarker) {
|
|
|
|
return BUF_FOUND;
|
|
|
|
return BUF_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -133,12 +133,12 @@ buf_bufto(register struct psock_buf *buf, u8_t endmarker,
|
|
|
|
c = **dataptr;
|
|
|
|
c = **dataptr;
|
|
|
|
--*datalen;
|
|
|
|
--*datalen;
|
|
|
|
++*dataptr;
|
|
|
|
++*dataptr;
|
|
|
|
|
|
|
|
|
|
|
|
if(c == endmarker) {
|
|
|
|
if(c == endmarker) {
|
|
|
|
return BUF_FOUND | BUF_FULL;
|
|
|
|
return BUF_FOUND | BUF_FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return BUF_FULL;
|
|
|
|
return BUF_FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
@ -178,7 +178,7 @@ PT_THREAD(psock_send(register struct psock *s, const char *buf,
|
|
|
|
unsigned int len))
|
|
|
|
unsigned int len))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PT_BEGIN(&s->psockpt);
|
|
|
|
PT_BEGIN(&s->psockpt);
|
|
|
|
|
|
|
|
( void ) PT_YIELD_FLAG;
|
|
|
|
/* If there is no data to send, we exit immediately. */
|
|
|
|
/* If there is no data to send, we exit immediately. */
|
|
|
|
if(len == 0) {
|
|
|
|
if(len == 0) {
|
|
|
|
PT_EXIT(&s->psockpt);
|
|
|
|
PT_EXIT(&s->psockpt);
|
|
|
@ -209,7 +209,7 @@ PT_THREAD(psock_send(register struct psock *s, const char *buf,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
PT_END(&s->psockpt);
|
|
|
|
PT_END(&s->psockpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
@ -217,7 +217,7 @@ PT_THREAD(psock_generator_send(register struct psock *s,
|
|
|
|
unsigned short (*generate)(void *), void *arg))
|
|
|
|
unsigned short (*generate)(void *), void *arg))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PT_BEGIN(&s->psockpt);
|
|
|
|
PT_BEGIN(&s->psockpt);
|
|
|
|
|
|
|
|
( void ) PT_YIELD_FLAG;
|
|
|
|
/* Ensure that there is a generator function to call. */
|
|
|
|
/* Ensure that there is a generator function to call. */
|
|
|
|
if(generate == NULL) {
|
|
|
|
if(generate == NULL) {
|
|
|
|
PT_EXIT(&s->psockpt);
|
|
|
|
PT_EXIT(&s->psockpt);
|
|
|
@ -228,7 +228,7 @@ PT_THREAD(psock_generator_send(register struct psock *s,
|
|
|
|
s->sendlen = generate(arg);
|
|
|
|
s->sendlen = generate(arg);
|
|
|
|
s->sendptr = uip_appdata;
|
|
|
|
s->sendptr = uip_appdata;
|
|
|
|
|
|
|
|
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
/* Call the generator function again if we are called to perform a
|
|
|
|
/* Call the generator function again if we are called to perform a
|
|
|
|
retransmission. */
|
|
|
|
retransmission. */
|
|
|
@ -238,9 +238,9 @@ PT_THREAD(psock_generator_send(register struct psock *s,
|
|
|
|
/* Wait until all data is sent and acknowledged. */
|
|
|
|
/* Wait until all data is sent and acknowledged. */
|
|
|
|
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
|
|
|
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
|
|
|
} while(s->sendlen > 0);
|
|
|
|
} while(s->sendlen > 0);
|
|
|
|
|
|
|
|
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
s->state = STATE_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
PT_END(&s->psockpt);
|
|
|
|
PT_END(&s->psockpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
@ -273,9 +273,9 @@ psock_newdata(struct psock *s)
|
|
|
|
PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
|
|
|
PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PT_BEGIN(&psock->psockpt);
|
|
|
|
PT_BEGIN(&psock->psockpt);
|
|
|
|
|
|
|
|
( void ) PT_YIELD_FLAG;
|
|
|
|
buf_setup(&psock->buf, (unsigned char*)psock->bufptr, psock->bufsize);
|
|
|
|
buf_setup(&psock->buf, (unsigned char*)psock->bufptr, psock->bufsize);
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
|
|
|
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
|
|
|
incoming data has been handled while waiting for a write. */
|
|
|
|
incoming data has been handled while waiting for a write. */
|
|
|
|
|
|
|
|
|
|
|
@ -289,7 +289,7 @@ PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
|
|
|
} while((buf_bufto(&psock->buf, c,
|
|
|
|
} while((buf_bufto(&psock->buf, c,
|
|
|
|
&psock->readptr,
|
|
|
|
&psock->readptr,
|
|
|
|
&psock->readlen) & BUF_FOUND) == 0);
|
|
|
|
&psock->readlen) & BUF_FOUND) == 0);
|
|
|
|
|
|
|
|
|
|
|
|
if(psock_datalen(psock) == 0) {
|
|
|
|
if(psock_datalen(psock) == 0) {
|
|
|
|
psock->state = STATE_NONE;
|
|
|
|
psock->state = STATE_NONE;
|
|
|
|
PT_RESTART(&psock->psockpt);
|
|
|
|
PT_RESTART(&psock->psockpt);
|
|
|
@ -300,9 +300,9 @@ PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
|
|
|
PT_THREAD(psock_readbuf(register struct psock *psock))
|
|
|
|
PT_THREAD(psock_readbuf(register struct psock *psock))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PT_BEGIN(&psock->psockpt);
|
|
|
|
PT_BEGIN(&psock->psockpt);
|
|
|
|
|
|
|
|
( void ) PT_YIELD_FLAG;
|
|
|
|
buf_setup(&psock->buf, (unsigned char * ) psock->bufptr, psock->bufsize);
|
|
|
|
buf_setup(&psock->buf, (unsigned char * ) psock->bufptr, psock->bufsize);
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
|
|
|
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
|
|
|
incoming data has been handled while waiting for a write. */
|
|
|
|
incoming data has been handled while waiting for a write. */
|
|
|
|
|
|
|
|
|
|
|
|