1 /*
2 * ecp.c - PPP Encryption Control Protocol.
3 *
4 * Copyright (c) 2002 Google, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * 3. The name(s) of the authors of this software must not be used to
20 * endorse or promote products derived from this software without
21 * prior written permission.
22 *
23 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
24 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
26 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
28 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
29 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 *
31 * Derived from ccp.c, which is:
32 *
33 * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 *
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 *
42 * 2. The name(s) of the authors of this software must not be used to
43 * endorse or promote products derived from this software without
44 * prior written permission.
45 *
46 * 3. Redistributions of any form whatsoever must retain the following
47 * acknowledgment:
48 * "This product includes software developed by Paul Mackerras
49 * <paulus@samba.org>".
50 *
51 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
52 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
54 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
55 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
56 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
57 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
58 */
59
60 #define RCSID "$Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp $"
61
62 static const char rcsid[] = RCSID;
63
64 #include <string.h>
65
66 #include "pppd.h"
67 #include "fsm.h"
68 #include "ecp.h"
69
70 static option_t ecp_option_list[] = {
71 { "noecp", o_bool, &ecp_protent.enabled_flag,
72 "Disable ECP negotiation" },
73 { "-ecp", o_bool, &ecp_protent.enabled_flag,
74 "Disable ECP negotiation", OPT_ALIAS },
75
76 { NULL }
77 };
78
79 /*
80 * Protocol entry points from main code.
81 */
82 static void ecp_init __P((int unit));
83 /*
84 static void ecp_open __P((int unit));
85 static void ecp_close __P((int unit, char *));
86 static void ecp_lowerup __P((int unit));
87 static void ecp_lowerdown __P((int));
88 static void ecp_input __P((int unit, u_char *pkt, int len));
89 static void ecp_protrej __P((int unit));
90 */
91 static int ecp_printpkt __P((u_char *pkt, int len,
92 void (*printer) __P((void *, char *, ...)),
93 void *arg));
94 /*
95 static void ecp_datainput __P((int unit, u_char *pkt, int len));
96 */
97
98 struct protent ecp_protent = {
99 PPP_ECP,
100 ecp_init,
101 NULL, /* ecp_input, */
102 NULL, /* ecp_protrej, */
103 NULL, /* ecp_lowerup, */
104 NULL, /* ecp_lowerdown, */
105 NULL, /* ecp_open, */
106 NULL, /* ecp_close, */
107 ecp_printpkt,
108 NULL, /* ecp_datainput, */
109 0,
110 "ECP",
111 "Encrypted",
112 ecp_option_list,
113 NULL,
114 NULL,
115 NULL
116 };
117
118 fsm ecp_fsm[NUM_PPP];
119 ecp_options ecp_wantoptions[NUM_PPP]; /* what to request the peer to use */
120 ecp_options ecp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
121 ecp_options ecp_allowoptions[NUM_PPP]; /* what we'll agree to do */
122 ecp_options ecp_hisoptions[NUM_PPP]; /* what we agreed to do */
123
124 static fsm_callbacks ecp_callbacks = {
125 NULL, /* ecp_resetci, */
126 NULL, /* ecp_cilen, */
127 NULL, /* ecp_addci, */
128 NULL, /* ecp_ackci, */
129 NULL, /* ecp_nakci, */
130 NULL, /* ecp_rejci, */
131 NULL, /* ecp_reqci, */
132 NULL, /* ecp_up, */
133 NULL, /* ecp_down, */
134 NULL,
135 NULL,
136 NULL,
137 NULL,
138 NULL, /* ecp_extcode, */
139 "ECP"
140 };
141
142 /*
143 * ecp_init - initialize ECP.
144 */
145 static void
ecp_init(unit)146 ecp_init(unit)
147 int unit;
148 {
149 fsm *f = &ecp_fsm[unit];
150
151 f->unit = unit;
152 f->protocol = PPP_ECP;
153 f->callbacks = &ecp_callbacks;
154 fsm_init(f);
155
156 memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options));
157 memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options));
158 memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));
159 memset(&ecp_hisoptions[unit], 0, sizeof(ecp_options));
160
161 }
162
163
164 static int
ecp_printpkt(p,plen,printer,arg)165 ecp_printpkt(p, plen, printer, arg)
166 u_char *p;
167 int plen;
168 void (*printer) __P((void *, char *, ...));
169 void *arg;
170 {
171 return 0;
172 }
173
174