Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ipv6cp.h Source File

ipv6cp.h

Go to the documentation of this file.
00001 /**
00002  * @file ipv6cp.h
00003  * @brief IPV6CP (PPP IPv6 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 _IPV6CP_H
00030 #define _IPV6CP_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "ppp/ppp.h"
00035 
00036 
00037 /**
00038  * @brief IPV6CP option types
00039  **/
00040 
00041 typedef enum
00042 {
00043    IPV6CP_OPTION_INTERFACE_ID       = 1, ///<Interface-Identifier
00044    IPV6CP_OPTION_IPV6_COMP_PROTOCOL = 2  ///<IPv6-Compression-Protocol
00045 } Ipv6cpOptionType;
00046 
00047 
00048 //CodeWarrior or Win32 compiler?
00049 #if defined(__CWCC__) || defined(_WIN32)
00050    #pragma pack(push, 1)
00051 #endif
00052 
00053 
00054 /**
00055  * @brief Interface-Identifier option
00056  **/
00057 
00058 typedef __start_packed struct
00059 {
00060    uint8_t type;       //0
00061    uint8_t length;     //1
00062    Eui64 interfaceId;  //2-9
00063 } __end_packed Ipv6cpInterfaceIdOption;
00064 
00065 
00066 /**
00067  * @brief IPv6-Compression-Protocol option
00068  **/
00069 
00070 typedef __start_packed struct
00071 {
00072    uint8_t type;      //0
00073    uint8_t length;    //1
00074    uint16_t protocol; //2-3
00075    uint8_t data[];    //4
00076 } __end_packed Ipv6cpIpCompProtocolOption;
00077 
00078 
00079 //CodeWarrior or Win32 compiler?
00080 #if defined(__CWCC__) || defined(_WIN32)
00081    #pragma pack(pop)
00082 #endif
00083 
00084 
00085 //IPV6CP FSM events
00086 error_t ipv6cpOpen(PppContext *context);
00087 error_t ipv6cpClose(PppContext *context);
00088 
00089 void ipv6cpTick(PppContext *context);
00090 
00091 void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
00092 
00093 error_t ipv6cpProcessConfigureReq(PppContext *context,
00094    const PppConfigurePacket *configureReqPacket);
00095 
00096 error_t ipv6cpProcessConfigureAck(PppContext *context,
00097    const PppConfigurePacket *configureAckPacket);
00098 
00099 error_t ipv6cpProcessConfigureNak(PppContext *context,
00100    const PppConfigurePacket *configureNakPacket);
00101 
00102 error_t ipv6cpProcessConfigureReject(PppContext *context,
00103    const PppConfigurePacket *configureRejPacket);
00104 
00105 error_t ipv6cpProcessTerminateReq(PppContext *context,
00106    const PppTerminatePacket *terminateReqPacket);
00107 
00108 error_t ipv6cpProcessTerminateAck(PppContext *context,
00109    const PppTerminatePacket *terminateAckPacket);
00110 
00111 error_t ipv6cpProcessCodeRej(PppContext *context,
00112    const PppCodeRejPacket *codeRejPacket);
00113 
00114 error_t ipv6cpProcessUnknownCode(PppContext *context,
00115    const PppPacket *packet);
00116 
00117 //IPV6CP FSM callback functions
00118 void ipv6cpThisLayerUp(PppContext *context);
00119 void ipv6cpThisLayerDown(PppContext *context);
00120 void ipv6cpThisLayerStarted(PppContext *context);
00121 void ipv6cpThisLayerFinished(PppContext *context);
00122 
00123 void ipv6cpInitRestartCount(PppContext *context, uint_t value);
00124 void ipv6cpZeroRestartCount(PppContext *context);
00125 
00126 error_t ipv6cpSendConfigureReq(PppContext *context);
00127 
00128 error_t ipv6cpSendConfigureAck(PppContext *context,
00129    const PppConfigurePacket *configureReqPacket);
00130 
00131 error_t ipv6cpSendConfigureNak(PppContext *context,
00132    const PppConfigurePacket *configureReqPacket);
00133 
00134 error_t ipv6cpSendConfigureRej(PppContext *context,
00135    const PppConfigurePacket *configureReqPacket);
00136 
00137 error_t ipv6cpSendTerminateReq(PppContext *context);
00138 
00139 error_t ipv6cpSendTerminateAck(PppContext *context,
00140    const PppTerminatePacket *terminateReqPacket);
00141 
00142 error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet);
00143 
00144 //IPV6CP options checking
00145 error_t ipv6cpParseOption(PppContext *context, PppOption *option,
00146    size_t inPacketLen, PppConfigurePacket *outPacket);
00147 
00148 error_t ipv6cpParseInterfaceIdOption(PppContext *context,
00149    Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket);
00150 
00151 #endif
00152