]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/ppp/v2_0/include/chap.h
Initial revision
[karo-tx-redboot.git] / packages / net / ppp / v2_0 / include / chap.h
1 //==========================================================================
2 //
3 //      include/chap.h
4 //
5 //==========================================================================
6 //####ECOSGPLCOPYRIGHTBEGIN####
7 // -------------------------------------------
8 // This file is part of eCos, the Embedded Configurable Operating System.
9 // Portions created by Nick Garnett are
10 // Copyright (C) 2003 eCosCentric Ltd.
11 //
12 // eCos is free software; you can redistribute it and/or modify it under
13 // the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 2 or (at your option) any later version.
15 //
16 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
17 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19 // for more details.
20 //
21 // You should have received a copy of the GNU General Public License along
22 // with eCos; if not, write to the Free Software Foundation, Inc.,
23 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 //
25 // As a special exception, if other files instantiate templates or use macros
26 // or inline functions from this file, or you compile this file and link it
27 // with other works to produce a work based on this file, this file does not
28 // by itself cause the resulting work to be covered by the GNU General Public
29 // License. However the source code for this file must still be made available
30 // in accordance with section (3) of the GNU General Public License.
31 //
32 // This exception does not invalidate any other reasons why a work based on
33 // this file might be covered by the GNU General Public License.
34 //
35 // -------------------------------------------
36 //####ECOSGPLCOPYRIGHTEND####
37 //####BSDCOPYRIGHTBEGIN####
38 //
39 // -------------------------------------------
40 //
41 // Portions of this software may have been derived from OpenBSD, 
42 // FreeBSD or other sources, and are covered by the appropriate
43 // copyright disclaimers included herein.
44 //
45 // -------------------------------------------
46 //
47 //####BSDCOPYRIGHTEND####
48 //==========================================================================
49
50 /*
51  * chap.h - Challenge Handshake Authentication Protocol definitions.
52  *
53  * Copyright (c) 1993 The Australian National University.
54  * All rights reserved.
55  *
56  * Redistribution and use in source and binary forms are permitted
57  * provided that the above copyright notice and this paragraph are
58  * duplicated in all such forms and that any documentation,
59  * advertising materials, and other materials related to such
60  * distribution and use acknowledge that the software was developed
61  * by the Australian National University.  The name of the University
62  * may not be used to endorse or promote products derived from this
63  * software without specific prior written permission.
64  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
65  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
66  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
67  *
68  * Copyright (c) 1991 Gregory M. Christy
69  * All rights reserved.
70  *
71  * Redistribution and use in source and binary forms are permitted
72  * provided that the above copyright notice and this paragraph are
73  * duplicated in all such forms and that any documentation,
74  * advertising materials, and other materials related to such
75  * distribution and use acknowledge that the software was developed
76  * by the author.
77  *
78  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
79  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
80  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
81  *
82  * $FreeBSD: src/usr.sbin/pppd/chap.h,v 1.7 1999/08/28 01:19:01 peter Exp $
83  */
84
85 #ifndef __CHAP_INCLUDE__
86
87 /* Code + ID + length */
88 #define CHAP_HEADERLEN          4
89
90 /*
91  * CHAP codes.
92  */
93
94 #define CHAP_DIGEST_MD5         5       /* use MD5 algorithm */
95 #define MD5_SIGNATURE_SIZE      16      /* 16 bytes in a MD5 message digest */
96 #define CHAP_MICROSOFT          0x80    /* use Microsoft-compatible alg. */
97 #define MS_CHAP_RESPONSE_LEN    49      /* Response length for MS-CHAP */
98
99 #define CHAP_CHALLENGE          1
100 #define CHAP_RESPONSE           2
101 #define CHAP_SUCCESS            3
102 #define CHAP_FAILURE            4
103
104 /*
105  *  Challenge lengths (for challenges we send) and other limits.
106  */
107 #define MIN_CHALLENGE_LENGTH    32
108 #define MAX_CHALLENGE_LENGTH    64
109 #define MAX_RESPONSE_LENGTH     64      /* sufficient for MD5 or MS-CHAP */
110
111 /*
112  * Each interface is described by a chap structure.
113  */
114
115 typedef struct chap_state {
116     int unit;                   /* Interface unit number */
117     int clientstate;            /* Client state */
118     int serverstate;            /* Server state */
119     u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */
120     u_char chal_len;            /* challenge length */
121     u_char chal_id;             /* ID of last challenge */
122     u_char chal_type;           /* hash algorithm for challenges */
123     u_char id;                  /* Current id */
124     char *chal_name;            /* Our name to use with challenge */
125     int chal_interval;          /* Time until we challenge peer again */
126     int timeouttime;            /* Timeout time in seconds */
127     int max_transmits;          /* Maximum # of challenge transmissions */
128     int chal_transmits;         /* Number of transmissions of challenge */
129     int resp_transmits;         /* Number of transmissions of response */
130     u_char response[MAX_RESPONSE_LENGTH];       /* Response to send */
131     u_char resp_length;         /* length of response */
132     u_char resp_id;             /* ID for response messages */
133     u_char resp_type;           /* hash algorithm for responses */
134     char *resp_name;            /* Our name to send with response */
135 } chap_state;
136
137
138 /*
139  * Client (peer) states.
140  */
141 #define CHAPCS_INITIAL          0       /* Lower layer down, not opened */
142 #define CHAPCS_CLOSED           1       /* Lower layer up, not opened */
143 #define CHAPCS_PENDING          2       /* Auth us to peer when lower up */
144 #define CHAPCS_LISTEN           3       /* Listening for a challenge */
145 #define CHAPCS_RESPONSE         4       /* Sent response, waiting for status */
146 #define CHAPCS_OPEN             5       /* We've received Success */
147
148 /*
149  * Server (authenticator) states.
150  */
151 #define CHAPSS_INITIAL          0       /* Lower layer down, not opened */
152 #define CHAPSS_CLOSED           1       /* Lower layer up, not opened */
153 #define CHAPSS_PENDING          2       /* Auth peer when lower up */
154 #define CHAPSS_INITIAL_CHAL     3       /* We've sent the first challenge */
155 #define CHAPSS_OPEN             4       /* We've sent a Success msg */
156 #define CHAPSS_RECHALLENGE      5       /* We've sent another challenge */
157 #define CHAPSS_BADAUTH          6       /* We've sent a Failure msg */
158
159 /*
160  * Timeouts.
161  */
162 #define CHAP_DEFTIMEOUT         3       /* Timeout time in seconds */
163 #define CHAP_DEFTRANSMITS       10      /* max # times to send challenge */
164
165 extern chap_state chap[];
166
167 void ChapAuthWithPeer __P((int, char *, int));
168 void ChapAuthPeer __P((int, char *, int));
169
170 extern struct protent chap_protent;
171
172 #define __CHAP_INCLUDE__
173 #endif /* __CHAP_INCLUDE__ */