chap.h revision 98311
152942Sbrian/*- 252942Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 352942Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 452942Sbrian * Internet Initiative Japan, Inc (IIJ) 552942Sbrian * All rights reserved. 652942Sbrian * 752942Sbrian * Redistribution and use in source and binary forms, with or without 852942Sbrian * modification, are permitted provided that the following conditions 952942Sbrian * are met: 1052942Sbrian * 1. Redistributions of source code must retain the above copyright 1152942Sbrian * notice, this list of conditions and the following disclaimer. 1252942Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1352942Sbrian * notice, this list of conditions and the following disclaimer in the 1452942Sbrian * documentation and/or other materials provided with the distribution. 1552942Sbrian * 1652942Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1752942Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1852942Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1952942Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2052942Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2152942Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2252942Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2352942Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2452942Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2552942Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2652942Sbrian * SUCH DAMAGE. 2752942Sbrian * 2852942Sbrian * $FreeBSD: head/usr.sbin/ppp/chap.h 98311 2002-06-17 01:12:38Z brian $ 2952942Sbrian */ 3052942Sbrian 3152942Sbrianstruct mbuf; 3252942Sbrianstruct physical; 3352942Sbrian 3452942Sbrian#define CHAP_CHALLENGE 1 3552942Sbrian#define CHAP_RESPONSE 2 3652942Sbrian#define CHAP_SUCCESS 3 3774916Sbrian#define CHAP_FAILURE 4 3874916Sbrian 3952942Sbrianstruct chap { 4052942Sbrian struct fdescriptor desc; 4152942Sbrian struct { 4252942Sbrian pid_t pid; 4352942Sbrian int fd; 4452942Sbrian struct { 4552942Sbrian char ptr[AUTHLEN * 2 + 3]; /* Allow for \r\n at the end (- NUL) */ 4652942Sbrian int len; 4752942Sbrian } buf; 4852942Sbrian } child; 4952942Sbrian struct authinfo auth; 5052942Sbrian struct { 5152942Sbrian u_char local[CHAPCHALLENGELEN + AUTHLEN]; /* I invented this one */ 5271006Sbrian u_char peer[CHAPCHALLENGELEN + AUTHLEN]; /* Peer gave us this one */ 5352942Sbrian } challenge; 5452942Sbrian#ifndef NODES 5552942Sbrian unsigned NTRespSent : 1; /* Our last response */ 5696582Sbrian int peertries; 5752942Sbrian u_char authresponse[CHAPAUTHRESPONSELEN]; /* CHAP 81 response */ 5852942Sbrian#endif 5952942Sbrian}; 6052942Sbrian 6152942Sbrian#define descriptor2chap(d) \ 6252942Sbrian ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL) 6352942Sbrian#define auth2chap(a) \ 6452942Sbrian ((struct chap *)((char *)a - (int)&((struct chap *)0)->auth)) 6552942Sbrian 6652942Sbrianstruct MSCHAPv2_resp { /* rfc2759 */ 6752942Sbrian char PeerChallenge[16]; 6852942Sbrian char Reserved[8]; 6952942Sbrian char NTResponse[24]; 7052942Sbrian char Flags; 7152942Sbrian}; 7252942Sbrian 7352942Sbrianextern void chap_Init(struct chap *, struct physical *); 7452942Sbrianextern void chap_ReInit(struct chap *); 7552942Sbrianextern struct mbuf *chap_Input(struct bundle *, struct link *, struct mbuf *); 7652942Sbrian