2001-06-13 21:52:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
|
|
|
|
* Internet Initiative Japan, Inc (IIJ)
|
|
|
|
* All rights reserved.
|
1995-02-27 03:18:28 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1995-02-27 03:18:28 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-02-27 03:18:28 +00:00
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-02-27 03:18:28 +00:00
|
|
|
*/
|
|
|
|
|
1998-01-29 00:49:32 +00:00
|
|
|
struct physical;
|
1998-04-07 00:54:26 +00:00
|
|
|
struct bundle;
|
1999-02-06 02:54:47 +00:00
|
|
|
struct authinfo;
|
|
|
|
typedef void (*auth_func)(struct authinfo *);
|
1995-02-27 03:18:28 +00:00
|
|
|
|
|
|
|
struct authinfo {
|
1999-02-06 02:54:47 +00:00
|
|
|
struct {
|
|
|
|
auth_func req;
|
|
|
|
auth_func success;
|
|
|
|
auth_func failure;
|
|
|
|
} fn;
|
|
|
|
struct {
|
|
|
|
struct fsmheader hdr;
|
|
|
|
char name[AUTHLEN];
|
|
|
|
} in;
|
1995-02-27 03:18:28 +00:00
|
|
|
struct pppTimer authtimer;
|
|
|
|
int retry;
|
|
|
|
int id;
|
1998-01-29 00:49:32 +00:00
|
|
|
struct physical *physical;
|
1998-04-03 19:24:07 +00:00
|
|
|
struct {
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
struct fsm_retry fsm; /* How often/frequently to resend requests */
|
1998-04-03 19:24:07 +00:00
|
|
|
} cfg;
|
1995-02-27 03:18:28 +00:00
|
|
|
};
|
|
|
|
|
2002-05-10 03:11:35 +00:00
|
|
|
#define auth_Failure(a) (*(a)->fn.failure)(a)
|
|
|
|
#define auth_Success(a) (*(a)->fn.success)(a)
|
1998-05-01 19:26:12 +00:00
|
|
|
|
1999-02-18 00:52:15 +00:00
|
|
|
extern const char *Auth2Nam(u_short, u_char);
|
1999-02-06 02:54:47 +00:00
|
|
|
extern void auth_Init(struct authinfo *, struct physical *,
|
|
|
|
auth_func, auth_func, auth_func);
|
1998-05-01 19:26:12 +00:00
|
|
|
extern void auth_StopTimer(struct authinfo *);
|
1999-02-06 02:54:47 +00:00
|
|
|
extern void auth_StartReq(struct authinfo *);
|
1998-05-01 19:26:12 +00:00
|
|
|
extern int auth_Validate(struct bundle *, const char *, const char *,
|
|
|
|
struct physical *);
|
|
|
|
extern char *auth_GetSecret(struct bundle *, const char *, int,
|
|
|
|
struct physical *);
|
1998-08-07 18:42:51 +00:00
|
|
|
extern int auth_SetPhoneList(const char *, char *, int);
|
|
|
|
extern int auth_Select(struct bundle *, const char *);
|
1999-02-06 02:54:47 +00:00
|
|
|
extern struct mbuf *auth_ReadHeader(struct authinfo *, struct mbuf *);
|
|
|
|
extern struct mbuf *auth_ReadName(struct authinfo *, struct mbuf *, int);
|