Embedded C project:18/12/2014

Dependencies:   DS1307 TextLCD mbed

Committer:
ninoderkinderen
Date:
Thu Dec 18 09:35:49 2014 +0000
Revision:
0:8d87bc453349
Programma embedded C

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ninoderkinderen 0:8d87bc453349 1 /*****************************************************************************
ninoderkinderen 0:8d87bc453349 2 * lcp.h - Network Link Control Protocol header file.
ninoderkinderen 0:8d87bc453349 3 *
ninoderkinderen 0:8d87bc453349 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
ninoderkinderen 0:8d87bc453349 5 * portions Copyright (c) 1997 Global Election Systems Inc.
ninoderkinderen 0:8d87bc453349 6 *
ninoderkinderen 0:8d87bc453349 7 * The authors hereby grant permission to use, copy, modify, distribute,
ninoderkinderen 0:8d87bc453349 8 * and license this software and its documentation for any purpose, provided
ninoderkinderen 0:8d87bc453349 9 * that existing copyright notices are retained in all copies and that this
ninoderkinderen 0:8d87bc453349 10 * notice and the following disclaimer are included verbatim in any
ninoderkinderen 0:8d87bc453349 11 * distributions. No written agreement, license, or royalty fee is required
ninoderkinderen 0:8d87bc453349 12 * for any of the authorized uses.
ninoderkinderen 0:8d87bc453349 13 *
ninoderkinderen 0:8d87bc453349 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
ninoderkinderen 0:8d87bc453349 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
ninoderkinderen 0:8d87bc453349 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ninoderkinderen 0:8d87bc453349 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
ninoderkinderen 0:8d87bc453349 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
ninoderkinderen 0:8d87bc453349 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
ninoderkinderen 0:8d87bc453349 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
ninoderkinderen 0:8d87bc453349 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
ninoderkinderen 0:8d87bc453349 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
ninoderkinderen 0:8d87bc453349 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ninoderkinderen 0:8d87bc453349 24 *
ninoderkinderen 0:8d87bc453349 25 ******************************************************************************
ninoderkinderen 0:8d87bc453349 26 * REVISION HISTORY
ninoderkinderen 0:8d87bc453349 27 *
ninoderkinderen 0:8d87bc453349 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
ninoderkinderen 0:8d87bc453349 29 * Ported to lwIP.
ninoderkinderen 0:8d87bc453349 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
ninoderkinderen 0:8d87bc453349 31 * Original derived from BSD codes.
ninoderkinderen 0:8d87bc453349 32 *****************************************************************************/
ninoderkinderen 0:8d87bc453349 33 /*
ninoderkinderen 0:8d87bc453349 34 * lcp.h - Link Control Protocol definitions.
ninoderkinderen 0:8d87bc453349 35 *
ninoderkinderen 0:8d87bc453349 36 * Copyright (c) 1989 Carnegie Mellon University.
ninoderkinderen 0:8d87bc453349 37 * All rights reserved.
ninoderkinderen 0:8d87bc453349 38 *
ninoderkinderen 0:8d87bc453349 39 * Redistribution and use in source and binary forms are permitted
ninoderkinderen 0:8d87bc453349 40 * provided that the above copyright notice and this paragraph are
ninoderkinderen 0:8d87bc453349 41 * duplicated in all such forms and that any documentation,
ninoderkinderen 0:8d87bc453349 42 * advertising materials, and other materials related to such
ninoderkinderen 0:8d87bc453349 43 * distribution and use acknowledge that the software was developed
ninoderkinderen 0:8d87bc453349 44 * by Carnegie Mellon University. The name of the
ninoderkinderen 0:8d87bc453349 45 * University may not be used to endorse or promote products derived
ninoderkinderen 0:8d87bc453349 46 * from this software without specific prior written permission.
ninoderkinderen 0:8d87bc453349 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
ninoderkinderen 0:8d87bc453349 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
ninoderkinderen 0:8d87bc453349 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
ninoderkinderen 0:8d87bc453349 50 *
ninoderkinderen 0:8d87bc453349 51 * $Id: lcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $
ninoderkinderen 0:8d87bc453349 52 */
ninoderkinderen 0:8d87bc453349 53
ninoderkinderen 0:8d87bc453349 54 #ifndef LCP_H
ninoderkinderen 0:8d87bc453349 55 #define LCP_H
ninoderkinderen 0:8d87bc453349 56 /*
ninoderkinderen 0:8d87bc453349 57 * Options.
ninoderkinderen 0:8d87bc453349 58 */
ninoderkinderen 0:8d87bc453349 59 #define CI_MRU 1 /* Maximum Receive Unit */
ninoderkinderen 0:8d87bc453349 60 #define CI_ASYNCMAP 2 /* Async Control Character Map */
ninoderkinderen 0:8d87bc453349 61 #define CI_AUTHTYPE 3 /* Authentication Type */
ninoderkinderen 0:8d87bc453349 62 #define CI_QUALITY 4 /* Quality Protocol */
ninoderkinderen 0:8d87bc453349 63 #define CI_MAGICNUMBER 5 /* Magic Number */
ninoderkinderen 0:8d87bc453349 64 #define CI_PCOMPRESSION 7 /* Protocol Field Compression */
ninoderkinderen 0:8d87bc453349 65 #define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
ninoderkinderen 0:8d87bc453349 66 #define CI_CALLBACK 13 /* callback */
ninoderkinderen 0:8d87bc453349 67 #define CI_MRRU 17 /* max reconstructed receive unit; multilink */
ninoderkinderen 0:8d87bc453349 68 #define CI_SSNHF 18 /* short sequence numbers for multilink */
ninoderkinderen 0:8d87bc453349 69 #define CI_EPDISC 19 /* endpoint discriminator */
ninoderkinderen 0:8d87bc453349 70
ninoderkinderen 0:8d87bc453349 71 /*
ninoderkinderen 0:8d87bc453349 72 * LCP-specific packet types (code numbers).
ninoderkinderen 0:8d87bc453349 73 */
ninoderkinderen 0:8d87bc453349 74 #define PROTREJ 8 /* Protocol Reject */
ninoderkinderen 0:8d87bc453349 75 #define ECHOREQ 9 /* Echo Request */
ninoderkinderen 0:8d87bc453349 76 #define ECHOREP 10 /* Echo Reply */
ninoderkinderen 0:8d87bc453349 77 #define DISCREQ 11 /* Discard Request */
ninoderkinderen 0:8d87bc453349 78 #define CBCP_OPT 6 /* Use callback control protocol */
ninoderkinderen 0:8d87bc453349 79
ninoderkinderen 0:8d87bc453349 80 /*
ninoderkinderen 0:8d87bc453349 81 * The state of options is described by an lcp_options structure.
ninoderkinderen 0:8d87bc453349 82 */
ninoderkinderen 0:8d87bc453349 83 typedef struct lcp_options {
ninoderkinderen 0:8d87bc453349 84 u_int passive : 1; /* Don't die if we don't get a response */
ninoderkinderen 0:8d87bc453349 85 u_int silent : 1; /* Wait for the other end to start first */
ninoderkinderen 0:8d87bc453349 86 u_int restart : 1; /* Restart vs. exit after close */
ninoderkinderen 0:8d87bc453349 87 u_int neg_mru : 1; /* Negotiate the MRU? */
ninoderkinderen 0:8d87bc453349 88 u_int neg_asyncmap : 1; /* Negotiate the async map? */
ninoderkinderen 0:8d87bc453349 89 u_int neg_upap : 1; /* Ask for UPAP authentication? */
ninoderkinderen 0:8d87bc453349 90 u_int neg_chap : 1; /* Ask for CHAP authentication? */
ninoderkinderen 0:8d87bc453349 91 u_int neg_magicnumber : 1; /* Ask for magic number? */
ninoderkinderen 0:8d87bc453349 92 u_int neg_pcompression : 1; /* HDLC Protocol Field Compression? */
ninoderkinderen 0:8d87bc453349 93 u_int neg_accompression : 1; /* HDLC Address/Control Field Compression? */
ninoderkinderen 0:8d87bc453349 94 u_int neg_lqr : 1; /* Negotiate use of Link Quality Reports */
ninoderkinderen 0:8d87bc453349 95 u_int neg_cbcp : 1; /* Negotiate use of CBCP */
ninoderkinderen 0:8d87bc453349 96 #ifdef PPP_MULTILINK
ninoderkinderen 0:8d87bc453349 97 u_int neg_mrru : 1; /* Negotiate multilink MRRU */
ninoderkinderen 0:8d87bc453349 98 u_int neg_ssnhf : 1; /* Negotiate short sequence numbers */
ninoderkinderen 0:8d87bc453349 99 u_int neg_endpoint : 1; /* Negotiate endpoint discriminator */
ninoderkinderen 0:8d87bc453349 100 #endif
ninoderkinderen 0:8d87bc453349 101 u_short mru; /* Value of MRU */
ninoderkinderen 0:8d87bc453349 102 #ifdef PPP_MULTILINK
ninoderkinderen 0:8d87bc453349 103 u_short mrru; /* Value of MRRU, and multilink enable */
ninoderkinderen 0:8d87bc453349 104 #endif
ninoderkinderen 0:8d87bc453349 105 u_char chap_mdtype; /* which MD type (hashing algorithm) */
ninoderkinderen 0:8d87bc453349 106 u32_t asyncmap; /* Value of async map */
ninoderkinderen 0:8d87bc453349 107 u32_t magicnumber;
ninoderkinderen 0:8d87bc453349 108 int numloops; /* Number of loops during magic number neg. */
ninoderkinderen 0:8d87bc453349 109 u32_t lqr_period; /* Reporting period for LQR 1/100ths second */
ninoderkinderen 0:8d87bc453349 110 #ifdef PPP_MULTILINK
ninoderkinderen 0:8d87bc453349 111 struct epdisc endpoint; /* endpoint discriminator */
ninoderkinderen 0:8d87bc453349 112 #endif
ninoderkinderen 0:8d87bc453349 113 } lcp_options;
ninoderkinderen 0:8d87bc453349 114
ninoderkinderen 0:8d87bc453349 115 /*
ninoderkinderen 0:8d87bc453349 116 * Values for phase from BSD pppd.h based on RFC 1661.
ninoderkinderen 0:8d87bc453349 117 */
ninoderkinderen 0:8d87bc453349 118 typedef enum {
ninoderkinderen 0:8d87bc453349 119 PHASE_DEAD = 0,
ninoderkinderen 0:8d87bc453349 120 PHASE_INITIALIZE,
ninoderkinderen 0:8d87bc453349 121 PHASE_ESTABLISH,
ninoderkinderen 0:8d87bc453349 122 PHASE_AUTHENTICATE,
ninoderkinderen 0:8d87bc453349 123 PHASE_CALLBACK,
ninoderkinderen 0:8d87bc453349 124 PHASE_NETWORK,
ninoderkinderen 0:8d87bc453349 125 PHASE_TERMINATE
ninoderkinderen 0:8d87bc453349 126 } LinkPhase;
ninoderkinderen 0:8d87bc453349 127
ninoderkinderen 0:8d87bc453349 128
ninoderkinderen 0:8d87bc453349 129
ninoderkinderen 0:8d87bc453349 130 extern LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */
ninoderkinderen 0:8d87bc453349 131 extern lcp_options lcp_wantoptions[];
ninoderkinderen 0:8d87bc453349 132 extern lcp_options lcp_gotoptions[];
ninoderkinderen 0:8d87bc453349 133 extern lcp_options lcp_allowoptions[];
ninoderkinderen 0:8d87bc453349 134 extern lcp_options lcp_hisoptions[];
ninoderkinderen 0:8d87bc453349 135 extern ext_accm xmit_accm[];
ninoderkinderen 0:8d87bc453349 136
ninoderkinderen 0:8d87bc453349 137
ninoderkinderen 0:8d87bc453349 138 void lcp_init (int);
ninoderkinderen 0:8d87bc453349 139 void lcp_open (int);
ninoderkinderen 0:8d87bc453349 140 void lcp_close (int, char *);
ninoderkinderen 0:8d87bc453349 141 void lcp_lowerup (int);
ninoderkinderen 0:8d87bc453349 142 void lcp_lowerdown(int);
ninoderkinderen 0:8d87bc453349 143 void lcp_sprotrej (int, u_char *, int); /* send protocol reject */
ninoderkinderen 0:8d87bc453349 144
ninoderkinderen 0:8d87bc453349 145 extern struct protent lcp_protent;
ninoderkinderen 0:8d87bc453349 146
ninoderkinderen 0:8d87bc453349 147 /* Default number of times we receive our magic number from the peer
ninoderkinderen 0:8d87bc453349 148 before deciding the link is looped-back. */
ninoderkinderen 0:8d87bc453349 149 #define DEFLOOPBACKFAIL 10
ninoderkinderen 0:8d87bc453349 150
ninoderkinderen 0:8d87bc453349 151 #endif /* LCP_H */