summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-25 10:45:34 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-25 10:45:34 +0000
commit2434bdddfe484d84c0fb9641875e8b9cbd2a22b0 (patch)
tree0413caac1f14afb3f10e2622bfb40692d9ff388b
parent9d29e15eadae49726b4abc0b357eafe125145984 (diff)
Fixed linking errors in pjnath when TCP is disabled in PJLIB
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2177 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/include/pj/activesock.h2
-rw-r--r--pjlib/src/pj/activesock.c9
-rw-r--r--pjnath/src/pjnath/turn_sock.c5
-rw-r--r--pjnath/src/pjturn-srv/listener_tcp.c9
-rw-r--r--pjnath/src/pjturn-srv/main.c2
5 files changed, 24 insertions, 3 deletions
diff --git a/pjlib/include/pj/activesock.h b/pjlib/include/pj/activesock.h
index e9f4759d..dd5d8270 100644
--- a/pjlib/include/pj/activesock.h
+++ b/pjlib/include/pj/activesock.h
@@ -413,6 +413,7 @@ PJ_DECL(pj_status_t) pj_activesock_sendto(pj_activesock_t *asock,
const pj_sockaddr_t *addr,
int addr_len);
+#if PJ_HAS_TCP
/**
* Starts asynchronous socket accept() operations on this active socket.
* Application must bind the socket before calling this function. This
@@ -457,6 +458,7 @@ PJ_DECL(pj_status_t) pj_activesock_start_connect(pj_activesock_t *asock,
const pj_sockaddr_t *remaddr,
int addr_len);
+#endif /* PJ_HAS_TCP */
/**
* @}
diff --git a/pjlib/src/pj/activesock.c b/pjlib/src/pj/activesock.c
index c4288a2a..45173c5b 100644
--- a/pjlib/src/pj/activesock.c
+++ b/pjlib/src/pj/activesock.c
@@ -75,13 +75,14 @@ static void ioqueue_on_read_complete(pj_ioqueue_key_t *key,
static void ioqueue_on_write_complete(pj_ioqueue_key_t *key,
pj_ioqueue_op_key_t *op_key,
pj_ssize_t bytes_sent);
+#if PJ_HAS_TCP
static void ioqueue_on_accept_complete(pj_ioqueue_key_t *key,
pj_ioqueue_op_key_t *op_key,
pj_sock_t sock,
pj_status_t status);
static void ioqueue_on_connect_complete(pj_ioqueue_key_t *key,
pj_status_t status);
-
+#endif
PJ_DEF(void) pj_activesock_cfg_default(pj_activesock_cfg *cfg)
{
@@ -121,8 +122,10 @@ PJ_DEF(pj_status_t) pj_activesock_create( pj_pool_t *pool,
pj_bzero(&ioq_cb, sizeof(ioq_cb));
ioq_cb.on_read_complete = &ioqueue_on_read_complete;
ioq_cb.on_write_complete = &ioqueue_on_write_complete;
+#if PJ_HAS_TCP
ioq_cb.on_connect_complete = &ioqueue_on_connect_complete;
ioq_cb.on_accept_complete = &ioqueue_on_accept_complete;
+#endif
status = pj_ioqueue_register_sock(pool, ioqueue, sock, asock,
&ioq_cb, &asock->key);
@@ -487,7 +490,7 @@ static void ioqueue_on_write_complete(pj_ioqueue_key_t *key,
}
}
-
+#if PJ_HAS_TCP
PJ_DEF(pj_status_t) pj_activesock_start_accept(pj_activesock_t *asock,
pj_pool_t *pool)
{
@@ -577,7 +580,6 @@ PJ_DEF(pj_status_t) pj_activesock_start_connect( pj_activesock_t *asock,
return pj_ioqueue_connect(asock->key, remaddr, addr_len);
}
-
static void ioqueue_on_connect_complete(pj_ioqueue_key_t *key,
pj_status_t status)
{
@@ -594,4 +596,5 @@ static void ioqueue_on_connect_complete(pj_ioqueue_key_t *key,
}
}
}
+#endif /* PJ_HAS_TCP */
diff --git a/pjnath/src/pjnath/turn_sock.c b/pjnath/src/pjnath/turn_sock.c
index e595d271..94ff80ab 100644
--- a/pjnath/src/pjnath/turn_sock.c
+++ b/pjnath/src/pjnath/turn_sock.c
@@ -111,6 +111,7 @@ PJ_DEF(pj_status_t) pj_turn_sock_create(pj_stun_config *cfg,
PJ_ASSERT_RETURN(cfg && p_turn_sock, PJ_EINVAL);
PJ_ASSERT_RETURN(af==pj_AF_INET() || af==pj_AF_INET6(), PJ_EINVAL);
PJ_ASSERT_RETURN(options==0, PJ_EINVAL);
+ PJ_ASSERT_RETURN(conn_type!=PJ_TURN_TP_TCP || PJ_HAS_TCP, PJ_EINVAL);
switch (conn_type) {
case PJ_TURN_TP_UDP:
@@ -640,6 +641,7 @@ static void turn_on_state(pj_turn_session *sess,
sizeof(addrtxt), 3)));
/* Initiate non-blocking connect */
+#if PJ_HAS_TCP
status=pj_activesock_start_connect(turn_sock->active_sock,
turn_sock->pool,
&info.server,
@@ -650,6 +652,9 @@ static void turn_on_state(pj_turn_session *sess,
pj_turn_sock_destroy(turn_sock);
return;
}
+#else
+ on_connect_complete(turn_sock->active_sock, PJ_SUCCESS);
+#endif
/* Done for now. Subsequent work will be done in
* on_connect_complete() callback.
diff --git a/pjnath/src/pjturn-srv/listener_tcp.c b/pjnath/src/pjturn-srv/listener_tcp.c
index e5369e5a..6d6fb33a 100644
--- a/pjnath/src/pjturn-srv/listener_tcp.c
+++ b/pjnath/src/pjturn-srv/listener_tcp.c
@@ -19,6 +19,8 @@
#include "turn.h"
#include <pj/compat/socket.h>
+#if PJ_HAS_TCP
+
struct accept_op
{
pj_ioqueue_op_key_t op_key;
@@ -478,3 +480,10 @@ static void tcp_dec_ref(pj_turn_transport *tp,
}
}
+#else /* PJ_HAS_TCP */
+
+/* To avoid empty translation unit warning */
+int listener_tcp_dummy = 0;
+
+#endif /* PJ_HAS_TCP */
+
diff --git a/pjnath/src/pjturn-srv/main.c b/pjnath/src/pjturn-srv/main.c
index 77e13d9b..6b2e9d1e 100644
--- a/pjnath/src/pjturn-srv/main.c
+++ b/pjnath/src/pjturn-srv/main.c
@@ -146,10 +146,12 @@ int main()
if (status != PJ_SUCCESS)
return err("Error creating UDP listener", status);
+#if PJ_HAS_TCP
status = pj_turn_listener_create_tcp(srv, pj_AF_INET(), NULL,
TURN_PORT, 1, 0, &listener);
if (status != PJ_SUCCESS)
return err("Error creating listener", status);
+#endif
status = pj_turn_srv_add_listener(srv, listener);
if (status != PJ_SUCCESS)