Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lwip_ecp.c Source File

lwip_ecp.c

00001 /*
00002  * ecp.c - PPP Encryption Control Protocol.
00003  *
00004  * Copyright (c) 2002 Google, Inc.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  * 3. The name(s) of the authors of this software must not be used to
00020  *    endorse or promote products derived from this software without
00021  *    prior written permission.
00022  *
00023  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
00024  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00025  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
00026  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00027  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
00028  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
00029  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00030  *
00031  * Derived from ccp.c, which is:
00032  *
00033  * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
00034  *
00035  * Redistribution and use in source and binary forms, with or without
00036  * modification, are permitted provided that the following conditions
00037  * are met:
00038  *
00039  * 1. Redistributions of source code must retain the above copyright
00040  *    notice, this list of conditions and the following disclaimer.
00041  *
00042  * 2. The name(s) of the authors of this software must not be used to
00043  *    endorse or promote products derived from this software without
00044  *    prior written permission.
00045  *
00046  * 3. Redistributions of any form whatsoever must retain the following
00047  *    acknowledgment:
00048  *    "This product includes software developed by Paul Mackerras
00049  *     <paulus@samba.org>".
00050  *
00051  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
00052  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00053  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
00054  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00055  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
00056  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
00057  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00058  */
00059 
00060 #include "netif/ppp/ppp_opts.h"
00061 #if PPP_SUPPORT && ECP_SUPPORT  /* don't build if not configured for use in lwipopts.h */
00062 
00063 #include <string.h>
00064 
00065 #include "netif/ppp/ppp_impl.h"
00066 
00067 #include "netif/ppp/fsm.h"
00068 #include "netif/ppp/ecp.h"
00069 
00070 #if PPP_OPTIONS
00071 static option_t ecp_option_list[] = {
00072     { "noecp", o_bool, &ecp_protent.enabled_flag,
00073       "Disable ECP negotiation" },
00074     { "-ecp", o_bool, &ecp_protent.enabled_flag,
00075       "Disable ECP negotiation", OPT_ALIAS },
00076 
00077     { NULL }
00078 };
00079 #endif /* PPP_OPTIONS */
00080 
00081 /*
00082  * Protocol entry points from main code.
00083  */
00084 static void ecp_init (int unit);
00085 /*
00086 static void ecp_open (int unit);
00087 static void ecp_close (int unit, char *);
00088 static void ecp_lowerup (int unit);
00089 static void ecp_lowerdown (int);
00090 static void ecp_input (int unit, u_char *pkt, int len);
00091 static void ecp_protrej (int unit);
00092 */
00093 #if PRINTPKT_SUPPORT
00094 static int  ecp_printpkt (const u_char *pkt, int len,
00095                   void (*printer) (void *, char *, ...),
00096                   void *arg);
00097 #endif /* PRINTPKT_SUPPORT */
00098 /*
00099 static void ecp_datainput (int unit, u_char *pkt, int len);
00100 */
00101 
00102 const struct protent ecp_protent = {
00103     PPP_ECP,
00104     ecp_init,
00105     NULL, /* ecp_input, */
00106     NULL, /* ecp_protrej, */
00107     NULL, /* ecp_lowerup, */
00108     NULL, /* ecp_lowerdown, */
00109     NULL, /* ecp_open, */
00110     NULL, /* ecp_close, */
00111 #if PRINTPKT_SUPPORT
00112     ecp_printpkt,
00113 #endif /* PRINTPKT_SUPPORT */
00114 #if PPP_DATAINPUT
00115     NULL, /* ecp_datainput, */
00116 #endif /* PPP_DATAINPUT */
00117 #if PRINTPKT_SUPPORT
00118     "ECP",
00119     "Encrypted",
00120 #endif /* PRINTPKT_SUPPORT */
00121 #if PPP_OPTIONS
00122     ecp_option_list,
00123     NULL,
00124 #endif /* PPP_OPTIONS */
00125 #if DEMAND_SUPPORT
00126     NULL,
00127     NULL
00128 #endif /* DEMAND_SUPPORT */
00129 };
00130 
00131 fsm ecp_fsm[NUM_PPP];
00132 ecp_options ecp_wantoptions[NUM_PPP];   /* what to request the peer to use */
00133 ecp_options ecp_gotoptions[NUM_PPP];    /* what the peer agreed to do */
00134 ecp_options ecp_allowoptions[NUM_PPP];  /* what we'll agree to do */
00135 ecp_options ecp_hisoptions[NUM_PPP];    /* what we agreed to do */
00136 
00137 static const fsm_callbacks ecp_callbacks = {
00138     NULL, /* ecp_resetci, */
00139     NULL, /* ecp_cilen, */
00140     NULL, /* ecp_addci, */
00141     NULL, /* ecp_ackci, */
00142     NULL, /* ecp_nakci, */
00143     NULL, /* ecp_rejci, */
00144     NULL, /* ecp_reqci, */
00145     NULL, /* ecp_up, */
00146     NULL, /* ecp_down, */
00147     NULL,
00148     NULL,
00149     NULL,
00150     NULL,
00151     NULL, /* ecp_extcode, */
00152     "ECP"
00153 };
00154 
00155 /*
00156  * ecp_init - initialize ECP.
00157  */
00158 static void
00159 ecp_init(unit)
00160     int unit;
00161 {
00162     fsm *f = &ecp_fsm[unit];
00163 
00164     f->unit = unit;
00165     f->protocol = PPP_ECP;
00166     f->callbacks = &ecp_callbacks;
00167     fsm_init(f);
00168 
00169 #if 0 /* Not necessary, everything is cleared in ppp_new() */
00170     memset(&ecp_wantoptions[unit],  0, sizeof(ecp_options));
00171     memset(&ecp_gotoptions[unit],   0, sizeof(ecp_options));
00172     memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));
00173     memset(&ecp_hisoptions[unit],   0, sizeof(ecp_options));
00174 #endif /* 0 */
00175 
00176 }
00177 
00178 
00179 #if PRINTPKT_SUPPORT
00180 static int
00181 ecp_printpkt(p, plen, printer, arg)
00182     const u_char *p;
00183     int plen;
00184     void (*printer) (void *, char *, ...);
00185     void *arg;
00186 {
00187     return 0;
00188 }
00189 #endif /* PRINTPKT_SUPPORT */
00190 
00191 #endif /* PPP_SUPPORT && ECP_SUPPORT */