1 /* $NetBSD: xsasl.h,v 1.1.1.1 2009/06/23 10:09:02 tron 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 */ 27 typedef 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 */ 49 typedef struct XSASL_SERVER_CREATE_ARGS { 50 VSTREAM *stream; 51 const char *server_addr; 52 const char *client_addr; 53 const char *service; 54 const char *user_realm; 55 const char *security_options; 56 int tls_flag; 57 } XSASL_SERVER_CREATE_ARGS; 58 59 typedef struct XSASL_SERVER_IMPL { 60 XSASL_SERVER *(*create) (struct XSASL_SERVER_IMPL *, XSASL_SERVER_CREATE_ARGS *); 61 void (*done) (struct XSASL_SERVER_IMPL *); 62 } XSASL_SERVER_IMPL; 63 64 extern XSASL_SERVER_IMPL *xsasl_server_init(const char *, const char *); 65 extern ARGV *xsasl_server_types(void); 66 67 #define xsasl_server_create(impl, args) \ 68 (impl)->create((impl), (args)) 69 #define XSASL_SERVER_CREATE(impl, args, a1, a2, a3, a4, a5, a6, a7) \ 70 xsasl_server_create((impl), (((args)->a1), ((args)->a2), ((args)->a3), \ 71 ((args)->a4), ((args)->a5), ((args)->a6), ((args)->a7), (args))) 72 #define xsasl_server_done(impl) (impl)->done((impl)); 73 74 /* 75 * Generic client object. Specific instances extend this with their own 76 * private data. 77 */ 78 typedef struct XSASL_CLIENT { 79 void (*free) (struct XSASL_CLIENT *); 80 int (*first) (struct XSASL_CLIENT *, const char *, const char *, const char *, const char **, VSTRING *); 81 int (*next) (struct XSASL_CLIENT *, const char *, VSTRING *); 82 } XSASL_CLIENT; 83 84 #define xsasl_client_free(client) (client)->free(client) 85 #define xsasl_client_first(client, server, method, user, pass, init_resp) \ 86 (client)->first((client), (server), (method), (user), (pass), (init_resp)) 87 #define xsasl_client_next(client, request, reply) \ 88 (client)->next((client), (request), (reply)) 89 #define xsasl_client_set_password(client, user, pass) \ 90 (client)->set_password((client), (user), (pass)) 91 92 /* 93 * Generic client implementation. Specific instances extend this with their 94 * own private data. 95 */ 96 typedef struct XSASL_CLIENT_CREATE_ARGS { 97 VSTREAM *stream; 98 const char *service; 99 const char *server_name; 100 const char *security_options; 101 } XSASL_CLIENT_CREATE_ARGS; 102 103 typedef struct XSASL_CLIENT_IMPL { 104 XSASL_CLIENT *(*create) (struct XSASL_CLIENT_IMPL *, XSASL_CLIENT_CREATE_ARGS *); 105 void (*done) (struct XSASL_CLIENT_IMPL *); 106 } XSASL_CLIENT_IMPL; 107 108 extern XSASL_CLIENT_IMPL *xsasl_client_init(const char *, const char *); 109 extern ARGV *xsasl_client_types(void); 110 111 #define xsasl_client_create(impl, args) \ 112 (impl)->create((impl), (args)) 113 #define XSASL_CLIENT_CREATE(impl, args, a1, a2, a3, a4) \ 114 xsasl_client_create((impl), (((args)->a1), ((args)->a2), ((args)->a3), \ 115 ((args)->a4), (args))) 116 #define xsasl_client_done(impl) (impl)->done((impl)); 117 118 /* 119 * Status codes. 120 */ 121 #define XSASL_AUTH_OK 1 /* Success */ 122 #define XSASL_AUTH_MORE 2 /* Need another c/s protocol exchange */ 123 #define XSASL_AUTH_DONE 3 /* Authentication completed */ 124 #define XSASL_AUTH_FORM 4 /* Cannot decode response */ 125 #define XSASL_AUTH_FAIL 5 /* Error */ 126 127 /* LICENSE 128 /* .ad 129 /* .fi 130 /* The Secure Mailer license must be distributed with this software. 131 /* AUTHOR(S) 132 /* Wietse Venema 133 /* IBM T.J. Watson Research 134 /* P.O. Box 704 135 /* Yorktown Heights, NY 10598, USA 136 /*--*/ 137 138 #endif 139