46 #ifndef _PLUGIN_COMMON_H_
47 #define _PLUGIN_COMMON_H_
51 # include <winsock2.h>
53 # include <sys/socket.h>
54 # include <netinet/in.h>
55 # include <arpa/inet.h>
65 #define PLUG_API __declspec(dllexport)
67 #define PLUG_API extern
70 #define SASL_CLIENT_PLUG_INIT( x ) \
71 extern sasl_client_plug_init_t x##_client_plug_init; \
72 PLUG_API int sasl_client_plug_init(const sasl_utils_t *utils, \
73 int maxversion, int *out_version, \
74 sasl_client_plug_t **pluglist, \
76 return x##_client_plug_init(utils, maxversion, out_version, \
77 pluglist, plugcount); \
80 #define SASL_SERVER_PLUG_INIT( x ) \
81 extern sasl_server_plug_init_t x##_server_plug_init; \
82 PLUG_API int sasl_server_plug_init(const sasl_utils_t *utils, \
83 int maxversion, int *out_version, \
84 sasl_server_plug_t **pluglist, \
86 return x##_server_plug_init(utils, maxversion, out_version, \
87 pluglist, plugcount); \
90 #define SASL_AUXPROP_PLUG_INIT( x ) \
91 extern sasl_auxprop_init_t x##_auxprop_plug_init; \
92 PLUG_API int sasl_auxprop_plug_init(const sasl_utils_t *utils, \
93 int maxversion, int *out_version, \
94 sasl_auxprop_plug_t **plug, \
95 const char *plugname) {\
96 return x##_auxprop_plug_init(utils, maxversion, out_version, \
100 #define SASL_CANONUSER_PLUG_INIT( x ) \
101 extern sasl_canonuser_init_t x##_canonuser_plug_init; \
102 PLUG_API int sasl_canonuser_init(const sasl_utils_t *utils, \
103 int maxversion, int *out_version, \
104 sasl_canonuser_plug_t **plug, \
105 const char *plugname) {\
106 return x##_canonuser_plug_init(utils, maxversion, out_version, \
112 #define SETERROR( utils, msg ) (utils)->seterror( (utils)->conn, 0, "%s", (msg) )
115 #define MEMERROR( utils ) \
116 (utils)->seterror( (utils)->conn, 0, \
117 "Out of Memory in " __FILE__ " near line %d", __LINE__ )
121 #define PARAMERROR( utils ) \
122 (utils)->seterror( (utils)->conn, 0, \
123 "Parameter Error in " __FILE__ " near line %d", __LINE__ )
127 typedef struct buffer_info
139 int _plug_ipfromstring(
const sasl_utils_t *utils,
const char *addr,
140 struct sockaddr *out, socklen_t outlen);
141 int _plug_iovec_to_buf(
const sasl_utils_t *utils,
const struct iovec *vec,
142 unsigned numiov, buffer_info_t **output);
143 int _plug_buf_alloc(
const sasl_utils_t *utils,
char **rwbuf,
144 unsigned *curlen,
unsigned newlen);
145 int _plug_strdup(
const sasl_utils_t * utils,
const char *in,
146 char **out,
int *outlen);
147 void _plug_free_string(
const sasl_utils_t *utils,
char **str);
148 void _plug_free_secret(
const sasl_utils_t *utils, sasl_secret_t **secret);
150 #define _plug_get_userid(utils, result, prompt_need) \
151 _plug_get_simple(utils, SASL_CB_USER, 0, result, prompt_need)
152 #define _plug_get_authid(utils, result, prompt_need) \
153 _plug_get_simple(utils, SASL_CB_AUTHNAME, 1, result, prompt_need)
154 int _plug_get_simple(
const sasl_utils_t *utils,
unsigned int id,
int required,
155 const char **result, sasl_interact_t **prompt_need);
157 int _plug_get_password(
const sasl_utils_t *utils, sasl_secret_t **secret,
158 unsigned int *iscopy, sasl_interact_t **prompt_need);
160 int _plug_challenge_prompt(
const sasl_utils_t *utils,
unsigned int id,
161 const char *challenge,
const char *promptstr,
162 const char **result, sasl_interact_t **prompt_need);
164 int _plug_get_realm(
const sasl_utils_t *utils,
const char **availrealms,
165 const char **realm, sasl_interact_t **prompt_need);
167 int _plug_make_prompts(
const sasl_utils_t *utils,
168 sasl_interact_t **prompts_res,
169 const char *user_prompt,
const char *user_def,
170 const char *auth_prompt,
const char *auth_def,
171 const char *pass_prompt,
const char *pass_def,
172 const char *echo_chal,
173 const char *echo_prompt,
const char *echo_def,
174 const char *realm_chal,
175 const char *realm_prompt,
const char *realm_def);
177 typedef struct decode_context {
178 const sasl_utils_t *utils;
179 unsigned int needsize;
183 unsigned int cursize;
184 unsigned int in_maxbuf;
187 void _plug_decode_init(decode_context_t *text,
188 const sasl_utils_t *utils,
unsigned int in_maxbuf);
190 int _plug_decode(decode_context_t *text,
191 const char *input,
unsigned inputlen,
192 char **output,
unsigned *outputsize,
unsigned *outputlen,
193 int (*decode_pkt)(
void *rock,
194 const char *input,
unsigned inputlen,
195 char **output,
unsigned *outputlen),
198 void _plug_decode_free(decode_context_t *text);
200 int _plug_parseuser(
const sasl_utils_t *utils,
201 char **user,
char **realm,
const char *user_realm,
202 const char *serverFQDN,
const char *input);
204 int _plug_make_fulluser(
const sasl_utils_t *utils,
205 char **fulluser,
const char * useronly,
const char *realm);
207 char * _plug_get_error_message (
const sasl_utils_t *utils,
214 void _plug_snprintf_os_info (
char * osbuf,
int osbuf_len);