This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cMiMicIpTcpSocket.h Source File

NyLPC_cMiMicIpTcpSocket.h

00001 /*********************************************************************************
00002  * PROJECT: MiMic
00003  * --------------------------------------------------------------------------------
00004  *
00005  * This file is part of MiMic
00006  * Copyright (C)2011 Ryo Iizuka
00007  *
00008  * MiMic is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * For further information please contact.
00022  *  http://nyatla.jp/
00023  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
00024  *
00025  *********************************************************************************/
00026 #ifndef NYLPC_CMIMICIPTCPSOCKET_H_
00027 #define NYLPC_CMIMICIPTCPSOCKET_H_
00028 
00029 
00030 
00031 #include "NyLPC_os.h"
00032 #include "../NyLPC_NetIf_ip_types.h"
00033 #include "NyLPC_cIPv4Payload.h"
00034 #include "../NyLPC_iTcpSocket.h"
00035 #include "NyLPC_cIPv4.h"
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif /* __cplusplus */
00040 
00041 
00042 typedef struct NyLPC_TcMiMicIpTcpSocket NyLPC_TcMiMicIpTcpSocket_t;
00043 
00044 
00045 /**********************************************************************
00046  *
00047  * NyLPC_TTcpListenerSynInfo struct
00048  *
00049  **********************************************************************/
00050 
00051 
00052 struct NyLPC_TTcpSocketSynParam
00053 {
00054     struct NyLPC_TIPv4Addr srcaddr;
00055     NyLPC_TUInt16 rport;
00056     NyLPC_TUInt16 mss;
00057     NyLPC_TUInt32 rcv_nxt32;
00058 };
00059 
00060 
00061 /**********************************************************************
00062  *
00063  * NyLPC_TcTcpSocket_TxQItem struct
00064  *
00065  **********************************************************************/
00066 
00067 /**
00068  * TXキューの数。この値は8未満にしてください。
00069  */
00070 #define NyLPC_TcTcpSocket_NUMBER_OF_TXQ 4
00071 
00072 struct NyLPC_TcTcpSocket_TxQItem
00073 {
00074     //最終更新時刻
00075     NyLPC_TUInt32 tick_of_sent;
00076     //このパケットのRTO(秒間隔)
00077     NyLPC_TUInt32 rto32;
00078     void* packet;
00079     //パケットのACK番号。この番号を受信できれば、再送パケットは消去可能である。
00080     NyLPC_TUInt32 ackno;
00081 };
00082 
00083 /**********************************************************************
00084  *
00085  * uip_conn struct
00086  *
00087  **********************************************************************/
00088 
00089 struct uip_conn
00090 {
00091     struct NyLPC_TIPv4Addr        ripaddr;  /**< The IP address of the remote host. */
00092     const struct NyLPC_TIPv4Addr* lipaddr;  /**< ローカルIP*/
00093     NyLPC_TUInt16                lport;     /**< The local TCP port, in network byte order. */
00094     NyLPC_TUInt16                rport;     /**< The local remote TCP port, in network byte order. */
00095     NyLPC_TUInt32 rcv_nxt32;    /**< The sequence number that we expect to receive next. */
00096     NyLPC_TUInt32 snd_nxt32;    /**< 送信用sqカウンター*/
00097     NyLPC_TUInt16 peer_mss;     /**< PeerのMSS*/
00098     NyLPC_TUInt16 default_mss;  /**< Peerの初期MMS*/
00099     /**Peerのウインドウサイズ*/
00100     NyLPC_TUInt16 peer_win;
00101     NyLPC_TUInt16 _padding;
00102     /**現在ソケットのRTO*/
00103     NyLPC_TUInt32 current_rto32;
00104 };
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 /**********************************************************************
00114  *
00115  * NyLPC_TcTcpSocket class
00116  *
00117  **********************************************************************/
00118 
00119 /**
00120  * uipサービスを使用したTCPソケットクラスです。
00121  * この関数は2つのタスクから呼び出されます。
00122  * [uipTask]  ->  [cTcpSocket] <- [Application]
00123  * ApplicationとuipTaskとの間での排他処理はインスタンスで制御されています。
00124  * Application側からのコールは内部でuipTaskとの間で排他処理を実行します。
00125  * Application側からのコールはリエントラントではありません。
00126  */
00127 
00128 struct NyLPC_TcMiMicIpTcpSocket
00129 {
00130     struct NyLPC_TiTcpSocket _super;
00131     NyLPC_TcIPv4_t* _parent_ipv4;
00132     //この変数は、uipタスクの実行する関数のみが変更する。
00133     struct uip_conn uip_connr;
00134     NyLPC_TcFifoBuffer_t rxbuf;
00135     struct{
00136         NyLPC_TUInt8 rp;
00137         NyLPC_TUInt8 wp;
00138         //送信キュー
00139         struct NyLPC_TcTcpSocket_TxQItem txq[NyLPC_TcTcpSocket_NUMBER_OF_TXQ];
00140     }txbuf;
00141     volatile NyLPC_TUInt8 tcpstateflags; /**< TCP state and flags. */
00142 };
00143 
00144 NyLPC_TBool NyLPC_cMiMicIpTcpSocket_initialize(NyLPC_TcMiMicIpTcpSocket_t* i_inst,void* i_rbuf,NyLPC_TUInt16 i_rbuf_len);
00145 
00146 
00147 #ifdef __cplusplus
00148 }
00149 #endif /* __cplusplus */
00150 
00151 #endif /* NYLPC_CTCPSOCKET_H_ */