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