2 * ecp.c - PPP Encryption Control Protocol.
4 * Copyright (c) 2002 Google, Inc.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by the Australian National University. The name of the University
13 * may not be used to endorse or promote products derived from this
14 * software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 * Derived from ccp.c, which is:
21 * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in
32 * the documentation and/or other materials provided with the
35 * 3. The name(s) of the authors of this software must not be used to
36 * endorse or promote products derived from this software without
37 * prior written permission.
39 * 4. Redistributions of any form whatsoever must retain the following
41 * "This product includes software developed by Paul Mackerras
42 * <paulus@samba.org>".
44 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
45 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
46 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
47 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
48 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
49 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
50 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53 #define RCSID "$Id: ecp.c,v 1.2 2002/12/04 23:03:32 paulus Exp $"
55 static const char rcsid[] = RCSID;
63 static option_t ecp_option_list[] = {
64 { "noecp", o_bool, &ecp_protent.enabled_flag,
65 "Disable ECP negotiation" },
66 { "-ecp", o_bool, &ecp_protent.enabled_flag,
67 "Disable ECP negotiation", OPT_ALIAS },
73 * Protocol entry points from main code.
75 static void ecp_init __P((int unit));
77 static void ecp_open __P((int unit));
78 static void ecp_close __P((int unit, char *));
79 static void ecp_lowerup __P((int unit));
80 static void ecp_lowerdown __P((int));
81 static void ecp_input __P((int unit, u_char *pkt, int len));
82 static void ecp_protrej __P((int unit));
84 static int ecp_printpkt __P((u_char *pkt, int len,
85 void (*printer) __P((void *, char *, ...)),
88 static void ecp_datainput __P((int unit, u_char *pkt, int len));
91 struct protent ecp_protent = {
94 NULL, /* ecp_input, */
95 NULL, /* ecp_protrej, */
96 NULL, /* ecp_lowerup, */
97 NULL, /* ecp_lowerdown, */
99 NULL, /* ecp_close, */
101 NULL, /* ecp_datainput, */
111 fsm ecp_fsm[NUM_PPP];
112 ecp_options ecp_wantoptions[NUM_PPP]; /* what to request the peer to use */
113 ecp_options ecp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
114 ecp_options ecp_allowoptions[NUM_PPP]; /* what we'll agree to do */
115 ecp_options ecp_hisoptions[NUM_PPP]; /* what we agreed to do */
117 static fsm_callbacks ecp_callbacks = {
118 NULL, /* ecp_resetci, */
119 NULL, /* ecp_cilen, */
120 NULL, /* ecp_addci, */
121 NULL, /* ecp_ackci, */
122 NULL, /* ecp_nakci, */
123 NULL, /* ecp_rejci, */
124 NULL, /* ecp_reqci, */
126 NULL, /* ecp_down, */
131 NULL, /* ecp_extcode, */
136 * ecp_init - initialize ECP.
142 fsm *f = &ecp_fsm[unit];
145 f->protocol = PPP_ECP;
146 f->callbacks = &ecp_callbacks;
149 memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options));
150 memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options));
151 memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));
152 memset(&ecp_hisoptions[unit], 0, sizeof(ecp_options));
158 ecp_printpkt(p, plen, printer, arg)
161 void (*printer) __P((void *, char *, ...));