Add ALPN interface
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index 83aa9a3..78102f0 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -861,6 +861,19 @@
#define POLARSSL_SSL_PROTO_TLS1_2
/**
+ * \def POLARSSL_SSL_ALPN
+ *
+ * Enable support for Application Layer Protocol Negotiation.
+ * draft-ietf-tls-applayerprotoneg-05
+ *
+ * This is disabled by default in the 1.3.x line since it breaks ABI
+ * compatibility.
+ *
+ * Uncomment this macro to enable support for ALPN.
+ */
+#define POLARSSL_SSL_ALPN
+
+/**
* \def POLARSSL_SSL_SESSION_TICKETS
*
* Enable support for RFC 5077 session tickets in SSL.
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index c1aff67..e4a8dc7 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -762,6 +762,14 @@
size_t hostname_len;
#endif
+#if defined(POLARSSL_SSL_ALPN)
+ /*
+ * ALPN extension
+ */
+ const char **alpn_list; /*!< ordered list of supported protocols */
+ const char *alpn_chosen; /*!< negotiated protocol */
+#endif
+
/*
* Secure renegotiation
*/
@@ -1232,6 +1240,28 @@
void *p_sni );
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
+#if defined(POLARSSL_SSL_ALPN)
+/**
+ * \brief Set the supported Application Layer Protocols.
+ *
+ * \param ssl SSL context
+ * \param protos NULL-terminated list of supported protocols,
+ * in decreasing preference order.
+ */
+void ssl_set_alpn_protocols( ssl_context *ssl, const char **protos );
+
+/**
+ * \brief Get the name of the negotiated Application Layer Protocol.
+ * This function should be called after the handshake is
+ * completed.
+ *
+ * \param ssl SSL context
+ *
+ * \return Protcol name, or NULL if no protocol was negotiated.
+ */
+const char *ssl_get_alpn_protocol( const ssl_context *ssl );
+#endif /* POLARSSL_SSL_ALPN */
+
/**
* \brief Set the maximum supported version sent from the client side
* and/or accepted at the server side