You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jr...@apache.org on 2018/04/05 19:34:19 UTC

[44/51] [partial] qpid-proton git commit: PROTON-1728: Reorganize the source tree

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/sasl-plugin.h
----------------------------------------------------------------------
diff --git a/c/include/proton/sasl-plugin.h b/c/include/proton/sasl-plugin.h
new file mode 100644
index 0000000..d420eaf
--- /dev/null
+++ b/c/include/proton/sasl-plugin.h
@@ -0,0 +1,145 @@
+#ifndef PROTON_SASL_PLUGIN_H
+#define PROTON_SASL_PLUGIN_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond INTERNAL */
+
+/*
+  Internal SASL authenticator interface: These are the entry points to a SASL implementations
+
+  Free up all data structures allocated by the SASL implementation
+  void free(pn_transport_t *transport);
+
+  Return space separated list of supported mechanisms (client and server)
+  If the returned string is dynamically allocated by the SASL implemetation
+  it must stay valid until the free entry point is called.
+  const char *list_mechs(pn_transport_t *transport);
+
+  Initialise for either client or server (can't call both for a
+  given transport/connection):
+  bool init_server(pn_transport_t *transport);
+  bool init_client(pn_transport_t *transport);
+
+  Writing:
+  void prepare_write(pn_transport_t *transport);
+
+  Reading:
+  Server side (process server SASL messages):
+  void process_init(pn_transport_t *transport, const char *mechanism, const pn_bytes_t *recv);
+  void process_response(pn_transport_t *transport, const pn_bytes_t *recv);
+
+  Client side (process client SASL messages)
+  bool process_mechanisms(pn_transport_t *transport, const char *mechs);
+  void process_challenge(pn_transport_t *transport, const pn_bytes_t *recv);
+  void process_outcome(pn_transport_t *transport);
+
+  Security layer interface (active after SASL succeeds)
+  bool    can_encrypt(pn_transport_t *transport);
+  ssize_t max_encrypt_size(pn_transport_t *transport);
+  ssize_t encode(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *out);
+  ssize_t decode(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *out);
+*/
+
+typedef struct pnx_sasl_implementation
+{
+    void (*free)(pn_transport_t *transport);
+
+    const char*  (*list_mechs)(pn_transport_t *transport);
+
+    bool (*init_server)(pn_transport_t *transport);
+    bool (*init_client)(pn_transport_t *transport);
+
+    void (*prepare_write)(pn_transport_t *transport);
+
+    void (*process_init)(pn_transport_t *transport, const char *mechanism, const pn_bytes_t *recv);
+    void (*process_response)(pn_transport_t *transport, const pn_bytes_t *recv);
+
+    bool (*process_mechanisms)(pn_transport_t *transport, const char *mechs);
+    void (*process_challenge)(pn_transport_t *transport, const pn_bytes_t *recv);
+    void (*process_outcome)(pn_transport_t *transport);
+
+    bool    (*can_encrypt)(pn_transport_t *transport);
+    ssize_t (*max_encrypt_size)(pn_transport_t *transport);
+    ssize_t (*encode)(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *out);
+    ssize_t (*decode)(pn_transport_t *transport, pn_bytes_t in, pn_bytes_t *out);
+
+} pnx_sasl_implementation;
+
+/* Shared SASL API used by the actual SASL authenticators */
+enum pnx_sasl_state {
+  SASL_NONE,
+  SASL_POSTED_INIT,
+  SASL_POSTED_MECHANISMS,
+  SASL_POSTED_RESPONSE,
+  SASL_POSTED_CHALLENGE,
+  SASL_RECVED_OUTCOME_SUCCEED,
+  SASL_RECVED_OUTCOME_FAIL,
+  SASL_POSTED_OUTCOME,
+  SASL_ERROR
+};
+
+/* APIs used by sasl implementations */
+PN_EXTERN void  pnx_sasl_logf(pn_transport_t *transport, const char *format, ...);
+
+PN_EXTERN void *pnx_sasl_get_context(pn_transport_t *transport);
+PN_EXTERN void  pnx_sasl_set_context(pn_transport_t *transport, void *context);
+
+PN_EXTERN bool  pnx_sasl_is_client(pn_transport_t *transport);
+PN_EXTERN bool  pnx_sasl_is_included_mech(pn_transport_t *transport, pn_bytes_t s);
+PN_EXTERN bool  pnx_sasl_is_transport_encrypted(pn_transport_t *transport);
+PN_EXTERN bool  pnx_sasl_get_allow_insecure_mechs(pn_transport_t *transport);
+PN_EXTERN bool  pnx_sasl_get_auth_required(pn_transport_t *transport);
+PN_EXTERN const char *pnx_sasl_get_external_username(pn_transport_t *transport);
+PN_EXTERN int   pnx_sasl_get_external_ssf(pn_transport_t *transport);
+
+PN_EXTERN const char *pnx_sasl_get_username(pn_transport_t *transport);
+PN_EXTERN const char *pnx_sasl_get_password(pn_transport_t *transport);
+PN_EXTERN void  pnx_sasl_clear_password(pn_transport_t *transport);
+PN_EXTERN const char *pnx_sasl_get_remote_fqdn(pn_transport_t *transport);
+PN_EXTERN const char *pnx_sasl_get_selected_mechanism(pn_transport_t *transport);
+
+PN_EXTERN void  pnx_sasl_set_bytes_out(pn_transport_t *transport, pn_bytes_t bytes);
+PN_EXTERN void  pnx_sasl_set_desired_state(pn_transport_t *transport, enum pnx_sasl_state desired_state);
+PN_EXTERN void  pnx_sasl_set_selected_mechanism(pn_transport_t *transport, const char *mechanism);
+PN_EXTERN void  pnx_sasl_set_local_hostname(pn_transport_t * transport, const char * fqdn);
+PN_EXTERN void  pnx_sasl_succeed_authentication(pn_transport_t *transport, const char *username);
+PN_EXTERN void  pnx_sasl_fail_authentication(pn_transport_t *transport);
+
+PN_EXTERN void  pnx_sasl_set_implementation(pn_transport_t *transport, const pnx_sasl_implementation *impl, void *context);
+PN_EXTERN void  pnx_sasl_set_default_implementation(const pnx_sasl_implementation *impl);
+
+/** @endcond */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sasl-plugin.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/sasl.h
----------------------------------------------------------------------
diff --git a/c/include/proton/sasl.h b/c/include/proton/sasl.h
new file mode 100644
index 0000000..90b08f5
--- /dev/null
+++ b/c/include/proton/sasl.h
@@ -0,0 +1,212 @@
+#ifndef PROTON_SASL_H
+#define PROTON_SASL_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * @copybrief sasl
+ *
+ * @addtogroup sasl
+ * @{
+ */
+
+/**
+ * The SASL layer is responsible for establishing an authenticated
+ * and/or encrypted tunnel over which AMQP frames are passed between
+ * peers. The peer acting as the SASL Client must provide
+ * authentication credentials. The peer acting as the SASL Server must
+ * provide authentication against the received credentials.
+ */
+typedef struct pn_sasl_t pn_sasl_t;
+
+/**
+ * The result of the SASL negotiation.
+ */
+typedef enum {
+  PN_SASL_NONE = -1,  /** negotiation not completed */
+  PN_SASL_OK = 0,     /** authentication succeeded */
+  PN_SASL_AUTH = 1,   /** failed due to bad credentials */
+  PN_SASL_SYS = 2,    /** failed due to a system error */
+  PN_SASL_PERM = 3,   /** failed due to unrecoverable error */
+  PN_SASL_TEMP = 4    /** failed due to transient error */
+} pn_sasl_outcome_t;
+
+/**
+ * Construct an Authentication and Security Layer object.
+ *
+ * This will return the SASL layer object for the supplied transport
+ * object. If there is currently no SASL layer one will be created.
+ *
+ * On the client side of an AMQP connection this will have the effect
+ * of ensuring that the AMQP SASL layer is used for that connection.
+ *
+ * @return an object representing the SASL layer.
+ */
+PN_EXTERN pn_sasl_t *pn_sasl(pn_transport_t *transport);
+
+/**
+ * Do we support extended SASL negotiation
+ *
+ * Do we support extended SASL negotiation?
+ * All implementations of Proton support ANONYMOUS and EXTERNAL on both
+ * client and server sides and PLAIN on the client side.
+ *
+ * Extended SASL implementations use an external library (Cyrus SASL)
+ * to support other mechanisms beyond these basic ones.
+ *
+ * @return true if we support extended SASL negotiation, false if we only support basic negotiation.
+ */
+PN_EXTERN bool pn_sasl_extended(void);
+
+/**
+ * Set the outcome of SASL negotiation
+ *
+ * Used by the server to set the result of the negotiation process.
+ *
+ * @todo
+ */
+PN_EXTERN void pn_sasl_done(pn_sasl_t *sasl, pn_sasl_outcome_t outcome);
+
+/**
+ * Retrieve the outcome of SASL negotiation.
+ *
+ * @todo
+ */
+PN_EXTERN pn_sasl_outcome_t pn_sasl_outcome(pn_sasl_t *sasl);
+
+/**
+ * Retrieve the authenticated user
+ *
+ * This is usually used at the the server end to find the name of the authenticated user.
+ * On the client it will merely return whatever user was passed in to the
+ * pn_transport_set_user_password() API.
+ *
+ * If pn_sasl_outcome() returns a value other than PN_SASL_OK, then there will be no user to return.
+ * The returned value is only reliable after the PN_TRANSPORT_AUTHENTICATED event has been received.
+ *
+ * @param[in] sasl the sasl layer
+ *
+ * @return
+ * If the SASL layer was not negotiated then 0 is returned
+ * If the ANONYMOUS mechanism is used then the user will be "anonymous"
+ * Otherwise a string containing the user is returned.
+ */
+PN_EXTERN const char *pn_sasl_get_user(pn_sasl_t *sasl);
+
+/**
+ * Return the selected SASL mechanism
+ *
+ * The returned value is only reliable after the PN_TRANSPORT_AUTHENTICATED event has been received.
+ *
+ * @param[in] sasl the SASL layer
+ *
+ * @return The authentication mechanism selected by the SASL layer
+ */
+PN_EXTERN const char *pn_sasl_get_mech(pn_sasl_t *sasl);
+
+/**
+ * SASL mechanisms that are to be considered for authentication
+ *
+ * This can be used on either the client or the server to restrict the SASL
+ * mechanisms that may be used to the mechanisms on the list.
+ *
+ * @param[in] sasl the SASL layer
+ * @param[in] mechs space separated list of mechanisms that are allowed for authentication
+ */
+PN_EXTERN void pn_sasl_allowed_mechs(pn_sasl_t *sasl, const char *mechs);
+
+/**
+ * Boolean to allow use of clear text authentication mechanisms
+ *
+ * By default the SASL layer is configured not to allow mechanisms that disclose
+ * the clear text of the password over an unencrypted AMQP connection. This specifically
+ * will disallow the use of the PLAIN mechanism without using SSL encryption.
+ *
+ * This default is to avoid disclosing password information accidentally over an
+ * insecure network.
+ *
+ * If you actually wish to use a clear text password unencrypted then you can use this
+ * API to set allow_insecure_mechs to true.
+ *
+ * @param[in] sasl the SASL layer
+ * @param[in] insecure set this to true to allow unencrypted PLAIN authentication.
+ *
+ */
+PN_EXTERN void pn_sasl_set_allow_insecure_mechs(pn_sasl_t *sasl, bool insecure);
+
+/**
+ * Return the current value for allow_insecure_mechs
+ *
+ * @param[in] sasl the SASL layer
+ */
+PN_EXTERN bool pn_sasl_get_allow_insecure_mechs(pn_sasl_t *sasl);
+
+/**
+ * Set the sasl configuration name
+ *
+ * This is used to construct the SASL configuration filename. In the current implementation
+ * it ".conf" is added to the name and the file is looked for in the configuration directory.
+ *
+ * If not set it will default to "proton-server" for a sasl server and "proton-client"
+ * for a client.
+ *
+ * @param[in] sasl the SASL layer
+ * @param[in] name the configuration name
+ */
+PN_EXTERN void pn_sasl_config_name(pn_sasl_t *sasl, const char *name);
+
+/**
+ * Set the sasl configuration path
+ *
+ * This is used to tell SASL where to look for the configuration file.
+ * In the current implementation it can be a colon separated list of directories.
+ *
+ * The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
+ * but if both methods are used then this pn_sasl_config_path() will take precedence.
+ *
+ * If not set the underlying implementation default will be used.
+ * for a client.
+ *
+ * @param[in] sasl the SASL layer
+ * @param[in] path the configuration path
+ */
+PN_EXTERN void pn_sasl_config_path(pn_sasl_t *sasl, const char *path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sasl.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/selectable.h
----------------------------------------------------------------------
diff --git a/c/include/proton/selectable.h b/c/include/proton/selectable.h
new file mode 100644
index 0000000..9bfb867
--- /dev/null
+++ b/c/include/proton/selectable.h
@@ -0,0 +1,271 @@
+#ifndef PROTON_SELECTABLE_H
+#define PROTON_SELECTABLE_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/object.h>
+#include <proton/event.h>
+#include <proton/type_compat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @cond INTERNAL
+ */
+
+/**
+ * An iterator for selectables.
+ */
+typedef pn_iterator_t pn_selectables_t;
+
+/**
+ * A ::pn_socket_t provides an abstract handle to an IO stream.  The
+ * pipe version is uni-directional.  The network socket version is
+ * bi-directional.  Both are non-blocking.
+ *
+ * pn_socket_t handles from pn_pipe() may only be used with
+ * pn_read(), pn_write(), pn_close() and pn_selector_select().
+ *
+ * pn_socket_t handles from pn_listen(), pn_accept() and
+ * pn_connect() must perform further IO using Proton functions.
+ * Mixing Proton io.h functions with native IO functions on the same
+ * handles will result in undefined behavior.
+ *
+ * pn_socket_t handles may only be used with a single pn_io_t during
+ * their lifetime.
+ */
+#if defined(_WIN32) && ! defined(__CYGWIN__)
+#ifdef _WIN64
+typedef unsigned __int64 pn_socket_t;
+#else
+typedef unsigned int pn_socket_t;
+#endif
+#define PN_INVALID_SOCKET (pn_socket_t)(~0)
+#else
+typedef int pn_socket_t;
+#define PN_INVALID_SOCKET (-1)
+#endif
+
+/**
+ * A selectable object provides an interface that can be used to
+ * incorporate proton's I/O into third party event loops.
+ *
+ * Every selectable is associated with exactly one file descriptor.
+ * Selectables may be interested in three kinds of events, read
+ * events, write events, and timer events. 
+ *
+ * When a read, write, or timer event occurs, the selectable must be
+ * notified by calling ::pn_selectable_readable(),
+ * ::pn_selectable_writable(), and ::pn_selectable_expired() as
+ * appropriate.
+ *
+ * Once a selectable reaches a terminal state (see
+ * ::pn_selectable_is_terminal()), it will never be interested in
+ * events of any kind. When this occurs it should be removed from the
+ * external event loop and discarded using ::pn_selectable_free().
+ */
+typedef struct pn_selectable_t pn_selectable_t;
+
+/**
+ * Construct a new selectables iterator.
+ *
+ * @return a pointer to a new selectables iterator
+ */
+PNX_EXTERN pn_selectables_t *pn_selectables(void);
+
+/**
+ * Get the next selectable from an iterator.
+ *
+ * @param[in] selectables a selectable iterator
+ * @return the next selectable from the iterator
+ */
+PNX_EXTERN pn_selectable_t *pn_selectables_next(pn_selectables_t *selectables);
+
+/**
+ * Free a selectables iterator.
+ *
+ * @param[in] selectables a selectables iterator (or NULL)
+ */
+PNX_EXTERN void pn_selectables_free(pn_selectables_t *selectables);
+
+PNX_EXTERN pn_selectable_t *pn_selectable(void);
+
+PNX_EXTERN void pn_selectable_on_readable(pn_selectable_t *sel, void (*readable)(pn_selectable_t *));
+PNX_EXTERN void pn_selectable_on_writable(pn_selectable_t *sel, void (*writable)(pn_selectable_t *));
+PNX_EXTERN void pn_selectable_on_expired(pn_selectable_t *sel, void (*expired)(pn_selectable_t *));
+PNX_EXTERN void pn_selectable_on_error(pn_selectable_t *sel, void (*error)(pn_selectable_t *));
+PNX_EXTERN void pn_selectable_on_release(pn_selectable_t *sel, void (*release)(pn_selectable_t *));
+PNX_EXTERN void pn_selectable_on_finalize(pn_selectable_t *sel, void (*finalize)(pn_selectable_t *));
+
+PNX_EXTERN pn_record_t *pn_selectable_attachments(pn_selectable_t *sel);
+
+/**
+ * Get the file descriptor associated with a selectable.
+ *
+ * @param[in] selectable a selectable object
+ * @return the file descriptor associated with the selectable
+ */
+PNX_EXTERN pn_socket_t pn_selectable_get_fd(pn_selectable_t *selectable);
+
+/**
+ * Set the file descriptor associated with a selectable.
+ *
+ * @param[in] selectable a selectable object
+ * @param[in] fd the file descriptor
+ */
+PNX_EXTERN void pn_selectable_set_fd(pn_selectable_t *selectable, pn_socket_t fd);
+
+/**
+ * Check if a selectable is interested in readable events.
+ *
+ * @param[in] selectable a selectable object
+ * @return true iff the selectable is interested in read events
+ */
+PNX_EXTERN bool pn_selectable_is_reading(pn_selectable_t *selectable);
+
+PNX_EXTERN void pn_selectable_set_reading(pn_selectable_t *sel, bool reading);
+
+/**
+ * Check if a selectable is interested in writable events.
+ *
+ * @param[in] selectable a selectable object
+ * @return true iff the selectable is interested in writable events
+ */
+PNX_EXTERN bool pn_selectable_is_writing(pn_selectable_t *selectable);
+
+  PNX_EXTERN void pn_selectable_set_writing(pn_selectable_t *sel, bool writing);
+
+/**
+ * Get the next deadline for a selectable.
+ *
+ * A selectable with a deadline is interested in being notified when
+ * that deadline expires. Zero indicates there is currently no
+ * deadline.
+ *
+ * @param[in] selectable a selectable object
+ * @return the next deadline or zero
+ */
+PNX_EXTERN pn_timestamp_t pn_selectable_get_deadline(pn_selectable_t *selectable);
+
+PNX_EXTERN void pn_selectable_set_deadline(pn_selectable_t *sel, pn_timestamp_t deadline);
+
+/**
+ * Notify a selectable that the file descriptor is readable.
+ *
+ * @param[in] selectable a selectable object
+ */
+PNX_EXTERN void pn_selectable_readable(pn_selectable_t *selectable);
+
+/**
+ * Notify a selectable that the file descriptor is writable.
+ *
+ * @param[in] selectable a selectable object
+ */
+PNX_EXTERN void pn_selectable_writable(pn_selectable_t *selectable);
+
+/**
+ * Notify a selectable that there is an error on the file descriptor.
+ *
+ * @param[in] selectable a selectable object
+ */
+PNX_EXTERN void pn_selectable_error(pn_selectable_t *selectable);
+
+/**
+ * Notify a selectable that its deadline has expired.
+ *
+ * @param[in] selectable a selectable object
+ */
+PNX_EXTERN void pn_selectable_expired(pn_selectable_t *selectable);
+
+/**
+ * Check if a selectable is registered.
+ *
+ * This flag is set via ::pn_selectable_set_registered() and can be
+ * used for tracking whether a given selectable has been registered
+ * with an external event loop.
+ *
+ * @param[in] selectable
+ * @return true if the selectable is registered
+ */
+PNX_EXTERN bool pn_selectable_is_registered(pn_selectable_t *selectable);
+
+/**
+ * Set the registered flag for a selectable.
+ *
+ * See ::pn_selectable_is_registered() for details.
+ *
+ * @param[in] selectable a selectable object
+ * @param[in] registered the registered flag
+ */
+PNX_EXTERN void pn_selectable_set_registered(pn_selectable_t *selectable, bool registered);
+
+/**
+ * Check if a selectable is in the terminal state.
+ *
+ * A selectable that is in the terminal state will never be interested
+ * in being notified of events of any kind ever again. Once a
+ * selectable reaches this state it should be removed from any
+ * external I/O loops and freed in order to reclaim any resources
+ * associated with it.
+ *
+ * @param[in] selectable a selectable object
+ * @return true if the selectable is in the terminal state, false otherwise
+ */
+PNX_EXTERN bool pn_selectable_is_terminal(pn_selectable_t *selectable);
+
+/**
+ * Terminate a selectable.
+ *
+ * @param[in] selectable a selectable object
+ */
+PNX_EXTERN void pn_selectable_terminate(pn_selectable_t *selectable);
+
+PNX_EXTERN void pn_selectable_release(pn_selectable_t *selectable);
+
+/**
+ * Free a selectable object.
+ *
+ * @param[in] selectable a selectable object (or NULL)
+ */
+PNX_EXTERN void pn_selectable_free(pn_selectable_t *selectable);
+
+/**
+ * Configure a selectable with a set of callbacks that emit readable,
+ * writable, and expired events into the supplied collector.
+ *
+ * @param[in] selectable a selectable object
+ * @param[in] collector a collector object
+ */
+PNX_EXTERN void pn_selectable_collect(pn_selectable_t *selectable, pn_collector_t *collector);
+
+/**
+ * @endcond
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* selectable.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/session.h
----------------------------------------------------------------------
diff --git a/c/include/proton/session.h b/c/include/proton/session.h
new file mode 100644
index 0000000..cabb1f2
--- /dev/null
+++ b/c/include/proton/session.h
@@ -0,0 +1,297 @@
+#ifndef PROTON_SESSION_H
+#define PROTON_SESSION_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/types.h>
+#include <proton/object.h>
+#include <proton/error.h>
+#include <proton/condition.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * @copybrief session
+ *
+ * @addtogroup session
+ * @{
+ */
+
+/**
+ * Factory for creating a new session on a given connection object.
+ *
+ * Creates a new session object and adds it to the set of sessions
+ * maintained by the connection object.
+ *
+ * @param[in] connection the connection object
+ * @return a pointer to the new session
+ */
+PN_EXTERN pn_session_t *pn_session(pn_connection_t *connection);
+
+/**
+ * Free a session object.
+ *
+ * When a session is freed it will no longer be retained by the
+ * connection once any internal references to the session are no
+ * longer needed. Freeing a session will free all links on that
+ * session and settle any deliveries on those links.
+ *
+ * @param[in] session the session object to free (or NULL)
+ */
+PN_EXTERN void pn_session_free(pn_session_t *session);
+
+/**
+ * **Deprecated** - Use ::pn_session_attachments().
+ *
+ * Get the application context that is associated with a session
+ * object.
+ *
+ * The application context for a session may be set using
+ * ::pn_session_set_context.
+ *
+ * @param[in] session the session whose context is to be returned.
+ * @return the application context for the session object
+ */
+PN_EXTERN void *pn_session_get_context(pn_session_t *session);
+
+/**
+ * **Deprecated** - Use ::pn_session_attachments().
+ *
+ * Set a new application context for a session object.
+ *
+ * The application context for a session object may be retrieved
+ * using ::pn_session_get_context.
+ *
+ * @param[in] session the session object
+ * @param[in] context the application context
+ */
+PN_EXTERN void pn_session_set_context(pn_session_t *session, void *context);
+
+/**
+ * Get the attachments that are associated with a session object.
+ *
+ * @param[in] session the session whose attachments are to be returned.
+ * @return the attachments for the session object
+ */
+PN_EXTERN pn_record_t *pn_session_attachments(pn_session_t *session);
+
+/**
+ * Get the endpoint state flags for a session.
+ *
+ * @param[in] session the session object
+ * @return the session's state flags
+ */
+PN_EXTERN pn_state_t pn_session_state(pn_session_t *session);
+
+/**
+ * **Deprecated**
+ *
+ * Get additional error information associated with the session.
+ *
+ * Whenever a session operation fails (i.e. returns an error code),
+ * additional error details can be obtained using this function. The
+ * error object that is returned may also be used to clear the error
+ * condition.
+ *
+ * The pointer returned by this operation is valid until the
+ * session object is freed.
+ *
+ * @param[in] session the session object
+ * @return the session's error object
+ */
+PN_EXTERN pn_error_t *pn_session_error(pn_session_t *session);
+
+/**
+ * Get the local condition associated with the session endpoint.
+ *
+ * The ::pn_condition_t object retrieved may be modified prior to
+ * closing the session in order to indicate a particular condition
+ * exists when the session closes. This is normally used to
+ * communicate error conditions to the remote peer, however it may
+ * also be used in non error cases. See ::pn_condition_t for more
+ * details.
+ *
+ * The pointer returned by this operation is valid until the session
+ * object is freed.
+ *
+ * @param[in] session the session object
+ * @return the session's local condition object
+ */
+PN_EXTERN pn_condition_t *pn_session_condition(pn_session_t *session);
+
+/**
+ * Get the remote condition associated with the session endpoint.
+ *
+ * The ::pn_condition_t object retrieved may be examined in order to
+ * determine whether the remote peer was indicating some sort of
+ * exceptional condition when the remote session endpoint was
+ * closed. The ::pn_condition_t object returned may not be modified.
+ *
+ * The pointer returned by this operation is valid until the
+ * session object is freed.
+ *
+ * @param[in] session the session object
+ * @return the session's remote condition object
+ */
+PN_EXTERN pn_condition_t *pn_session_remote_condition(pn_session_t *session);
+
+/**
+ * Get the parent connection for a session object.
+ *
+ * This operation retrieves the parent pn_connection_t object that
+ * contains the given pn_session_t object.
+ *
+ * @param[in] session the session object
+ * @return the parent connection object
+ */
+PN_EXTERN pn_connection_t *pn_session_connection(pn_session_t *session);
+
+/**
+ * Open a session.
+ *
+ * Once this operation has completed, the PN_LOCAL_ACTIVE state flag
+ * will be set.
+ *
+ * @param[in] session the session object
+ */
+PN_EXTERN void pn_session_open(pn_session_t *session);
+
+/**
+ * Close a session.
+ *
+ * Once this operation has completed, the PN_LOCAL_CLOSED state flag
+ * will be set. This may be called without calling
+ * ::pn_session_open, in this case it is equivalent to calling
+ * ::pn_session_open followed by ::pn_session_close.
+ *
+ * @param[in] session the session object
+ */
+PN_EXTERN void pn_session_close(pn_session_t *session);
+
+/**
+ * Get the incoming capacity of the session measured in bytes.
+ *
+ * The incoming capacity of a session determines how much incoming
+ * message data the session will buffer. Note that if this value is
+ * less than the negotiated frame size of the transport, it will be
+ * rounded up to one full frame.
+ *
+ * @param[in] session the session object
+ * @return the incoming capacity of the session in bytes
+ */
+PN_EXTERN size_t pn_session_get_incoming_capacity(pn_session_t *session);
+
+/**
+ * Set the incoming capacity for a session object.
+ *
+ * The incoming capacity of a session determines how much incoming
+ * message data the session will buffer. Note that if this value is
+ * less than the negotiated frame size of the transport, it will be
+ * rounded up to one full frame.
+ *
+ * @param[in] session the session object
+ * @param[in] capacity the incoming capacity for the session
+ */
+PN_EXTERN void pn_session_set_incoming_capacity(pn_session_t *session, size_t capacity);
+
+/**
+ * Get the outgoing window for a session object.
+ *
+ * @param[in] session the session object
+ * @return  the outgoing window for the session
+ */
+PN_EXTERN size_t pn_session_get_outgoing_window(pn_session_t *session);
+
+/**
+ * Set the outgoing window for a session object.
+ *
+ * @param[in] session the session object
+ * @param[in] window the outgoing window for the session
+ */
+PN_EXTERN void pn_session_set_outgoing_window(pn_session_t *session, size_t window);
+
+/**
+ * Get the number of outgoing bytes currently buffered by a session.
+ *
+ * @param[in] session the session object
+ * @return the number of outgoing bytes currently buffered
+ */
+PN_EXTERN size_t pn_session_outgoing_bytes(pn_session_t *session);
+
+/**
+ * Get the number of incoming bytes currently buffered by a session.
+ *
+ * @param[in] session the session object
+ * @return the number of incoming bytes currently buffered
+ */
+PN_EXTERN size_t pn_session_incoming_bytes(pn_session_t *session);
+
+/**
+ * Retrieve the first session from a given connection that matches the
+ * specified state mask.
+ *
+ * Examines the state of each session owned by the connection, and
+ * returns the first session that matches the given state mask. If
+ * state contains both local and remote flags, then an exact match
+ * against those flags is performed. If state contains only local or
+ * only remote flags, then a match occurs if any of the local or
+ * remote flags are set respectively.
+ *
+ * @param[in] connection to be searched for matching sessions
+ * @param[in] state mask to match
+ * @return the first session owned by the connection that matches the
+ * mask, else NULL if no sessions match
+ */
+PN_EXTERN pn_session_t *pn_session_head(pn_connection_t *connection, pn_state_t state);
+
+/**
+ * Retrieve the next session from a given connection that matches the
+ * specified state mask.
+ *
+ * When used with ::pn_session_head, application can access all
+ * sessions on the connection that match the given state. See
+ * ::pn_session_head for description of match behavior.
+ *
+ * @param[in] session the previous session obtained from
+ *                    ::pn_session_head or ::pn_session_next
+ * @param[in] state mask to match.
+ * @return the next session owned by the connection that matches the
+ * mask, else NULL if no sessions match
+ */
+PN_EXTERN pn_session_t *pn_session_next(pn_session_t *session, pn_state_t state);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* session.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/ssl.h
----------------------------------------------------------------------
diff --git a/c/include/proton/ssl.h b/c/include/proton/ssl.h
new file mode 100644
index 0000000..81a17a2
--- /dev/null
+++ b/c/include/proton/ssl.h
@@ -0,0 +1,460 @@
+#ifndef PROTON_SSL_H
+#define PROTON_SSL_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * @copybrief ssl
+ *
+ * @addtogroup ssl
+ * @{
+ */
+
+/**    
+ * API for using SSL with the Transport Layer.
+ *
+ * A Transport may be configured to use SSL for encryption and/or authentication.  A
+ * Transport can be configured as either an "SSL client" or an "SSL server".  An SSL
+ * client is the party that proactively establishes a connection to an SSL server.  An SSL
+ * server is the party that accepts a connection request from a remote SSL client.
+ *
+ * This SSL implementation defines the following objects:
+
+ * @li A top-level object that stores the configuration used by one or more SSL
+ * sessions (pn_ssl_domain_t).
+ * @li A per-connection SSL session object that performs the encryption/authentication
+ * associated with the transport (pn_ssl_t).
+ * @li The encryption parameters negotiated for the SSL session (pn_ssl_state_t).
+ *
+ * A pn_ssl_domain_t object must be created and configured before an SSL session can be
+ * established.  The pn_ssl_domain_t is used to construct an SSL session (pn_ssl_t).  The
+ * session "adopts" its configuration from the pn_ssl_domain_t that was used to create it.
+ * For example, pn_ssl_domain_t can be configured as either a "client" or a "server".  SSL
+ * sessions constructed from this domain will perform the corresponding role (either
+ * client or server).
+ *
+ * If either an SSL server or client needs to identify itself with the remote node, it
+ * must have its SSL certificate configured (see ::pn_ssl_domain_set_credentials()).
+ *
+ * If either an SSL server or client needs to verify the identity of the remote node, it
+ * must have its database of trusted CAs configured (see ::pn_ssl_domain_set_trusted_ca_db()).
+ *
+ * An SSL server connection may allow the remote client to connect without SSL (eg. "in
+ * the clear"), see ::pn_ssl_domain_allow_unsecured_client().
+ *
+ * The level of verification required of the remote may be configured (see
+ * ::pn_ssl_domain_set_peer_authentication)
+ *
+ * Support for SSL Client Session resume is provided (see ::pn_ssl_init,
+ * ::pn_ssl_resume_status).
+ */
+typedef struct pn_ssl_domain_t pn_ssl_domain_t;
+
+/**
+ * @see pn_ssl
+ */
+typedef struct pn_ssl_t pn_ssl_t;
+
+/**
+ * Determines the type of SSL endpoint.
+ */
+typedef enum {
+  PN_SSL_MODE_CLIENT = 1, /**< Local connection endpoint is an SSL client */
+  PN_SSL_MODE_SERVER      /**< Local connection endpoint is an SSL server */
+} pn_ssl_mode_t;
+
+/**
+ * Indicates whether an SSL session has been resumed.
+ */
+typedef enum {
+  PN_SSL_RESUME_UNKNOWN,        /**< Session resume state unknown/not supported */
+  PN_SSL_RESUME_NEW,            /**< Session renegotiated - not resumed */
+  PN_SSL_RESUME_REUSED          /**< Session resumed from previous session. */
+} pn_ssl_resume_status_t;
+
+/**
+ * Tests for SSL implementation present
+ *
+ *  @return true if we support SSL, false if not
+ */
+PN_EXTERN bool pn_ssl_present( void );
+
+/**
+ * Create an SSL configuration domain
+ *
+ * This method allocates an SSL domain object.  This object is used to hold the SSL
+ * configuration for one or more SSL sessions.  The SSL session object (pn_ssl_t) is
+ * allocated from this object.
+ *
+ * @param[in] mode the role, client or server, assumed by all SSL sessions created
+ * with this domain.
+ * @return a pointer to the SSL domain, if SSL support is present.
+ */
+PN_EXTERN pn_ssl_domain_t *pn_ssl_domain(pn_ssl_mode_t mode);
+
+/**
+ * Release an SSL configuration domain
+ *
+ * This method frees an SSL domain object allocated by ::pn_ssl_domain.
+ * @param[in] domain the domain to destroy.
+ */
+PN_EXTERN void pn_ssl_domain_free(pn_ssl_domain_t *domain);
+
+/**
+ * Set the certificate that identifies the local node to the remote.
+ *
+ * This certificate establishes the identity for the local node for all SSL sessions
+ * created from this domain.  It will be sent to the remote if the remote needs to verify
+ * the identity of this node.  This may be used for both SSL servers and SSL clients (if
+ * client authentication is required by the server).
+ *
+ * @note This setting effects only those pn_ssl_t objects created after this call
+ * returns.  pn_ssl_t objects created before invoking this method will use the domain's
+ * previous setting.
+ *
+ * @param[in] domain the ssl domain that will use this certificate.
+ * @param[in] credential_1 specifier for the file/database containing the identifying
+ * certificate. For Openssl users, this is a PEM file. For Windows SChannel users, this is
+ * the PKCS#12 file or system store.
+ * @param[in] credential_2 an optional key to access the identifying certificate. For
+ * Openssl users, this is an optional PEM file containing the private key used to sign the
+ * certificate. For Windows SChannel users, this is the friendly name of the
+ * self-identifying certificate if there are multiple certificates in the store.
+ * @param[in] password the password used to sign the key, else NULL if key is not
+ * protected.
+ * @return 0 on success
+ */
+PN_EXTERN int  pn_ssl_domain_set_credentials(pn_ssl_domain_t *domain,
+                                            const char *credential_1,
+                                            const char *credential_2,
+                                            const char *password);
+
+/**
+ * Configure the set of trusted CA certificates used by this domain to verify peers.
+ *
+ * If the local SSL client/server needs to verify the identity of the remote, it must
+ * validate the signature of the remote's certificate.  This function sets the database of
+ * trusted CAs that will be used to verify the signature of the remote's certificate.
+ *
+ * @note This setting effects only those pn_ssl_t objects created after this call
+ * returns.  pn_ssl_t objects created before invoking this method will use the domain's
+ * previous setting.
+ *
+ * @param[in] domain the ssl domain that will use the database.
+ * @param[in] certificate_db database of trusted CAs, used to authenticate the peer.
+ * @return 0 on success
+ */
+PN_EXTERN int pn_ssl_domain_set_trusted_ca_db(pn_ssl_domain_t *domain,
+                                const char *certificate_db);
+
+/**
+ * Determines the level of peer validation.
+ *
+ * ANONYMOUS_PEER does not require a valid certificate, and permits
+ * use of ciphers that do not provide authentication.
+ *
+ * VERIFY_PEER will only connect to those peers that provide a valid
+ * identifying certificate signed by a trusted CA and are using an
+ * authenticated cipher.
+ *
+ * VERIFY_PEER_NAME is like VERIFY_PEER, but also requires the peer's
+ * identity as contained in the certificate to be valid (see
+ * ::pn_ssl_set_peer_hostname).
+ *
+ * ANONYMOUS_PEER is configured by default.
+ */
+typedef enum {
+  PN_SSL_VERIFY_NULL = 0,   /**< internal use only */
+  PN_SSL_VERIFY_PEER,       /**< require peer to provide a valid identifying certificate */
+  PN_SSL_ANONYMOUS_PEER,    /**< do not require a certificate nor cipher authorization */
+  PN_SSL_VERIFY_PEER_NAME   /**< require valid certificate and matching name */
+} pn_ssl_verify_mode_t;
+
+/**
+ * Configure the level of verification used on the peer certificate.
+ *
+ * This method controls how the peer's certificate is validated, if at all.  By default,
+ * neither servers nor clients attempt to verify their peers (PN_SSL_ANONYMOUS_PEER).
+ * Once certificates and trusted CAs are configured, peer verification can be enabled.
+ *
+ * @note In order to verify a peer, a trusted CA must be configured. See
+ * ::pn_ssl_domain_set_trusted_ca_db().
+ *
+ * @note Servers must provide their own certificate when verifying a peer.  See
+ * ::pn_ssl_domain_set_credentials().
+ *
+ * @note This setting effects only those pn_ssl_t objects created after this call
+ * returns.  pn_ssl_t objects created before invoking this method will use the domain's
+ * previous setting.
+ *
+ * @param[in] domain the ssl domain to configure.
+ * @param[in] mode the level of validation to apply to the peer
+ * @param[in] trusted_CAs path to a database of trusted CAs that the server will advertise
+ * to the peer client if the server has been configured to verify its peer.
+ * @return 0 on success
+ */
+PN_EXTERN int pn_ssl_domain_set_peer_authentication(pn_ssl_domain_t *domain,
+                                                    const pn_ssl_verify_mode_t mode,
+                                                    const char *trusted_CAs);
+
+/**
+ * Configure the list of permitted TLS protocols
+ *
+ * @param[in] domain the ssl domain to configure.
+ * @param[in] protocols string representing the protocol list.
+ * This list is a space separated string of the allowed TLS protocols,
+ * The current possibilities are TLSv1 TLSv1.1 TLSv1.2. None of the earlier SSL
+ * protocols are allowed for security reason.
+ *
+ * @note If this API not called then all the TLS protocols are allowed. The API only acts to
+ * restrict the allowed protocols to the specified set.
+ * @return 0 on success
+ */
+PN_EXTERN int pn_ssl_domain_set_protocols(pn_ssl_domain_t *domain, const char *protocols);
+
+/**
+ * Configure the list of permitted ciphers
+ *
+ * @note The syntax of the permitted list is undefined and will depend on the
+ * underlying SSL implementation.
+ *
+ * @param[in] domain the ssl domain to configure.
+ * @param[in] ciphers string representing the cipher list
+ * @return 0 on success
+ */
+PN_EXTERN int pn_ssl_domain_set_ciphers(pn_ssl_domain_t *domain, const char *ciphers);
+
+/**
+ * Permit a server to accept connection requests from non-SSL clients.
+ *
+ * This configures the server to "sniff" the incoming client data stream, and dynamically
+ * determine whether SSL/TLS is being used.  This option is disabled by default: only
+ * clients using SSL/TLS are accepted.
+ *
+ * @param[in] domain the domain (server) that will accept the client connections.
+ * @return 0 on success
+ */
+PN_EXTERN int pn_ssl_domain_allow_unsecured_client(pn_ssl_domain_t *domain);
+
+/**
+ * Create a new SSL session object associated with a transport.
+ *
+ * A transport must have an SSL object in order to "speak" SSL over its connection. This
+ * method allocates an SSL object associates it with the transport.
+ *
+ * @param[in] transport the transport that will own the new SSL session.
+ * @return a pointer to the SSL object configured for this transport.  Returns NULL if
+ * no SSL session is associated with the transport.
+ */
+PN_EXTERN pn_ssl_t *pn_ssl(pn_transport_t *transport);
+
+/**
+ * Initialize an SSL session.
+ *
+ * This method configures an SSL object using the configuration provided by the given
+ * domain.
+ *
+ * @param[in] ssl the ssl session to configured.
+ * @param[in] domain the ssl domain used to configure the SSL session.
+ * @param[in] session_id if supplied, attempt to resume a previous SSL
+ * session that used the same session_id.  If no previous SSL session
+ * is available, a new session will be created using the session_id
+ * and stored for future session restore (see ::::pn_ssl_resume_status).
+ * @return 0 on success, else an error code.
+ */
+PN_EXTERN int pn_ssl_init(pn_ssl_t *ssl,
+                          pn_ssl_domain_t *domain,
+                          const char *session_id);
+
+/**
+ * Get the name of the Cipher that is currently in use.
+ *
+ * Gets a text description of the cipher that is currently active, or
+ * returns FALSE if SSL is not active (no cipher).  Note that the
+ * cipher in use may change over time due to renegotiation or other
+ * changes to the SSL state.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @param[in,out] buffer buffer of size bytes to hold cipher name
+ * @param[in] size maximum number of bytes in buffer.
+ * @return True if cipher name written to buffer, False if no cipher in use.
+ */
+PN_EXTERN bool pn_ssl_get_cipher_name(pn_ssl_t *ssl, char *buffer, size_t size);
+
+/**
+ * Get the SSF (security strength factor) of the Cipher that is currently in use.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @return the ssf, note that 0 means no security.
+ */
+PN_EXTERN int pn_ssl_get_ssf(pn_ssl_t *ssl);
+
+/**
+ * Get the name of the SSL protocol that is currently in use.
+ *
+ * Gets a text description of the SSL protocol that is currently active, or returns FALSE if SSL
+ * is not active.  Note that the protocol may change over time due to renegotiation.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @param[in,out] buffer buffer of size bytes to hold the version identifier
+ * @param[in] size maximum number of bytes in buffer.
+ * @return True if the version information was written to buffer, False if SSL connection
+ * not ready.
+ */
+PN_EXTERN bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *buffer, size_t size);
+
+/**
+ * Check whether the state has been resumed.
+ *
+ * Used for client session resume.  When called on an active session, indicates whether
+ * the state has been resumed from a previous session.
+ *
+ * @note This is a best-effort service - there is no guarantee that the remote server will
+ * accept the resumed parameters.  The remote server may choose to ignore these
+ * parameters, and request a re-negotiation instead.
+ *
+ * @param[in] ssl the ssl session to check
+ * @return status code indicating whether or not the session has been resumed.
+ */
+PN_EXTERN pn_ssl_resume_status_t pn_ssl_resume_status(pn_ssl_t *ssl);
+
+/**
+ * Set the expected identity of the remote peer.
+ *
+ * By default, SSL will use the hostname associated with the connection that
+ * the transport is bound to (see ::pn_connection_set_hostname).  This method
+ * allows the caller to override that default.
+ *
+ * The hostname is used for two purposes: 1) when set on an SSL client, it is sent to the
+ * server during the handshake (if Server Name Indication is supported), and 2) it is used
+ * to check against the identifying name provided in the peer's certificate. If the
+ * supplied name does not exactly match a SubjectAltName (type DNS name), or the
+ * CommonName entry in the peer's certificate, the peer is considered unauthenticated
+ * (potential imposter), and the SSL connection is aborted.
+ *
+ * @note Verification of the hostname is only done if PN_SSL_VERIFY_PEER_NAME is enabled.
+ * See ::pn_ssl_domain_set_peer_authentication.
+ *
+ * @param[in] ssl the ssl session.
+ * @param[in] hostname the expected identity of the remote. Must conform to the syntax as
+ * given in RFC1034, Section 3.5.
+ * @return 0 on success.
+ */
+PN_EXTERN int pn_ssl_set_peer_hostname(pn_ssl_t *ssl, const char *hostname);
+
+/**
+ * Access the configured peer identity.
+ *
+ * Return the expected identity of the remote peer, as set by ::pn_ssl_set_peer_hostname.
+ *
+ * @param[in] ssl the ssl session.
+ * @param[out] hostname buffer to hold the null-terminated name string. If null, no string
+ * is written.
+ * @param[in,out] bufsize on input set to the number of octets in hostname. On output, set
+ * to the number of octets needed to hold the value of hostname plus a null byte.  Zero if
+ * no hostname set.
+ * @return 0 on success.
+ */
+PN_EXTERN int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *hostname, size_t *bufsize);
+
+/**
+ * Get the subject from the peers certificate.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @return A null terminated string representing the full subject,
+ * which is valid until the ssl object is destroyed.
+ */
+PN_EXTERN const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl);
+
+/**
+ * Enumeration identifying the sub fields of the subject field in the ssl certificate.
+ */
+typedef enum {
+  PN_SSL_CERT_SUBJECT_COUNTRY_NAME,
+  PN_SSL_CERT_SUBJECT_STATE_OR_PROVINCE,
+  PN_SSL_CERT_SUBJECT_CITY_OR_LOCALITY,
+  PN_SSL_CERT_SUBJECT_ORGANIZATION_NAME,
+  PN_SSL_CERT_SUBJECT_ORGANIZATION_UNIT,
+  PN_SSL_CERT_SUBJECT_COMMON_NAME
+} pn_ssl_cert_subject_subfield;
+
+/**
+ * Enumeration identifying hashing algorithm.
+ */
+typedef enum {
+  PN_SSL_SHA1,   /* Produces hash that is 20 bytes long */
+  PN_SSL_SHA256, /* Produces hash that is 32 bytes long */
+  PN_SSL_SHA512, /* Produces hash that is 64 bytes long */
+  PN_SSL_MD5     /* Produces hash that is 16 bytes long */
+} pn_ssl_hash_alg;
+
+/**
+ * Get the fingerprint of the certificate. The certificate fingerprint (as displayed in the Fingerprints section when
+ * looking at a certificate with say the Firefox browser) is the hexadecimal hash of the entire certificate.
+ * The fingerprint is not part of the certificate, rather it is computed from the certificate and can be used to uniquely identify a certificate.
+ * @param[in] ssl0 the ssl client/server to query
+ * @param[in] fingerprint char pointer. The certificate fingerprint (in hex format) will be populated in this array.
+ *            If sha1 is the digest name, the fingerprint is 41 characters long (40 + 1 '\0' character), 65 characters long for
+ *            sha256 and 129 characters long for sha512 and 33 characters for md5.
+ * @param[in] fingerprint_length - Must be at >= 33 for md5, >= 41 for sha1, >= 65 for sha256 and >=129 for sha512.
+ * @param[in] hash_alg the hash algorithm to use. Must be of type pn_ssl_hash_alg (currently supports sha1, sha256, sha512 and md5)
+ * @return error code - Returns 0 on success. Return a value less than zero if there were any errors. Upon execution of this function,
+ *                      char *fingerprint will contain the appropriate null terminated hex fingerprint
+ */
+PN_EXTERN int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl0,
+                                          char *fingerprint,
+                                          size_t fingerprint_length,
+                                          pn_ssl_hash_alg hash_alg);
+
+/**
+ * Returns a char pointer that contains the value of the sub field of the subject field in the ssl certificate. The subject field usually contains the following sub fields -
+ * C = ISO3166 two character country code
+ * ST = state or province
+ * L = Locality; generally means city
+ * O = Organization - Company Name
+ * OU = Organization Unit - division or unit
+ * CN = CommonName
+ * @param[in] ssl0 the ssl client/server to query
+ * @param[in] field The enumeration pn_ssl_cert_subject_subfield representing the required sub field.
+ * @return A null terminated string which contains the requested sub field value which is valid until the ssl object is destroyed.
+ */
+PN_EXTERN const char* pn_ssl_get_remote_subject_subfield(pn_ssl_t *ssl0, pn_ssl_cert_subject_subfield field);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ssl.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/terminus.h
----------------------------------------------------------------------
diff --git a/c/include/proton/terminus.h b/c/include/proton/terminus.h
new file mode 100644
index 0000000..b2344c0
--- /dev/null
+++ b/c/include/proton/terminus.h
@@ -0,0 +1,309 @@
+#ifndef PROTON_TERMINUS_H
+#define PROTON_TERMINUS_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/codec.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * @copybrief terminus
+ *
+ * @addtogroup terminus
+ * @{
+ */
+
+/**
+ * Encapsulates the endpoint state associated with an AMQP Terminus.
+ *
+ * An AMQP Terminus acts as either a source or target for messages,
+ * but never both. Every AMQP link is associated with both a source
+ * terminus and a target terminus that is negotiated during link
+ * establishment. A terminus consists of an AMQP address, along with a
+ * number of other properties defining the quality of service and
+ * behaviour of the link.
+ */
+typedef struct pn_terminus_t pn_terminus_t;
+
+/**
+ * Type of an AMQP terminus.
+ */
+typedef enum {
+  PN_UNSPECIFIED = 0, /**< indicates a nonexistent terminus, may used
+                         as a source or target */
+  PN_SOURCE = 1, /**< indicates a source of messages */
+  PN_TARGET = 2, /**< indicates a target for messages */
+  PN_COORDINATOR = 3 /**< a special target identifying a transaction
+                        coordinator */
+} pn_terminus_type_t;
+
+/**
+ * Durability mode of an AMQP terminus.
+ *
+ * An AMQP terminus may provide durable storage for its state, thereby
+ * permitting link recovery in the event of endpoint failures. This
+ * durability may be applied to the configuration of the terminus
+ * only, or to all delivery state as well.
+ */
+typedef enum {
+  PN_NONDURABLE = 0, /**< indicates a non durable terminus */
+  PN_CONFIGURATION = 1, /**< indicates a terminus with durably held
+                           configuration, but not delivery state */
+  PN_DELIVERIES = 2 /**< indicates a terminus with both durably held
+                       configuration and durably held delivery
+                       state. */
+} pn_durability_t;
+
+/**
+ * Expiry policy of an AMQP terminus.
+ *
+ * An orphaned terminus can only exist for the timeout configured by
+ * ::pn_terminus_set_timeout. The expiry policy determines when a
+ * terminus is considered orphaned, i.e. when the expiry timer starts
+ * counting down.
+ */
+typedef enum {
+  PN_EXPIRE_WITH_LINK, /**< the terminus is orphaned when the parent link is closed */
+  PN_EXPIRE_WITH_SESSION, /**< the terminus is orphaned when the parent session is closed */
+  PN_EXPIRE_WITH_CONNECTION, /**< the terminus is orphaned when the parent connection is closed */
+  PN_EXPIRE_NEVER /**< the terminus is never considered orphaned */
+} pn_expiry_policy_t;
+
+/**
+ * Distribution mode of an AMQP terminus.
+ *
+ * The distribution mode of a source terminus defines the behaviour
+ * when multiple receiving links provide addresses that resolve to the
+ * same node.
+ */
+typedef enum {
+  PN_DIST_MODE_UNSPECIFIED = 0, /**< the behaviour is defined by the node */
+  PN_DIST_MODE_COPY = 1, /**< the receiver gets all messages */
+  PN_DIST_MODE_MOVE = 2 /**< the receiver competes for messages */
+} pn_distribution_mode_t;
+
+/**
+ * Get the type of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return the terminus type
+ */
+PN_EXTERN pn_terminus_type_t pn_terminus_get_type(pn_terminus_t *terminus);
+
+/**
+ * Set the type of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] type the terminus type
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_type(pn_terminus_t *terminus, pn_terminus_type_t type);
+
+/**
+ * Get the address of a terminus object.
+ *
+ * The pointer returned by this operation is valid until
+ * ::pn_terminus_set_address is called or until the terminus is freed
+ * due to its parent link being freed.
+ *
+ * @param[in] terminus a terminus object
+ * @return a pointer to the address
+ */
+PN_EXTERN const char *pn_terminus_get_address(pn_terminus_t *terminus);
+
+/**
+ * Set the address of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] address an AMQP address string
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_address(pn_terminus_t *terminus, const char *address);
+
+/**
+ * Get the distribution mode of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return the distribution mode of the terminus
+ */
+PN_EXTERN pn_distribution_mode_t pn_terminus_get_distribution_mode(const pn_terminus_t *terminus);
+
+/**
+ * Set the distribution mode of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] mode the distribution mode for the terminus
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_distribution_mode(pn_terminus_t *terminus, pn_distribution_mode_t mode);
+
+/**
+ * Get the durability mode of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return the terminus durability mode
+ */
+PN_EXTERN pn_durability_t pn_terminus_get_durability(pn_terminus_t *terminus);
+
+/**
+ * Set the durability mode of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] durability the terminus durability mode
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_durability(pn_terminus_t *terminus,
+                                         pn_durability_t durability);
+
+/**
+ * Get the expiry policy of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return the expiry policy of the terminus
+ */
+PN_EXTERN pn_expiry_policy_t pn_terminus_get_expiry_policy(pn_terminus_t *terminus);
+
+/**
+ * Set the expiry policy of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] policy the expiry policy for the terminus
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_expiry_policy(pn_terminus_t *terminus, pn_expiry_policy_t policy);
+
+/**
+ * Get the timeout of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return the timeout of the terminus
+ */
+PN_EXTERN pn_seconds_t pn_terminus_get_timeout(pn_terminus_t *terminus);
+
+/**
+ * Set the timeout of a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] timeout the timeout for the terminus
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_timeout(pn_terminus_t *terminus, pn_seconds_t timeout);
+
+/**
+ * Get the dynamic flag for a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @return true if the dynamic flag is set for the terminus, false otherwise
+ */
+PN_EXTERN bool pn_terminus_is_dynamic(pn_terminus_t *terminus);
+
+/**
+ * Set the dynamic flag for a terminus object.
+ *
+ * @param[in] terminus a terminus object
+ * @param[in] dynamic the dynamic flag for the terminus
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_set_dynamic(pn_terminus_t *terminus, bool dynamic);
+
+/**
+ * Access/modify the AMQP properties data for a terminus object.
+ *
+ * This operation will return a pointer to a ::pn_data_t object that
+ * is valid until the terminus object is freed due to its parent link
+ * being freed. Any data contained by the ::pn_data_t object will be
+ * sent as the AMQP properties for the parent terminus object. Note
+ * that this MUST take the form of a symbol keyed map to be valid.
+ *
+ * @param[in] terminus a terminus object
+ * @return a pointer to a pn_data_t representing the terminus properties
+ */
+PN_EXTERN pn_data_t *pn_terminus_properties(pn_terminus_t *terminus);
+
+/**
+ * Access/modify the AMQP capabilities data for a terminus object.
+ *
+ * This operation will return a pointer to a ::pn_data_t object that
+ * is valid until the terminus object is freed due to its parent link
+ * being freed. Any data contained by the ::pn_data_t object will be
+ * sent as the AMQP capabilities for the parent terminus object. Note
+ * that this MUST take the form of an array of symbols to be valid.
+ *
+ * @param[in] terminus a terminus object
+ * @return a pointer to a pn_data_t representing the terminus capabilities
+ */
+PN_EXTERN pn_data_t *pn_terminus_capabilities(pn_terminus_t *terminus);
+
+/**
+ * Access/modify the AMQP outcomes for a terminus object.
+ *
+ * This operation will return a pointer to a ::pn_data_t object that
+ * is valid until the terminus object is freed due to its parent link
+ * being freed. Any data contained by the ::pn_data_t object will be
+ * sent as the AMQP outcomes for the parent terminus object. Note
+ * that this MUST take the form of an array of symbols to be valid.
+ *
+ * @param[in] terminus a terminus object
+ * @return a pointer to a pn_data_t representing the terminus outcomes
+ */
+PN_EXTERN pn_data_t *pn_terminus_outcomes(pn_terminus_t *terminus);
+
+/**
+ * Access/modify the AMQP filter set for a terminus object.
+ *
+ * This operation will return a pointer to a ::pn_data_t object that
+ * is valid until the terminus object is freed due to its parent link
+ * being freed. Any data contained by the ::pn_data_t object will be
+ * sent as the AMQP filter set for the parent terminus object. Note
+ * that this MUST take the form of a symbol keyed map to be valid.
+ *
+ * @param[in] terminus a source terminus object
+ * @return a pointer to a pn_data_t representing the terminus filter set
+ */
+PN_EXTERN pn_data_t *pn_terminus_filter(pn_terminus_t *terminus);
+
+/**
+ * Copy a terminus object.
+ *
+ * @param[in] terminus the terminus object to be copied into
+ * @param[in] src the terminus to be copied from
+ * @return 0 on success or an error code on failure
+ */
+PN_EXTERN int pn_terminus_copy(pn_terminus_t *terminus, pn_terminus_t *src);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* terminus.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/transport.h
----------------------------------------------------------------------
diff --git a/c/include/proton/transport.h b/c/include/proton/transport.h
new file mode 100644
index 0000000..84494f1
--- /dev/null
+++ b/c/include/proton/transport.h
@@ -0,0 +1,680 @@
+#ifndef PROTON_TRANSPORT_H
+#define PROTON_TRANSPORT_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/import_export.h>
+#include <proton/type_compat.h>
+#include <proton/condition.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ *
+ * @copybrief transport
+ *
+ * @addtogroup transport
+ * @{
+ */
+
+/**
+ * Holds the trace flags for an AMQP transport.
+ *
+ * The trace flags for an AMQP transport control what sort of
+ * information is logged by an AMQP transport. The following bits can
+ * be set:
+ *
+ * - ::PN_TRACE_OFF
+ * - ::PN_TRACE_RAW
+ * - ::PN_TRACE_FRM
+ * - ::PN_TRACE_DRV
+ * - ::PN_TRACE_EVT
+ *
+ */
+typedef int pn_trace_t;
+
+/**
+ * Callback for customizing logging behaviour.
+ */
+typedef void (*pn_tracer_t)(pn_transport_t *transport, const char *message);
+
+/**
+ * Turn logging off entirely.
+ */
+#define PN_TRACE_OFF (0)
+
+/**
+ * Log raw binary data going in and out of the transport.
+ */
+#define PN_TRACE_RAW (1)
+
+/**
+ * Log protocol frames going in and out of the transport.
+ */
+#define PN_TRACE_FRM (2)
+
+/**
+ * Log driver-related events.  For example, initialization, end of
+ * stream, and so on.
+ */
+#define PN_TRACE_DRV (4)
+
+/**
+ * Log events.
+ */
+#define PN_TRACE_EVT (8)
+
+/**
+ * Factory for creating a transport.
+ *
+ * A transport is used by a connection to interface with the network.
+ * There can only be one connection associated with a transport. See
+ * pn_transport_bind().
+ *
+ * Initially a transport is configured to be a client transport. Use
+ * pn_transport_set_server() to configure the transport as a server
+ * transport.
+ *
+ * A client transport initiates outgoing connections.
+ *
+ * A client transport must be configured with the protocol layers to
+ * use and cannot configure itself automatically.
+ *
+ * A server transport accepts incoming connections. It can
+ * automatically configure itself to include the various protocol
+ * layers depending on the incoming protocol headers.
+ *
+ * @return pointer to new transport
+ */
+PN_EXTERN pn_transport_t *pn_transport(void);
+
+/**
+ * Configure a transport as a server
+ *
+ * @param[in] transport a transport object
+ */
+PN_EXTERN void pn_transport_set_server(pn_transport_t *transport);
+
+/**
+ * Free a transport object.
+ *
+ * When a transport is freed, it is automatically unbound from its
+ * associated connection.
+ *
+ * @param[in] transport a transport object or NULL
+ */
+PN_EXTERN void pn_transport_free(pn_transport_t *transport);
+
+/**
+ * Retrieve the authenticated user.
+ *
+ * This is usually used at the the server end to find the name of the
+ * authenticated user.  On the client it will merely return whatever
+ * user was passed in to the pn_connection_set_user() API of the bound
+ * connection.
+ *
+ * The returned value is only reliable after the
+ * PN_TRANSPORT_AUTHENTICATED event has been received.
+ *
+ * @param[in] transport the transport
+ *
+ * @return If a the user is anonymous (either no SASL layer is
+ * negotiated or the SASL ANONYMOUS mechanism is used) then the user
+ * will be "anonymous" Otherwise a string containing the user is
+ * returned.
+ */
+PN_EXTERN const char *pn_transport_get_user(pn_transport_t *transport);
+
+/**
+ * Set whether a non-authenticated transport connection is allowed.
+ *
+ * There are several ways within the AMQP protocol suite to get
+ * unauthenticated connections:
+ *
+ * - Use no SASL layer (with either no TLS or TLS without client certificates)
+ * - Use a SASL layer but the ANONYMOUS mechanism
+ *
+ * The default if this option is not set is to allow unauthenticated connections.
+ *
+ * @param[in] transport the transport
+ * @param[in] required boolean is true when authenticated connections are required
+ */
+PN_EXTERN void pn_transport_require_auth(pn_transport_t *transport, bool required);
+
+/**
+ * Tell whether the transport connection is authenticated
+ *
+ * Note that this property may not be stable until the PN_CONNECTION_REMOTE_OPEN
+ * event is received.
+ *
+ * @param[in] transport the transport
+ * @return bool representing authentication
+ */
+PN_EXTERN bool pn_transport_is_authenticated(pn_transport_t *transport);
+
+/**
+ * Set whether a non encrypted transport connection is allowed
+ *
+ * There are several ways within the AMQP protocol suite to get encrypted connections:
+ * - Use TLS
+ * - Use a SASL with a mechanism that supports security layers
+ *
+ * The default if this option is not set is to allow unencrypted connections.
+ *
+ * @param[in] transport the transport
+ * @param[in] required boolean is true when encrypted connections are required
+ */
+PN_EXTERN void pn_transport_require_encryption(pn_transport_t *transport, bool required);
+
+/**
+ * Tell whether the transport connection is encrypted
+ *
+ * Note that this property may not be stable until the PN_CONNECTION_REMOTE_OPEN
+ * event is received.
+ *
+ * @param[in] transport the transport
+ * @return bool representing encryption
+ */
+PN_EXTERN bool pn_transport_is_encrypted(pn_transport_t *transport);
+
+/**
+ * Get additional information about the condition of the transport.
+ *
+ * When a PN_TRANSPORT_ERROR event occurs, this operation can be used
+ * to access the details of the error condition.
+ *
+ * The pointer returned by this operation is valid until the
+ * transport object is freed.
+ *
+ * @param[in] transport the transport object
+ * @return the transport's condition object
+ */
+PN_EXTERN pn_condition_t *pn_transport_condition(pn_transport_t *transport);
+
+/**
+ * **Deprecated**
+ */
+PN_EXTERN pn_error_t *pn_transport_error(pn_transport_t *transport);
+
+/**
+ * Binds the transport to an AMQP connection.
+ *
+ * @return an error code, or 0 on success
+ */
+PN_EXTERN int pn_transport_bind(pn_transport_t *transport, pn_connection_t *connection);
+
+/**
+ * Unbinds a transport from its AMQP connection.
+ *
+ * @return an error code, or 0 on success
+ */
+PN_EXTERN int pn_transport_unbind(pn_transport_t *transport);
+
+/**
+ * Update a transports trace flags.
+ *
+ * The trace flags for a transport control what sort of information is
+ * logged. See ::pn_trace_t for more details.
+ *
+ * @param[in] transport a transport object
+ * @param[in] trace the trace flags
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_trace(pn_transport_t *transport, pn_trace_t trace);
+
+/**
+ * Set the tracing function used by a transport.
+ *
+ * The tracing function is called to perform logging. Overriding this
+ * function allows embedding applications to divert the engine's
+ * logging to a place of their choice.
+ *
+ * @param[in] transport a transport object
+ * @param[in] tracer the tracing function
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_set_tracer(pn_transport_t *transport, pn_tracer_t tracer);
+
+/**
+ * Get the tracing function used by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the tracing function used by a transport
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN pn_tracer_t pn_transport_get_tracer(pn_transport_t *transport);
+
+/**
+ * **Deprecated** - Use ::pn_transport_attachments().
+ *
+ * Get the application context that is associated with a transport object.
+ *
+ * The application context for a transport may be set using
+ * ::pn_transport_set_context.
+ *
+ * @param[in] transport the transport whose context is to be returned.
+ * @return the application context for the transport object
+ */
+PN_EXTERN void *pn_transport_get_context(pn_transport_t *transport);
+
+/**
+ * **Deprecated** - Use ::pn_transport_attachments().
+ *
+ * Set a new application context for a transport object.
+ *
+ * The application context for a transport object may be retrieved using
+ * ::pn_transport_get_context.
+ *
+ * @param[in] transport the transport object
+ * @param[in] context the application context
+ */
+PN_EXTERN void pn_transport_set_context(pn_transport_t *transport, void *context);
+
+/**
+ * Get the attachments that are associated with a transport object.
+ *
+ * @param[in] transport the transport whose attachments are to be returned.
+ * @return the attachments for the transport object
+ */
+PN_EXTERN pn_record_t *pn_transport_attachments(pn_transport_t *transport);
+
+/**
+ * Log a message using a transport's logging mechanism.
+ *
+ * This can be useful in a debugging context as the log message will
+ * be prefixed with the transport's identifier.
+ *
+ * @param[in] transport a transport object
+ * @param[in] message the message to be logged
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_log(pn_transport_t *transport, const char *message);
+
+/**
+ * Log a printf formatted message using a transport's logging
+ * mechanism.
+ *
+ * This can be useful in a debugging context as the log message will
+ * be prefixed with the transport's identifier.
+ *
+ * @param[in] transport a transport object
+ * @param[in] fmt the printf formatted message to be logged
+ * @param[in] ap a vector containing the format arguments
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_vlogf(pn_transport_t *transport, const char *fmt, va_list ap);
+
+/**
+ * Log a printf formatted message using a transport's logging
+ * mechanism.
+ *
+ * This can be useful in a debugging context as the log message will
+ * be prefixed with the transport's identifier.
+ *
+ * @param[in] transport a transport object
+ * @param[in] fmt the printf formatted message to be logged
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...);
+
+/**
+ * Get the maximum allowed channel for a transport.
+ * This will be the minimum of
+ *   1. limit imposed by this proton implementation
+ *   2. limit imposed by remote peer
+ *   3. limit imposed by this application, using pn_transport_set_channel_max()
+ *
+ * @param[in] transport a transport object
+ * @return the maximum allowed channel
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport);
+
+/**
+ * Set the maximum allowed channel number for a transport.
+ * Note that this is the maximum channel number allowed, giving a
+ * valid channel number range of [0..channel_max]. Therefore the
+ * maximum number of simultaneously active channels will be
+ * channel_max plus 1.
+ * You can call this function more than once to raise and lower
+ * the limit your application imposes on max channels for this
+ * transport.  However, smaller limits may be imposed by this
+ * library, or by the remote peer.
+ * After the OPEN frame has been sent to the remote peer,
+ * further calls to this function will have no effect.
+ *
+ * @param[in] transport a transport object
+ * @param[in] channel_max the maximum allowed channel
+ * @return PN_OK, or PN_STATE_ERR if it is too late to change channel_max
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN int pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max);
+
+/**
+ * Get the maximum allowed channel of a transport's remote peer.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum allowed channel of the transport's remote peer
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN uint16_t pn_transport_remote_channel_max(pn_transport_t *transport);
+
+/**
+ * Get the maximum frame size of a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum frame size of the transport object
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN uint32_t pn_transport_get_max_frame(pn_transport_t *transport);
+
+/**
+ * Set the maximum frame size of a transport.
+ *
+ * @param[in] transport a transport object
+ * @param[in] size the maximum frame size for the transport object
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_set_max_frame(pn_transport_t *transport, uint32_t size);
+
+/**
+ * Get the maximum frame size of a transport's remote peer.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum frame size of the transport's remote peer
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN uint32_t pn_transport_get_remote_max_frame(pn_transport_t *transport);
+
+/**
+ * Get the idle timeout for a transport.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @return the transport's idle timeout
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN pn_millis_t pn_transport_get_idle_timeout(pn_transport_t *transport);
+
+/**
+ * Set the idle timeout for a transport.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @param[in] timeout the idle timeout for the transport object
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN void pn_transport_set_idle_timeout(pn_transport_t *transport, pn_millis_t timeout);
+
+/**
+ * Get the idle timeout for a transport's remote peer.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @return the idle timeout for the transport's remote peer
+ *
+ * @internal XXX Deprecate!
+ */
+PN_EXTERN pn_millis_t pn_transport_get_remote_idle_timeout(pn_transport_t *transport);
+
+/**
+ * **Deprecated**
+ */
+PN_EXTERN ssize_t pn_transport_input(pn_transport_t *transport, const char *bytes, size_t available);
+
+/**
+ * **Deprecated**
+ */
+PN_EXTERN ssize_t pn_transport_output(pn_transport_t *transport, char *bytes, size_t size);
+
+/**
+ * Get the amount of free space for input following the transport's
+ * tail pointer.
+ *
+ * If the engine is in an exceptional state such as encountering an
+ * error condition or reaching the end of stream state, a negative
+ * value will be returned indicating the condition. If an error is
+ * indicated, further details can be obtained from
+ * ::pn_transport_error. Calls to ::pn_transport_process may alter the
+ * value of this pointer. See ::pn_transport_process for details.
+ *
+ * @param[in] transport the transport
+ * @return the free space in the transport, PN_EOS or error code if < 0
+ */
+PN_EXTERN ssize_t pn_transport_capacity(pn_transport_t *transport);
+
+/**
+ * Get the transport's tail pointer.
+ *
+ * The amount of free space following this pointer is reported by
+ * ::pn_transport_capacity. Calls to ::pn_transport_process may alter
+ * the value of this pointer. See ::pn_transport_process for details.
+ *
+ * @param[in] transport the transport
+ * @return a pointer to the transport's input buffer, NULL if no capacity available.
+ */
+PN_EXTERN char *pn_transport_tail(pn_transport_t *transport);
+
+/**
+ * Pushes the supplied bytes into the tail of the transport.
+ *
+ * This is equivalent to copying @c size bytes after the tail pointer
+ * and then calling ::pn_transport_process with an argument of @c
+ * size. Only some of the bytes will be copied if there is
+ * insufficient capacity available. Use ::pn_transport_capacity to
+ * determine how much capacity the transport has.
+ *
+ * @param[in] transport the transport
+ * @param[in] src the start of the data to push into the transport
+ * @param[in] size the amount of data to push into the transport
+ *
+ * @return the number of bytes pushed on success, or error code if < 0
+ */
+PN_EXTERN ssize_t pn_transport_push(pn_transport_t *transport, const char *src, size_t size);
+
+/**
+ * Process input data following the tail pointer.
+ *
+ * Calling this function will cause the transport to consume @c size
+ * bytes of input occupying the free space following the tail pointer.
+ * Calls to this function may change the value of ::pn_transport_tail,
+ * as well as the amount of free space reported by
+ * ::pn_transport_capacity.
+ *
+ * @param[in] transport the transport
+ * @param[in] size the amount of data written to the transport's input buffer
+ * @return 0 on success, or error code if < 0
+ */
+PN_EXTERN int pn_transport_process(pn_transport_t *transport, size_t size);
+
+/**
+ * Indicate that the input has reached End Of Stream (EOS).
+ *
+ * This tells the transport that no more input will be forthcoming.
+ *
+ * @param[in] transport the transport
+ * @return 0 on success, or error code if < 0
+ */
+PN_EXTERN int pn_transport_close_tail(pn_transport_t *transport);
+
+/**
+ * Get the number of pending output bytes following the transport's
+ * head pointer.
+ *
+ * If the engine is in an exceptional state such as encountering an
+ * error condition or reaching the end of stream state, a negative
+ * value will be returned indicating the condition. If an error is
+ * indicated, further details can be obtained from
+ * ::pn_transport_error. Calls to ::pn_transport_pop may alter the
+ * value of this pointer. See ::pn_transport_pop for details.
+ *
+ * @param[in] transport the transport
+ * @return the number of pending output bytes, or an error code
+ */
+PN_EXTERN ssize_t pn_transport_pending(pn_transport_t *transport);
+
+/**
+ * Get the transport's head pointer.
+ *
+ * This pointer references queued output data. The
+ * ::pn_transport_pending function reports how many bytes of output
+ * data follow this pointer. Calls to ::pn_transport_pop may alter
+ * this pointer and any data it references. See ::pn_transport_pop for
+ * details.
+ *
+ * @param[in] transport the transport
+ * @return a pointer to the transport's output buffer, or NULL if no pending output.
+ */
+PN_EXTERN const char *pn_transport_head(pn_transport_t *transport);
+
+/**
+ * Copies @c size bytes from the head of the transport to the @c dst
+ * pointer.
+ *
+ * It is an error to call this with a value of @c size that is greater
+ * than the value reported by ::pn_transport_pending.
+ *
+ * @param[in] transport the transport
+ * @param[out] dst the destination buffer
+ * @param[in] size the capacity of the destination buffer
+ * @return number of bytes copied on success, or error code if < 0
+ */
+PN_EXTERN ssize_t pn_transport_peek(pn_transport_t *transport, char *dst, size_t size);
+
+/**
+ * Removes @c size bytes of output from the pending output queue
+ * following the transport's head pointer.
+ *
+ * Calls to this function may alter the transport's head pointer as
+ * well as the number of pending bytes reported by
+ * ::pn_transport_pending.
+ *
+ * @param[in] transport the transport
+ * @param[in] size the number of bytes to remove
+ */
+PN_EXTERN void pn_transport_pop(pn_transport_t *transport, size_t size);
+
+/**
+ * Indicate that the output has closed.
+ *
+ * This tells the transport that no more output will be popped.
+ *
+ * @param[in] transport the transport
+ * @return 0 on success, or error code if < 0
+ */
+PN_EXTERN int pn_transport_close_head(pn_transport_t *transport);
+
+/**
+ * Check if a transport has buffered data.
+ *
+ * @param[in] transport a transport object
+ * @return true if the transport has buffered data, false otherwise
+ */
+PN_EXTERN bool pn_transport_quiesced(pn_transport_t *transport);
+
+/**
+ * True if pn_transport_close_head() has been called.
+ */
+PN_EXTERN bool pn_transport_head_closed(pn_transport_t *transport);
+
+/**
+ * True if pn_transport_close_tail() has been called.
+ */
+PN_EXTERN bool pn_transport_tail_closed(pn_transport_t *transport);
+
+/**
+ * Equivalent to pn_transport_head_closed(transport) && pn_transport_tail_closed(transport)
+ */
+PN_EXTERN bool pn_transport_closed(pn_transport_t *transport);
+
+/**
+ * Process any pending transport timer events.
+ *
+ * This method should be called after all pending input has been
+ * processed by the transport (see ::pn_transport_input), and before
+ * generating output (see ::pn_transport_output). It returns the
+ * deadline for the next pending timer event, if any are present.
+ *
+ * @param[in] transport the transport to process.
+ * @param[in] now the current time
+ *
+ * @return if non-zero, then the expiration time of the next pending timer event for the
+ * transport.  The caller must invoke pn_transport_tick again at least once at or before
+ * this deadline occurs.
+ */
+PN_EXTERN pn_timestamp_t pn_transport_tick(pn_transport_t *transport, pn_timestamp_t now);
+
+/**
+ * Get the number of frames output by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the number of frames output by the transport
+ */
+PN_EXTERN uint64_t pn_transport_get_frames_output(const pn_transport_t *transport);
+
+/**
+ * Get the number of frames input by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the number of frames input by the transport
+ */
+PN_EXTERN uint64_t pn_transport_get_frames_input(const pn_transport_t *transport);
+
+/**
+ * Access the AMQP Connection associated with the transport.
+ *
+ * @param[in] transport a transport object
+ * @return the connection context for the transport, or NULL if
+ *         none
+ */
+PN_EXTERN pn_connection_t *pn_transport_connection(pn_transport_t *transport);
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}
+ */
+
+#endif /* transport.h */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org