summaryrefslogtreecommitdiff
path: root/pjlib-util/include/pjlib-util/stun_simple.h
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib-util/include/pjlib-util/stun_simple.h')
-rw-r--r--pjlib-util/include/pjlib-util/stun_simple.h77
1 files changed, 76 insertions, 1 deletions
diff --git a/pjlib-util/include/pjlib-util/stun_simple.h b/pjlib-util/include/pjlib-util/stun_simple.h
index 3d10379..a0b1b69 100644
--- a/pjlib-util/include/pjlib-util/stun_simple.h
+++ b/pjlib-util/include/pjlib-util/stun_simple.h
@@ -1,4 +1,4 @@
-/* $Id: stun_simple.h 3553 2011-05-05 06:14:19Z nanang $ */
+/* $Id: stun_simple.h 4224 2012-08-09 05:21:25Z nanang $ */
/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -199,6 +199,81 @@ PJ_DECL(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
const pj_str_t *srv2, int port2,
pj_sockaddr_in mapped_addr[]);
+
+/*
+ * This structre describes configurable setting for requesting mapped address.
+ */
+typedef struct pjstun_setting
+{
+ /**
+ * Specifies whether STUN request generated by old STUN library should
+ * insert magic cookie (specified in RFC 5389) in the transaction ID.
+ */
+ pj_bool_t use_stun2;
+
+ /**
+ * Host name or IP address string of the first STUN server.
+ */
+ pj_str_t srv1;
+
+ /**
+ * The port number of the first STUN server.
+ */
+ int port1;
+
+ /**
+ * Host name or IP address string of the second STUN server.
+ */
+ pj_str_t srv2;
+
+ /**
+ * The port number of the second STUN server.
+ */
+ int port2;
+
+} pjstun_setting;
+
+
+/**
+ * Another version of mapped address resolution of local sockets to multiple
+ * STUN servers configured in #pjstun_setting. This function is able to find
+ * the mapped addresses of multiple sockets simultaneously, and for each
+ * socket, two requests will be sent to two different STUN servers to see if
+ * both servers get the same public address for the same socket. (Note that
+ * application can specify the same address for the two servers, but still
+ * two requests will be sent for each server).
+ *
+ * This function will perform necessary retransmissions of the requests if
+ * response is not received within a predetermined period. When all responses
+ * have been received, the function will compare the mapped addresses returned
+ * by the servers, and when both are equal, the address will be returned in
+ * \a mapped_addr argument.
+ *
+ * @param pf The pool factory where memory will be allocated from.
+ * @param opt The STUN settings.
+ * @param sock_cnt Number of sockets in the socket array.
+ * @param sock Array of local UDP sockets which public addresses are
+ * to be queried from the STUN servers.
+ * @param mapped_addr Array to receive the mapped public address of the local
+ * UDP sockets, when the function returns PJ_SUCCESS.
+ *
+ * @return This functions returns PJ_SUCCESS if responses are
+ * received from all servers AND all servers returned the
+ * same mapped public address. Otherwise this function may
+ * return one of the following error codes:
+ * - PJLIB_UTIL_ESTUNNOTRESPOND: no respons from servers.
+ * - PJLIB_UTIL_ESTUNSYMMETRIC: different mapped addresses
+ * are returned by servers.
+ * - etc.
+ *
+ */
+PJ_DECL(pj_status_t) pjstun_get_mapped_addr2( pj_pool_factory *pf,
+ const pjstun_setting *opt,
+ int sock_cnt,
+ pj_sock_t sock[],
+ pj_sockaddr_in mapped_addr[]);
+
+
PJ_END_DECL
/**