1 /* $NetBSD: ecp.c,v 1.4 2014/10/25 21:11:37 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 #if 0 64 #define RCSID "Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp " 65 static const char rcsid[] = RCSID; 66 #else 67 __RCSID("$NetBSD: ecp.c,v 1.4 2014/10/25 21:11:37 christos Exp $"); 68 #endif 69 70 #include <string.h> 71 72 #include "pppd.h" 73 #include "fsm.h" 74 #include "ecp.h" 75 76 static option_t ecp_option_list[] = { 77 { "noecp", o_bool, &ecp_protent.enabled_flag, 78 "Disable ECP negotiation" }, 79 { "-ecp", o_bool, &ecp_protent.enabled_flag, 80 "Disable ECP negotiation", OPT_ALIAS }, 81 82 { NULL } 83 }; 84 85 /* 86 * Protocol entry points from main code. 87 */ 88 static void ecp_init __P((int unit)); 89 /* 90 static void ecp_open __P((int unit)); 91 static void ecp_close __P((int unit, char *)); 92 static void ecp_lowerup __P((int unit)); 93 static void ecp_lowerdown __P((int)); 94 static void ecp_input __P((int unit, u_char *pkt, int len)); 95 static void ecp_protrej __P((int unit)); 96 */ 97 static int ecp_printpkt __P((u_char *pkt, int len, 98 void (*printer) __P((void *, char *, ...)), 99 void *arg)); 100 /* 101 static void ecp_datainput __P((int unit, u_char *pkt, int len)); 102 */ 103 104 struct protent ecp_protent = { 105 PPP_ECP, 106 ecp_init, 107 NULL, /* ecp_input, */ 108 NULL, /* ecp_protrej, */ 109 NULL, /* ecp_lowerup, */ 110 NULL, /* ecp_lowerdown, */ 111 NULL, /* ecp_open, */ 112 NULL, /* ecp_close, */ 113 ecp_printpkt, 114 NULL, /* ecp_datainput, */ 115 0, 116 "ECP", 117 "Encrypted", 118 ecp_option_list, 119 NULL, 120 NULL, 121 NULL 122 }; 123 124 fsm ecp_fsm[NUM_PPP]; 125 ecp_options ecp_wantoptions[NUM_PPP]; /* what to request the peer to use */ 126 ecp_options ecp_gotoptions[NUM_PPP]; /* what the peer agreed to do */ 127 ecp_options ecp_allowoptions[NUM_PPP]; /* what we'll agree to do */ 128 ecp_options ecp_hisoptions[NUM_PPP]; /* what we agreed to do */ 129 130 static fsm_callbacks ecp_callbacks = { 131 NULL, /* ecp_resetci, */ 132 NULL, /* ecp_cilen, */ 133 NULL, /* ecp_addci, */ 134 NULL, /* ecp_ackci, */ 135 NULL, /* ecp_nakci, */ 136 NULL, /* ecp_rejci, */ 137 NULL, /* ecp_reqci, */ 138 NULL, /* ecp_up, */ 139 NULL, /* ecp_down, */ 140 NULL, 141 NULL, 142 NULL, 143 NULL, 144 NULL, /* ecp_extcode, */ 145 "ECP" 146 }; 147 148 /* 149 * ecp_init - initialize ECP. 150 */ 151 static void 152 ecp_init(unit) 153 int unit; 154 { 155 fsm *f = &ecp_fsm[unit]; 156 157 f->unit = unit; 158 f->protocol = PPP_ECP; 159 f->callbacks = &ecp_callbacks; 160 fsm_init(f); 161 162 memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options)); 163 memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options)); 164 memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options)); 165 memset(&ecp_hisoptions[unit], 0, sizeof(ecp_options)); 166 167 } 168 169 170 static int 171 ecp_printpkt(p, plen, printer, arg) 172 u_char *p; 173 int plen; 174 void (*printer) __P((void *, char *, ...)); 175 void *arg; 176 { 177 return 0; 178 } 179 180