auth.h revision 134789
18876Srgrimes/*-
24Srgrimes * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
34Srgrimes *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
44Srgrimes *                           Internet Initiative Japan, Inc (IIJ)
58876Srgrimes * All rights reserved.
64Srgrimes *
74Srgrimes * Redistribution and use in source and binary forms, with or without
84Srgrimes * modification, are permitted provided that the following conditions
94Srgrimes * are met:
104Srgrimes * 1. Redistributions of source code must retain the above copyright
118876Srgrimes *    notice, this list of conditions and the following disclaimer.
128876Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
134Srgrimes *    notice, this list of conditions and the following disclaimer in the
144Srgrimes *    documentation and/or other materials provided with the distribution.
158876Srgrimes *
164Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
178876Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
194Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
204Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
214Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228876Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
234Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
244Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
254Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2617865Spst * SUCH DAMAGE.
274Srgrimes *
284Srgrimes * $FreeBSD: head/usr.sbin/ppp/auth.h 134789 2004-09-05 01:46:52Z brian $
294Srgrimes */
304Srgrimes
314Srgrimesstruct physical;
322056Swollmanstruct bundle;
332056Swollmanstruct authinfo;
342056Swollmantypedef void (*auth_func)(struct authinfo *);
352056Swollman
365588Sbdestruct authinfo {
375588Sbde  struct {
3817865Spst    auth_func req;
397090Sbde    auth_func success;
405588Sbde    auth_func failure;
415588Sbde  } fn;
4212662Sdg  struct {
4312662Sdg    struct fsmheader hdr;
444Srgrimes    char name[AUTHLEN];
454Srgrimes  } in;
4612662Sdg  struct pppTimer authtimer;
474Srgrimes  int retry;
48798Swollman  int id;
4917865Spst  struct physical *physical;
5017865Spst  struct {
5117865Spst    struct fsm_retry fsm;	/* How often/frequently to resend requests */
5217847Spst  } cfg;
534Srgrimes};
54718Swollman
55718Swollman#define auth_Failure(a) (*(a)->fn.failure)(a)
5617865Spst#define auth_Success(a) (*(a)->fn.success)(a)
5717865Spst
585588Sbdeextern const char *Auth2Nam(u_short, u_char);
594Srgrimesextern void auth_Init(struct authinfo *, struct physical *,
604Srgrimes                      auth_func, auth_func, auth_func);
614Srgrimesextern void auth_StopTimer(struct authinfo *);
624Srgrimesextern void auth_StartReq(struct authinfo *);
63798Swollmanextern int auth_Validate(struct bundle *, const char *, const char *);
644Srgrimesextern char *auth_GetSecret(const char *, size_t);
654Srgrimesextern int auth_SetPhoneList(const char *, char *, int);
664Srgrimesextern int auth_Select(struct bundle *, const char *);
674Srgrimesextern struct mbuf *auth_ReadHeader(struct authinfo *, struct mbuf *);
6817865Spstextern struct mbuf *auth_ReadName(struct authinfo *, struct mbuf *, size_t);
694Srgrimes