chap.h revision 267654
1162017Ssam/*-
2162017Ssam * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
3162017Ssam *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
4162017Ssam *                           Internet Initiative Japan, Inc (IIJ)
5162017Ssam * All rights reserved.
6162017Ssam *
7162017Ssam * Redistribution and use in source and binary forms, with or without
8162017Ssam * modification, are permitted provided that the following conditions
9162017Ssam * are met:
10162017Ssam * 1. Redistributions of source code must retain the above copyright
11162017Ssam *    notice, this list of conditions and the following disclaimer.
12172683Smlaier * 2. Redistributions in binary form must reproduce the above copyright
13162017Ssam *    notice, this list of conditions and the following disclaimer in the
14162017Ssam *    documentation and/or other materials provided with the distribution.
15162017Ssam *
16162017Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17162017Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18162017Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19162017Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20162017Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21162017Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22162017Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23162017Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24162017Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25162017Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26162017Ssam * SUCH DAMAGE.
27162017Ssam *
28162017Ssam * $FreeBSD: releng/9.3/usr.sbin/ppp/chap.h 173710 2007-11-17 23:14:06Z jb $
29162017Ssam */
30162017Ssam
31162017Ssamstruct mbuf;
32162017Ssamstruct physical;
33162017Ssam
34162017Ssam#define	CHAP_CHALLENGE	1
35162017Ssam#define	CHAP_RESPONSE	2
36162017Ssam#define	CHAP_SUCCESS	3
37162017Ssam#define	CHAP_FAILURE	4
38162017Ssam
39162017Ssamstruct chap {
40162017Ssam  struct fdescriptor desc;
41162017Ssam  struct {
42162017Ssam    pid_t pid;
43162017Ssam    int fd;
44162017Ssam    struct {
45162017Ssam      char ptr[AUTHLEN * 2 + 3];	/* Allow for \r\n at the end (- NUL) */
46162017Ssam      int len;
47162017Ssam    } buf;
48162017Ssam  } child;
49162017Ssam  struct authinfo auth;
50162017Ssam  struct {
51162017Ssam    u_char local[CHAPCHALLENGELEN + AUTHLEN];	/* I invented this one */
52162017Ssam    u_char peer[CHAPCHALLENGELEN + AUTHLEN];	/* Peer gave us this one */
53162017Ssam  } challenge;
54162017Ssam#ifndef NODES
55162017Ssam  unsigned NTRespSent : 1;		/* Our last response */
56162017Ssam  int peertries;
57162017Ssam  u_char authresponse[CHAPAUTHRESPONSELEN];	/* CHAP 81 response */
58162017Ssam#endif
59162017Ssam};
60162017Ssam
61162017Ssam#define descriptor2chap(d) \
62162017Ssam  ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL)
63162017Ssam#define auth2chap(a) \
64162017Ssam  ((struct chap *)((char *)a - (uintptr_t)&((struct chap *)0)->auth))
65162017Ssam
66162017Ssamstruct MSCHAPv2_resp {		/* rfc2759 */
67162017Ssam  char PeerChallenge[16];
68162017Ssam  char Reserved[8];
69162017Ssam  char NTResponse[24];
70162017Ssam  char Flags;
71162017Ssam};
72162017Ssam
73162017Ssamextern void chap_Init(struct chap *, struct physical *);
74162017Ssamextern void chap_ReInit(struct chap *);
75162017Ssamextern struct mbuf *chap_Input(struct bundle *, struct link *, struct mbuf *);
76162017Ssam