chap.h revision 98311
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. 66059Samurai * 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. 156059Samurai * 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. 276059Samurai * 2850479Speter * $FreeBSD: head/usr.sbin/ppp/chap.h 98311 2002-06-17 01:12:38Z brian $ 296059Samurai */ 306059Samurai 3136285Sbrianstruct mbuf; 3236285Sbrianstruct physical; 3336285Sbrian 346059Samurai#define CHAP_CHALLENGE 1 356059Samurai#define CHAP_RESPONSE 2 366059Samurai#define CHAP_SUCCESS 3 376059Samurai#define CHAP_FAILURE 4 3830715Sbrian 3936285Sbrianstruct chap { 4058028Sbrian struct fdescriptor desc; 4143888Sbrian struct { 4243888Sbrian pid_t pid; 4343888Sbrian int fd; 4443888Sbrian struct { 4543888Sbrian char ptr[AUTHLEN * 2 + 3]; /* Allow for \r\n at the end (- NUL) */ 4643888Sbrian int len; 4743888Sbrian } buf; 4843888Sbrian } child; 4936285Sbrian struct authinfo auth; 5045907Sbrian struct { 5145907Sbrian u_char local[CHAPCHALLENGELEN + AUTHLEN]; /* I invented this one */ 5245907Sbrian u_char peer[CHAPCHALLENGELEN + AUTHLEN]; /* Peer gave us this one */ 5345907Sbrian } challenge; 5493418Sbrian#ifndef NODES 5544106Sbrian unsigned NTRespSent : 1; /* Our last response */ 5644106Sbrian int peertries; 5767910Sbrian u_char authresponse[CHAPAUTHRESPONSELEN]; /* CHAP 81 response */ 5844123Sbrian#endif 5936285Sbrian}; 6030733Sbrian 6143888Sbrian#define descriptor2chap(d) \ 6243888Sbrian ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL) 6367910Sbrian#define auth2chap(a) \ 6467910Sbrian ((struct chap *)((char *)a - (int)&((struct chap *)0)->auth)) 6536285Sbrian 6698311Sbrianstruct MSCHAPv2_resp { /* rfc2759 */ 6798311Sbrian char PeerChallenge[16]; 6898311Sbrian char Reserved[8]; 6998311Sbrian char NTResponse[24]; 7098311Sbrian char Flags; 7198311Sbrian}; 7298311Sbrian 7343693Sbrianextern void chap_Init(struct chap *, struct physical *); 7443888Sbrianextern void chap_ReInit(struct chap *); 7546686Sbrianextern struct mbuf *chap_Input(struct bundle *, struct link *, struct mbuf *); 76