Oops! re-add net_read() in testcode

This commit is contained in:
Sukchan Lee
2017-10-20 13:47:43 +09:00
parent 7b1949da6c
commit d40ba2a67c

View File

@@ -88,6 +88,7 @@ int tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf)
{ {
int rc = 0; int rc = 0;
#if USE_USRSCTP == 1
struct socket *psock = (struct socket *)sock; struct socket *psock = (struct socket *)sock;
struct sockaddr_in addr; struct sockaddr_in addr;
char name[INET6_ADDRSTRLEN]; char name[INET6_ADDRSTRLEN];
@@ -98,6 +99,8 @@ int tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf)
struct sctp_rcvinfo rcv_info; struct sctp_rcvinfo rcv_info;
unsigned int infotype; unsigned int infotype;
while(1)
{
n = usrsctp_recvv(psock, recvbuf->payload, MAX_SDU_LEN, n = usrsctp_recvv(psock, recvbuf->payload, MAX_SDU_LEN,
(struct sockaddr *)&addr, &from_len, (void *)&rcv_info, (struct sockaddr *)&addr, &from_len, (void *)&rcv_info,
&infolen, &infotype, &flags); &infolen, &infotype, &flags);
@@ -106,6 +109,7 @@ int tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf)
printf("Notification of length %llu received.\n", printf("Notification of length %llu received.\n",
(unsigned long long)n); (unsigned long long)n);
} else { } else {
c_uint32_t ppid = ntohl(rcv_info.rcv_ppid);
if (infotype == SCTP_RECVV_RCVINFO) { if (infotype == SCTP_RECVV_RCVINFO) {
printf("Msg of length %llu received from %s:%u" printf("Msg of length %llu received from %s:%u"
"on stream %u with SSN %u and TSN %u, PPID %u," "on stream %u with SSN %u and TSN %u, PPID %u,"
@@ -116,14 +120,43 @@ int tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf)
rcv_info.rcv_sid, rcv_info.rcv_sid,
rcv_info.rcv_ssn, rcv_info.rcv_ssn,
rcv_info.rcv_tsn, rcv_info.rcv_tsn,
ntohl(rcv_info.rcv_ppid), ppid,
rcv_info.rcv_context, rcv_info.rcv_context,
(flags & MSG_EOR) ? 1 : 0); (flags & MSG_EOR) ? 1 : 0);
} else { } else {
#if 0
if (ppid == SCTP_S1AP_PPID)
#endif
{
rc = n; rc = n;
break;
} }
} }
} }
}
}
#else
while(1)
{
rc = net_read(sock, recvbuf->payload, recvbuf->len, 0);
if (rc == -2)
{
continue;
}
else if (rc <= 0)
{
if (sock->sndrcv_errno == EAGAIN)
{
continue;
}
break;
}
else
{
break;
}
}
#endif
return rc; return rc;
} }