#ifndef MASTER_AUTH_H
#define MASTER_AUTH_H
#include "network.h"
struct master_service;
#define AUTH_MASTER_PROTOCOL_MAJOR_VERSION 1
#define AUTH_MASTER_PROTOCOL_MINOR_VERSION 1
#define MASTER_AUTH_COOKIE_SIZE (128/8)
#define MASTER_AUTH_MAX_DATA_SIZE (2048*2)
#define MASTER_AUTH_ERRMSG_INTERNAL_FAILURE \
"Internal error occurred. Refer to server log for more information."
enum mail_auth_request_flags {
MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION = 0x01
};
struct master_auth_request {
unsigned int tag;
pid_t auth_pid;
unsigned int auth_id;
unsigned int client_pid;
uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];
struct ip_addr local_ip, remote_ip;
uint32_t flags;
uint32_t data_size;
ino_t ino;
};
enum master_auth_status {
MASTER_AUTH_STATUS_OK,
MASTER_AUTH_STATUS_INTERNAL_ERROR
};
struct master_auth_reply {
unsigned int tag;
enum master_auth_status status;
pid_t mail_pid;
};
typedef void master_auth_callback_t(const struct master_auth_reply *reply,
void *context);
struct master_auth *
master_auth_init(struct master_service *service, const char *path);
void master_auth_deinit(struct master_auth **auth);
void master_auth_request(struct master_auth *auth, int fd,
const struct master_auth_request *request,
const unsigned char *data,
master_auth_callback_t *callback,
void *context, unsigned int *tag_r);
void master_auth_request_abort(struct master_auth *auth, unsigned int tag);
#endif