jabberd2  2.6.1
Data Structures | Typedefs | Functions
sasl.c File Reference
#include "sx.h"
#include "sasl.h"
#include <gsasl.h>
#include <gsasl-mech.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  _sx_sasl_st
 our sasl application context More...
 
struct  _sx_sasl_sess_st
 our sasl per session context More...
 

Typedefs

typedef struct _sx_sasl_st_sx_sasl_t
 our sasl application context More...
 
typedef struct _sx_sasl_sess_st_sx_sasl_sess_t
 our sasl per session context More...
 

Functions

static nad_t _sx_sasl_success (sx_t s, const char *data, int dlen)
 utility: generate a success nad More...
 
static nad_t _sx_sasl_failure (sx_t s, const char *err, const char *text)
 utility: generate a failure nad More...
 
static nad_t _sx_sasl_challenge (sx_t s, const char *data, int dlen)
 utility: generate a challenge nad More...
 
static nad_t _sx_sasl_response (sx_t s, const char *data, int dlen)
 utility: generate a response nad More...
 
static nad_t _sx_sasl_abort (sx_t s)
 utility: generate an abort nad More...
 
static int _sx_sasl_wio (sx_t s, sx_plugin_t p, sx_buf_t buf)
 
static int _sx_sasl_rio (sx_t s, sx_plugin_t p, sx_buf_t buf)
 
void _sx_sasl_open (sx_t s, Gsasl_session *sd)
 move the stream to the auth state More...
 
static void _sx_sasl_stream (sx_t s, sx_plugin_t p)
 make the stream authenticated second time round More...
 
static void _sx_sasl_features (sx_t s, sx_plugin_t p, nad_t nad)
 
static void _sx_sasl_notify_success (sx_t s, void *arg)
 auth done, restart the stream More...
 
static void _sx_sasl_client_process (sx_t s, sx_plugin_t p, Gsasl_session *sd, const char *mech, const char *in, int inlen)
 process handshake packets from the client More...
 
static void _sx_sasl_server_process (sx_t s, sx_plugin_t p, Gsasl_session *sd, const char *in, int inlen)
 process handshake packets from the server More...
 
static int _sx_sasl_process (sx_t s, sx_plugin_t p, nad_t nad)
 main nad processor More...
 
static void _sx_sasl_free (sx_t s, sx_plugin_t p)
 cleanup More...
 
static int _sx_sasl_gsasl_callback (Gsasl *gsasl_ctx, Gsasl_session *sd, Gsasl_property prop)
 
static void _sx_sasl_unload (sx_plugin_t p)
 
int sx_sasl_init (sx_env_t env, sx_plugin_t p, va_list args)
 args: appname, callback, cb arg More...
 
int sx_sasl_auth (sx_plugin_t p, sx_t s, const char *appname, const char *mech, const char *user, const char *pass)
 kick off the auth handshake More...
 

Typedef Documentation

◆ _sx_sasl_t

typedef struct _sx_sasl_st * _sx_sasl_t

our sasl application context

◆ _sx_sasl_sess_t

our sasl per session context

Function Documentation

◆ _sx_sasl_success()

static nad_t _sx_sasl_success ( sx_t  s,
const char *  data,
int  dlen 
)
static

utility: generate a success nad

Definition at line 47 of file sasl.c.

References nad_add_namespace(), nad_append_cdata(), nad_append_elem(), nad_new(), and uri_SASL.

Referenced by _sx_sasl_client_process().

◆ _sx_sasl_failure()

static nad_t _sx_sasl_failure ( sx_t  s,
const char *  err,
const char *  text 
)
static

utility: generate a failure nad

Definition at line 62 of file sasl.c.

References nad_add_namespace(), nad_append_cdata(), nad_append_elem(), nad_new(), and uri_SASL.

Referenced by _sx_sasl_client_process(), and _sx_sasl_process().

◆ _sx_sasl_challenge()

static nad_t _sx_sasl_challenge ( sx_t  s,
const char *  data,
int  dlen 
)
static

utility: generate a challenge nad

Definition at line 81 of file sasl.c.

References nad_add_namespace(), nad_append_cdata(), nad_append_elem(), nad_new(), and uri_SASL.

Referenced by _sx_sasl_client_process().

◆ _sx_sasl_response()

static nad_t _sx_sasl_response ( sx_t  s,
const char *  data,
int  dlen 
)
static

utility: generate a response nad

Definition at line 96 of file sasl.c.

References nad_add_namespace(), nad_append_cdata(), nad_append_elem(), nad_new(), and uri_SASL.

Referenced by _sx_sasl_server_process().

◆ _sx_sasl_abort()

static nad_t _sx_sasl_abort ( sx_t  s)
static

utility: generate an abort nad

Definition at line 111 of file sasl.c.

References nad_add_namespace(), nad_append_elem(), nad_new(), and uri_SASL.

Referenced by _sx_sasl_server_process().

◆ _sx_sasl_wio()

static int _sx_sasl_wio ( sx_t  s,
sx_plugin_t  p,
sx_buf_t  buf 
)
static

◆ _sx_sasl_rio()

static int _sx_sasl_rio ( sx_t  s,
sx_plugin_t  p,
sx_buf_t  buf 
)
static

◆ _sx_sasl_open()

void _sx_sasl_open ( sx_t  s,
Gsasl_session *  sd 
)

◆ _sx_sasl_stream()

static void _sx_sasl_stream ( sx_t  s,
sx_plugin_t  p 
)
static

make the stream authenticated second time round

Definition at line 226 of file sasl.c.

References _sx_debug, _sx_sasl_open(), _sx_plugin_st::index, _sx_st::plugin_data, and ZONE.

Referenced by sx_sasl_init().

◆ _sx_sasl_features()

static void _sx_sasl_features ( sx_t  s,
sx_plugin_t  p,
nad_t  nad 
)
static

◆ _sx_sasl_notify_success()

static void _sx_sasl_notify_success ( sx_t  s,
void *  arg 
)
static

auth done, restart the stream

Definition at line 306 of file sasl.c.

References _sx_chain_io_plugin(), _sx_debug, _sx_reset(), _sx_st::flags, sx_server_init(), and ZONE.

Referenced by _sx_sasl_client_process().

◆ _sx_sasl_client_process()

static void _sx_sasl_client_process ( sx_t  s,
sx_plugin_t  p,
Gsasl_session *  sd,
const char *  mech,
const char *  in,
int  inlen 
)
static

◆ _sx_sasl_server_process()

static void _sx_sasl_server_process ( sx_t  s,
sx_plugin_t  p,
Gsasl_session *  sd,
const char *  in,
int  inlen 
)
static

process handshake packets from the server

Definition at line 522 of file sasl.c.

References _sx_debug, _sx_nad_write(), _sx_sasl_abort(), _sx_sasl_response(), and ZONE.

Referenced by _sx_sasl_process().

◆ _sx_sasl_process()

static int _sx_sasl_process ( sx_t  s,
sx_plugin_t  p,
nad_t  nad 
)
static

◆ _sx_sasl_free()

static void _sx_sasl_free ( sx_t  s,
sx_plugin_t  p 
)
static

cleanup

Definition at line 713 of file sasl.c.

References _sx_debug, _sx_plugin_st::index, _sx_st::plugin_data, and ZONE.

Referenced by sx_sasl_init().

◆ _sx_sasl_gsasl_callback()

static int _sx_sasl_gsasl_callback ( Gsasl *  gsasl_ctx,
Gsasl_session *  sd,
Gsasl_property  prop 
)
static

◆ _sx_sasl_unload()

static void _sx_sasl_unload ( sx_plugin_t  p)
static

◆ sx_sasl_init()

int sx_sasl_init ( sx_env_t  env,
sx_plugin_t  p,
va_list  args 
)

◆ sx_sasl_auth()

int sx_sasl_auth ( sx_plugin_t  p,
sx_t  s,
const char *  appname,
const char *  mech,
const char *  user,
const char *  pass 
)