1/* $NetBSD: xsasl.h,v 1.3 2020/03/18 19:05:22 christos Exp $ */ 2 3#ifndef _XSASL_H_INCLUDED_ 4#define _XSASL_H_INCLUDED_ 5 6/*++ 7/* NAME 8/* xsasl 3h 9/* SUMMARY 10/* Postfix SASL plug-in interface 11/* SYNOPSIS 12/* #include <xsasl.h> 13/* DESCRIPTION 14/* .nf 15 16 /* 17 * Utility library. 18 */ 19#include <argv.h> 20#include <vstream.h> 21#include <vstring.h> 22 23 /* 24 * Generic server object. Specific instances extend this with their own 25 * private data. 26 */ 27typedef struct XSASL_SERVER { 28 void (*free) (struct XSASL_SERVER *); 29 int (*first) (struct XSASL_SERVER *, const char *, const char *, VSTRING *); 30 int (*next) (struct XSASL_SERVER *, const char *, VSTRING *); 31 const char *(*get_mechanism_list) (struct XSASL_SERVER *); 32 const char *(*get_username) (struct XSASL_SERVER *); 33} XSASL_SERVER; 34 35#define xsasl_server_free(server) (server)->free(server) 36#define xsasl_server_first(server, method, init_resp, reply) \ 37 (server)->first((server), (method), (init_resp), (reply)) 38#define xsasl_server_next(server, request, reply) \ 39 (server)->next((server), (request), (reply)) 40#define xsasl_server_get_mechanism_list(server) \ 41 (server)->get_mechanism_list((server)) 42#define xsasl_server_get_username(server) \ 43 (server)->get_username((server)) 44 45 /* 46 * Generic server implementation. Specific instances extend this with their 47 * own private data. 48 */ 49typedef struct XSASL_SERVER_CREATE_ARGS { 50 VSTREAM *stream; 51 int addr_family; 52 const char *server_addr; 53 const char *server_port; 54 const char *client_addr; 55 const char *client_port; 56 const char *service; 57 const char *user_realm; 58 const char *security_options; 59 int tls_flag; 60} XSASL_SERVER_CREATE_ARGS; 61 62typedef struct XSASL_SERVER_IMPL { 63 XSASL_SERVER *(*create) (struct XSASL_SERVER_IMPL *, XSASL_SERVER_CREATE_ARGS *); 64 void (*done) (struct XSASL_SERVER_IMPL *); 65} XSASL_SERVER_IMPL; 66 67extern XSASL_SERVER_IMPL *xsasl_server_init(const char *, const char *); 68extern ARGV *xsasl_server_types(void); 69 70#define xsasl_server_create(impl, args) \ 71 (impl)->create((impl), (args)) 72#define XSASL_SERVER_CREATE(impl, args, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ 73 xsasl_server_create((impl), (((args)->a1), ((args)->a2), ((args)->a3), \ 74 ((args)->a4), ((args)->a5), ((args)->a6), ((args)->a7), ((args)->a8), \ 75 ((args)->a9), ((args)->a10), (args))) 76#define xsasl_server_done(impl) (impl)->done((impl)); 77 78 /* 79 * Generic client object. Specific instances extend this with their own 80 * private data. 81 */ 82typedef struct XSASL_CLIENT { 83 void (*free) (struct XSASL_CLIENT *); 84 int (*first) (struct XSASL_CLIENT *, const char *, const char *, const char *, const char **, VSTRING *); 85 int (*next) (struct XSASL_CLIENT *, const char *, VSTRING *); 86} XSASL_CLIENT; 87 88#define xsasl_client_free(client) (client)->free(client) 89#define xsasl_client_first(client, server, method, user, pass, init_resp) \ 90 (client)->first((client), (server), (method), (user), (pass), (init_resp)) 91#define xsasl_client_next(client, request, reply) \ 92 (client)->next((client), (request), (reply)) 93#define xsasl_client_set_password(client, user, pass) \ 94 (client)->set_password((client), (user), (pass)) 95 96 /* 97 * Generic client implementation. Specific instances extend this with their 98 * own private data. 99 */ 100typedef struct XSASL_CLIENT_CREATE_ARGS { 101 VSTREAM *stream; 102 const char *service; 103 const char *server_name; 104 const char *security_options; 105} XSASL_CLIENT_CREATE_ARGS; 106 107typedef struct XSASL_CLIENT_IMPL { 108 XSASL_CLIENT *(*create) (struct XSASL_CLIENT_IMPL *, XSASL_CLIENT_CREATE_ARGS *); 109 void (*done) (struct XSASL_CLIENT_IMPL *); 110} XSASL_CLIENT_IMPL; 111 112extern XSASL_CLIENT_IMPL *xsasl_client_init(const char *, const char *); 113extern ARGV *xsasl_client_types(void); 114 115#define xsasl_client_create(impl, args) \ 116 (impl)->create((impl), (args)) 117#define XSASL_CLIENT_CREATE(impl, args, a1, a2, a3, a4) \ 118 xsasl_client_create((impl), (((args)->a1), ((args)->a2), ((args)->a3), \ 119 ((args)->a4), (args))) 120#define xsasl_client_done(impl) (impl)->done((impl)); 121 122 /* 123 * Status codes. 124 */ 125#define XSASL_AUTH_OK 1 /* Success */ 126#define XSASL_AUTH_MORE 2 /* Need another c/s protocol exchange */ 127#define XSASL_AUTH_DONE 3 /* Authentication completed */ 128#define XSASL_AUTH_FORM 4 /* Cannot decode response */ 129#define XSASL_AUTH_FAIL 5 /* Error */ 130#define XSASL_AUTH_TEMP 6 /* Temporary error condition */ 131 132/* LICENSE 133/* .ad 134/* .fi 135/* The Secure Mailer license must be distributed with this software. 136/* AUTHOR(S) 137/* Wietse Venema 138/* IBM T.J. Watson Research 139/* P.O. Box 704 140/* Yorktown Heights, NY 10598, USA 141/* 142/* Wietse Venema 143/* Google, Inc. 144/* 111 8th Avenue 145/* New York, NY 10011, USA 146/*--*/ 147 148#endif 149