Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
ipcp.h
Go to the documentation of this file.
00001 /** 00002 * @file ipcp.h 00003 * @brief IPCP (PPP Internet Protocol 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 _IPCP_H 00030 #define _IPCP_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "ppp/ppp.h" 00035 00036 //Subnet mask 00037 #define IPCP_DEFAULT_SUBNET_MASK IPV4_ADDR(255, 255, 255, 255) 00038 00039 00040 /** 00041 * @brief IPCP option types 00042 **/ 00043 00044 typedef enum 00045 { 00046 IPCP_OPTION_IP_ADDRESSES = 1, ///<IP-Addresses 00047 IPCP_OPTION_IP_COMP_PROTOCOL = 2, ///<IP-Compression-Protocol 00048 IPCP_OPTION_IP_ADDRESS = 3, ///<IP-Address 00049 IPCP_OPTION_PRIMARY_DNS = 129, ///<Primary-DNS-Server-Address 00050 IPCP_OPTION_PRIMARY_NBNS = 130, ///<Primary-NBNS-Server-Address 00051 IPCP_OPTION_SECONDARY_DNS = 131, ///<Secondary-DNS-Server-Address 00052 IPCP_OPTION_SECONDARY_NBNS = 132 ///<Secondary-NBNS-Server-Address 00053 } IpcpOptionType; 00054 00055 00056 //CodeWarrior or Win32 compiler? 00057 #if defined(__CWCC__) || defined(_WIN32) 00058 #pragma pack(push, 1) 00059 #endif 00060 00061 00062 /** 00063 * @brief IP-Addresses option 00064 **/ 00065 00066 typedef __start_packed struct 00067 { 00068 uint8_t type; //0 00069 uint8_t length; //1 00070 Ipv4Addr srcIpAddr; //2-5 00071 Ipv4Addr destIpAddr; //6-9 00072 } __end_packed IpcpIpAddressesOption; 00073 00074 00075 /** 00076 * @brief IP-Compression-Protocol option 00077 **/ 00078 00079 typedef __start_packed struct 00080 { 00081 uint8_t type; //0 00082 uint8_t length; //1 00083 uint16_t protocol; //2-3 00084 uint8_t data[]; //4 00085 } __end_packed IpcpIpCompProtocolOption; 00086 00087 00088 /** 00089 * @brief IP-Address option 00090 **/ 00091 00092 typedef __start_packed struct 00093 { 00094 uint8_t type; //0 00095 uint8_t length; //1 00096 Ipv4Addr ipAddr; //2-5 00097 } __end_packed IpcpIpAddressOption; 00098 00099 00100 /** 00101 * @brief Primary-DNS-Server-Address option 00102 **/ 00103 00104 typedef __start_packed struct 00105 { 00106 uint8_t type; //0 00107 uint8_t length; //1 00108 Ipv4Addr ipAddr; //2-5 00109 } __end_packed IpcpPrimaryDnsOption; 00110 00111 00112 /** 00113 * @brief Primary-NBNS-Server-Address option 00114 **/ 00115 00116 typedef __start_packed struct 00117 { 00118 uint8_t type; //0 00119 uint8_t length; //1 00120 Ipv4Addr ipAddr; //2-5 00121 } __end_packed IpcpPrimaryNbnsOption; 00122 00123 00124 /** 00125 * @brief Secondary-DNS-Server-Address option 00126 **/ 00127 00128 typedef __start_packed struct 00129 { 00130 uint8_t type; //0 00131 uint8_t length; //1 00132 Ipv4Addr ipAddr; //2-5 00133 } __end_packed IpcpSecondaryDnsOption; 00134 00135 00136 /** 00137 * @brief Secondary-NBNS-Server-Address option 00138 **/ 00139 00140 typedef __start_packed struct 00141 { 00142 uint8_t type; //0 00143 uint8_t length; //1 00144 Ipv4Addr ipAddr; //2-5 00145 } __end_packed IpcpSecondaryNbnsOption; 00146 00147 00148 //CodeWarrior or Win32 compiler? 00149 #if defined(__CWCC__) || defined(_WIN32) 00150 #pragma pack(pop) 00151 #endif 00152 00153 00154 //IPCP FSM events 00155 error_t ipcpOpen(PppContext *context); 00156 error_t ipcpClose(PppContext *context); 00157 00158 void ipcpTick(PppContext *context); 00159 00160 void ipcpProcessPacket(PppContext *context, const PppPacket *packet, size_t length); 00161 00162 error_t ipcpProcessConfigureReq(PppContext *context, 00163 const PppConfigurePacket *configureReqPacket); 00164 00165 error_t ipcpProcessConfigureAck(PppContext *context, 00166 const PppConfigurePacket *configureAckPacket); 00167 00168 error_t ipcpProcessConfigureNak(PppContext *context, 00169 const PppConfigurePacket *configureNakPacket); 00170 00171 error_t ipcpProcessConfigureReject(PppContext *context, 00172 const PppConfigurePacket *configureRejPacket); 00173 00174 error_t ipcpProcessTerminateReq(PppContext *context, 00175 const PppTerminatePacket *terminateReqPacket); 00176 00177 error_t ipcpProcessTerminateAck(PppContext *context, 00178 const PppTerminatePacket *terminateAckPacket); 00179 00180 error_t ipcpProcessCodeRej(PppContext *context, 00181 const PppCodeRejPacket *codeRejPacket); 00182 00183 error_t ipcpProcessUnknownCode(PppContext *context, 00184 const PppPacket *packet); 00185 00186 //IPCP FSM callback functions 00187 void ipcpThisLayerUp(PppContext *context); 00188 void ipcpThisLayerDown(PppContext *context); 00189 void ipcpThisLayerStarted(PppContext *context); 00190 void ipcpThisLayerFinished(PppContext *context); 00191 00192 void ipcpInitRestartCount(PppContext *context, uint_t value); 00193 void ipcpZeroRestartCount(PppContext *context); 00194 00195 error_t ipcpSendConfigureReq(PppContext *context); 00196 00197 error_t ipcpSendConfigureAck(PppContext *context, 00198 const PppConfigurePacket *configureReqPacket); 00199 00200 error_t ipcpSendConfigureNak(PppContext *context, 00201 const PppConfigurePacket *configureReqPacket); 00202 00203 error_t ipcpSendConfigureRej(PppContext *context, 00204 const PppConfigurePacket *configureReqPacket); 00205 00206 error_t ipcpSendTerminateReq(PppContext *context); 00207 00208 error_t ipcpSendTerminateAck(PppContext *context, 00209 const PppTerminatePacket *terminateReqPacket); 00210 00211 error_t ipcpSendCodeRej(PppContext *context, const PppPacket *packet); 00212 00213 //IPCP options checking 00214 error_t ipcpParseOption(PppContext *context, PppOption *option, 00215 size_t inPacketLen, PppConfigurePacket *outPacket); 00216 00217 error_t ipcpParseIpAddressOption(PppContext *context, 00218 IpcpIpAddressOption *option, PppConfigurePacket *outPacket); 00219 00220 #endif 00221
Generated on Tue Jul 12 2022 17:10:13 by
