This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
NyLPC_cIPv4.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 * Parts of this file were leveraged from uIP: 00027 * 00028 * Copyright (c) 2001-2003, Adam Dunkels. 00029 * All rights reserved. 00030 * 00031 * Redistribution and use in source and binary forms, with or without 00032 * modification, are permitted provided that the following conditions 00033 * are met: 00034 * 1. Redistributions of source code must retain the above copyright 00035 * notice, this list of conditions and the following disclaimer. 00036 * 2. Redistributions in binary form must reproduce the above copyright 00037 * notice, this list of conditions and the following disclaimer in the 00038 * documentation and/or other materials provided with the distribution. 00039 * 3. The name of the author may not be used to endorse or promote 00040 * products derived from this software without specific prior 00041 * written permission. 00042 * 00043 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00044 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00045 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00046 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00047 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00048 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00049 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00050 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00051 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00052 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00053 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00054 */ 00055 /** 00056 * @file 00057 * このファイルは、NyLPC_cIPv4IPv4クラスを定義します。 00058 */ 00059 #ifndef NYLPC_CIPV4TCP_H_ 00060 #define NYLPC_CIPV4TCP_H_ 00061 00062 00063 00064 #include "NyLPC_os.h" 00065 #include "../NyLPC_NetIf_ip_types.h" 00066 #include "../NyLPC_cIPv4Config.h" 00067 00068 00069 #ifdef __cplusplus 00070 extern "C" { 00071 #endif /* __cplusplus */ 00072 /********************************************************************** 00073 * 00074 * Closs reference 00075 * 00076 **********************************************************************/ 00077 00078 typedef struct NyLPC_TcMiMicIpBaseSocket NyLPC_TcMiMicIpBaseSocket_t; 00079 00080 00081 /********************************************************************** 00082 * 00083 * class NyLPC_TcIPv4 00084 * 00085 **********************************************************************/ 00086 typedef struct NyLPC_TcIPv4 NyLPC_TcIPv4_t; 00087 00088 00089 00090 00091 /** 00092 * Socketの最大生成数 00093 * この値は、NyLPC_cTcpSocketクラス,NyLPC_cTcpListener,NyLPC_cUdpの最大生成数になります。 00094 */ 00095 #define NyLPC_cIPv4_MAX_SOCKET 10 00096 00097 00098 00099 /** 00100 * NyLPC_TcIPv4クラスの構造体です。 00101 */ 00102 struct NyLPC_TcIPv4 00103 { 00104 /** 参照しているIPスタックの環境値です。この値は、start関数が設定します。*/ 00105 const NyLPC_TcIPv4Config_t* _ref_config; 00106 /** ソケットリソースの保護用。コールバック関数から呼び出されるソケット内部のリソース保護に使用する共通MUTEX*/ 00107 NyLPC_TcMutex_t _sock_mutex; 00108 /** リスナリソースの保護用。コールバック関数から呼び出されるソケット内部のリソース保護に使用する共通MUTEX*/ 00109 NyLPC_TcMutex_t _listener_mutex; 00110 /** 0-0xfffまでを巡回するカウンタ*/ 00111 NyLPC_TUInt16 tcp_port_counter; 00112 }; 00113 00114 /** 00115 * コンストラクタです。インスタンスを初期化します。 00116 * @param i_inst 00117 * 初期化するインスタンス 00118 */ 00119 void NyLPC_cIPv4_initialize( 00120 NyLPC_TcIPv4_t* i_inst); 00121 00122 /** 00123 * デストラクタです。インスタンスを破棄して、確保している動的リソースを元に戻します。 00124 * @param i_inst 00125 * 破棄するインスタンス 00126 * initializeが成功したインスタンスだけが指定できます。 00127 */ 00128 void NyLPC_cIPv4_finalize( 00129 NyLPC_TcIPv4_t* i_inst); 00130 00131 /** 00132 * この関数は、インスタンスにTCP/IP処理の準備をするように伝えます。 00133 * @param i_inst 00134 * 操作するインスタンス 00135 * @param i_ref_configlation 00136 * IPの環境値をセットしたオブジェクトを指定します。 00137 * この値は、stop関数を実行するまでの間、維持してください。 00138 */ 00139 void NyLPC_cIPv4_start( 00140 NyLPC_TcIPv4_t* i_inst, 00141 const NyLPC_TcIPv4Config_t* i_ref_configlation); 00142 00143 /** 00144 * この関数はTCP/IP処理を停止することを伝えます。 00145 * @param i_inst 00146 * 操作するインスタンス。 00147 * startで開始済みで無ければなりません。 00148 * @note 00149 * 現在、接続中の接続に対する保障は未実装です。安全に使用することが出来ません。 00150 */ 00151 void NyLPC_cIPv4_stop( 00152 NyLPC_TcIPv4_t* i_inst); 00153 00154 /** 00155 * この関数は、RxIPパケットを処理して、管理下のインスタンスに処理を依頼します。 00156 * 現在の関数は、i_rxに最大64バイトの応答パケットのイメージを格納することがあります。 00157 * 応答パケットは、RXに対するACKパケットです。 00158 * 格納の有無は戻り値を確認することで判ります。 00159 * この関数はstart-stopの間だけコールすることが出来ます。start,stopと非同期に実行しないでください。 00160 * @param i_inst 00161 * 操作するインスタンスです。 00162 * @param i_rx 00163 * RXパケットを格納したメモリアドレスです。 00164 * 最低でも、64バイト以上のサイズが必要です。 00165 * @param i_rx_size 00166 * i_rxに格納したデータのサイズです。 00167 * @return 00168 * 応答パケットを格納したメモリです。 00169 */ 00170 void* NyLPC_cIPv4_rx(NyLPC_TcIPv4_t* i_inst,const void* i_rx,NyLPC_TUInt16 i_rx_size); 00171 /** 00172 * この関数は、定期的にインスタンスへ実行機会を与える関数です。 00173 * TCPの再送、無通信タイムアウトなどを処理します。 00174 * 約1秒おきに呼び出してください。 00175 * @param i_inst 00176 * 操作するインスタンスです。 00177 */ 00178 void NyLPC_cIPv4_periodec(NyLPC_TcIPv4_t* i_inst); 00179 00180 /** 00181 * ソケットリソースとコールバックの排他処理に使う共通MUTEXを返します。 00182 * このMutexはソケット同士の干渉が起こらない処理にだけ使ってください。 00183 */ 00184 #define NyLPC_cIPv4_getSockMutex(i_inst) (&((i_inst)->_sock_mutex)) 00185 /** 00186 * リスナーリソースとコールバックの排他処理に使う共通MUTEXを返します。 00187 */ 00188 #define NyLPC_cIPv4_getListenerMutex(i_inst) (&((i_inst)->_listener_mutex)) 00189 00190 /** 00191 * ポート0で使用するポート番号を返します。 00192 * @return 00193 * 49152 - (49152+0x0ffff)番までのポートのうち、使用中でないポート番号を返します。 00194 * エラー時は0です。 00195 */ 00196 NyLPC_TUInt16 NyLPC_cIPv4_getNewPortNumber(NyLPC_TcIPv4_t* i_inst); 00197 00198 00199 #ifdef __cplusplus 00200 } 00201 #endif /* __cplusplus */ 00202 00203 #endif
Generated on Tue Jul 12 2022 15:46:15 by 1.7.2