xref: /freebsd/usr.sbin/ppp/chap.h (revision a38cc901822e184de11b34991ce48d54f1955537)
1af57ed9fSAtsushi Murai /*
2af57ed9fSAtsushi Murai  *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
3af57ed9fSAtsushi Murai  *
4af57ed9fSAtsushi Murai  *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
5af57ed9fSAtsushi Murai  *
6af57ed9fSAtsushi Murai  * Redistribution and use in source and binary forms are permitted
7af57ed9fSAtsushi Murai  * provided that the above copyright notice and this paragraph are
8af57ed9fSAtsushi Murai  * duplicated in all such forms and that any documentation,
9af57ed9fSAtsushi Murai  * advertising materials, and other materials related to such
10af57ed9fSAtsushi Murai  * distribution and use acknowledge that the software was developed
11af57ed9fSAtsushi Murai  * by the Internet Initiative Japan.  The name of the
12af57ed9fSAtsushi Murai  * IIJ may not be used to endorse or promote products derived
13af57ed9fSAtsushi Murai  * from this software without specific prior written permission.
14af57ed9fSAtsushi Murai  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15af57ed9fSAtsushi Murai  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16af57ed9fSAtsushi Murai  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17af57ed9fSAtsushi Murai  *
18a38cc901SBrian Somers  * $Id: chap.h,v 1.14 1999/02/18 19:45:06 brian Exp $
19af57ed9fSAtsushi Murai  *
20af57ed9fSAtsushi Murai  *	TODO:
21af57ed9fSAtsushi Murai  */
22af57ed9fSAtsushi Murai 
232764b86aSBrian Somers struct mbuf;
2463b73463SBrian Somers struct physical;
2563b73463SBrian Somers 
26af57ed9fSAtsushi Murai #define	CHAP_CHALLENGE	1
27af57ed9fSAtsushi Murai #define	CHAP_RESPONSE	2
28af57ed9fSAtsushi Murai #define	CHAP_SUCCESS	3
29af57ed9fSAtsushi Murai #define	CHAP_FAILURE	4
3075240ed1SBrian Somers 
31e2ebb036SBrian Somers struct chap {
3258330d7bSBrian Somers   struct descriptor desc;
3358330d7bSBrian Somers   struct {
3458330d7bSBrian Somers     pid_t pid;
3558330d7bSBrian Somers     int fd;
3658330d7bSBrian Somers     struct {
3758330d7bSBrian Somers       char ptr[AUTHLEN * 2 + 3];	/* Allow for \r\n at the end (- NUL) */
3858330d7bSBrian Somers       int len;
3958330d7bSBrian Somers     } buf;
4058330d7bSBrian Somers   } child;
41e2ebb036SBrian Somers   struct authinfo auth;
42a38cc901SBrian Somers   struct {
43a38cc901SBrian Somers     u_char local[CHAPCHALLENGELEN + AUTHLEN];	/* I invented this one */
44a38cc901SBrian Somers     u_char peer[CHAPCHALLENGELEN + AUTHLEN];	/* Peer gave us this one */
45a38cc901SBrian Somers   } challenge;
46f522bee0SBrian Somers #ifdef HAVE_DES
475e315498SBrian Somers   unsigned NTRespSent : 1;		/* Our last response */
485e315498SBrian Somers   int peertries;
49f522bee0SBrian Somers #endif
50e2ebb036SBrian Somers };
516eaa6ac5SBrian Somers 
5258330d7bSBrian Somers #define descriptor2chap(d) \
5358330d7bSBrian Somers   ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL)
5458330d7bSBrian Somers #define auth2chap(a) (struct chap *)((char *)a - (int)&((struct chap *)0)->auth)
551ae349f5Scvs2svn 
56f0cdd9c0SBrian Somers extern void chap_Init(struct chap *, struct physical *);
5758330d7bSBrian Somers extern void chap_ReInit(struct chap *);
58f0cdd9c0SBrian Somers extern void chap_Input(struct physical *, struct mbuf *);
59