summaryrefslogtreecommitdiff
path: root/pjnath/src/pjturn-srv
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-03-09 23:52:48 +0000
committerBenny Prijono <bennylp@teluu.com>2008-03-09 23:52:48 +0000
commitc2b574db5c151d0f71726bf7e9c604f50501f559 (patch)
tree1a7c4a7b3a85d262b1a06c5cc671a0f8f29dc0b6 /pjnath/src/pjturn-srv
parent401a7c0fa414523fc6a9d6cf78b503809f00995a (diff)
More ticket #485: initial (incomplete) work on TURN client session library
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1854 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/src/pjturn-srv')
-rw-r--r--pjnath/src/pjturn-srv/allocation.c19
-rw-r--r--pjnath/src/pjturn-srv/main.c18
-rw-r--r--pjnath/src/pjturn-srv/turn.h11
3 files changed, 24 insertions, 24 deletions
diff --git a/pjnath/src/pjturn-srv/allocation.c b/pjnath/src/pjturn-srv/allocation.c
index 5698ea41..da35266c 100644
--- a/pjnath/src/pjturn-srv/allocation.c
+++ b/pjnath/src/pjturn-srv/allocation.c
@@ -40,15 +40,6 @@ enum {
#define DEF_LIFETIME 300
-
-/* ChannelData header */
-typedef struct channel_data_hdr
-{
- pj_uint16_t ch_number;
- pj_uint16_t length;
-} channel_data_hdr;
-
-
/* Parsed Allocation request. */
typedef struct alloc_request
{
@@ -912,10 +903,12 @@ PJ_DEF(void) pj_turn_allocation_on_rx_client_pkt(pj_turn_allocation *alloc,
/*
* This is not a STUN packet, must be ChannelData packet.
*/
- channel_data_hdr *cd = (channel_data_hdr*)pkt->pkt;
+ pj_turn_channel_data *cd = (pj_turn_channel_data*)pkt->pkt;
pj_turn_permission *perm;
pj_ssize_t len;
+ pj_assert(sizeof(*cd)==4);
+
/* For UDP check the packet length */
if (alloc->listener->tp_type == PJ_TURN_TP_UDP) {
if (pkt->len < pj_ntohs(cd->length)+sizeof(*cd)) {
@@ -978,7 +971,7 @@ static void handle_peer_pkt(pj_turn_allocation *alloc,
*/
if (perm->channel != PJ_TURN_INVALID_CHANNEL) {
/* Send ChannelData */
- channel_data_hdr *cd = (channel_data_hdr*)rel->tp.tx_pkt;
+ pj_turn_channel_data *cd = (pj_turn_channel_data*)rel->tp.tx_pkt;
if (len > PJ_TURN_MAX_PKT_LEN) {
char peer_addr[80];
@@ -994,11 +987,11 @@ static void handle_peer_pkt(pj_turn_allocation *alloc,
cd->length = pj_htons((pj_uint16_t)len);
/* Copy data */
- pj_memcpy(rel->tp.rx_pkt+sizeof(channel_data_hdr), pkt, len);
+ pj_memcpy(rel->tp.rx_pkt+sizeof(pj_turn_channel_data), pkt, len);
/* Send to client */
pj_turn_listener_sendto(alloc->listener, rel->tp.tx_pkt,
- len+sizeof(channel_data_hdr), 0,
+ len+sizeof(pj_turn_channel_data), 0,
&alloc->hkey.clt_addr,
pj_sockaddr_get_len(&alloc->hkey.clt_addr));
} else {
diff --git a/pjnath/src/pjturn-srv/main.c b/pjnath/src/pjturn-srv/main.c
index 55b450c9..3cddafc1 100644
--- a/pjnath/src/pjturn-srv/main.c
+++ b/pjnath/src/pjturn-srv/main.c
@@ -1,3 +1,21 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
#include "turn.h"
int err(const char *title, pj_status_t status)
diff --git a/pjnath/src/pjturn-srv/turn.h b/pjnath/src/pjturn-srv/turn.h
index a6dcd9ec..871db425 100644
--- a/pjnath/src/pjturn-srv/turn.h
+++ b/pjnath/src/pjturn-srv/turn.h
@@ -30,18 +30,7 @@ typedef struct pj_turn_srv pj_turn_srv;
typedef struct pj_turn_pkt pj_turn_pkt;
-#define PJ_TURN_INVALID_CHANNEL 0xFFFF
#define PJ_TURN_INVALID_LIS_ID ((unsigned)-1)
-#define PJ_TURN_NO_TIMEOUT ((long)0x7FFFFFFF)
-#define PJ_TURN_MAX_PKT_LEN 3000
-#define PJ_TURN_PERM_TIMEOUT 300
-#define PJ_TURN_CHANNEL_TIMEOUT 600
-
-/** Transport types */
-enum {
- PJ_TURN_TP_UDP = 16, /**< UDP. */
- PJ_TURN_TP_TCP = 6 /**< TCP. */
-};
/**
* Get transport type name string.