conn.c File Reference

Connection management. More...

## Macros

#define | DEFAULT_SEND_QUEUE_MAX 64
| The default maximum send queue size. More...
#define | DISCONNECT_TIMEOUT 2000 /* 2 seconds */
| The time to wait (in milliseconds) for graceful disconnection to complete before the connection is reset. More...
#define | CONNECT_TIMEOUT 5000 /* 5 seconds */
| The time to wait (in milliseconds) for a connection attempt to succeed or error. More...

## Functions

static int | _disconnect_cleanup (xmpp_conn_t *conn, void *userdata)
static char * | _conn_build_stream_tag (xmpp_conn_t *conn, char **attributes, size_t attributes_len)
static int | _conn_open_stream_with_attributes (xmpp_conn_t *conn, char **attributes, size_t attributes_len)
static void | _conn_attributes_new (xmpp_conn_t *conn, char **attrs, char ***attributes, size_t *attributes_len)
static void | _conn_attributes_destroy (xmpp_conn_t *conn, char **attributes, size_t attributes_len)
static void | _handle_stream_start (char *name, char **attrs, void *userdata)
static void | _handle_stream_end (char *name, void *userdata)
static void | _handle_stream_stanza (xmpp_stanza_t *stanza, void *userdata)
static unsigned short | _conn_default_port (xmpp_conn_t *conn, xmpp_conn_type_t type)
static void | _conn_reset (xmpp_conn_t *conn)
static int | _conn_connect (xmpp_conn_t *conn, const char *domain, const char *host, unsigned short port, xmpp_conn_type_t type, xmpp_conn_handler callback, void *userdata)
static int | _send_raw (xmpp_conn_t *conn, char *data, size_t len)
void | xmpp_send_error (xmpp_conn_t *conn, xmpp_error_type_t type, char *text)
xmpp_conn_t * | xmpp_conn_new (xmpp_ctx_t *ctx)
| Create a new Strophe connection object. More...
xmpp_conn_t * | xmpp_conn_clone (xmpp_conn_t *conn)
| Clone a Strophe connection object. More...
void | xmpp_conn_set_keepalive (xmpp_conn_t *conn, int timeout, int interval)
| Set TCP keepalive parameters Turn on TCP keepalive and set timeout and interval. More...
int | xmpp_conn_release (xmpp_conn_t *conn)
| Release a Strophe connection object. More...
const char * | xmpp_conn_get_jid (const xmpp_conn_t *conn)
| Get the JID which is or will be bound to the connection. More...
const char * | xmpp_conn_get_bound_jid (const xmpp_conn_t *conn)
| Get the JID discovered during binding time. More...
void | xmpp_conn_set_jid (xmpp_conn_t *conn, const char *jid)
| Set the JID of the user that will be bound to the connection. More...
void | xmpp_conn_set_certfail_handler (xmpp_conn_t *const conn, xmpp_certfail_handler hndl)
| Set the Handler function which will be called when the TLS stack can't verify the CA of the server we're trying to connect to. More...
void | xmpp_conn_set_cafile (xmpp_conn_t *const conn, const char *path)
| Set the CAfile. More...
void | xmpp_conn_set_capath (xmpp_conn_t *const conn, const char *path)
| Set the CApath. More...
xmpp_tlscert_t * | xmpp_conn_get_peer_cert (xmpp_conn_t *const conn)
| Retrieve the peer certificate. More...
void | xmpp_conn_set_client_cert (xmpp_conn_t *const conn, const char *const cert, const char *const key)
| Set the Client Certificate and Private Key that will be bound to the connection. More...
unsigned int | xmpp_conn_cert_xmppaddr_num (xmpp_conn_t *const conn)
| Get the number of xmppAddr entries in the client certificate. More...
char * | xmpp_conn_cert_xmppaddr (xmpp_conn_t *const conn, unsigned int n)
| Get a specific xmppAddr entry. More...
const char * | xmpp_conn_get_pass (const xmpp_conn_t *conn)
| Get the password used for authentication of a connection. More...
void | xmpp_conn_set_pass (xmpp_conn_t *conn, const char *pass)
| Set the password used to authenticate the connection. More...
xmpp_ctx_t * | xmpp_conn_get_context (xmpp_conn_t *conn)
| Get the strophe context that the connection is associated with. More...
int | xmpp_connect_client (xmpp_conn_t *conn, const char *altdomain, unsigned short altport, xmpp_conn_handler callback, void *userdata)
| Initiate a connection to the XMPP server. More...
int | xmpp_connect_component (xmpp_conn_t *conn, const char *server, unsigned short port, xmpp_conn_handler callback, void *userdata)
| Initiate a component connection to server. More...
int | xmpp_connect_raw (xmpp_conn_t *conn, const char *altdomain, unsigned short altport, xmpp_conn_handler callback, void *userdata)
| Initiate a raw connection to the XMPP server. More...
void | conn_established (xmpp_conn_t *conn)
int | xmpp_conn_open_stream_default (xmpp_conn_t *conn)
| Send the default opening stream tag. More...
int | xmpp_conn_open_stream (xmpp_conn_t *conn, char **attributes, size_t attributes_len)
| Send an opening stream tag. More...
int | xmpp_conn_tls_start (xmpp_conn_t *conn)
| Start synchronous TLS handshake with the server. More...
void | conn_disconnect_clean (xmpp_conn_t *conn)
| Cleanly disconnect the connection. More...
void | conn_disconnect (xmpp_conn_t *conn)
| Disconnect from the XMPP server. More...
void | conn_prepare_reset (xmpp_conn_t *conn, xmpp_open_handler handler)
void | conn_parser_reset (xmpp_conn_t *conn)
void | xmpp_disconnect (xmpp_conn_t *conn)
| Initiate termination of the connection to the XMPP server. More...
void | xmpp_send_raw_string (xmpp_conn_t *conn, const char *fmt,...)
| Send a raw string to the XMPP server. More...
void | xmpp_send_raw (xmpp_conn_t *conn, const char *data, size_t len)
| Send raw bytes to the XMPP server. More...
void | xmpp_send (xmpp_conn_t *conn, xmpp_stanza_t *stanza)
| Send an XML stanza to the XMPP server. More...
void | conn_open_stream (xmpp_conn_t *conn)
| Send the opening <stream:stream> tag to the server. More...
int | conn_tls_start (xmpp_conn_t *conn)
long | xmpp_conn_get_flags (const xmpp_conn_t *conn)
| Return applied flags for the connection. More...
int | xmpp_conn_set_flags (xmpp_conn_t *conn, long flags)
| Set flags for the connection. More...
void | xmpp_conn_disable_tls (xmpp_conn_t *conn)
| Disable TLS for this connection, called by users of the library. More...
int | xmpp_conn_is_secured (xmpp_conn_t *conn)
| Return whether TLS session is established or not. More...
int | xmpp_conn_is_connecting (xmpp_conn_t *conn)
int | xmpp_conn_is_connected (xmpp_conn_t *conn)
int | xmpp_conn_is_disconnected (xmpp_conn_t *conn)
static void | _log_open_tag (xmpp_conn_t *conn, char **attrs)
static char * | _get_stream_attribute (char **attrs, char *name)

## Detailed Description

Connection management.

## Macro Definition Documentation

## DEFAULT_SEND_QUEUE_MAX

#define DEFAULT_SEND_QUEUE_MAX 64

The default maximum send queue size.

This is currently unused.

## DISCONNECT_TIMEOUT

#define DISCONNECT_TIMEOUT 2000 /* 2 seconds */

The time to wait (in milliseconds) for graceful disconnection to complete before the connection is reset.

The default is 2 seconds.

## CONNECT_TIMEOUT

#define CONNECT_TIMEOUT 5000 /* 5 seconds */

The time to wait (in milliseconds) for a connection attempt to succeed or error.

The default is 5 seconds.

## Function Documentation

## _disconnect_cleanup()

static int _disconnect_cleanup | ( | xmpp_conn_t * | conn,
|  | void * | userdata
| ) |  |

static

## _conn_build_stream_tag()

static char * _conn_build_stream_tag | ( | xmpp_conn_t * | conn,
|  | char ** | attributes,
|  | size_t | attributes_len
| ) |  |

static

## _conn_open_stream_with_attributes()

static int _conn_open_stream_with_attributes | ( | xmpp_conn_t * | conn,
|  | char ** | attributes,
|  | size_t | attributes_len
| ) |  |

static

## _conn_attributes_new()

static void _conn_attributes_new | ( | xmpp_conn_t * | conn,
|  | char ** | attrs,
|  | char *** | attributes,
|  | size_t * | attributes_len
| ) |  |

static

## _conn_attributes_destroy()

static void _conn_attributes_destroy | ( | xmpp_conn_t * | conn,
|  | char ** | attributes,
|  | size_t | attributes_len
| ) |  |

static

## _handle_stream_start()

static void _handle_stream_start | ( | char * | name,
|  | char ** | attrs,
|  | void * | userdata
| ) |  |

static

## _handle_stream_end()

static void _handle_stream_end | ( | char * | name,
|  | void * | userdata
| ) |  |

static

## _handle_stream_stanza()

static void _handle_stream_stanza | ( | xmpp_stanza_t * | stanza,
|  | void * | userdata
| ) |  |

static

## _conn_default_port()

static unsigned short _conn_default_port | ( | xmpp_conn_t * | conn,
|  | xmpp_conn_type_t | type
| ) |  |

static

## _conn_reset()

static void _conn_reset | ( | xmpp_conn_t * | conn | ) |

static

## _conn_connect()

static int _conn_connect | ( | xmpp_conn_t * | conn,
|  | const char * | domain,
|  | const char * | host,
|  | unsigned short | port,
|  | xmpp_conn_type_t | type,
|  | xmpp_conn_handler | callback,
|  | void * | userdata
| ) |  |

static

## _send_raw()

static int _send_raw | ( | xmpp_conn_t * | conn,
|  | char * | data,
|  | size_t | len
| ) |  |

static

## xmpp_send_error()

void xmpp_send_error | ( | xmpp_conn_t * | conn,
|  | xmpp_error_type_t | type,
|  | char * | text
| ) |  |

## conn_established()

void conn_established | ( | xmpp_conn_t * | conn | ) |

## conn_disconnect_clean()

void conn_disconnect_clean | ( | xmpp_conn_t * | conn | ) |

Cleanly disconnect the connection.

This function is only called by the stream parser when </stream:stream> is received, and it not intended to be called by code outside of Strophe.

Parameters

  conn | a Strophe connection object

## conn_disconnect()

void conn_disconnect | ( | xmpp_conn_t * | conn | ) |

Disconnect from the XMPP server.

This function immediately disconnects from the XMPP server, and should not be used outside of the Strophe library.

Parameters

  conn | a Strophe connection object

## conn_prepare_reset()

void conn_prepare_reset | ( | xmpp_conn_t * | conn,
|  | xmpp_open_handler | handler
| ) |  |

## conn_parser_reset()

void conn_parser_reset | ( | xmpp_conn_t * | conn | ) |

## conn_open_stream()

void conn_open_stream | ( | xmpp_conn_t * | conn | ) |

Send the opening <stream:stream> tag to the server.

This function is used by Strophe to begin an XMPP stream. It should not be used outside of the library.

Parameters

  conn | a Strophe connection object

## conn_tls_start()

int conn_tls_start | ( | xmpp_conn_t * | conn | ) |

## _log_open_tag()

static void _log_open_tag | ( | xmpp_conn_t * | conn,
|  | char ** | attrs
| ) |  |

static

## _get_stream_attribute()

static char* _get_stream_attribute | ( | char ** | attrs,
|  | char * | name
| ) |  |

static