summaryrefslogtreecommitdiff
path: root/pjnath
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-03-22 09:33:26 +0000
committerBenny Prijono <bennylp@teluu.com>2008-03-22 09:33:26 +0000
commit855bcda8119a227e45d3cc897b53db98ca334c7a (patch)
tree25a39539c7fb0dcb2c9f504fd2a3c426dc97cd9e /pjnath
parent5b79998fe36e220752c5e6cdf5ca6b06faa0f407 (diff)
Added comment about byte ordering in TURN CHANNEL-NUMBER attribute and modified select() parameter in TURN client
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1888 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath')
-rw-r--r--pjnath/include/pjnath/stun_msg.h6
-rw-r--r--pjnath/src/pjturn-client/client_main.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h
index 15114808..5cf0f6c9 100644
--- a/pjnath/include/pjnath/stun_msg.h
+++ b/pjnath/include/pjnath/stun_msg.h
@@ -872,11 +872,17 @@ typedef struct pj_stun_uint_attr pj_stun_channel_number_attr;
/**
* Get 16bit channel number from 32bit integral value.
+ * Note that uint32 attributes are always stored in host byte order
+ * after they have been parsed from the PDU, so no need to do ntohs()
+ * here.
*/
#define PJ_STUN_GET_CH_NB(u32) ((pj_uint16_t)(u32>>16))
/**
* Convert 16bit channel number into 32bit integral value.
+ * Note that uint32 attributes will be converted to network byte order
+ * when the attribute is written to packet, so no need to do htons()
+ * here.
*/
#define PJ_STUN_SET_CH_NB(chnum) (((pj_uint32_t)chnum) << 16)
diff --git a/pjnath/src/pjturn-client/client_main.c b/pjnath/src/pjturn-client/client_main.c
index 9c428fcf..117da1c0 100644
--- a/pjnath/src/pjturn-client/client_main.c
+++ b/pjnath/src/pjturn-client/client_main.c
@@ -190,7 +190,7 @@ static int worker_thread(void *unused)
while (!g.quit) {
const pj_time_val delay = {0, 10};
- int i;
+ int i, n=0;
pj_fd_set_t readset;
/* Poll ioqueue for the TURN client */
@@ -203,9 +203,11 @@ static int worker_thread(void *unused)
PJ_FD_ZERO(&readset);
for (i=0; i<PJ_ARRAY_SIZE(g.peer); ++i) {
PJ_FD_SET(g.peer[i].sock, &readset);
+ if (g.peer[i].sock > n)
+ n = g.peer[i].sock;
}
- if (pj_sock_select(64, &readset, NULL, NULL, &delay) <= 0)
+ if (pj_sock_select(n+1, &readset, NULL, NULL, &delay) <= 0)
continue;
/* Handle incoming data on peer socket */