Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
lcp.h
00001 /** 00002 * @file lcp.h 00003 * @brief LCP (PPP Link Control Protocol) 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _LCP_H 00030 #define _LCP_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "ppp/ppp.h" 00035 00036 00037 /** 00038 * @brief LCP option types 00039 **/ 00040 00041 typedef enum 00042 { 00043 LCP_OPTION_MRU = 1, ///<Maximum-Receive-Unit 00044 LCP_OPTION_ACCM = 2, ///<Async-Control-Character-Map 00045 LCP_OPTION_AUTH_PROTOCOL = 3, ///<Authentication-Protocol 00046 LCP_OPTION_QUALITY_PROTOCOL = 4, ///<Quality-Protocol 00047 LCP_OPTION_MAGIC_NUMBER = 5, ///<Magic-Number 00048 LCP_OPTION_PFC = 7, ///<Protocol-Field-Compression 00049 LCP_OPTION_ACFC = 8 ///<Address-and-Control-Field-Compression 00050 } LcpOptionType; 00051 00052 00053 //CodeWarrior or Win32 compiler? 00054 #if defined(__CWCC__) || defined(_WIN32) 00055 #pragma pack(push, 1) 00056 #endif 00057 00058 00059 /** 00060 * @brief Maximum-Receive-Unit option 00061 **/ 00062 00063 typedef __start_packed struct 00064 { 00065 uint8_t type; //0 00066 uint8_t length; //1 00067 uint16_t mru; //2-3 00068 } __end_packed LcpMruOption; 00069 00070 00071 /** 00072 * @brief Async-Control-Character-Map option 00073 **/ 00074 00075 typedef __start_packed struct 00076 { 00077 uint8_t type; //0 00078 uint8_t length; //1 00079 uint32_t accm; //2-5 00080 } __end_packed LcpAccmOption; 00081 00082 00083 /** 00084 * @brief Authentication-Protocol option 00085 **/ 00086 00087 typedef __start_packed struct 00088 { 00089 uint8_t type; //0 00090 uint8_t length; //1 00091 uint16_t protocol; //2-3 00092 uint8_t data[]; //4 00093 } __end_packed LcpAuthProtocolOption; 00094 00095 00096 /** 00097 * @brief Quality-Protocol option 00098 **/ 00099 00100 typedef __start_packed struct 00101 { 00102 uint8_t type; //0 00103 uint8_t length; //1 00104 uint16_t protocol; //2-3 00105 uint8_t data[]; //4 00106 } __end_packed LcpQualityProtocolOption; 00107 00108 00109 /** 00110 * @brief Magic-Number option 00111 **/ 00112 00113 typedef __start_packed struct 00114 { 00115 uint8_t type; //0 00116 uint8_t length; //1 00117 uint32_t magicNumber; //2-5 00118 } __end_packed LcpMagicNumberOption; 00119 00120 00121 /** 00122 * @brief Protocol-Field-Compression option 00123 **/ 00124 00125 typedef __start_packed struct 00126 { 00127 uint8_t type; //0 00128 uint8_t length; //1 00129 } __end_packed LcpPfcOption; 00130 00131 00132 /** 00133 * @brief Address-and-Control-Field-Compression option 00134 **/ 00135 00136 typedef __start_packed struct 00137 { 00138 uint8_t type; //0 00139 uint8_t length; //1 00140 } __end_packed LcpAcfcOption; 00141 00142 00143 //CodeWarrior or Win32 compiler? 00144 #if defined(__CWCC__) || defined(_WIN32) 00145 #pragma pack(pop) 00146 #endif 00147 00148 00149 //LCP FSM events 00150 error_t lcpOpen(PppContext *context); 00151 error_t lcpClose(PppContext *context); 00152 00153 void lcpTick(PppContext *context); 00154 00155 void lcpProcessPacket(PppContext *context, const PppPacket *packet, size_t length); 00156 00157 error_t lcpProcessConfigureReq(PppContext *context, 00158 const PppConfigurePacket *configureReqPacket); 00159 00160 error_t lcpProcessConfigureAck(PppContext *context, 00161 const PppConfigurePacket *configureAckPacket); 00162 00163 error_t lcpProcessConfigureNak(PppContext *context, 00164 const PppConfigurePacket *configureNakPacket); 00165 00166 error_t lcpProcessConfigureReject(PppContext *context, 00167 const PppConfigurePacket *configureRejPacket); 00168 00169 error_t lcpProcessTerminateReq(PppContext *context, 00170 const PppTerminatePacket *terminateReqPacket); 00171 00172 error_t lcpProcessTerminateAck(PppContext *context, 00173 const PppTerminatePacket *terminateAckPacket); 00174 00175 error_t lcpProcessCodeRej(PppContext *context, 00176 const PppCodeRejPacket *codeRejPacket); 00177 00178 error_t lcpProcessProtocolRej(PppContext *context, 00179 const PppProtocolRejPacket *protocolRejPacket); 00180 00181 error_t lcpProcessEchoReq(PppContext *context, 00182 const PppEchoPacket *echoReqPacket); 00183 00184 error_t lcpProcessEchoRep(PppContext *context, 00185 const PppEchoPacket *echoRepPacket); 00186 00187 error_t lcpProcessDiscardReq(PppContext *context, 00188 const PppDiscardReqPacket *discardReqPacket); 00189 00190 error_t lcpProcessUnknownCode(PppContext *context, 00191 const PppPacket *packet); 00192 00193 error_t lcpProcessUnknownProtocol(PppContext *context, 00194 uint16_t protocol, const uint8_t *information, size_t length); 00195 00196 //LCP FSM callback functions 00197 void lcpThisLayerUp(PppContext *context); 00198 void lcpThisLayerDown(PppContext *context); 00199 void lcpThisLayerStarted(PppContext *context); 00200 void lcpThisLayerFinished(PppContext *context); 00201 00202 void lcpInitRestartCount(PppContext *context, uint_t value); 00203 void lcpZeroRestartCount(PppContext *context); 00204 00205 error_t lcpSendConfigureReq(PppContext *context); 00206 00207 error_t lcpSendConfigureAck(PppContext *context, 00208 const PppConfigurePacket *configureReqPacket); 00209 00210 error_t lcpSendConfigureNak(PppContext *context, 00211 const PppConfigurePacket *configureReqPacket); 00212 00213 error_t lcpSendConfigureRej(PppContext *context, 00214 const PppConfigurePacket *configureReqPacket); 00215 00216 error_t lcpSendTerminateReq(PppContext *context); 00217 00218 error_t lcpSendTerminateAck(PppContext *context, 00219 const PppTerminatePacket *terminateReqPacket); 00220 00221 error_t lcpSendCodeRej(PppContext *context, const PppPacket *packet); 00222 error_t lcpSendEchoRep(PppContext *context, const PppEchoPacket *echoReqPacket); 00223 00224 //LCP options checking 00225 error_t lcpParseOption(PppContext *context, PppOption *option, 00226 size_t inPacketLen, PppConfigurePacket *outPacket); 00227 00228 error_t lcpParseMruOption(PppContext *context, 00229 LcpMruOption *option, PppConfigurePacket *outPacket); 00230 00231 error_t lcpParseAccmOption(PppContext *context, 00232 LcpAccmOption *option, PppConfigurePacket *outPacket); 00233 00234 error_t lcpParseAuthProtocolOption(PppContext *context, 00235 LcpAuthProtocolOption *option, PppConfigurePacket *outPacket); 00236 00237 error_t lcpParseMagicNumberOption(PppContext *context, 00238 LcpMagicNumberOption *option, PppConfigurePacket *outPacket); 00239 00240 error_t lcpParsePfcOption(PppContext *context, 00241 LcpPfcOption *option, PppConfigurePacket *outPacket); 00242 00243 error_t lcpParseAcfcOption(PppContext *context, 00244 LcpAcfcOption *option, PppConfigurePacket *outPacket); 00245 00246 #endif 00247
Generated on Tue Jul 12 2022 17:10:14 by
1.7.2