xref: /freebsd/usr.sbin/ppp/auth.h (revision 65309e5cda5d671cbca4763b481566ce387dcf7e)
165309e5cSBrian Somers /*-
265309e5cSBrian Somers  * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
365309e5cSBrian Somers  *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
465309e5cSBrian Somers  *                           Internet Initiative Japan, Inc (IIJ)
565309e5cSBrian Somers  * All rights reserved.
6b808c756SAtsushi Murai  *
765309e5cSBrian Somers  * Redistribution and use in source and binary forms, with or without
865309e5cSBrian Somers  * modification, are permitted provided that the following conditions
965309e5cSBrian Somers  * are met:
1065309e5cSBrian Somers  * 1. Redistributions of source code must retain the above copyright
1165309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer.
1265309e5cSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
1365309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
1465309e5cSBrian Somers  *    documentation and/or other materials provided with the distribution.
15b808c756SAtsushi Murai  *
1665309e5cSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1765309e5cSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1865309e5cSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1965309e5cSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2065309e5cSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2165309e5cSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2265309e5cSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2365309e5cSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2465309e5cSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2565309e5cSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2665309e5cSBrian Somers  * SUCH DAMAGE.
27b808c756SAtsushi Murai  *
2897d92980SPeter Wemm  * $FreeBSD$
29b808c756SAtsushi Murai  */
30b808c756SAtsushi Murai 
3163b73463SBrian Somers struct physical;
322764b86aSBrian Somers struct bundle;
33f0cdd9c0SBrian Somers struct authinfo;
34f0cdd9c0SBrian Somers typedef void (*auth_func)(struct authinfo *);
35b808c756SAtsushi Murai 
36b808c756SAtsushi Murai struct authinfo {
37f0cdd9c0SBrian Somers   struct {
38f0cdd9c0SBrian Somers     auth_func req;
39f0cdd9c0SBrian Somers     auth_func success;
40f0cdd9c0SBrian Somers     auth_func failure;
41f0cdd9c0SBrian Somers   } fn;
42f0cdd9c0SBrian Somers   struct {
43f0cdd9c0SBrian Somers     struct fsmheader hdr;
44f0cdd9c0SBrian Somers     char name[AUTHLEN];
45f0cdd9c0SBrian Somers   } in;
46b808c756SAtsushi Murai   struct pppTimer authtimer;
47b808c756SAtsushi Murai   int retry;
48b808c756SAtsushi Murai   int id;
4963b73463SBrian Somers   struct physical *physical;
50cd9647a1SBrian Somers   struct {
51479508cfSBrian Somers     struct fsm_retry fsm;	/* How often/frequently to resend requests */
52cd9647a1SBrian Somers   } cfg;
53b808c756SAtsushi Murai };
54b808c756SAtsushi Murai 
55f0cdd9c0SBrian Somers #define auth_Failure(a) (*a->fn.failure)(a);
56f0cdd9c0SBrian Somers #define auth_Success(a) (*a->fn.success)(a);
57dd7e2610SBrian Somers 
585e315498SBrian Somers extern const char *Auth2Nam(u_short, u_char);
59f0cdd9c0SBrian Somers extern void auth_Init(struct authinfo *, struct physical *,
60f0cdd9c0SBrian Somers                       auth_func, auth_func, auth_func);
61dd7e2610SBrian Somers extern void auth_StopTimer(struct authinfo *);
62f0cdd9c0SBrian Somers extern void auth_StartReq(struct authinfo *);
63dd7e2610SBrian Somers extern int auth_Validate(struct bundle *, const char *, const char *,
64643f4904SBrian Somers                          struct physical *);
65dd7e2610SBrian Somers extern char *auth_GetSecret(struct bundle *, const char *, int,
66643f4904SBrian Somers                             struct physical *);
6792b09558SBrian Somers extern int auth_SetPhoneList(const char *, char *, int);
6892b09558SBrian Somers extern int auth_Select(struct bundle *, const char *);
69f0cdd9c0SBrian Somers extern struct mbuf *auth_ReadHeader(struct authinfo *, struct mbuf *);
70f0cdd9c0SBrian Somers extern struct mbuf *auth_ReadName(struct authinfo *, struct mbuf *, int);
71