178189Sbrian/*- 278189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 378189Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 478189Sbrian * Internet Initiative Japan, Inc (IIJ) 578189Sbrian * All rights reserved. 66756Samurai * 778189Sbrian * Redistribution and use in source and binary forms, with or without 878189Sbrian * modification, are permitted provided that the following conditions 978189Sbrian * are met: 1078189Sbrian * 1. Redistributions of source code must retain the above copyright 1178189Sbrian * notice, this list of conditions and the following disclaimer. 1278189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1378189Sbrian * notice, this list of conditions and the following disclaimer in the 1478189Sbrian * documentation and/or other materials provided with the distribution. 156756Samurai * 1678189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1778189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1878189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1978189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2078189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2178189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2278189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2378189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2478189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2578189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2678189Sbrian * SUCH DAMAGE. 276756Samurai * 2850479Speter * $FreeBSD$ 296756Samurai */ 306756Samurai 3136285Sbrianstruct physical; 3236285Sbrianstruct bundle; 3343693Sbrianstruct authinfo; 3443693Sbriantypedef void (*auth_func)(struct authinfo *); 356756Samurai 366756Samuraistruct authinfo { 3743693Sbrian struct { 3843693Sbrian auth_func req; 3943693Sbrian auth_func success; 4043693Sbrian auth_func failure; 4143693Sbrian } fn; 4243693Sbrian struct { 4343693Sbrian struct fsmheader hdr; 4443693Sbrian char name[AUTHLEN]; 4543693Sbrian } in; 466756Samurai struct pppTimer authtimer; 476756Samurai int retry; 486756Samurai int id; 4936285Sbrian struct physical *physical; 5036285Sbrian struct { 5144305Sbrian struct fsm_retry fsm; /* How often/frequently to resend requests */ 5236285Sbrian } cfg; 536756Samurai}; 546756Samurai 5596324Sbrian#define auth_Failure(a) (*(a)->fn.failure)(a) 5696324Sbrian#define auth_Success(a) (*(a)->fn.success)(a) 5743693Sbrian 5844106Sbrianextern const char *Auth2Nam(u_short, u_char); 5943693Sbrianextern void auth_Init(struct authinfo *, struct physical *, 6043693Sbrian auth_func, auth_func, auth_func); 6136285Sbrianextern void auth_StopTimer(struct authinfo *); 6243693Sbrianextern void auth_StartReq(struct authinfo *); 63134789Sbrianextern int auth_Validate(struct bundle *, const char *, const char *); 64134789Sbrianextern char *auth_GetSecret(const char *, size_t); 6538174Sbrianextern int auth_SetPhoneList(const char *, char *, int); 6638174Sbrianextern int auth_Select(struct bundle *, const char *); 6743693Sbrianextern struct mbuf *auth_ReadHeader(struct authinfo *, struct mbuf *); 68134789Sbrianextern struct mbuf *auth_ReadName(struct authinfo *, struct mbuf *, size_t); 69