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.
Fork of libMiMic by
NyLPC_cMiMicIpNetIf_protected.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 00027 #ifndef NyLPC_MiMicIpNetIf_protected_H 00028 #define NyLPC_MiMicIpNetIf_protected_H 00029 #include "NyLPC_cMiMicIpNetIf.h" 00030 #include "NyLPC_os.h" 00031 #include "NyLPC_cIPv4Arp.h" 00032 #include "NyLPC_cIPv4.h" 00033 #include "NyLPC_cIPv4IComp.h" 00034 #include "../driver/ethernet/EthDev.h" 00035 #include "NyLPC_cMiMicIpTcpSocket.h" 00036 #include "NyLPC_cMiMicIpUdpSocket.h" 00037 #include "NyLPC_cMiMicIpTcpListener.h" 00038 00039 /********************************************************************** 00040 * 00041 * NyLPC_TcUipService_t 00042 * 00043 **********************************************************************/ 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif /* __cplusplus */ 00047 00048 //#define NyLPC_TcUipService_SIZE_OF_REPLY_BUF 128 00049 00050 00051 00052 struct NyLPC_TcMiMicIpNetIf 00053 { 00054 volatile NyLPC_TUInt16 _status; /**< ステータスビット*/ 00055 NyLPC_TcSemaphore_t _emac_semapho; /** EMACの制御用セマフォです。*/ 00056 NyLPC_TcStopwatch_t _arp_sw; /**<ARP用のストップウォッチ*/ 00057 NyLPC_TcStopwatch_t _periodic_sw; /**<周期実行用のストップウォッチ*/ 00058 /** ARP処理インスタンス*/ 00059 NyLPC_TcIPv4Arp_t _arp; 00060 /** TCPv4処理インスタンス*/ 00061 NyLPC_TcIPv4_t _tcpv4; 00062 /** ICOMP処理インスタンス*/ 00063 NyLPC_TcIPv4IComp_t _icomp; 00064 /** (Ethernetメモリ排他制御用)*/ 00065 NyLPC_TcMutex_t _mutex; 00066 const struct TiEthernetDevice* _ethif; 00067 struct NyLPC_TNetInterfaceInfo _netinfo; 00068 }; 00069 00070 00071 /** 唯一のサービスインスタンス - Single service instance*/ 00072 extern NyLPC_TcMiMicIpNetIf_t* _NyLPC_TcMiMicIpNetIf_inst; 00073 00074 /** 00075 * @param i_mac_addr 00076 * システムで唯一のUIPサービスを初期化します。1度だけ実行できます。 00077 */ 00078 NyLPC_TBool NyLPC_cMiMicIpNetIf_initialize(NyLPC_TcMiMicIpNetIf_t* i_inst); 00079 00080 /** 00081 * サービスが初期化済みならtrueです。 - true if service was initialized. 00082 */ 00083 #define NyLPC_cMiMicIpNetIf_isInitService() (_NyLPC_TcMiMicIpNetIf_inst!=NULL) 00084 /** 00085 * サービスが稼働中か返します。 00086 */ 00087 #define NyLPC_cMiMicIpNetIf_isRun() NyLPC_TUInt16_isBitOn(_NyLPC_TcMiMicIpNetIf_inst->_status,NyLPC_TcMiMicIpNetIf_STATUSBIT_IS_RUNNING) 00088 00089 00090 /********************************************************************** 00091 * コントロールビットの定義 00092 **********************************************************************/ 00093 //サービスが実行中の場合1 00094 #define NyLPC_TcMiMicIpNetIf_STATUSBIT_IS_RUNNING 0 00095 #define NyLPC_TcMiMicIpNetIf_ORDER_START 1 00096 #define NyLPC_TcMiMicIpNetIf_ORDER_STOP 2 00097 00098 00099 00100 #define INST_TYPE_NyLPC_Unknown 0 00101 #define INST_TYPE_NyLPC_TcTcpListener 1 00102 #define INST_TYPE_NyLPC_TcTcpSocket 2 00103 00104 00105 /********************************************************************** 00106 * 00107 * IPスタックからコールする関数群 00108 * 00109 **********************************************************************/ 00110 00111 /** 00112 * NyLPC_cUipService_allocTxBufが返却するメモリサイズ。 00113 * 00114 */ 00115 #define NyLPC_cMiMicIpNetIf_SYS_TX_BUF_SIZE (64-sizeof(struct NyLPC_TEthernetIIHeader)) 00116 00117 00118 /** 00119 * IPv4パケットをネットワークに送信します。 00120 * この関数は、リエントラントを許容します。 00121 * @param i_eth_payload 00122 * NyLPC_cUipService_getTxFrame、または、NyLPC_cUipService_recvIPv4Rxで得たバッファに、 00123 * IPv4パケットを書きこんだものを指定してください。 00124 */ 00125 void NyLPC_cMiMicIpNetIf_sendIPv4Tx(void* i_eth_payload); 00126 00127 /** 00128 * 送信ペイロードメモリを返します。 00129 * この関数は、リエントラントを許容します。 00130 * @param i_hint 00131 * 取得したいメモリサイズを指定します。(このサイズは、イーサネットヘッダのサイズを含みません。) 00132 * このサイズよりも小さなサイズが割り当てられることがあります。 00133 * @param o_size 00134 * 取得メモリのイーサネットヘッダを除いたペイロード部分の長さ 00135 * @return 00136 * 成功:IPペイロードのためのメモリブロックを返します。/失敗:NULL 00137 * メモリは、[TEthPacket][payload]の構造で返されます。 00138 */ 00139 void* NyLPC_cMiMicIpNetIf_allocTxBuf(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size); 00140 00141 /** 00142 * システム用の小さな送信ペイロードメモリを返します。 00143 * この関数は、リエントラントを許容します。 00144 * 返却するメモリブロックのサイズが小さいこと、メモリが確実に返される点がNyLPC_cUipService_allocTxBufと異なります。 00145 * この関数が返すメモリのサイズは、NyLPC_cUipService_SYS_TX_BUF_SIZEの値です。 00146 * 関数を使用するコードでは開始時に1度だけNyLPC_cUipService_SYS_TX_BUF_SIZEの値を確認して下さい。 00147 */ 00148 void* NyLPC_cMiMicIpNetIf_allocSysTxBuf(void); 00149 00150 /** 00151 * allocTxbufで確保したメモリを開放します。 00152 */ 00153 void* NyLPC_cMiMicIpNetIf_releaseTxBuf(void* i_buf); 00154 00155 /** 00156 * 指定したIPアドレスを要求するARPリクエストを発行します。 00157 */ 00158 void NyLPC_cMiMicIpNetIf_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr); 00159 00160 /** 00161 * ARPテーブルに指定したIPがあるかを返します。 00162 */ 00163 NyLPC_TBool NyLPC_cMiMicIpNetIf_hasArpInfo(const struct NyLPC_TIPv4Addr* i_addr); 00164 00165 00166 void NyLPC_cMiMicIpNetIf_releaseTcpSocketMemory(const NyLPC_TcMiMicIpTcpSocket_t* i_inst); 00167 void NyLPC_cMiMicIpNetIf_releaseUdpSocketMemory(const NyLPC_TcMiMicIpUdpSocket_t* i_inst); 00168 void NyLPC_cMiMicIpNetIf_releaseTcpListenerMemory(const NyLPC_TcMiMicIpTcpListener_t* i_inst); 00169 00170 NyLPC_TcMiMicIpTcpListener_t* NyLPC_cMiMicIpNetIf_getListenerByPeerPort(NyLPC_TUInt16 i_port); 00171 NyLPC_TcMiMicIpUdpSocket_t* NyLPC_cMiMicIpNetIf_getMatchUdpSocket(NyLPC_TUInt16 i_lport); 00172 NyLPC_TBool NyLPC_cMiMicIpNetIf_isClosedTcpPort(NyLPC_TUInt16 i_lport); 00173 NyLPC_TcMiMicIpUdpSocket_t* NyLPC_cMiMicIpNetIf_getMatchMulticastUdpSocket( 00174 const struct NyLPC_TIPv4Addr* i_mcast_ip,NyLPC_TUInt16 i_lport); 00175 NyLPC_TcMiMicIpTcpSocket_t* NyLPC_cMiMicIpNetIf_getMatchTcpSocket( 00176 NyLPC_TUInt16 i_lport,struct NyLPC_TIPv4Addr i_rip,NyLPC_TUInt16 i_rport); 00177 void NyLPC_cMiMicIpNetIf_callPeriodic(void); 00178 void NyLPC_cMiMicIpNetIf_callSocketStart(const NyLPC_TcIPv4Config_t* i_cfg); 00179 void NyLPC_cMiMicIpNetIf_callSocketStop(void); 00180 00181 00182 00183 00184 00185 #ifdef __cplusplus 00186 } 00187 #endif /* __cplusplus */ 00188 00189 #endif 00190
Generated on Tue Jul 12 2022 16:22:58 by
