summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2007-07-13 16:22:09 +0000
committerLuigi Rizzo <rizzo@icir.org>2007-07-13 16:22:09 +0000
commite950538bdd1ebc5086c0f5422e7867794fdfb926 (patch)
treedae29c664c9f07f1ce2e0daf9798b30270777fd4 /include
parent4d915d13c703334e34ecdbeb7024ec29a53a67a3 (diff)
Small improvement to the STUN support so it can be used by
sockets other than RTP ones. The main change is a new API function in main/rtp.c (see there for a description) int ast_stun_request(int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer) which can be used to send an STUN request on a socket, and optionally wait for a reply and store the STUN_MAPPED_ADDRESS into the 'answer' argument (obviously, the version that waits for a reply is blocking, but this is no different from DNS resolutions). Internally there are minor modifications to let stun_handle_packet() be somewhat configurable on how to parse the body of responses. At the moment i am not committing any change to the clients, but adding STUN client support is extremely simple, e.g. chan_sip.c could do something like this: + add a variable to store the stun server address; static struct sockaddr_in stunaddr = { 0, }; /*!< stun server address */ + add code to parse a config file of the form "stunaddr=my.stun.server.org:3478" (not shown for brevity); + right after binding the main sip socket, talk to the stun server to determine the externally visible address if (stunaddr.sin_addr.s_addr != 0) ast_stun_request(sipsock, &stunaddr, NULL, &externip); so now 'externip' is set with the externally visible address. so it is really trivial. Similarly ast_stun_request could be called when creating the RTP socket (possibly adding a struct sockaddr_in field in the struct ast_rtp to store the externalip). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75034 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/rtp.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/asterisk/rtp.h b/include/asterisk/rtp.h
index 492ad9119..8d54cbe88 100644
--- a/include/asterisk/rtp.h
+++ b/include/asterisk/rtp.h
@@ -211,7 +211,22 @@ void ast_rtp_setdtmfcompensate(struct ast_rtp *rtp, int compensate);
/*! \brief Enable STUN capability */
void ast_rtp_setstun(struct ast_rtp *rtp, int stun_enable);
-/*! \brief Send STUN request (??) */
+/*! \brief Generic STUN request
+ * send a generic stun request to the server specified.
+ * \param s the socket used to send the request
+ * \param dst the address of the STUN server
+ * \param username if non null, add the username in the request
+ * \param answer if non null, the function waits for a response and
+ * puts here the externally visible address.
+ * \return 0 on success, other values on error.
+ * The interface it may change in the future.
+ */
+int ast_stun_request(int s, struct sockaddr_in *dst,
+ const char *username, struct sockaddr_in *answer);
+
+/*! \brief Send STUN request for an RTP socket
+ * Deprecated, this is just a wrapper for ast_rtp_stun_request()
+ */
void ast_rtp_stun_request(struct ast_rtp *rtp, struct sockaddr_in *suggestion, const char *username);
/*! \brief The RTP bridge.