Strophe: conn.c File Reference

Strophe 0.9 XMPP client library

Macros | Functions
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 *const conn, void *const userdata)
static char * | _conn_build_stream_tag (xmpp_conn_t *const 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 *const userdata)
static void | _handle_stream_end (char *name, void *const userdata)
static void | _handle_stream_stanza (xmpp_stanza_t *stanza, void *const userdata)
static unsigned short | _conn_default_port (xmpp_conn_t *const conn, xmpp_conn_type_t type)
static void | _conn_reset (xmpp_conn_t *const conn)
static int | _conn_connect (xmpp_conn_t *const conn, const char *const domain, const char *const host, unsigned short port, xmpp_conn_type_t type, xmpp_certfail_handler certfail_cb, xmpp_conn_handler callback, void *const userdata)
void | xmpp_send_error (xmpp_conn_t *const conn, xmpp_error_type_t const type, char *const text)
xmpp_conn_t * | xmpp_conn_new (xmpp_ctx_t *const ctx)
| Create a new Strophe connection object. More...
xmpp_conn_t * | xmpp_conn_clone (xmpp_conn_t *const conn)
| Clone a Strophe connection object. More...
void | xmpp_conn_set_keepalive (xmpp_conn_t *const 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 *const conn)
| Release a Strophe connection object. More...
const char * | xmpp_conn_get_jid (const xmpp_conn_t *const 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 *const conn)
| Get the JID discovered during binding time. More...
void | xmpp_conn_set_jid (xmpp_conn_t *const conn, const char *const jid)
| Set the JID of the user that will be bound to the connection. More...
const char * | xmpp_conn_get_pass (const xmpp_conn_t *const conn)
| Get the password used for authentication of a connection. More...
void | xmpp_conn_set_pass (xmpp_conn_t *const conn, const char *const pass)
| Set the password used to authenticate the connection. More...
xmpp_ctx_t * | xmpp_conn_get_context (xmpp_conn_t *const conn)
| Get the strophe context that the connection is associated with. More...
int | xmpp_connect_client (xmpp_conn_t *const conn, const char *const altdomain, unsigned short altport, xmpp_certfail_handler certfail_cb, xmpp_conn_handler callback, void *const userdata)
| Initiate a connection to the XMPP server. More...
int | xmpp_connect_component (xmpp_conn_t *const conn, const char *const server, unsigned short port, xmpp_conn_handler callback, void *const userdata)
| Initiate a component connection to server. More...
int | xmpp_connect_raw (xmpp_conn_t *const conn, const char *const altdomain, unsigned short altport, xmpp_certfail_handler certfail_cb, xmpp_conn_handler callback, void *const userdata)
| Initiate a raw connection to the XMPP server. More...
void | conn_established (xmpp_conn_t *const conn)
int | xmpp_conn_open_stream_default (xmpp_conn_t *const conn)
| Send the default opening stream tag. More...
int | xmpp_conn_open_stream (xmpp_conn_t *const conn, char **attributes, size_t attributes_len)
| Send an opening stream tag. More...
int | xmpp_conn_tls_start (xmpp_conn_t *const conn)
| Start synchronous TLS handshake with the server. More...
void | conn_disconnect_clean (xmpp_conn_t *const conn)
| Cleanly disconnect the connection. More...
void | conn_disconnect (xmpp_conn_t *const conn)
| Disconnect from the XMPP server. More...
void | conn_prepare_reset (xmpp_conn_t *const conn, xmpp_open_handler handler)
void | conn_parser_reset (xmpp_conn_t *const conn)
void | xmpp_disconnect (xmpp_conn_t *const conn)
| Initiate termination of the connection to the XMPP server. More...
void | xmpp_send_raw_string (xmpp_conn_t *const conn, const char *const fmt,...)
| Send a raw string to the XMPP server. More...
void | xmpp_send_raw (xmpp_conn_t *const conn, const char *const data, const size_t len)
| Send raw bytes to the XMPP server. More...
void | xmpp_send (xmpp_conn_t *const conn, xmpp_stanza_t *const stanza)
| Send an XML stanza to the XMPP server. More...
void | conn_open_stream (xmpp_conn_t *const conn)
| Send the opening <stream:stream> tag to the server. More...
int | conn_tls_start (xmpp_conn_t *const conn)
long | xmpp_conn_get_flags (const xmpp_conn_t *const conn)
| Return applied flags for the connection. More...
int | xmpp_conn_set_flags (xmpp_conn_t *const conn, long flags)
| Set flags for the connection. More...
void | xmpp_conn_disable_tls (xmpp_conn_t *const conn)
| Disable TLS for this connection, called by users of the library. More...
void | xmpp_conn_tlscert_path (xmpp_conn_t *const conn, char *path)
int | xmpp_conn_is_secured (xmpp_conn_t *const conn)
| Return whether TLS session is established or not. More...
xmpp_tlscert_t * | xmpp_conn_tls_peer_cert (xmpp_conn_t *const conn)
int | xmpp_conn_tlscert_version (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_serialnumber (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_subjectname (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_issuername (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_fingerprint (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_notbefore (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_notafter (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_signature_algorithm (struct _tlscert_t *cert)
char * | xmpp_conn_tlscert_key_algorithm (struct _tlscert_t *cert)
void | xmpp_conn_free_tlscert (xmpp_ctx_t *ctx, struct _tlscert_t *cert)
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 *const | conn,
|  | void *const | userdata
| ) |  |
| static

## ◆ _conn_build_stream_tag()

static char * _conn_build_stream_tag | ( | xmpp_conn_t *const | 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 *const | userdata
| ) |  |
| static

## ◆ _handle_stream_end()

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

## ◆ _handle_stream_stanza()

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

## ◆ _conn_default_port()

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

## ◆ _conn_reset()

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

## ◆ _conn_connect()

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

## ◆ xmpp_send_error()

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

## ◆ conn_established()

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

## ◆ conn_disconnect_clean()

void conn_disconnect_clean | ( | xmpp_conn_t *const | 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 *const | 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 *const | conn,
|  | xmpp_open_handler | handler
| ) |  |

## ◆ conn_parser_reset()

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

## ◆ conn_open_stream()

void conn_open_stream | ( | xmpp_conn_t *const | 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 *const | conn | ) |

## ◆ xmpp_conn_tlscert_path()

void xmpp_conn_tlscert_path | ( | xmpp_conn_t *const | conn,
|  | char * | path
| ) |  |

## ◆ xmpp_conn_tls_peer_cert()

xmpp_tlscert_t* xmpp_conn_tls_peer_cert | ( | xmpp_conn_t *const | conn | ) |

## ◆ xmpp_conn_tlscert_version()

int xmpp_conn_tlscert_version | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_serialnumber()

char* xmpp_conn_tlscert_serialnumber | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_subjectname()

char* xmpp_conn_tlscert_subjectname | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_issuername()

char* xmpp_conn_tlscert_issuername | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_fingerprint()

char* xmpp_conn_tlscert_fingerprint | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_notbefore()

char* xmpp_conn_tlscert_notbefore | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_notafter()

char* xmpp_conn_tlscert_notafter | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_signature_algorithm()

char* xmpp_conn_tlscert_signature_algorithm | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_tlscert_key_algorithm()

char* xmpp_conn_tlscert_key_algorithm | ( | struct _tlscert_t * | cert | ) |

## ◆ xmpp_conn_free_tlscert()

void xmpp_conn_free_tlscert | ( | xmpp_ctx_t * | ctx,
|  | struct _tlscert_t * | cert
| ) |  |

## ◆ _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