Add SHARES and USER AUTHORIZATION sections.
[doldaconnect.git] / daemon / auth.h
CommitLineData
d3372da9 1/*
2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19#ifndef _AUTH_H
20#define _AUTH_H
21
22#include <wchar.h>
23
3616b334 24#include "net.h"
25
d3372da9 26#define AUTH_SUCCESS 0 /* Authentication successful and done */
27#define AUTH_DENIED 1 /* Ultimately failed - reason in handle->text */
28#define AUTH_PASS 2 /* Pass data - look in handle->prompt */
29#define AUTH_ERR 3 /* An error occurred that */
30
31#define AUTH_PR_AUTO 0
32#define AUTH_PR_NOECHO 1
33#define AUTH_PR_ECHO 2
34#define AUTH_PR_INFO 3
35#define AUTH_PR_ERROR 4
36
37struct authhandle;
38
39struct authmech
40{
41 struct authmech *next;
42 int enabled;
43 wchar_t *name;
44 int (*inithandle)(struct authhandle *handle, char *username);
45 void (*release)(struct authhandle *handle);
3616b334 46 int (*authenticate)(struct authhandle *handle, struct socket *sk, char *data);
d3372da9 47 int (*renewcred)(struct authhandle *handle);
48 int (*opensess)(struct authhandle *handle);
49 int (*closesess)(struct authhandle *handle);
3616b334 50 int (*available)(struct socket *sk);
d3372da9 51};
52
53struct authhandle
54{
55 int refcount;
56 struct authmech *mech;
57 int prompt;
58 wchar_t *text;
59 void *mechdata;
60};
61
3616b334 62int authenticate(struct authhandle *handle, struct socket *sk, char *data);
d3372da9 63struct authhandle *initauth(wchar_t *mechname, char *username);
64void authgethandle(struct authhandle *auth);
65void authputhandle(struct authhandle *auth);
66int authrenewcred(struct authhandle *handle);
67int authopensess(struct authhandle *handle);
68int authclosesess(struct authhandle *handle);
69void regmech(struct authmech *mech);
3616b334 70int authavailable(struct authmech *mech, struct socket *sk);
d3372da9 71
72extern struct authmech *mechs;
73
74#endif