chap.h revision 45907
1214501Srpaulo/*
2214501Srpaulo *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
3214501Srpaulo *
4214501Srpaulo *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
5214501Srpaulo *
6252726Srpaulo * Redistribution and use in source and binary forms are permitted
7252726Srpaulo * provided that the above copyright notice and this paragraph are
8214501Srpaulo * duplicated in all such forms and that any documentation,
9214501Srpaulo * advertising materials, and other materials related to such
10214501Srpaulo * distribution and use acknowledge that the software was developed
11214501Srpaulo * by the Internet Initiative Japan.  The name of the
12214501Srpaulo * IIJ may not be used to endorse or promote products derived
13214501Srpaulo * from this software without specific prior written permission.
14214501Srpaulo * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15214501Srpaulo * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16214501Srpaulo * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17214501Srpaulo *
18214501Srpaulo * $Id: chap.h,v 1.14 1999/02/18 19:45:06 brian Exp $
19214501Srpaulo *
20214501Srpaulo *	TODO:
21214501Srpaulo */
22214501Srpaulo
23214501Srpaulostruct mbuf;
24214501Srpaulostruct physical;
25214501Srpaulo
26214501Srpaulo#define	CHAP_CHALLENGE	1
27214501Srpaulo#define	CHAP_RESPONSE	2
28214501Srpaulo#define	CHAP_SUCCESS	3
29214501Srpaulo#define	CHAP_FAILURE	4
30214501Srpaulo
31214501Srpaulostruct chap {
32214501Srpaulo  struct descriptor desc;
33214501Srpaulo  struct {
34214501Srpaulo    pid_t pid;
35214501Srpaulo    int fd;
36214501Srpaulo    struct {
37214501Srpaulo      char ptr[AUTHLEN * 2 + 3];	/* Allow for \r\n at the end (- NUL) */
38214501Srpaulo      int len;
39214501Srpaulo    } buf;
40214501Srpaulo  } child;
41214501Srpaulo  struct authinfo auth;
42214501Srpaulo  struct {
43214501Srpaulo    u_char local[CHAPCHALLENGELEN + AUTHLEN];	/* I invented this one */
44214501Srpaulo    u_char peer[CHAPCHALLENGELEN + AUTHLEN];	/* Peer gave us this one */
45214501Srpaulo  } challenge;
46214501Srpaulo#ifdef HAVE_DES
47214501Srpaulo  unsigned NTRespSent : 1;		/* Our last response */
48214501Srpaulo  int peertries;
49214501Srpaulo#endif
50214501Srpaulo};
51214501Srpaulo
52214501Srpaulo#define descriptor2chap(d) \
53214501Srpaulo  ((d)->type == CHAP_DESCRIPTOR ? (struct chap *)(d) : NULL)
54214501Srpaulo#define auth2chap(a) (struct chap *)((char *)a - (int)&((struct chap *)0)->auth)
55214501Srpaulo
56214501Srpauloextern void chap_Init(struct chap *, struct physical *);
57214501Srpauloextern void chap_ReInit(struct chap *);
58214501Srpauloextern void chap_Input(struct physical *, struct mbuf *);
59214501Srpaulo