Commit 266357e4 authored by Pekka Pessi's avatar Pekka Pessi

Updated SCTP semantics to use "TCP".

darcs-hash:20060418051041-65a35-7338749511f9710bddb7bcf52b2a0116826ee75c.gz
parent e46f62e9
...@@ -1147,7 +1147,7 @@ tport_vtable_t const *tport_vtables[TPORT_NUMBER_OF_TYPES + 1] = ...@@ -1147,7 +1147,7 @@ tport_vtable_t const *tport_vtables[TPORT_NUMBER_OF_TYPES + 1] =
&tport_tls_client_vtable, &tport_tls_client_vtable,
&tport_tls_vtable, &tport_tls_vtable,
#endif #endif
#if HAVE_SCTP && 0 /* SCTP is broken */ #if HAVE_SCTP /* SCTP is broken */
&tport_sctp_client_vtable, &tport_sctp_client_vtable,
&tport_sctp_vtable, &tport_sctp_vtable,
#endif #endif
...@@ -1283,7 +1283,10 @@ int tport_tbind(tport_t *self, ...@@ -1283,7 +1283,10 @@ int tport_tbind(tport_t *self,
if (http_connect && public == 0) if (http_connect && public == 0)
public = tport_type_connect; public = tport_type_connect;
if (server && public == 0) if (public && public != tport_type_stun)
server = 0;
if (server)
retval = tport_bind_server(mr, mytpn, transports, public, ta_args(ta)); retval = tport_bind_server(mr, mytpn, transports, public, ta_args(ta));
else else
retval = tport_bind_client(mr, mytpn, transports, public, ta_args(ta)); retval = tport_bind_client(mr, mytpn, transports, public, ta_args(ta));
...@@ -1348,8 +1351,10 @@ int tport_bind_client(tport_master_t *mr, ...@@ -1348,8 +1351,10 @@ int tport_bind_client(tport_master_t *mr,
pri->pri_public = tport_type_client; /* XXX */ pri->pri_public = tport_type_client; /* XXX */
} }
if (!pri) if (!pri) {
SU_DEBUG_3(("tport_alloc_primary: %s failed\n", why));
tport_zap_primary(*tbf); tport_zap_primary(*tbf);
}
return pri ? 0 : -1; return pri ? 0 : -1;
} }
......
...@@ -157,7 +157,7 @@ static ...@@ -157,7 +157,7 @@ static
int tport_recv_sctp(tport_t *self) int tport_recv_sctp(tport_t *self)
{ {
msg_t *msg; msg_t *msg;
int N, veclen, exact = 0, eos; int N, n, veclen;
msg_iovec_t iovec[2] = {{ 0 }}; msg_iovec_t iovec[2] = {{ 0 }};
char sctp_buf[TP_SCTP_MSG_MAX]; char sctp_buf[TP_SCTP_MSG_MAX];
...@@ -165,11 +165,25 @@ int tport_recv_sctp(tport_t *self) ...@@ -165,11 +165,25 @@ int tport_recv_sctp(tport_t *self)
iovec[0].mv_base = sctp_buf; iovec[0].mv_base = sctp_buf;
iovec[0].mv_len = sizeof(sctp_buf); iovec[0].mv_len = sizeof(sctp_buf);
#if 0
N = su_vrecv(self->tp_socket, iovec, 1, 0, NULL, NULL); N = su_vrecv(self->tp_socket, iovec, 1, 0, NULL, NULL);
if (N == SOCKET_ERROR) if (N == SOCKET_ERROR)
return tport_recv_error_report(self); return tport_recv_error_report(self);
#endif
veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, exact = 1); N = su_getmsgsize(self->tp_socket);
if (N == SOCKET_ERROR) {
int err = su_errno();
SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, self,
su_strerror(err), err));
return -1;
}
if (N == 0) {
if (self->tp_msg)
msg_recv_commit(self->tp_msg, 0, 1);
return 0; /* End of stream */
}
veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 0);
if (veclen < 0) if (veclen < 0)
return -1; return -1;
...@@ -180,14 +194,14 @@ int tport_recv_sctp(tport_t *self) ...@@ -180,14 +194,14 @@ int tport_recv_sctp(tport_t *self)
*msg_addr(msg) = *self->tp_addr; *msg_addr(msg) = *self->tp_addr;
*msg_addrlen(msg) = su_sockaddr_size(self->tp_addr); *msg_addrlen(msg) = su_sockaddr_size(self->tp_addr);
memcpy(iovec[0].mv_base, sctp_buf, iovec[0].mv_len); n = su_vrecv(self->tp_socket, iovec, veclen, 0, NULL, NULL);
if (self->tp_master->mr_dump_file) if (self->tp_master->mr_dump_file)
tport_dump_iovec(self, msg, N, iovec, veclen, "recv", "from"); tport_dump_iovec(self, msg, n, iovec, veclen, "recv", "from");
msg_recv_commit(msg, N, eos = 1); /* Mark buffer as used */ msg_recv_commit(msg, n, 0); /* Mark buffer as used */
return 2; return 1;
} }
static int tport_send_sctp(tport_t const *self, msg_t *msg, static int tport_send_sctp(tport_t const *self, msg_t *msg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment