chap.h revision 272461
11590Srgrimes/*-
21590Srgrimes * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
31590Srgrimes *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
41590Srgrimes *                           Internet Initiative Japan, Inc (IIJ)
51590Srgrimes * All rights reserved.
61590Srgrimes *
71590Srgrimes * Redistribution and use in source and binary forms, with or without
81590Srgrimes * modification, are permitted provided that the following conditions
91590Srgrimes * are met:
101590Srgrimes * 1. Redistributions of source code must retain the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer.
121590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
131590Srgrimes *    notice, this list of conditions and the following disclaimer in the
141590Srgrimes *    documentation and/or other materials provided with the distribution.
151590Srgrimes *
161590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
201590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261590Srgrimes * SUCH DAMAGE.
271590Srgrimes *
281590Srgrimes * $FreeBSD: releng/10.1/usr.sbin/ppp/chap.h 173710 2007-11-17 23:14:06Z jb $
291590Srgrimes */
301590Srgrimes
311590Srgrimesstruct mbuf;
321590Srgrimesstruct physical;
331590Srgrimes
341590Srgrimes#define	CHAP_CHALLENGE	1
3528202Scharnier#define	CHAP_RESPONSE	2
361590Srgrimes#define	CHAP_SUCCESS	3
371590Srgrimes#define	CHAP_FAILURE	4
3887708Smarkm
391590Srgrimesstruct chap {
4091387Sdwmalone  struct fdescriptor desc;
411590Srgrimes  struct {
4291387Sdwmalone    pid_t pid;
4328202Scharnier    int fd;
4491387Sdwmalone    struct {
451590Srgrimes      char ptr[AUTHLEN * 2 + 3];	/* Allow for \r\n at the end (- NUL) */
4691387Sdwmalone      int len;
4791387Sdwmalone    } buf;
4891387Sdwmalone  } child;
491590Srgrimes  struct authinfo auth;
501590Srgrimes  struct {
511590Srgrimes    u_char local[CHAPCHALLENGELEN + AUTHLEN];	/* I invented this one */
521590Srgrimes    u_char peer[CHAPCHALLENGELEN + AUTHLEN];	/* Peer gave us this one */
531590Srgrimes  } challenge;
5428202Scharnier#ifndef NODES
551590Srgrimes  unsigned NTRespSent : 1;		/* Our last response */
561590Srgrimes  int peertries;
57207607Simp  u_char authresponse[CHAPAUTHRESPONSELEN];	/* CHAP 81 response */
581590Srgrimes#endif
5936792Simp};
60207607Simp
611590Srgrimes#define descriptor2chap(d) \
621590Srgrimes  ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL)
631590Srgrimes#define auth2chap(a) \
64207607Simp  ((struct chap *)((char *)a - (uintptr_t)&((struct chap *)0)->auth))
651590Srgrimes
661590Srgrimesstruct MSCHAPv2_resp {		/* rfc2759 */
6728202Scharnier  char PeerChallenge[16];
6885155Sbde  char Reserved[8];
691590Srgrimes  char NTResponse[24];
701590Srgrimes  char Flags;
711590Srgrimes};
721590Srgrimes
731590Srgrimesextern void chap_Init(struct chap *, struct physical *);
741590Srgrimesextern void chap_ReInit(struct chap *);
751590Srgrimesextern struct mbuf *chap_Input(struct bundle *, struct link *, struct mbuf *);
761590Srgrimes